Files
tk-mini-program/unpackage/dist/dev/mp-weixin/pages/Setting/Setting.js
pengxiaolong 0044f8f334 优化代码
2025-09-29 20:48:31 +08:00

211 lines
6.7 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const components_request = require("../../components/request.js");
const components_postFile = require("../../components/postFile.js");
const components_generateFileName = require("../../components/generateFileName.js");
const components_goEasyTool_tool = require("../../components/goEasyTool/tool.js");
const _sfc_main = {
inject: ["$global"],
data() {
return {
userinfo: "",
name: "",
id: "",
info: {},
useravatar: "",
email: null,
havaPassword: false
};
},
onLoad(option) {
this.id = option.id;
this.getUserInfo();
},
onShow() {
this.getUserInfo();
},
methods: {
//获取个人信息
getUserInfo() {
components_request.request({
url: "user/getUserInfo",
method: "POST",
data: {
id: this.id
},
userInfo: true
}).then((res) => {
if (res.code == 200) {
this.userinfo = res.data;
common_vendor.index.setStorageSync("userinfo", res.data);
setTimeout(() => {
common_vendor.index.getStorage({
key: "userinfo",
success: (res2) => {
this.id = res2.data.id;
this.name = res2.data.nickName;
this.userinfo = this.useravatar = res2.data.headerIcon;
this.email = res2.data.email;
this.havaPassword = res2.data.havaPassword;
}
});
}, 300);
} else {
common_vendor.index.__f__("log", "at pages/Setting/Setting.vue:144", res.msg);
}
});
},
//修改密码
modifyPassword() {
common_vendor.index.navigateTo({
url: "/pages/Setting/settingmod/changePassword?id=" + this.id + "&havaPassword=" + this.havaPassword
});
},
// 修改邮箱
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,
id: this.id
},
userInfo: true
}).then((res2) => {
components_request.request({
url: "user/confirm",
method: "POST",
data: {
uuid: data.uuid,
id: this.id
},
userInfo: true
}).then((res3) => {
if (res3.code === 200) {
common_vendor.index.showToast({
title: "登录成功",
icon: "success"
});
} else {
common_vendor.index.showToast({
title: res3,
icon: "none"
});
}
}).catch((err) => {
common_vendor.index.showToast({
title: "登录失败",
icon: "none"
});
});
}).catch((err) => {
common_vendor.index.showToast({
title: "登录失败",
icon: "none"
});
});
}
}
});
},
onBack() {
common_vendor.index.navigateBack({
delta: 1
});
},
// 选择头像
async Userinfo(e) {
const { avatarUrl } = e.detail;
this.userinfo = avatarUrl;
this.changeHeaderIcon();
},
// 修改头像
changeHeaderIcon() {
components_goEasyTool_tool.goEasylogout(this.$goeasy);
common_vendor.index.showLoading({
title: "修改中...",
mask: true
});
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:262", "修改调用返回", 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.hideLoading();
common_vendor.index.showToast({
title: ress.msg,
icon: "none"
});
}
});
}).catch((err) => {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: "上传失败",
icon: "none"
});
});
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
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 == true ? "" : "未设置"),
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"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/Setting/Setting.js.map