优化后,再次提交
This commit is contained in:
93
unpackage/dist/dev/mp-weixin/pages/personalcenter/account.js
vendored
Normal file
93
unpackage/dist/dev/mp-weixin/pages/personalcenter/account.js
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const request_three_one_api_info = require("../../request/three_one_api/info.js");
|
||||
const _sfc_main = {
|
||||
__name: "account",
|
||||
setup(__props) {
|
||||
const saving = common_vendor.ref(false);
|
||||
const showOldPwd = common_vendor.ref(false);
|
||||
const showNewPwd = common_vendor.ref(false);
|
||||
const showConfirmPwd = common_vendor.ref(false);
|
||||
const formData = common_vendor.reactive({
|
||||
oldPassword: "",
|
||||
newPassword: "",
|
||||
confirmPassword: ""
|
||||
});
|
||||
const handleSave = async () => {
|
||||
if (!formData.oldPassword) {
|
||||
common_vendor.index.showToast({ title: "请输入旧密码", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (!formData.newPassword) {
|
||||
common_vendor.index.showToast({ title: "请输入新密码", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (formData.newPassword.length < 6) {
|
||||
common_vendor.index.showToast({ title: "新密码长度至少6位", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (!formData.confirmPassword) {
|
||||
common_vendor.index.showToast({ title: "请确认新密码", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (formData.newPassword !== formData.confirmPassword) {
|
||||
common_vendor.index.showToast({ title: "两次输入的密码不一致", icon: "none" });
|
||||
return;
|
||||
}
|
||||
if (formData.oldPassword === formData.newPassword) {
|
||||
common_vendor.index.showToast({ title: "新密码不能与旧密码相同", icon: "none" });
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
const params = {
|
||||
oldPassword: formData.oldPassword,
|
||||
newPassword: formData.newPassword,
|
||||
confirmPassword: formData.confirmPassword
|
||||
};
|
||||
const res = await request_three_one_api_info.updatePassword(params);
|
||||
if (res.code === 0) {
|
||||
common_vendor.index.showToast({ title: "密码修改成功", icon: "success" });
|
||||
formData.oldPassword = "";
|
||||
formData.newPassword = "";
|
||||
formData.confirmPassword = "";
|
||||
setTimeout(() => {
|
||||
common_vendor.index.navigateBack();
|
||||
}, 1500);
|
||||
} else {
|
||||
common_vendor.index.showToast({ title: res.msg || "修改失败", icon: "none" });
|
||||
}
|
||||
} catch (err) {
|
||||
common_vendor.index.__f__("error", "at pages/personalcenter/account.vue:131", "修改密码失败:", err);
|
||||
common_vendor.index.showToast({ title: "修改失败", icon: "none" });
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
a: showOldPwd.value ? "text" : "password",
|
||||
b: formData.oldPassword,
|
||||
c: common_vendor.o(($event) => formData.oldPassword = $event.detail.value),
|
||||
d: common_vendor.n(showOldPwd.value ? "cuIcon-attention" : "cuIcon-attentionforbid"),
|
||||
e: common_vendor.o(($event) => showOldPwd.value = !showOldPwd.value),
|
||||
f: showNewPwd.value ? "text" : "password",
|
||||
g: formData.newPassword,
|
||||
h: common_vendor.o(($event) => formData.newPassword = $event.detail.value),
|
||||
i: common_vendor.n(showNewPwd.value ? "cuIcon-attention" : "cuIcon-attentionforbid"),
|
||||
j: common_vendor.o(($event) => showNewPwd.value = !showNewPwd.value),
|
||||
k: showConfirmPwd.value ? "text" : "password",
|
||||
l: formData.confirmPassword,
|
||||
m: common_vendor.o(($event) => formData.confirmPassword = $event.detail.value),
|
||||
n: common_vendor.n(showConfirmPwd.value ? "cuIcon-attention" : "cuIcon-attentionforbid"),
|
||||
o: common_vendor.o(($event) => showConfirmPwd.value = !showConfirmPwd.value),
|
||||
p: common_vendor.o(handleSave),
|
||||
q: saving.value,
|
||||
r: common_vendor.gei(_ctx, "")
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5e16536a"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/personalcenter/account.js.map
|
||||
Reference in New Issue
Block a user