221 lines
6.8 KiB
JavaScript
221 lines
6.8 KiB
JavaScript
"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",
|
|
email: "",
|
|
//邮箱
|
|
Verificationcode: "",
|
|
//验证码
|
|
id: "",
|
|
//用户id
|
|
error: false,
|
|
//邮箱错误
|
|
VerificationcodeSent: false,
|
|
//验证码是否已发送
|
|
turnsoutemail: "",
|
|
//修改前的邮箱
|
|
countdown: 0,
|
|
//验证码倒计时
|
|
isCounting: false,
|
|
//是否正在倒计时
|
|
timer: null
|
|
//倒计时定时器
|
|
};
|
|
},
|
|
onLoad(options) {
|
|
this.turnsoutemail = this.email = options.email == "null" ? "" : options.email;
|
|
this.id = options.id;
|
|
},
|
|
methods: {
|
|
// 倒计时
|
|
startCountdown() {
|
|
this.countdown = 60;
|
|
this.isCounting = true;
|
|
this.timer = setInterval(() => {
|
|
this.countdown--;
|
|
if (this.countdown <= 0) {
|
|
this.isCounting = false;
|
|
}
|
|
}, 1e3);
|
|
},
|
|
//提交验证
|
|
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:120", "修改调用返回", 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:144", "修改调用失败", err);
|
|
common_vendor.index.hideLoading();
|
|
common_vendor.index.showToast({
|
|
title: "修改失败",
|
|
icon: "none"
|
|
});
|
|
});
|
|
},
|
|
//发送验证码
|
|
sendVerificationCode() {
|
|
if (this.isCounting) {
|
|
return;
|
|
}
|
|
components_request.request({
|
|
url: "user/sendUpdateMailConfirmMail",
|
|
method: "POST",
|
|
data: {
|
|
mailAddress: this.email
|
|
},
|
|
userInfo: true
|
|
}).then((ress) => {
|
|
this.VerificationcodeSent = true;
|
|
this.startCountdown();
|
|
});
|
|
},
|
|
//第一次提交
|
|
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:190", "修改调用返回", 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:221", "修改调用失败", 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
|
|
});
|
|
}
|
|
}
|
|
};
|
|
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.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.t($data.isCounting ? `${$data.countdown}秒后重发` : "获取验证码"),
|
|
j: common_vendor.o((...args) => $options.sendVerificationCode && $options.sendVerificationCode(...args)),
|
|
k: common_vendor.s($data.isCounting ? "background-image: linear-gradient(0deg, #cccccc, #dddddd); cursor: not-allowed;" : "")
|
|
} : {}, {
|
|
l: $data.VerificationcodeSent && $data.turnsoutemail != ""
|
|
}, $data.VerificationcodeSent && $data.turnsoutemail != "" ? {
|
|
m: common_vendor.t($data.turnsoutemail)
|
|
} : {}, {
|
|
n: common_vendor.o((...args) => $options.onSubmit && $options.onSubmit(...args)),
|
|
o: 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);
|
|
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/Setting/settingmod/changeEmail.js.map
|