"use strict"; const common_vendor = require("../../../common/vendor.js"); const components_goEasyTool_tool = require("../../../components/goEasyTool/tool.js"); const components_request = require("../../../components/request.js"); const _sfc_main = { data() { return { oldPassword: "", //旧密码 newPassword: "", //新密码 confirmPassword: "", //确认密码 showoldPassword: true, //旧密码是否显示 shownewPassword: true, //新密码是否显示 showconfirmPassword: true, //确认密码是否显示 oldPasswordError: false, //旧密码错误 newPasswordErrorone: false, //新密码错误 newPasswordErrortwo: false, //新密码错误 confirmPasswordError: false, //确认密码错误 id: "", //用户id havaPassword: null, //是否有密码/false无密码/true有密码 email: "" //邮箱 }; }, onLoad() { common_vendor.index.getStorage({ key: "userinfo", success: (res) => { this.id = res.data.id; this.havaPassword = res.data.havaPassword; common_vendor.index.__f__("log", "at pages/Setting/settingmod/changePassword.vue:130", this.id, this.havaPassword); this.email = res.data.email; } }); }, onShow() { common_vendor.index.getStorage({ key: "userinfo", success: (res) => { this.id = res.data.id; this.havaPassword = res.data.havaPassword; common_vendor.index.__f__("log", "at pages/Setting/settingmod/changePassword.vue:141", this.id, this.havaPassword); this.email = res.data.email; } }); }, methods: { // 忘记密码 onforgetPassword() { if (this.email === "" || this.email === null) { common_vendor.index.showToast({ title: "请先绑定邮箱再进行操作", icon: "none", duration: 2e3 }); return; } components_request.request({ url: "user/forgetMail", method: "POST", data: { mailAddress: this.email }, userInfo: true }).then((ress) => { if (ress.code === 200) { common_vendor.index.showToast({ title: "已向您的" + this.email + "邮箱发送密码重置邮件,请在邮箱中进行密码重置", icon: "success", duration: 5e3 }); } else { common_vendor.index.showToast({ title: ress.data, icon: "none", duration: 2e3 }); } }).catch(() => { common_vendor.index.showToast({ title: "网络错误", icon: "none", duration: 2e3 }); }); }, // 验证密码合法性 validatePassword(password) { const regex = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)[A-Za-z\d]{6,16}$/; return regex.test(password); }, // 确认修改 onConfirm() { this.oldPasswordError = false; this.newPasswordErrorone = false; this.newPasswordErrortwo = false; this.confirmPasswordError = false; if (this.email === "" || this.email === null) { common_vendor.index.showToast({ title: "请先绑定邮箱再进行操作", icon: "none", duration: 2e3 }); return; } if (this.oldPassword === "" && this.havaPassword == true) { this.oldPasswordError = true; return; } if (this.validatePassword(this.oldPassword) === false && this.havaPassword == true) { this.oldPasswordError = true; return; } if (this.validatePassword(this.newPassword) === false) { this.newPasswordErrorone = true; return; } if (this.newPassword === "") { this.newPasswordErrorone = true; return; } if (this.newPassword === this.oldPassword) { this.newPasswordErrortwo = true; return; } if (this.confirmPassword !== this.newPassword) { this.confirmPasswordError = true; return; } if (this.havaPassword) { common_vendor.index.showLoading({ title: "修改中...", mask: true }); components_goEasyTool_tool.goEasylogout(this.$goeasy); components_request.request({ url: "user/updateUserInfo", method: "POST", data: { id: this.id, newPassword: this.newPassword, confirmPassword: this.confirmPassword, oldPassword: this.oldPassword }, userInfo: true }).then((ress) => { common_vendor.index.__f__("log", "at pages/Setting/settingmod/changePassword.vue:246", "修改调用返回", ress); if (ress.code === 200) { common_vendor.index.showToast({ title: "修改成功", icon: "success" }); common_vendor.index.setStorageSync("userinfo", ress.data); components_goEasyTool_tool.goEasylogin( this.$goeasy, String(ress.data.id), ress.data.headerIcon, ress.data.nickName ); common_vendor.index.hideLoading(); common_vendor.index.navigateBack({ delta: 1 }); } else { common_vendor.index.hideLoading(); common_vendor.index.showToast({ title: ress.data, icon: "none" }); } }); } else { common_vendor.index.showLoading({ title: "修改中...", mask: true }); components_request.request({ url: "user/setPassword", method: "POST", data: { id: this.id, password: this.newPassword, confirmPassword: this.confirmPassword }, userInfo: true }).then((ress) => { common_vendor.index.__f__("log", "at pages/Setting/settingmod/changePassword.vue:288", "修改调用返回", ress); if (ress.code === 200) { common_vendor.index.showToast({ title: "修改成功", icon: "success" }); common_vendor.index.hideLoading(); common_vendor.index.navigateBack({ delta: 1 }); } else { common_vendor.index.hideLoading(); common_vendor.index.showToast({ title: ress.data, icon: "none" }); } }); } }, //新密码显示/隐藏 changenewPassword() { this.shownewPassword = !this.shownewPassword; }, // 确认密码显示/隐藏 changeconfirmPassword() { this.showconfirmPassword = !this.showconfirmPassword; }, // 旧密码显示/隐藏 changeoldPassword() { this.showoldPassword = !this.showoldPassword; }, // 返回上一页 onBack() { common_vendor.index.__f__("log", "at pages/Setting/settingmod/changePassword.vue:324", 1); common_vendor.wx$1.navigateBack({ delta: 1 }); } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_vendor.o((...args) => $options.onBack && $options.onBack(...args)), b: $data.havaPassword }, $data.havaPassword ? { c: $data.showoldPassword, d: $data.oldPassword, e: common_vendor.o(($event) => $data.oldPassword = $event.detail.value), f: common_vendor.o((...args) => $options.changeoldPassword && $options.changeoldPassword(...args)), g: $data.showoldPassword ? "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Displaypassword.png" : "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/notdisplaypassword.png" } : {}, { h: $data.havaPassword }, $data.havaPassword ? {} : {}, { i: $data.oldPasswordError == true && $data.havaPassword == true }, $data.oldPasswordError == true && $data.havaPassword == true ? {} : {}, { j: $data.shownewPassword, k: $data.newPassword, l: common_vendor.o(($event) => $data.newPassword = $event.detail.value), m: common_vendor.o((...args) => $options.changenewPassword && $options.changenewPassword(...args)), n: $data.shownewPassword ? "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Displaypassword.png" : "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/notdisplaypassword.png", o: $data.newPasswordErrorone }, $data.newPasswordErrorone ? {} : {}, { p: $data.newPasswordErrortwo }, $data.newPasswordErrortwo ? {} : {}, { q: $data.showconfirmPassword, r: $data.confirmPassword, s: common_vendor.o(($event) => $data.confirmPassword = $event.detail.value), t: common_vendor.o((...args) => $options.changeconfirmPassword && $options.changeconfirmPassword(...args)), v: $data.showconfirmPassword ? "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Displaypassword.png" : "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/notdisplaypassword.png", w: $data.confirmPasswordError }, $data.confirmPasswordError ? {} : {}, { x: common_vendor.o((...args) => $options.onConfirm && $options.onConfirm(...args)), y: common_vendor.o((...args) => $options.onforgetPassword && $options.onforgetPassword(...args)) }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6e931930"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/Setting/settingmod/changePassword.js.map