优化代码
This commit is contained in:
@@ -29,7 +29,7 @@ export default {
|
||||
name: "",
|
||||
id: "",
|
||||
info: {},
|
||||
userSig: "",
|
||||
useravatar: "",
|
||||
};
|
||||
},
|
||||
onLoad(option) {
|
||||
@@ -38,13 +38,7 @@ export default {
|
||||
success: (res) => {
|
||||
this.id = res.data.id;
|
||||
this.name = res.data.nickName;
|
||||
this.userinfo = res.data.headerIcon;
|
||||
},
|
||||
});
|
||||
uni.getStorage({
|
||||
key: "userSig",
|
||||
success: (res) => {
|
||||
this.userSig = res.data;
|
||||
this.userinfo = this.useravatar = res.data.headerIcon;
|
||||
},
|
||||
});
|
||||
},
|
||||
@@ -70,7 +64,36 @@ export default {
|
||||
title: "修改中...",
|
||||
mask: true,
|
||||
});
|
||||
|
||||
if (this.useravatar == this.userinfo) {
|
||||
request({
|
||||
url: "user/updateUserInfo",
|
||||
method: "POST",
|
||||
data: {
|
||||
id: this.id,
|
||||
headerIcon: this.userinfo.split("/").pop(),
|
||||
nickName: this.name,
|
||||
},
|
||||
userInfo: true,
|
||||
}).then((ress) => {
|
||||
if (ress.code === 200) {
|
||||
uni.showToast({
|
||||
title: "修改成功",
|
||||
icon: "success",
|
||||
});
|
||||
uni.setStorageSync("userinfo", ress.data.info);
|
||||
goEasylogin(this.$goeasy,String(ress.data.info.id),ress.data.info.headerIcon,ress.data.info.nickName);
|
||||
uni.hideLoading();
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "修改失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
});
|
||||
}else{
|
||||
postFile({
|
||||
path: this.userinfo,
|
||||
name: generateFileName(),
|
||||
@@ -83,10 +106,10 @@ export default {
|
||||
id: this.id,
|
||||
headerIcon: res.split("/").pop(),
|
||||
nickName: this.name,
|
||||
usersig: this.userSig.userSig,
|
||||
},
|
||||
userInfo: true,
|
||||
}).then((ress) => {
|
||||
console.log("修改调用返回",ress);
|
||||
if (ress.code === 200) {
|
||||
uni.showToast({
|
||||
title: "修改成功",
|
||||
@@ -109,8 +132,9 @@ export default {
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
console.log('上传失败', err);
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user