调整样式

This commit is contained in:
2025-11-17 17:30:29 +08:00
parent 7ee926dc66
commit ab5c01bf5c
9 changed files with 643 additions and 407 deletions

View File

@@ -141,115 +141,120 @@
</template>
<script>
import UCellItemPlus from "../../components/ucellitem/UCellItemPlus.vue";
import config from "@/common/config.js" // 全局配置文件
export default {
components: { UCellItemPlus },
data() {
return {
avatar:uni.getStorageSync('lifeData').vuex_user.user.avatar.includes(config.staticUrl)?uni.getStorageSync('lifeData').vuex_user.user.avatar:config.staticUrl+uni.getStorageSync('lifeData').vuex_user.user.avatar,
show:true,
gridList:[
{name:"我的合同",icon:"../../static/icon/我的合同.png",url:"pages/center/history"},
{name:"我的账单",icon:"../../static/icon/我的账单.png",url:"pages/bill/bill"},
{name:"我的待付",icon:"../../static/icon/我的待付.png",url:"pages/unpaid/unpaid"},
{name:"水电缴费",icon:"../../static/icon/水电缴费.png",url:"pages/wae/wae"}
],
cellList:[
{title:"我的租赁资产",icon:"star",function:"goTo",url:"pages/center/myLease"},
{title:"我的预约",icon:"star",function:"goTo",url:"pages/reserve/reserveRecords"},
{title:"缴费记录",icon:"star",function:"goTo",url:"pages/bill/payHistory"},
{title:"水电费明细",icon:"star",function:"goTo",url:"pages/wae/waeRecords"}
],
}
},
onLoad() {
uni.$on('updateAvatar', (obj) => {
// 获取数据
this.updateAvatar();
})
},
onUnload() {
// 移除监听事件
uni.$off('updateAvatar');
},
onShow(){
// 检查token
this.checkToken();
},
methods: {
logout() {
// 登录成功修改token与用户信息
this.$u.vuex('vuex_token', '');
this.$u.vuex('vuex_user', {});
this.$u.route('/pages/login/login')
},
profile(){
this.$u.route('/pages/profile/profile')
},
toMessage(){
this.$u.route('/pages/message/message')
},
toSetting(){
this.$u.route('/pages/profile/setting')
},
//拨打固定电话
callPhoneNumber() {
uni.makePhoneCall({
phoneNumber: "18720989281",
});
},
problem(){
this.$u.route({
url: 'pages/login/problem'
})
},
// 关于作者
aboutMe() {
this.$u.route('/pages/profile/aboutMe')
},
toMyLease(){
this.$u.route('/pages/center/myLease')
},
checkToken(){
// 判断是否有token
let lifeData = uni.getStorageSync('lifeData');
let token = lifeData.vuex_token
if(!token){
// 没有token 则跳转到登录
return uni.reLaunch({
url:'../login/login'
})
}else{
// 判断Token是否有效
let url = "/api/profile/isExpiration";
this.$u.get(url,{
token:token
}).then(obj => {
if(obj.data){
// 没有token过期则跳转到登录
return uni.reLaunch({
url:'../login/login'
})
}
});
}
},
code(){
this.$mytip.toast('敬请期待')
},
clickNav(url){
if(url){
this.$u.route(url);
}else{
this.$mytip.toast('敬请期待')
}
},
updateAvatar(){
this.avatar = uni.getStorageSync('lifeData').vuex_user.user.avatar.includes(config.staticUrl)?uni.getStorageSync('lifeData').vuex_user.user.avatar:config.staticUrl+uni.getStorageSync('lifeData').vuex_user.user.avatar
},
}
}
import UCellItemPlus from "../../components/ucellitem/UCellItemPlus.vue";
import config from "@/common/config.js";
export default {
components: { UCellItemPlus },
data() {
const life = uni.getStorageSync('lifeData') || {}
const user = (life.vuex_user && life.vuex_user.user) || {}
return {
user, // user 信息放这里即可
show: true,
gridList: [
{name:"我的合同",icon:"../../static/icon/我的合同.png",url:"pages/center/history"},
{name:"我的账单",icon:"../../static/icon/我的账单.png",url:"pages/bill/bill"},
{name:"我的待付",icon:"../../static/icon/我的待付.png",url:"pages/unpaid/unpaid"},
{name:"水电缴费",icon:"../../static/icon/水电缴费.png",url:"pages/wae/wae"}
],
cellList: [
{title:"我的租赁资产",icon:"star",url:"pages/center/myLease"},
{title:"我的预约",icon:"star",url:"pages/reserve/reserveRecords"},
{title:"缴费记录",icon:"star",url:"pages/bill/payHistory"},
{title:"水电费明细",icon:"star",url:"pages/wae/waeRecords"}
]
}
},
computed: {
avatar() {
const life = uni.getStorageSync('lifeData') || {}
const user = (life.vuex_user && life.vuex_user.user) || {}
const raw = user.avatar || ""
if (!raw) return "/static/images/default-avatar.png"
return raw.includes(config.staticUrl)
? raw
: config.staticUrl + raw
}
},
onLoad() {
uni.$on('updateAvatar', () => {
this.updateAvatar();
})
},
onUnload() {
uni.$off('updateAvatar')
},
onShow() {
this.checkToken();
},
methods: {
logout() {
this.$u.vuex('vuex_token', '');
this.$u.vuex('vuex_user', {});
this.$u.route('/pages/login/login')
},
toMessage() {
this.$u.route('/pages/message/message')
},
toSetting() {
this.$u.route('/pages/profile/setting')
},
callPhoneNumber() {
uni.makePhoneCall({ phoneNumber: "18720989281" });
},
aboutMe() {
this.$u.route('/pages/profile/aboutMe')
},
toMyLease() {
this.$u.route('/pages/center/myLease')
},
checkToken() {
let lifeData = uni.getStorageSync('lifeData') || {};
let token = lifeData.vuex_token
if (!token) {
console.log("登录态不存在")
return uni.reLaunch({ url:'../login/login' })
}
let url = "/api/profile/isExpiration";
this.$u.get(url,{ token }).then(obj => {
if(obj.data){
return uni.reLaunch({ url:'../login/login' })
}
});
},
clickNav(url){
if(url){
this.$u.route(url);
}else{
this.$mytip.toast('敬请期待')
}
},
updateAvatar() {
// 触发 computed 自动更新
this.$forceUpdate()
}
}
}
</script>
<style lang="scss" scoped>