personal.vue
9.4 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<template>
<view class="personal">
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<view class="headBox">
<!-- #ifdef MP -->
<!-- 登录 -->
<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">
<view @click="openPersonalInfo" class="u-m-r-20"><image class="avatar" mode="aspectFill" :src="userInfo.avatar || '/static/default.png'"></image></view>
<view @click="openPersonalInfo" class="u-flex-1">
<view class="nickName u-flex">
<view class="name u-m-r-10" v-if="userInfo.realName">
<text style="#FFFFFF;font-size: 18px;">{{ userInfo.realName }}</text>
</view>
</view>
<view style="#FFFFFF;font-size: 14px;" v-if="userInfo.phoneNumber">手机号:{{ userInfo.phoneNumber | phone }}</view>
<view v-else><text style="#FFFFFF;font-size: 14px;">手机号:未绑定</text></view>
</view>
</block>
<block v-else>
<view class="u-m-r-20">
<view class="avatar u-flex"><u-icon name="account-fill" color="black" size="30"></u-icon></view>
</view>
<view class="u-flex-1">
<view @click="openLoginFunc" class="u-font-lg click-login">请点击登录</view>
<view @click="clickAccountFunc" class="detail"><text class="text">绑定账号</text></view>
</view>
</block>
<view><u-icon name="arrow-right" color="black" size="13"></u-icon></view>
</view>
<!-- #endif -->
<!-- #ifndef MP -->
<!-- 登录 -->
<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">
<view @click="openPersonalInfo" class="u-m-r-20"><image class="avatar" mode="aspectFill" :src="userInfo.avatar || '/static/default.png'"></image></view>
<view @click="openPersonalInfo" class="u-flex-1">
<view class="nickName u-flex">
<view class="name u-m-r-10" v-if="userInfo.realName">
<text style="#FFFFFF;font-size: 18px;">{{ userInfo.realName }}</text>
</view>
</view>
<view style="#FFFFFF;font-size: 14px;" v-if="userInfo.phoneNumber">手机号:{{ userInfo.phoneNumber | phone }}</view>
<view v-else><text style="#FFFFFF;font-size: 14px;">手机号:未绑定</text></view>
</view>
</block>
<block v-else>
<view class="u-m-r-20">
<view class="avatar u-flex" style="justify-content: center"><u-icon name="account-fill" color="black" size="30"></u-icon></view>
</view>
<view class="u-flex-1">
<view @click="openLoginFunc" class="u-font-lg" style="color: black; font-weight: bold">登录</view>
<view @click="clickAccountFunc" style="color: black" class="detail">绑定账号</view>
</view>
</block>
<view><u-icon name="arrow-right" color="black" size="13"></u-icon></view>
</view>
<!-- #endif -->
</view>
<view class="u-flex my-nav">
<view class="nav-main">
<view @click="onTokenJump('/sysNotifySubPage/sysNotifyPage/systemNotify')" class="u-flex nav-link">
<view class="nav-image"><image class="image" src="../../static/sys-not.png"></image></view>
<view class="nav-center"><text class="text">系统通知</text></view>
<view class="nav-right"><image class="image" src="../../static/arrow-right.png"></image></view>
</view>
<view @click="onTokenJump('/feedBackSubPage/feedback/feedback')" class="u-flex nav-link">
<view class="nav-image"><image class="image" src="../../static/find-sugg.png"></image></view>
<view class="nav-center"><text class="text">意见反馈</text></view>
<view class="nav-right"><image class="image" src="../../static/arrow-right.png"></image></view>
</view>
</view>
<view v-if="userInfo.isToken || userInfo" class="u-flex" style="justify-content: center; width: 600rpx">
<u-button @click.top="onLoginoutFunc" type="primary" shape="circle" text="退出账号"></u-button>
</view>
</view>
<!-- 绑定账号 -->
<view>
<u-modal :showConfirmButton="false" :show="show" :title="title">
<view v-if="!bindPhone" class="loginPhone">
<view class="form-row"><u--input shape="circle" class="input" prefixIcon="account-fill" type="text" placeholder="登录账号" v-model="account"></u--input></view>
<view class="form-row item-bind">
<u--input
class="input"
shape="circle"
prefixIcon="lock-fill"
suffixIconStyle="color: #909399"
type="password"
placeholder="登录密码"
v-model="password"
@change="passwordChange"
></u--input>
</view>
<view class="u-flex item-phone">
<view class="phone-hide">手机验证码登录</view>
<view class="bind-phone-text" @click="bindPhoneFunc">手机绑定</view>
</view>
</view>
<view v-else class="loginPhone">
<view class="form-row">
<u--input
shape="circle"
class="input"
type="text"
v-model="phone"
placeholder="请输入手机号码"
placeholder-style="font-weight:normal;color:#bbbbbb;"
></u--input>
</view>
<view class="form-row row-top">
<u--input
shape="circle"
class="input"
type="text"
v-model="vCode"
placeholder="请输入验证码"
placeholder-style="font-weight:normal;color:#bbbbbb;"
></u--input>
<view style="color: #377dff" class="getvcode" :class="{ forhidden: readonly }" @click="getVcode">{{ codeText }}</view>
</view>
<view class="u-flex item-phone">
<view class="phone-hide">手机验证码登录</view>
<view class="bind-phone-text" @click="bindAccountFunc">账号绑定</view>
</view>
</view>
<view class="bottom-content">
<view class="u-flex content">
<view class="cancel"><u-button @click="show = false" type="info" shape="circle" text="取消"></u-button></view>
<view class="confrim"><u-button @click="bindConfirm" type="primary" shape="circle" text="确认"></u-button></view>
</view>
</view>
</u-modal>
</view>
<!-- 退出登录 -->
<view>
<u-popup bgColor="transparent" :overlay="true" :show="showLogout" mode="bottom">
<view class="u-flex logout-main">
<view class="main"><text style="color: #999999">确定要退出当前账号?</text></view>
<view @click.top="logoutBtn" class="main"><text style="color: #f95e5a">退出登录</text></view>
<view class="main"><text @click.top="closeLogout" style="color: #3478f7">取消</text></view>
</view>
</u-popup>
</view>
<!-- 退出登录 -->
<f-tabbar></f-tabbar>
</view>
</template>
<script>
var clear;
import base from '@/config/baseUrl';
import fTabbar from '@/components/module/f-tabbar/f-tabbar';
import fNavbar from '@/components/module/f-navbar/f-navbar';
import { mapState, mapMutations } from 'vuex';
export default {
components: {
fTabbar,
fNavbar
},
data() {
return {
PrimaryColor: '#0079fe', //主题色
showLogout: false,
readonly: false,
codeText: '获取验证码',
phone: '', //号码
vCode: '', //验证码
tips: '验证码',
bindPhone: false,
show: false,
title: '绑定账号',
systemInfo: base.systemInfo,
PrimaryButtonColor: '#0079fe' //主题色
};
},
onLoad() {
// 隐藏原生的tabbar
uni.hideTabBar();
},
computed: {
...mapState(['userInfo'])
},
methods: {
...mapMutations(['emptyUserInfo']),
// 跳转前判断登录
onTokenJump(url) {
this.judgeLogin(() => {
uni.navigateTo({
url: url
});
});
},
onJump(url) {
uni.navigateTo({
url: url
});
},
openLoginFunc() {
uni.navigateTo({
url: '/publicLoginSubPage/public/login'
});
},
openPersonalInfo() {
let obj = {
data: this.userInfo
};
uni.navigateTo({
url: '/publicLoginSubPage/other/set?data=' + JSON.stringify(obj)
});
},
clickAccountFunc() {
this.show = true;
},
bindConfirm() {},
bindPhoneFunc() {
this.bindPhone = true;
},
bindAccountFunc() {
this.bindPhone = false;
},
//验证码按钮文字状态
getCodeState() {
const _this = this;
this.readonly = true;
this.codeText = '60S后重新获取';
var s = 60;
clear = setInterval(() => {
s--;
_this.codeText = s + 'S后重新获取';
if (s <= 0) {
clearInterval(clear);
_this.codeText = '获取验证码';
_this.readonly = false;
}
}, 1000);
},
//获取验证码
getVcode() {
console.log('getVcode');
if (this.readonly) {
uni.showToast({
title: '验证码已发送~',
icon: 'none'
});
return;
}
if (this.phone == '') {
uni.showToast({
title: '请输入手机号~',
icon: 'none'
});
return;
}
const phoneRegular = /^1\d{10}$/;
if (!phoneRegular.test(this.phone)) {
uni.showToast({
title: '手机号格式不正确~',
icon: 'none'
});
return;
}
let httpData = {};
// 获取验证码接口
// uni.$u.http.post('您的接口', httpData).then(res => {
this.getCodeState(); //开始倒计时
// })
},
onLoginoutFunc() {
this.showLogout = true;
},
closeLogout() {
this.showLogout = false;
},
logoutBtn() {
let that = this;
uni.showModal({
title: '退出登录',
content: '你确定退出登录吗?',
success(res) {
if (res.confirm) {
that.emptyUserInfo();
that.showLogout = false;
setTimeout(() => {
uni.navigateTo({
url: '/publicLoginSubPage/public/login'
});
}, 500);
} else if (res.cancel) {
}
}
});
}
}
};
</script>
<style lang="scss" scoped>
@import './static/personal.scss';
</style>