info.vue
3.9 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
<template>
<view class="container">
<view class="user-list x-bc">
<text class="list-name">头像</text>
<view class="x-f" @tap="onChooseImg">
<image class="avatar" :src="userData.avatar" mode=""></image>
<text class="cuIcon-right"></text>
</view>
</view>
<view class="user-list x-bc">
<text class="list-name">昵称</text>
<view class="x-f">
<input class="list-val" v-model="userData.nickname" />
<text class="cuIcon-right"></text>
</view>
</view>
<!-- <picker style="width: 750rpx;" mode="date" :value="userData.birthday" :start="startDate" :end="endDate" @change="onDateChange">
<view class="user-list x-bc">
<text class="list-name">生日</text>
<view class="x-f">
<text class="list-val">{{ userData.birthday || startDate }}</text>
<text class="cuIcon-right"></text>
</view>
</view>
</picker>
<view class="user-list x-bc" @tap="jump('/pages/user/edit-phone')">
<text class="list-name">修改手机号</text>
<view class="x-f">
<text class="list-val">{{ userData.mobile }}</text>
<text class="cuIcon-right"></text>
</view>
</view> -->
<view class="btn-box flex align-center justify-center"><button class="cu-btn confirem-btn" @tap="editUserInfo">保存</button></view>
<!-- 自定义底部导航 -->
<shopro-tabbar></shopro-tabbar>
<!-- 关注弹窗 -->
<shopro-float-btn></shopro-float-btn>
<!-- 连续弹窗提醒 -->
<shopro-notice-modal></shopro-notice-modal>
<!-- 登录提示 -->
<shopro-login-modal></shopro-login-modal>
</view>
</template>
<script>
import shoproModal from '@/components/shopro-modal/shopro-modal.vue';
import { mapMutations, mapActions, mapState } from 'vuex';
export default {
components: {
shoproModal
},
data() {
const currentDate = this.getDate({
format: true
});
return {
userData: {}
};
},
computed: {
...mapState({
userInfo: state => state.user.userInfo
}),
startDate() {
return this.getDate('start');
},
endDate() {
return this.getDate('end');
}
},
onLoad() {
let userData = JSON.stringify(this.userInfo);
this.userData = JSON.parse(userData);
},
methods: {
...mapActions(['getUserInfo']),
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 60;
} else if (type === 'end') {
year = year;
}
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
// 选择日期
onDateChange(e) {
this.userData.birthday = e.detail.value;
},
jump(path, parmas) {
this.$Router.push({
path: path,
query: parmas
});
},
editUserInfo() {
let that = this;
that.$api('user.profile', {
nickname: that.userData.nickname,
birthday: that.userData.birthday,
avatar: that.userData.avatar
}).then(res => {
if (res.code === 1) {
that.$tools.toast('修改信息成功');
that.getUserInfo();
setTimeout(() => {
that.$Router.back();
}, 1000);
}
});
},
onChooseImg() {
let that = this;
that.$tools.chooseImage(1).then(res => {
that.$tools.uploadImage('index/upload', res[0]).then(res => {
that.userData.avatar = res.full_url;
});
});
}
}
};
</script>
<style lang="scss">
.user-list {
background: #fff;
height: 100rpx;
border-bottom: 1rpx solid #f6f6f6;
padding: 0 20rpx;
.list-name {
font-size: 28rpx;
}
.avatar {
width: 67rpx;
height: 67rpx;
border-radius: 50%;
// background: #ccc;
}
.cuIcon-right {
margin-left: 25rpx;
}
.list-val {
color: #999;
font-size: 28rpxc;
text-align: right;
}
}
.btn-box {
margin-top: 60rpx;
.confirem-btn {
width: 710rpx;
height: 80rpx;
background: linear-gradient(135deg,#08a3e3, #0ac6d2);
border: 1rpx solid rgba(238, 238, 238, 1);
border-radius: 16rpx;
font-size: 30rpx;
color: rgba(#fff, 0.9);
position: fixed;
bottom: 64px;
}
}
</style>