修改头像和昵称

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