优化代码

This commit is contained in:
pengxiaolong
2025-08-05 22:05:56 +08:00
parent 3eddd94922
commit 40c3282515
86 changed files with 1700 additions and 399 deletions

View File

@@ -12,7 +12,9 @@ const _sfc_main = {
name: "",
id: "",
info: {},
useravatar: ""
useravatar: "",
email: null,
havaPassword: false
};
},
onLoad(option) {
@@ -22,110 +24,157 @@ const _sfc_main = {
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;
}
});
},
onShow() {
common_vendor.index.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;
}
});
},
methods: {
cancel() {
//修改密码
modifyPassword() {
common_vendor.index.navigateTo({
url: "/pages/Setting/settingmod/changePassword?id=" + this.id
});
},
// 修改邮箱
modifyEmailAddress() {
common_vendor.index.navigateTo({
url: "/pages/Setting/settingmod/changeEmail?email=" + this.email + "&id=" + this.id
});
},
// 修改昵称
inputNickname() {
common_vendor.index.navigateTo({
url: "/pages/Setting/settingmod/changeNickname?name=" + this.name + "&id=" + this.id
});
},
// 扫码登录web端
scanCode() {
common_vendor.index.scanCode({
success: (res) => {
const data = JSON.parse(res.result);
if (data.type === "qrcdoe") {
components_request.request({
url: "user/scan",
method: "POST",
data: {
uuid: data.uuid,
userId: this.id
},
userInfo: true
}).then((res2) => {
if (res2.code === 200) {
common_vendor.index.showToast({
title: "登录成功",
icon: "success"
});
} else {
common_vendor.index.showToast({
title: res2,
icon: "none"
});
}
}).catch((err) => {
common_vendor.index.showToast({
title: "登录失败",
icon: "none"
});
});
}
}
});
},
onBack() {
common_vendor.index.navigateBack({
delta: 1
});
},
// 输入昵称
inputName(e) {
this.name = e.detail.value;
},
// 选择头像
async Userinfo(e) {
const { avatarUrl } = e.detail;
this.userinfo = avatarUrl;
this.changeHeaderIcon();
},
// 微信登录
wxLogin(e) {
// 修改头像
changeHeaderIcon() {
components_goEasyTool_tool.goEasylogout(this.$goeasy);
common_vendor.index.showLoading({
title: "修改中...",
mask: true
});
if (this.useravatar == this.userinfo) {
components_postFile.uploadFile({
path: this.userinfo,
name: components_generateFileName.generateFileName()
}).then((res) => {
components_request.request({
url: "user/updateUserInfo",
method: "POST",
data: {
id: this.id,
headerIcon: this.userinfo.split("/").pop(),
headerIcon: res.split("/").pop(),
nickName: this.name
},
userInfo: true
}).then((ress) => {
common_vendor.index.__f__("log", "at pages/Setting/Setting.vue:226", "修改调用返回", ress);
if (ress.code === 200) {
common_vendor.index.showToast({
title: "修改成功",
icon: "success"
});
common_vendor.index.setStorageSync("userinfo", ress.data.info);
components_goEasyTool_tool.goEasylogin(this.$goeasy, String(ress.data.info.id), ress.data.info.headerIcon, ress.data.info.nickName);
components_goEasyTool_tool.goEasylogin(
this.$goeasy,
String(ress.data.info.id),
ress.data.info.headerIcon,
ress.data.info.nickName
);
common_vendor.index.hideLoading();
common_vendor.index.navigateBack({
delta: 1
});
} else {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: "修改失败",
title: ress.msg,
icon: "none"
});
}
});
} else {
components_postFile.uploadFile({
path: this.userinfo,
name: components_generateFileName.generateFileName()
}).then((res) => {
components_request.request({
url: "user/updateUserInfo",
method: "POST",
data: {
id: this.id,
headerIcon: res.split("/").pop(),
nickName: this.name
},
userInfo: true
}).then((ress) => {
common_vendor.index.__f__("log", "at pages/Setting/Setting.vue:112", "修改调用返回", ress);
if (ress.code === 200) {
common_vendor.index.showToast({
title: "修改成功",
icon: "success"
});
common_vendor.index.setStorageSync("userinfo", ress.data.info);
components_goEasyTool_tool.goEasylogin(this.$goeasy, String(ress.data.info.id), ress.data.info.headerIcon, ress.data.info.nickName);
common_vendor.index.hideLoading();
common_vendor.index.navigateBack({
delta: 1
});
} else {
common_vendor.index.showToast({
title: "修改失败",
icon: "none"
});
}
});
}).catch((err) => {
common_vendor.index.__f__("log", "at pages/Setting/Setting.vue:135", "上传失败", err);
}).catch((err) => {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: "上传失败",
icon: "none"
});
}
});
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: $data.userinfo,
b: common_vendor.o((...args) => $options.Userinfo && $options.Userinfo(...args)),
c: common_vendor.o((...args) => $options.inputName && $options.inputName(...args)),
d: $data.name,
e: common_vendor.o(($event) => $data.name = $event.detail.value),
f: common_vendor.o((...args) => $options.wxLogin && $options.wxLogin(...args)),
g: common_vendor.o((...args) => $options.cancel && $options.cancel(...args))
a: common_vendor.o((...args) => $options.onBack && $options.onBack(...args)),
b: $data.userinfo,
c: common_vendor.o((...args) => $options.Userinfo && $options.Userinfo(...args)),
d: common_vendor.t($data.name),
e: common_vendor.o((...args) => $options.inputNickname && $options.inputNickname(...args)),
f: common_vendor.t($data.email == "" || $data.email == null ? "未绑定" : $data.email),
g: common_vendor.o((...args) => $options.modifyEmailAddress && $options.modifyEmailAddress(...args)),
h: common_vendor.t($data.havaPassword ? "" : "未设置"),
i: common_vendor.o((...args) => $options.modifyPassword && $options.modifyPassword(...args)),
j: common_vendor.o((...args) => $options.scanCode && $options.scanCode(...args))
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-3c55a289"]]);