personalData.vue
4.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
<template>
<view class="page">
<view class="box">
<view class="item">
<view class="left">用户头像</view>
<view class="right " @click="chooseImage">
<image :src="avatar==''?'../../static/headtou.png':avatar" class="avator" />
<image src="../../static/right.png" mode="widthFix" class="jiantou" />
</view>
</view>
<view class="item">
<view class="left">用户昵称</view>
<view class="right entername">
<input type="text" placeholder="请输入用户昵称" @input="enternickname" :value="nickname" placeholder-class="enterword">
</view>
</view>
</view>
<view class="btn" @click="surechange">确认</view>
</view>
</template>
<script>
import app from "../../App.vue";
export default {
data() {
return {
nickname:'',
avatar:''
}
},
onLoad(options) {
this.nickname=options.nickname;
console.log(this.nickname)
this.avatar=options.avatar;
},
methods: {
// 输入用户昵称
enternickname(e){
this.nickname=e.detail.value
},
// 上传头像
chooseImage() {
let that = this;
uni.chooseImage({
count: 9,
sizeType: ['original', 'compressed'],
success: function (res) {
console.log(res)
console.log(res.tempFilePaths);
console.log(res.tempFilePaths[0])
app.upload('image', res.tempFilePaths[0], "post").then((res) => {
console.log('上传文件', res);
let url = app.globalData.imgurl+res.url;
that.avatar=url
console.log(that.avatar)
}).catch((err) => {
console.log(err)
})
},
fail: function (res) { }
})
},
//确认修改
surechange(){
let that = this;
if(that.avatar==''){
uni.showToast({
title:'请上传头像',
icon:'none'
})
return false
}
if(that.nickname==''){
uni.showToast({
title:'请输入昵称',
icon:'none'
})
return false
}
var url = 'member/update_user';
var params = {
avatar: that.avatar,
nickname:that.nickname,
longitude:uni.getStorageSync("longitude"),
latitude:uni.getStorageSync("latitude")
}
console.log('7766554', params)
app.post(url, params).then((res) => {
console.log(res);
uni.showToast({
title:"提交成功",
icon:'none'
})
setTimeout(function(){
uni.navigateBack({
checked:true
})
},1500)
}).catch((err) => {
console.log(err)
})
}
}
}
</script>
<style>
page {
background: #F7F7F7;
}
.box {
padding: 0 32rpx;
box-sizing: border-box;
background: #fff;
margin-top: 16rpx;
}
.item {
height: 108rpx;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #EDEDED;
}
.left {
width: calc(100% -220rpx);
display: flex;
align-items: center;
font-size: 28rpx;
font-family: PingFangHK-Regular, PingFangHK;
font-weight: 400;
color: rgba(8, 18, 31, 1);
}
.right {
width: 168rpx;
font-size: 28rpx;
font-family: PingFangHK-Regular, PingFangHK;
font-weight: 400;
color: rgba(61, 69, 76, 1);
display: flex;
align-items: center;
justify-content: flex-end;
}
.right .avator {
width: 84rpx;
height:84rpx;
font-size: 0;
border-radius: 50%;
}
.right .jiantou {
width: 32rpx;
margin-left: 16rpx;
}
.btn {
width: 686rpx;
height: 84rpx;
background: rgba(194, 148, 69, 1);
border-radius: 8rpx;
font-size: 32rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: rgba(255, 255, 255, 1);
display: flex;
justify-content: center;
align-items: center;
position:fixed;
bottom:20rpx;
left:32rpx;
}
page{
overflow-y: hidden;
}
.entername{
width:490rpx;
}
.entername input{
width:100%;
color:#3D454C;
font-size: 28rpx;
text-align: right;
}
.enterword{
color:#3D454C;
font-size: 28rpx;
}
.headimg{
width:120rpx;
height:120rpx;
font-size: 0;
border-radius: 50%;
}
.headimg image{
border-radius: 50%;
}
</style>