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
<template>
<div>
<headerNav title="个人信息"/>
<van-cell-group>
<!--<van-cell title="修改个人信息" is-link />-->
<!--<van-cell title="修改登录密码" is-link />-->
<!--<van-cell title="修改绑定手机" is-link />-->
<!--<van-cell title="关联账号" is-link />-->
<!--<van-cell title="切换账号" is-link to="/login" />-->
<van-cell title="昵称" :value="user.nickname" @click="onShowNicknameDialog" />
<van-cell title="头像" @click="onShowAvatarDialog" >
<img width="24px" :src="user.avatar" >
</van-cell>
</van-cell-group>
<!-- 昵称修改弹出 -->
<van-dialog
v-model="showNicknameDialog"
:before-close="onShowNicknameDialogClose"
show-cancel-button
>
<van-field
:value="user.nickname"
label="昵称"
placeholder="请输入昵称"
@input="inputNickname"
/>
</van-dialog>
<!---->
</div>
</template>
<script>
import { getUserInfo, doUserUpdateNickname } from '../../../api/user.js';
import { Dialog } from 'vant';
export default {
data() {
return {
user: {},
showNicknameDialog: false,
updateNickname: undefined,
};
},
methods: {
onShowNicknameDialog: function () {
this.showNicknameDialog = true;
this.updateNickname = this.user.nickname;
},
inputNickname: function (value) {
this.updateNickname = value;
},
onShowNicknameDialogClose: function (action, done) {
if (action === 'confirm') {
let that = this;
let response = doUserUpdateNickname(this.updateNickname);
response.then(data => {
// 修改
that.user.nickname = that.updateNickname;
// 关闭弹窗
done();
});
} else {
done();
}
},
onShowAvatarDialog: function () {
// TODO 芋艿,头像上传
alert('头像上传暂未开发');
}
},
mounted() {
let response = getUserInfo();
response.then(data => {
this.user = data;
});
}
}
</script>
<style>
</style>