修改头像和昵称

This commit is contained in:
dengjie
2023-01-30 23:11:48 +08:00
parent d9ae6c0989
commit 95724b4ddc

View File

@@ -34,6 +34,7 @@
data() {
return {
avatar: '',
avatarUrl: '',
model: {
userInfo: {
name: ''
@@ -77,7 +78,7 @@
success: (res) => {
console.log('上传头像', JSON.parse(res.data));
// setTimeout(() => {
resolve(JSON.parse(res.data).data.uri)
resolve(JSON.parse(res.data).data.url)
// }, 1000)
}
});
@@ -90,24 +91,24 @@
sizeType: ['original', 'compressed'], //original 原图compressed 压缩图,默认二者都有
success: (res) => {
// console.log(res.tempFilePaths[0]); //成功则返回图片的本地文件路径列表 tempFilePaths
// this.avatar = res.tempFilePaths[0] //更新本地浏览头像图片
this.avatar = res.tempFilePaths[0] //更新本地浏览头像图片
if (res.tempFilePaths[0]) {
this.updatePromise(res.tempFilePaths[0]) //上传图片
}
const result = this.updatePromise(res.tempFilePaths[0])
const result = this.updatePromise(res.tempFilePaths[0]) //上传图片
result.then(value => {
this.avatar = value
this.avatarUrl = '/' + value
console.log(this.avatarUrl);
})
}
}
});
},
//提交头像和昵称
handleSubmit() {
console.log('昵称', this.model.userInfo.name);
console.log('头像', this.avatar);
console.log('头像', this.avatarUrl);
this.$apiServe.updateUser({
nickname: this.model.userInfo.name,
avatar: this.avatar
avatar: this.avatarUrl
}).then(res => {
console.log('修改头像昵称==', res);
this.$toast.success(res.data.msg)