优化代码
This commit is contained in:
@@ -1,15 +1,167 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../common/vendor.js");
|
||||
const components_request = require("../../../components/request.js");
|
||||
const components_goEasyTool_tool = require("../../../components/goEasyTool/tool.js");
|
||||
const _sfc_main = {
|
||||
data() {
|
||||
return {
|
||||
title: "Hello"
|
||||
title: "Hello",
|
||||
email: "",
|
||||
//邮箱
|
||||
Verificationcode: "",
|
||||
//验证码
|
||||
id: "",
|
||||
//用户id
|
||||
error: false,
|
||||
//邮箱错误
|
||||
VerificationcodeSent: false,
|
||||
//验证码是否已发送
|
||||
turnsoutemail: ""
|
||||
//修改前的邮箱
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
onLoad(options) {
|
||||
this.turnsoutemail = this.email = options.email == "null" ? "" : options.email;
|
||||
this.id = options.id;
|
||||
},
|
||||
methods: {
|
||||
// 返回上一页
|
||||
//提交验证
|
||||
onSubmit() {
|
||||
if (this.turnsoutemail == "") {
|
||||
this.setEmail();
|
||||
} else {
|
||||
this.hasEmail();
|
||||
}
|
||||
},
|
||||
//有邮箱修改
|
||||
hasEmail() {
|
||||
if (!this.validateEmail(this.email)) {
|
||||
this.error = true;
|
||||
return;
|
||||
}
|
||||
common_vendor.index.showLoading({
|
||||
title: "修改中...",
|
||||
mask: true
|
||||
});
|
||||
components_request.request({
|
||||
url: "user/updateUserMail",
|
||||
method: "POST",
|
||||
data: {
|
||||
code: this.Verificationcode,
|
||||
mailAddress: this.email
|
||||
},
|
||||
userInfo: true
|
||||
}).then((ress) => {
|
||||
common_vendor.index.__f__("log", "at pages/Setting/settingmod/changeEmail.vue:98", "修改调用返回", ress);
|
||||
if (ress.code === 200) {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({
|
||||
title: "修改成功,请到您的邮箱进行验证激活",
|
||||
duration: 5e3,
|
||||
icon: "none"
|
||||
});
|
||||
setTimeout(() => {
|
||||
common_vendor.index.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
}, 5e3);
|
||||
} else {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({
|
||||
title: ress.msg,
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
}).catch((err) => {
|
||||
common_vendor.index.__f__("log", "at pages/Setting/settingmod/changeEmail.vue:122", "修改调用失败", err);
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({
|
||||
title: "修改失败",
|
||||
icon: "none"
|
||||
});
|
||||
});
|
||||
},
|
||||
//发送验证码
|
||||
sendVerificationCode() {
|
||||
components_request.request({
|
||||
url: "user/sendUpdateMailConfirmMail",
|
||||
method: "POST",
|
||||
data: {
|
||||
mailAddress: this.email
|
||||
},
|
||||
userInfo: true
|
||||
}).then((ress) => {
|
||||
this.VerificationcodeSent = true;
|
||||
});
|
||||
},
|
||||
//第一次提交
|
||||
setEmail() {
|
||||
if (!this.validateEmail(this.email)) {
|
||||
this.error = true;
|
||||
return;
|
||||
}
|
||||
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,
|
||||
email: this.email
|
||||
},
|
||||
userInfo: true
|
||||
}).then((ress) => {
|
||||
common_vendor.index.__f__("log", "at pages/Setting/settingmod/changeEmail.vue:164", "修改调用返回", ress);
|
||||
if (ress.code === 200) {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({
|
||||
title: "修改成功,请到您的邮箱进行验证激活",
|
||||
duration: 5e3,
|
||||
icon: "none"
|
||||
});
|
||||
common_vendor.index.setStorageSync("userinfo", ress.data);
|
||||
components_goEasyTool_tool.goEasylogin(
|
||||
this.$goeasy,
|
||||
String(ress.data.id),
|
||||
ress.data.headerIcon,
|
||||
ress.data.nickName
|
||||
);
|
||||
setTimeout(() => {
|
||||
common_vendor.index.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
}, 5e3);
|
||||
} else {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({
|
||||
title: ress.msg,
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
}).catch((err) => {
|
||||
common_vendor.index.__f__("log", "at pages/Setting/settingmod/changeEmail.vue:195", "修改调用失败", err);
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({
|
||||
title: "修改失败",
|
||||
icon: "none"
|
||||
});
|
||||
});
|
||||
},
|
||||
//邮箱验证
|
||||
validateEmail(email) {
|
||||
const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
||||
return regex.test(email);
|
||||
},
|
||||
//联系客服
|
||||
onCustomerService() {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/Mine/minecomponents/contact"
|
||||
});
|
||||
},
|
||||
//返回上一页
|
||||
onBack() {
|
||||
common_vendor.wx$1.navigateBack({
|
||||
delta: 1
|
||||
@@ -18,9 +170,27 @@ const _sfc_main = {
|
||||
}
|
||||
};
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return {
|
||||
a: common_vendor.o((...args) => $options.onBack && $options.onBack(...args))
|
||||
};
|
||||
return common_vendor.e({
|
||||
a: common_vendor.o((...args) => $options.onBack && $options.onBack(...args)),
|
||||
b: $data.email,
|
||||
c: common_vendor.o(($event) => $data.email = $event.detail.value),
|
||||
d: $data.turnsoutemail == ""
|
||||
}, $data.turnsoutemail == "" ? {} : {}, {
|
||||
e: $data.error
|
||||
}, $data.error ? {} : {}, {
|
||||
f: $data.turnsoutemail != ""
|
||||
}, $data.turnsoutemail != "" ? {
|
||||
g: $data.Verificationcode,
|
||||
h: common_vendor.o(($event) => $data.Verificationcode = $event.detail.value),
|
||||
i: common_vendor.o((...args) => $options.sendVerificationCode && $options.sendVerificationCode(...args))
|
||||
} : {}, {
|
||||
j: $data.VerificationcodeSent && $data.turnsoutemail != ""
|
||||
}, $data.VerificationcodeSent && $data.turnsoutemail != "" ? {
|
||||
k: common_vendor.t($data.turnsoutemail)
|
||||
} : {}, {
|
||||
l: common_vendor.o((...args) => $options.onSubmit && $options.onSubmit(...args)),
|
||||
m: common_vendor.o((...args) => $options.onCustomerService && $options.onCustomerService(...args))
|
||||
});
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-87d0cc44"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
|
||||
Reference in New Issue
Block a user