personal.vue
4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<template>
<view class="personal-page">
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<view class="header-box">
<view class="u-flex u-p-l-30 u-p-r-20 u-p-t-75 u-p-b-30">
<block v-if="userInfo.isToken || userInfo.isThirdLogin">
<view @click.top="navigatorPersonal" class="u-m-r-20">
<image class="avatar" mode="aspectFill" :src="setHeadImage"></image>
</view>
<view class="u-flex-1" @click.top="navigatorPersonal">
<view class="nickName u-flex">
<view class="name u-m-r-10" v-if="userInfo.realName || userInfo.nickName">
<text class="nick-name">{{ userInfo.realName || userInfo.nickName }}</text>
</view>
<view v-if="userInfo.isThirdLogin" @click.stop="openBindAccountModal" class="detail"><text
class="text">绑定账号</text></view>
</view>
<view class="phone-number" v-if="userInfo.phoneNumber">
{{ handlePhoneFunc(userInfo.phoneNumber || '') }}
</view>
</view>
</block>
<block v-else>
<view class="u-m-r-20" @click="navigatorLogin">
<view class="avatar u-flex">
<image class="avatar" mode="aspectFill" src="/static/logo.png"></image>
</view>
</view>
<view class="u-flex-1">
<view @click="navigatorLogin" class="u-font-lg click-login login-btn">请点击登录</view>
</view>
</block>
<view v-if="userInfo.isToken" @click="navigatorPersonal">
<u-icon name="arrow-right" color="white" size="13"></u-icon>
</view>
</view>
</view>
<view class="u-flex my-nav">
<view class="nav-main">
<view v-for="(item,index) in systemList" :key="index" @click="onTokenJump(item.url)" class="u-flex nav-link">
<view class="nav-image">
<image class="image" :src="item.leftIcon"></image>
</view>
<view class="nav-center"><text class="text">{{item.text}}</text></view>
<view class="nav-right">
<image class="image" :src="item.rightIcon"></image>
</view>
</view>
</view>
<view @click="openLogoutPopup" class="u-flex logout-text">
<button class="submit" size="default" @click="openLogoutPopup"><text class="text">退出账号</text></button>
</view>
</view>
<!-- 绑定账号 -->
<bind-account-modal ref="bindAccountRef" :show="showBindAccount" @cancelAccountModal="handleCancelAccountModal" />
<!-- 退出登录 -->
<logout-account-modal ref="logoutAccountRef" :show="showLogout" @logoutBtn="logoutBtn" @closeLogoutPopup="closeLogoutPopup"/>
<f-tabbar></f-tabbar>
</view>
</template>
<script>
import fTabbar from '@/components/module/f-tabbar/f-tabbar';
import fNavbar from '@/components/module/f-navbar/f-navbar';
import bindAccountModal from './components/bind-account-modal.vue'
import logoutAccountModal from './components/logout-account-modal.vue'
import { mapState,mapMutations } from 'vuex';
import { useNavigateTo,useReLaunch,useShowModal } from '@/plugins/utils.js'
import { systemList } from './config/data.js'
export default {
components: {
fTabbar,
fNavbar,
bindAccountModal,
logoutAccountModal,
},
data() {
return {
showBindAccount: false,
showLogout: false,
thirdObj: {},
systemList,
};
},
onLoad(e) {
// 隐藏原生的tabbar
uni.hideTabBar();
},
computed: {
...mapState(['userInfo', 'plateInfo']),
setHeadImage() {
return this.userInfo.avatar || this.thirdObj.avatarUrl || '/static/logo.png'
}
},
methods: {
...mapMutations(['emptyUserInfo', 'setUserInfo', 'setPlateInfo']),
handlePhoneFunc(e) {
//手机号前三后四位显示
const result = /^(\d{3})\d{4}(\d{4})$/;
const y = e.toString().replace(result, '$1****$2');
return y;
},
// 跳转前判断登录
onTokenJump(url) {
if(!url) return
this.judgeLogin(() => {
useNavigateTo(url)
});
},
onJump(url) {
if(!url) return
useNavigateTo(url)
},
navigatorLogin() {
useNavigateTo('/login-subpackage/public/login')
},
navigatorPersonal() {
let data = {
data: this.userInfo,
third: this.thirdObj
};
useNavigateTo('/login-subpackage/other/set?data=', data)
},
openBindAccountModal() {
this.showBindAccount = true;
this.$refs.bindAccountRef.resetFunc()
},
openLogoutPopup() {
this.showLogout = true;
},
closeLogoutPopup() {
this.showLogout = false;
},
logoutBtn() {
const that = this
useShowModal('您确定要退出登录吗?', '退出登录', '确定').then(res => {
if (res.confirm) {
that.emptyUserInfo();
that.showLogout = false;
//不能使用navigatorTo,会显示返回按钮
useReLaunch('/login-subpackage/public/login')
}
})
},
handleCancelAccountModal() {
this.showBindAccount = false;
}
}
};
</script>
<style lang="scss" scoped>
@import './static/personal.scss';
</style>