personalDetails.vue
12.5 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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
<!-- 修改个人信息 -->
<template>
<view class="container fs28" :style="{height:screenHeight+'px'}">
<global-loading />
<view class="headBox">
<view class="personalHead-box flex-sp-between flex-display flex-items">
<label>头像</label>
<image
class="user-headImg"
:src="$baseURL+item.headImage || 'https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/img//user/morentouxiang.png'"
@click="userHeadTap"
></image>
<!-- <image class="user-headImg" v-if="item.headImage" :src="item.headImage"></image>
<image class="user-headImg" v-else src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/img//user/morentouxiang.png">
</image> -->
</view>
</view>
<view class="personalBack-box flex-items-plus flex-column">
<view class="personalHead-box flex-sp-between flex-display flex-items">
<label>昵称</label>
<!-- <label class="font-color-999" v-if="item.name">{{item.name}}</label>-->
<!-- <label class="font-color-999" v-else>{{item.phone}}</label>-->
<!-- <input class="nameInput" v-if="name" v-model="name" type="text" placeholder="请输入内容" @blur="changeName(1)" /> -->
<!-- <input class="nameInput" v-else type="text" v-model="phone" placeholder="请输入内容" @blur="changeName(2)" /> -->
<input class="nameInput" v-model="name" type="text" placeholder="请输入内容" @blur="changeName" />
</view>
<view class="personalHead-box flex-sp-between flex-display flex-items" @click="sexShowClick">
<label>性别</label>
<label class="font-color-999">{{item.sex}}</label>
</view>
<view class="personalHead-box1 flex-sp-between flex-display flex-items" @click="changeTime">
<label>生日</label>
<label class="font-color-999">{{birthday | parsebirthday}}</label>
<!-- <u-calendar v-model="birthdateShow" :mode="mode"></u-calendar> -->
</view>
</view>
<view class="iphoneNumback-box flex-items-plus">
<view class="iphoneNum-box flex-row-plus flex-sp-between flex-items">
<label style="width: 50%;">手机号</label>
<label class="font-color-C5AA7B" v-if="phone">{{phone}}</label>
<label class="font-color-C5AA7B" v-else>
<!-- #ifdef MP-ALIPAY -->
<button class="verifyPhone" open-type="getAuthorize" @getAuthorize="onGetAuthorize"
@error="onAuthError" scope='phoneNumber'>去验证</button>
<!-- #endif -->
<!-- #ifndef MP-ALIPAY -->
去验证
<!-- #endif -->
</label>
</view>
</view>
<view class="agreement">
<view class="agreement agreement_top" @click="protocol('app_privacy_agreement')">
<text>隐私协议</text>
<image src="../../static/images/right.png" mode=""></image>
</view>
<view class="agreement" @click="protocol('app_user_agreement')">
<text>服务协议</text>
<image src="../../static/images/right.png" mode=""></image>
</view>
</view>
<view class="mar-top-100">
<view class="exitLoginBut flex-items-plus" @click="quit">退出登录</view>
<!-- #ifdef APP-PLUS -->
<view class="cancellation" @click="cancellation">注销账号</view>
<!-- #endif -->
</view>
<!-- 修改性别弹窗 -->
<u-select v-model="sexShow" title="修改性别" :list="sexList" @confirm="ConfirmSex"></u-select>
<!-- 修改生日弹窗 -->
<u-picker v-model="timeShow" mode="time" title="修改生日" :params="params" start-year="1970" @confirm="ConfirmTime">
</u-picker>
<!-- <view>
<u-popup v-model="sexShow" mode="center" close-icon-size ="20" border-radius="10" :closeable='true' close-icon-pos = "top-right">
<view class="flex-items-plus flex-column">
<label class="mar-top-50 fs-bold">性别</label>
<u-radio-group class="sexRadio-box flex-items-plus flex-column" v-model="item.sex" @change="sexRadioGroupChange">
<u-radio class="sexRadio"
v-for="(item, index) in sexList" :key="index"
:name="item.id"
:disabled="item.disabled"
active-color="#C5AA7B"
>
{{item.name}}
</u-radio>
</u-radio-group>
</view>
</u-popup>
</view> -->
</view>
</template>
<script>
const NET = require('../../utils/request')
const API = require('../../config/api')
export default {
data() {
return {
screenHeight: 0,
birthdateShow: false,
mode: 'date',
birthday: '',
// sexList: [{
// id: 1,
// name: '男',
// disabled: false
// }, {
// id: 2,
// name: '女',
// disabled: false
// }],
sexShow: false,
timeShow: false,
item: {},
UpdateInfoQuery: {
headimg: '',
sex: '',
nickname: ''
},
code: '',
phone: '',
name: '',
sexList: [{
value: '1',
label: '男'
},
{
value: '2',
label: '女'
}
],
params: { // 日期
year: true,
month: true,
day: true,
hour: false,
minute: false,
second: false
},
}
},
onLoad() {
this.GetUser()
},
mounted() {
// 获取手机的屏幕高度
uni.getSystemInfo({
success: (res) => {
this.screenHeight = res.screenHeight
}
})
},
methods: {
// 多商户用户协议
protocol(type) {
uni.navigateTo({
url: 'protocol?type=' + type
})
},
cancellation() {
uni.showModal({
title: "温馨提示",
content: "是否注销此账号!",
confirmText:"前往注销",
success(res) {
if (res.cancel) {
uni.showToast({
icon: 'none',
title: '已取消'
})
} else if (res.confirm) {
uni.navigateTo({
url: 'unsubscribe'
})
}
}
})
},
// 修改生日
changeTime() {
if (this.birthday == '1970-01-01' || this.birthday == '') {
this.timeShow = true
}
},
// 修改昵称
changeName() {
const newName = this.name || this.phone
if (!newName) {
uni.showToast({
title: '请输入新的内容',
icon: "none"
})
return false
}
// uni.showLoading({
// mask: true,
// title: "正在加载中"
// })
NET.request(API.UpdateUser, {
name: newName
}, 'POST').then(res => {
this.GetUser()
uni.hideLoading()
uni.showToast({
title: '修改成功',
icon: "success"
})
}).catch(res => {
uni.hideLoading()
})
},
// 提交修改生日
ConfirmTime(content) {
if (this.birthday == '1970-01-01' || this.birthday == '') {
let birthday = content.year + '-' + content.month + '-' + content.day
// uni.showLoading({
// mask: true,
// title: "正在加载中"
// })
NET.request(API.UpdateUser, {
birthday
}, 'POST').then(res => {
this.GetUser()
uni.hideLoading()
uni.showToast({
title: '修改成功',
icon: "success"
})
}).catch(res => {
uni.hideLoading()
})
}
},
// 点击弹窗修改性别
sexShowClick() {
this.sexShow = true
},
// 提交修改性别
ConfirmSex(content) {
// uni.showLoading({
// mask: true,
// title: "正在加载中"
// })
let sex = content[0].label
NET.request(API.UpdateUser, {
sex
}, 'POST').then(res => {
this.GetUser()
uni.hideLoading()
uni.showToast({
title: '修改成功',
icon: "success"
})
}).catch(res => {
uni.hideLoading()
})
},
// 获取用户信息
GetUser() {
NET.request(API.GetUser, {}, 'GET').then(res => {
this.item = res.data
this.phone =res.data.phone
this.name = res.data.name
this.birthday = res.data.birthday
}).catch(res => {
})
},
userHeadTap() {
// return
uni.chooseImage({
count: 1,
sizeType: ['compressed','album', 'camera'],
success: (res) => {
const tempFilePaths = res.tempFilePaths;
// 这里可以进行图片上传操作,以下只是示例更新本地数据
this.item.headImage = tempFilePaths[0];
// console.log('23423423',res)
uni.uploadFile({
url: API.UpUrl,
filePath: tempFilePaths[0],
name: 'file',
success: (uploadRes) => {
console.log('上传成功', JSON.parse(uploadRes.data).data);
NET.request(API.UpdateUser, {
headImage:JSON.parse(uploadRes.data).data
}, 'POST').then(res => {
this.GetUser()
uni.hideLoading()
uni.showToast({
title: '修改成功',
icon: "success"
})
}).catch(res => {
uni.hideLoading()
})
},
fail: (err) => {
console.log('上传失败', err);
}
})
}
})
},
//生日
birthdateChange(e) {
return
this.item.birth = e.result
},
// 性别
sexRadioGroupChange(e) {
return
},
quit() {
// uni.showLoading({
// mask: true,
// title: '正在退出...',
// duration: 2000,
// });
setTimeout(function() {
uni.removeStorageSync('storage_key');
uni.removeStorageSync('distributorId');
uni.removeStorageSync("allCartNum")
uni.reLaunch({
url: 'login',
success() {
uni.hideLoading()
}
})
}, 1000)
},
onGetAuthorize() {
const that = this
// uni.showLoading({
// mask: true,
// title: '验证中...',
// })
this.$showLoading()
my.getPhoneNumber({
success: (res) => {
this.$hideLoading()
let encryptedData = res.response;
console.log('encryptedData:', encryptedData)
NET.request(API.UpdateAliPhone, {
'phone': encryptedData
}, 'POST').then(res => {
console.log('UpdateAliPhone res: ', res)
const item = res.data
uni.setStorageSync('storage_key', item);
that.phone = item.phone
// uni.hideLoading()
}).finally(res => {
uni.hideLoading()
})
},
fail: (res) => {
this.$hideLoading()
console.log('getPhoneNumber failed', res);
uni.hideLoading()
uni.showToast({
title: '验证失败',
icon: 'none'
})
}
});
},
onAuthError() {
console.log('onAuthError')
}
},
filters: {
parsebirthday(birthday) {
if (birthday == '') {
return "1970-01-01"
} else {
return birthday
}
}
}
}
</script>
<style lang='scss'>
.agreement {
/* width: 710rpx; */
margin: 20rpx auto 0;
background-color: #fff;
.agreement_top {
&::after {
content: "";
display: block;
position: absolute;
left: 32rpx;
bottom: 0;
width: 646rpx;
height: 4rpx;
background: #F5F7FA;
}
}
.agreement {
width: 100%;
height: 108rpx;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
color: #333;
padding: 0 10rpx 0 32rpx;
box-sizing: border-box;
position: relative;
image {
width: 60rpx;
height: 60rpx;
}
}
}
.phoneWxBut {
width: 160rpx;
height: 60rpx;
border: 1rpx solid #FF7800;
border-radius: 44rpx;
font-size: 28rpx;
line-height: 60rpx;
}
.container {
width: 100%;
background-color: #F7F7F7;
padding: 20rpx;
.personalBack-box {
width: 100%;
background-color: #FFFFFF;
.personalHead-box {
width: 90%;
border-bottom: 1upx solid #E5E5E5;
padding-bottom: 20upx;
margin-top: 36upx;
.nameInput {
text-align: right;
}
}
.personalHead-box1 {
width: 90%;
margin-top: 36upx;
padding-bottom: 20upx;
.user-headImg {
width: 120upx;
height: 112upx;
border-radius: 50%;
}
}
}
.iphoneNumback-box {
width: 100%;
background-color: #FFFFFF;
height: 100upx;
margin-top: 20upx;
.iphoneNum-box {
width: 90%;
.verifyPhone {
color: #C5AA7B;
font-size: 30upx;
border: 0;
}
}
}
.exitLoginBut {
height: 100upx;
background: #39be7a;
color: #FFEBC4;
}
.cancellation {
height: 100rpx;
margin: 24rpx auto 0;
display: flex;
align-items: center;
justify-content: center;
color: #C5AA7B;
font-size: 28rpx;
background: #FFFFFF;
border: 3rpx solid #F3F4F5;
}
.sexRadio-box {
width: 520upx;
height: 328upx;
.sexRadio {
margin-top: 30upx;
padding-bottom: 44upx;
}
}
.headBox {
margin-bottom: 20rpx;
background: #FFFFFF;
padding: 25rpx 0;
.personalHead-box {
width: 90%;
margin: 0 auto;
}
.user-headImg {
width: 120upx;
height: 112upx;
border-radius: 50%;
}
}
}
</style>