mydetails.vue
2.88 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
<template>
<ul>
<li>
<label @click="setAvatar">头像
<span class="details-icon">
<span class="head-portrait user-avatar" :style='icoStyle'></span>
<span class="icon icon-right"></span>
</span>
</label>
</li>
<li>
<label>昵称<input class="nickname" v-model='nickname' @blur="setNickname"></label>
</li>
<li>
<label @click="setAender">性别
<span class="details-gender">
<span class="gender">{{ gender }}</span>
<span class="icon icon-right"></span>
</span>
</label>
</li>
<li>
<label>生日
<span class="details-birthday">
<input class="birthday" type="date" v-model='birthday' @change="setBirthday" required></input>
<span class="icon icon-right"></span>
</span>
</label>
</li>
</ul>
</template>
<script>
const $ = require('yoho-jquery');
const yoho = require('yoho');
const tip = require('common/tip');
const genderSel = require('common/select')([{
key:'1',
val:'MEN'
}, {
key:'2',
val:'WOMEN'
}]);
module.exports = {
props: ['head_ico', 'nickname', 'gender', 'birthday'],
data() {
return {
icoStyle: this.head_ico ? 'background-image:url(' + this.head_ico + ');' : ''
};
},
methods: {
setAvatar: function() {
yoho.goSetAvatar();
},
setNickname: function() {
this.saveDetails({
nickname: this.nickname
});
},
setAender: function() {
let _this = this;
genderSel.show(function(item) {
_this.gender = item.val.toLowerCase();
_this.saveDetails({
nickname: _this.nickname,
gender: item.key
});
})
},
setBirthday: function() {
this.saveDetails({
nickname: this.nickname,
birthday: this.birthday
});
},
saveDetails: function(params) {
$.ajax({
method: 'POST',
url: '/home/save-mydetails',
data: params
}).then(result => {
if (result.code !== 200) {
tip(result.message || '设置失败');
}
}).fail(() => {
tip('网络错误');
});
}
}
};
</script>
<style>
@import "../../scss/home/_details.css";
</style>