personziliao.vue
5.3 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
<template>
<div class="container">
<div class="weiquanlist">
<div class="weiquanitem flextwo">
<div class="weiguitou flexone">
<div class="left">用户头像</div>
<!-- @click="chooseImage" -->
</div>
<div class="flexone">
<div class="right rightavatar">
<input
type="file"
class="shangtu"
accept="image/*"
@change="afterRead"
/>
<img
:src="avatar == '' ? '../../static/headtou.png' : avatar"
class="avator"
alt=""
/>
</div>
<img src="../../../assets/youjiantou.png" alt="" class="youjian" />
</div>
</div>
<div class="weiquanitem flextwo">
<div class="weiguitou flexone">
<div class="left">昵称</div>
</div>
<div class="nameitemright flexone">
<div class="nameitemk">
<input type="text" placeholder="请输入昵称" v-model="nickname" />
</div>
<!-- <img src="../../../assets/youjiantou.png" alt="" class="youjian" /> -->
</div>
</div>
<div class="weiquanitem flextwo">
<div class="weiguitou flexone">
<div class="left">地址</div>
</div>
<div class="nameitemright flexone">
<div class="nameitemk">
<input type="text" placeholder="请输入地址" v-model="address" />
</div>
<!-- <img src="../../../assets/youjiantou.png" alt="" class="youjian" /> -->
</div>
</div>
<!-- <div class="weiquanitem flextwo">
<div class="weiguitou flexone">
<div>性别</div>
<div class="nameitem">女</div>
</div>
<img src="../../../assets/youjiantou.png" alt="" class="youjian" />
</div>
<div class="weiquanitem flextwo">
<div class="weiguitou flexone">
<div>年龄</div>
<div class="nameitem">23</div>
</div>
<img src="../../../assets/youjiantou.png" alt="" class="youjian" />
</div>
<div class="weiquanitem flextwo">
<div class="weiguitou flexone">
<div>生日</div>
<div class="nameitem">11月30日</div>
</div>
<img src="../../../assets/youjiantou.png" alt="" class="youjian" />
</div>
<div class="weiquanitem flextwo">
<div class="weiguitou flexone">
<div>星座</div>
<div class="nameitem">射手座</div>
</div>
<img src="../../../assets/youjiantou.png" alt="" class="youjian" />
</div> -->
</div>
<div class="tuichu" @click="save">保存</div>
<van-loading type="spinner" color="#1989fa" v-if="cardzheng" />
</div>
</template>
<script>
import Vue from "vue";
import { Toast, Uploader, Loading } from "vant";
import "vant/lib/index.css";
Vue.use(Loading);
Vue.use(Toast);
Vue.use(Uploader);
export default {
data() {
return {
avatar: '',
cardzheng: false,
nickname: '',
address: ''
}
},
created() {
this.avatar = localStorage.getItem("avatar")
this.address = localStorage.getItem("address")
this.nickname = localStorage.getItem("nickname")
},
methods: {
// 上传图片
afterRead(e) {
console.log(e);
let file = e.target.files[0];
let that = this;
that.cardzheng = true;
var formdata = new FormData();
formdata.append("file", file);
var url = "/api/common/upload";
let param = {
id: 1
};
that.$uploadFile
.post(url, formdata)
.then(function (res) {
that.cardzheng = false;
console.log(res);
that.cardzheng = false;
let url = "https://app.chinesenooddles.com" + res.data.url;
that.avatar = url;
console.log(that.avatar)
that.chuanimage = res.data.url;
})
.catch(err => {
console.log(err);
});
},
save() {
let that = this;
if (that.avatar == '') {
Toast("请上传头像")
return false
}
if (that.nickname == '') {
Toast("请输入昵称")
return false
}
var url = '/api/member/update_user';
var params = {
avatar: that.avatar,
nickname: that.nickname,
address: that.address
}
console.log('7766554', params)
that.$axios.post(url, params).then((res) => {
console.log(res);
Toast("提交成功")
setTimeout(function () {
that.$router.go(-1)
}, 1500)
}).catch((err) => {
console.log(err)
})
}
}
};
</script>
<style scoped>
@import "../../style/homepage.css";
.van-loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 99;
}
.avator {
width: 0.92rem;
height: 0.92rem;
border-radius: 50%;
/* margin-left: 0.2rem; */
}
.left {
width: 1.3rem;
}
.nameitemk {
flex: 1;
margin-right: 0.2rem;
color: #191919;
font-size: 0.28rem;
}
.nameitemk input {
text-align: right;
width: 100%;
}
.nameitemright {
flex: 1;
}
.rightavatar {
position: relative;
margin-right: 0.2rem;
}
.shangtu {
width: 0.78rem;
height: 0.78rem;
position: absolute;
left: 0;
top: 0;
background: transparent;
border: none;
outline: none;
opacity: 0;
}
</style>