personal.vue
10.2 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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
<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.token">
<view class="u-m-r-20"><image class="avatar" mode="aspectFill" :src="userInfo.headLogo || '/static/logo.png'"></image></view>
<view class="u-flex-1" @click="onJump('/pages/personal/set')">
<view class="nickName u-flex">
<view class="name u-m-r-10" v-if="userInfo.nickName">{{ userInfo.nickName }}</view>
</view>
<view class="detail" v-if="userInfo.phoneNum">手机号:{{ userInfo.phoneNum | phone }}</view>
<view class="detail" v-else>手机号:未绑定</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 @click="openPersonalInfo" 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.token">
<view class="u-m-r-20"><image class="avatar" mode="aspectFill" :src="userInfo.headLogo"></image></view>
<view class="u-flex-1" @click="onJump('/pages/user/set')">
<view class="nickName">{{ userInfo.userName }}</view>
<view class="detail" v-if="userInfo.phoneNum">手机号:{{ userInfo.phoneNum | phone }}</view>
<view class="detail" v-else>手机号:未绑定</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 @click="openPersonalInfo" name="arrow-right" color="black" size="13"></u-icon></view>
</view>
<!-- #endif -->
</view>
<view style="height: 50rpx;"></view>
<view class="cell-group">
<view
class="cell-item u-flex"
@click="onJump(item.url)"
:style="[{ animation: 'show ' + ((index + 1) * 0.2 + 0.2) + 's' }]"
v-for="(item, index) in list"
:key="index"
>
<u-icon :name="item.icon" size="14" color="#333"></u-icon>
<view class="title u-flex-m">{{ item.title }}</view>
<u-icon name="arrow-right" size="14" color="#333"></u-icon>
</view>
</view>
<view class="u-flex" style="justify-content: center;">
<button class="submit" size="default" @click="onLoginoutFunc" :style="{ background: PrimaryButtonColor }">退出账号</button>
</view>
<!-- 绑定账号 -->
<view>
<u-modal confirmText="绑定账号" @confirm="bindConfirm" :show="show" :title="title">
<view v-if="!bindPhone" class="loginPhone">
<view class="form-row">
<u--input class="input" prefixIcon="account-fill" type="text" placeholder="登录账号" border="surround" v-model="account"></u--input>
</view>
<view class="form-row">
<u--input
class="input"
prefixIcon="lock-fill"
:suffixIcon="showPasswordIcon"
suffixIconStyle="color: #909399"
type="password"
placeholder="登录密码"
border="surround"
v-model="password"
@change="passwordChange"
></u--input>
</view>
<view class="u-flex" style="flex-direction: row;margin-top: 20rpx;justify-content: space-between;">
<view style="visibility: hidden;">手机验证码登录</view>
<view style="color: #0079fe;font-size: 14px;" @click="bindPhoneFunc">手机绑定</view>
</view>
</view>
<view v-else class="loginPhone">
<view class="form-row">
<u--input class="input" type="text" v-model="phone" placeholder="请输入手机号码" placeholder-style="font-weight:normal;color:#bbbbbb;"></u--input>
</view>
<view class="form-row">
<u--input class="input" type="text" v-model="vCode" placeholder="请输入验证码" placeholder-style="font-weight:normal;color:#bbbbbb;"></u--input>
<view class="getvcode" :class="{ forhidden: readonly }" @click="getVcode">{{ codeText }}</view>
</view>
<view class="u-flex" style="flex-direction: row;margin-top: 20rpx;justify-content: space-between;">
<view style="visibility: hidden;">手机验证码登录</view>
<view style="color: #0079fe;font-size: 14px;" @click="bindAccountFunc">账号绑定</view>
</view>
</view>
</u-modal>
</view>
<!-- 退出登录 -->
<view>
<u-popup bgColor="transparent" :overlay="true" :show="showLogout" mode="bottom">
<view class="u-flex" style="flex-direction: column;height: 300rpx;margin: 30rpx 40rpx;background:#f5f5f5;border-radius: 20rpx;">
<view style="width:669rpx;height: 100rpx;border-bottom: 1rpx solid #d6d6d6;text-align: center;line-height: 86rpx;">
<text style="color:#999999">确定要退出当前账号?</text>
</view>
<view style="width:669rpx;height: 100rpx;border-bottom: 1rpx solid #d6d6d6;text-align: center;line-height: 86rpx;">
<text style="color:#f95e5a">退出登录</text>
</view>
<view style="width:669rpx;height: 100rpx;text-align: center;line-height: 86rpx;"><text @click="closeLogout" style="color:#3478f7">取消</text></view>
</view>
</u-popup>
</view>
<f-tabbar></f-tabbar>
</view>
</template>
<script>
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 } 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', //主题色
list: [
{
title: '系统通知',
url: '../systemNotify/systemNotify',
icon: 'setting-fill'
},
{
title: '意见反馈',
url: '../feedback/feedback',
icon: 'more-circle-fill'
}
]
};
},
onLoad() {
// 隐藏原生的tabbar
uni.hideTabBar();
},
computed: {
...mapState(['userInfo'])
},
methods: {
onJump(url) {
uni.navigateTo({
url: url
});
},
openLoginFunc() {
uni.navigateTo({
url: './login'
});
},
openPersonalInfo() {
uni.navigateTo({
url: './set'
});
},
clickAccountFunc() {
this.show = true;
},
bindConfirm() {
this.show = false;
},
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;
}
}
};
</script>
<style lang="scss" scoped>
.headBox {
background-color: #fff;
border-top: 0.01px solid #f5f5f5;
height: 250rpx;
.avatar {
width: 50px;
height: 50px;
border-radius: 25px;
background-color: #ccc;
}
.nickName {
.btn {
font-size: 22rpx;
font-weight: normal;
color: #666;
background: #fff;
border-radius: 5rpx;
height: 45rpx;
line-height: 45rpx;
padding: 0 10rpx;
position: relative;
.itemButton {
border-radius: 0;
text-align: left;
opacity: 0;
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
}
.name {
color: #fff;
font-weight: bold;
font-size: 32rpx;
}
.placardVip {
background: #2a2e44;
color: #f4d6a1;
font-size: 22rpx;
padding: 4rpx 10rpx;
text-align: center;
border-radius: 4rpx;
}
}
.detail {
color: #fff;
font-size: 24rpx;
padding-top: 6rpx;
}
}
.cell-group {
.cell-item {
border-bottom: 2rpx solid #eee;
background-color: #fff;
border-radius: 10rpx;
padding: 20rpx 24rpx;
.title {
color: #333;
font-size: 28rpx;
padding: 0 10rpx;
font-weight: bold;
margin: 0;
}
.more {
font-size: 24rpx;
color: #999;
}
}
}
.submit {
margin-top: 160rpx;
color: #fff;
width: 650rpx;
border: none;
}
.loginPhone {
width: 750rpx;
padding: 0rpx 10rpx;
.form-row {
position: relative;
.input {
font-size: 34rpx;
line-height: 102rpx;
height: 94rpx;
box-sizing: border-box;
font-size: 30rpx;
padding: 0;
font-weight: bold;
}
.getvcode {
font-size: 26rpx;
height: 50rpx;
color: #333;
line-height: 52rpx;
background: #eee;
min-width: 188rpx;
text-align: center;
border-radius: 8rpx;
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 17rpx;
z-index: 11;
&.forhidden {
background: #eee;
color: #cccccc;
}
}
}
}
</style>