优化代码
This commit is contained in:
@@ -62,9 +62,7 @@
|
||||
<view class="Nickname" @click="modifyPassword">
|
||||
<view class="avatarmodify-item">密码</view>
|
||||
<view class="NicknameInput">
|
||||
<view class="NicknameInput-name">{{
|
||||
havaPassword ? "" : "未设置"
|
||||
}}</view>
|
||||
<view class="NicknameInput-name">{{ havaPassword == true ? "" : "未设置" }}</view>
|
||||
<image
|
||||
class="more"
|
||||
src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/More.png"
|
||||
@@ -108,34 +106,52 @@ export default {
|
||||
};
|
||||
},
|
||||
onLoad(option) {
|
||||
uni.getStorage({
|
||||
key: "userinfo",
|
||||
success: (res) => {
|
||||
this.id = res.data.id;
|
||||
this.name = res.data.nickName;
|
||||
this.userinfo = this.useravatar = res.data.headerIcon;
|
||||
this.email = res.data.email;
|
||||
this.havaPassword = res.data.havaPassword;
|
||||
},
|
||||
});
|
||||
this.id = option.id;
|
||||
this.getUserInfo();
|
||||
},
|
||||
onShow() {
|
||||
uni.getStorage({
|
||||
key: "userinfo",
|
||||
success: (res) => {
|
||||
this.id = res.data.id;
|
||||
this.name = res.data.nickName;
|
||||
this.userinfo = this.useravatar = res.data.headerIcon;
|
||||
this.email = res.data.email;
|
||||
this.havaPassword = res.data.havaPassword;
|
||||
},
|
||||
});
|
||||
this.getUserInfo();
|
||||
},
|
||||
methods: {
|
||||
//获取个人信息
|
||||
getUserInfo() {
|
||||
request({
|
||||
url: "user/getUserInfo",
|
||||
method: "POST",
|
||||
data: {
|
||||
id: this.id,
|
||||
},
|
||||
userInfo: true,
|
||||
}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.userinfo = res.data;
|
||||
uni.setStorageSync("userinfo", res.data);
|
||||
setTimeout(() => {
|
||||
uni.getStorage({
|
||||
key: "userinfo",
|
||||
success: (res) => {
|
||||
this.id = res.data.id;
|
||||
this.name = res.data.nickName;
|
||||
this.userinfo = this.useravatar = res.data.headerIcon;
|
||||
this.email = res.data.email;
|
||||
this.havaPassword = res.data.havaPassword;
|
||||
},
|
||||
});
|
||||
}, 300);
|
||||
} else {
|
||||
console.log(res.msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
//修改密码
|
||||
modifyPassword() {
|
||||
uni.navigateTo({
|
||||
url: "/pages/Setting/settingmod/changePassword?id=" + this.id,
|
||||
url:
|
||||
"/pages/Setting/settingmod/changePassword?id=" +
|
||||
this.id +
|
||||
"&havaPassword=" +
|
||||
this.havaPassword,
|
||||
});
|
||||
},
|
||||
// 修改邮箱
|
||||
@@ -166,24 +182,25 @@ export default {
|
||||
userId: this.id,
|
||||
},
|
||||
userInfo: true,
|
||||
}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.showToast({
|
||||
title: "登录成功",
|
||||
icon: "success",
|
||||
});
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: res,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.showToast({
|
||||
title: "登录成功",
|
||||
icon: "success",
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
uni.showToast({
|
||||
title: "登录失败",
|
||||
icon: "none",
|
||||
})
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
}
|
||||
// 其他类型暂不处理
|
||||
|
||||
Reference in New Issue
Block a user