|
@@ -22,25 +22,32 @@ const _sfc_main = {
|
|
|
// Flag to prevent multiple requests
|
|
|
loginCodeTimer: 0,
|
|
|
// Countdown timer for login code
|
|
|
- isSendingLoginCode: false
|
|
|
+ isSendingLoginCode: false,
|
|
|
// Flag to prevent multiple requests
|
|
|
+ showForgotPopup: false,
|
|
|
+ forgotPhone: "",
|
|
|
+ forgotCode: "",
|
|
|
+ newPassword: "",
|
|
|
+ confirmPassword: "",
|
|
|
+ forgotCodeTimer: 0,
|
|
|
+ isSendingForgotCode: false
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
// 处理微信登录
|
|
|
async oneClickLogin() {
|
|
|
- common_vendor.index.__f__("log", "at pages/login/login.vue:92", "WeChat login button clicked");
|
|
|
+ common_vendor.index.__f__("log", "at pages/login/login.vue:123", "WeChat login button clicked");
|
|
|
common_vendor.index.getUserProfile({
|
|
|
desc: "用于完善用户资料",
|
|
|
lang: "zh_CN",
|
|
|
success: (userRes) => {
|
|
|
- common_vendor.index.__f__("log", "at pages/login/login.vue:98", userRes);
|
|
|
+ common_vendor.index.__f__("log", "at pages/login/login.vue:129", userRes);
|
|
|
common_vendor.index.showLoading({ title: "登录中...", mask: true });
|
|
|
common_vendor.index.login({
|
|
|
provider: "weixin",
|
|
|
success: (wx_res) => {
|
|
|
- common_vendor.index.__f__("log", "at pages/login/login.vue:105", "uni.getUserProfile success:", userRes);
|
|
|
- common_vendor.index.__f__("log", "at pages/login/login.vue:106", "uni.login success, got code:", wx_res.code);
|
|
|
+ common_vendor.index.__f__("log", "at pages/login/login.vue:136", "uni.getUserProfile success:", userRes);
|
|
|
+ common_vendor.index.__f__("log", "at pages/login/login.vue:137", "uni.login success, got code:", wx_res.code);
|
|
|
common_vendor.index.request({
|
|
|
url: "http://localhost:3333/WeChart/login",
|
|
|
method: "POST",
|
|
@@ -53,32 +60,32 @@ const _sfc_main = {
|
|
|
var _a;
|
|
|
common_vendor.index.hideLoading();
|
|
|
if (res.statusCode === 200 && res.data) {
|
|
|
- common_vendor.index.__f__("log", "at pages/login/login.vue:119", "Backend login success:", res.data);
|
|
|
+ common_vendor.index.__f__("log", "at pages/login/login.vue:150", "Backend login success:", res.data);
|
|
|
common_vendor.index.showToast({ title: "登录成功", icon: "success" });
|
|
|
setTimeout(() => {
|
|
|
common_vendor.index.switchTab({ url: "/pages/home/index" });
|
|
|
}, 1500);
|
|
|
} else {
|
|
|
- common_vendor.index.__f__("error", "at pages/login/login.vue:125", "Backend login failed:", res);
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:156", "Backend login failed:", res);
|
|
|
common_vendor.index.showToast({ title: ((_a = res.data) == null ? void 0 : _a.message) || "登录失败", icon: "none" });
|
|
|
}
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
common_vendor.index.hideLoading();
|
|
|
- common_vendor.index.__f__("error", "at pages/login/login.vue:131", "Backend request failed:", err);
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:162", "Backend request failed:", err);
|
|
|
common_vendor.index.showToast({ title: "微信登录失败", icon: "none" });
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
common_vendor.index.hideLoading();
|
|
|
- common_vendor.index.__f__("error", "at pages/login/login.vue:138", "uni.login failed:", err);
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:169", "uni.login failed:", err);
|
|
|
common_vendor.index.showToast({ title: "微信登录失败", icon: "none" });
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
- common_vendor.index.__f__("error", "at pages/login/login.vue:144", "uni.getUserProfile failed:", err);
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:175", "uni.getUserProfile failed:", err);
|
|
|
common_vendor.index.showToast({ title: "获取用户信息失败", icon: "none" });
|
|
|
}
|
|
|
});
|
|
@@ -106,7 +113,7 @@ const _sfc_main = {
|
|
|
common_vendor.index.hideLoading();
|
|
|
this.isSendingLoginCode = false;
|
|
|
if (res.statusCode === 200 && res.data) {
|
|
|
- common_vendor.index.__f__("log", "at pages/login/login.vue:175", "Send login code success:", res.data);
|
|
|
+ common_vendor.index.__f__("log", "at pages/login/login.vue:206", "Send login code success:", res.data);
|
|
|
common_vendor.index.showToast({ title: "验证码已发送", icon: "success" });
|
|
|
this.loginCodeTimer = 60;
|
|
|
const timerInterval = setInterval(() => {
|
|
@@ -117,59 +124,87 @@ const _sfc_main = {
|
|
|
}
|
|
|
}, 1e3);
|
|
|
} else {
|
|
|
- common_vendor.index.__f__("error", "at pages/login/login.vue:189", "Send login code failed:", res);
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:220", "Send login code failed:", res);
|
|
|
common_vendor.index.showToast({ title: ((_a = res.data) == null ? void 0 : _a.message) || "发送失败", icon: "none" });
|
|
|
}
|
|
|
} catch (err) {
|
|
|
common_vendor.index.hideLoading();
|
|
|
this.isSendingLoginCode = false;
|
|
|
- common_vendor.index.__f__("error", "at pages/login/login.vue:195", "Send login code request failed:", err);
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:226", "Send login code request failed:", err);
|
|
|
common_vendor.index.showToast({ title: "发送失败", icon: "none" });
|
|
|
}
|
|
|
},
|
|
|
async doLogin() {
|
|
|
- var _a;
|
|
|
+ var _a, _b;
|
|
|
if (!this.agreed) {
|
|
|
common_vendor.index.showToast({ title: "请先同意协议", icon: "none" });
|
|
|
return;
|
|
|
}
|
|
|
- if (!this.phone || !this.code) {
|
|
|
- common_vendor.index.showToast({ title: "请填写手机号和验证码", icon: "none" });
|
|
|
- return;
|
|
|
- }
|
|
|
- common_vendor.index.showLoading({ title: "登录中...", mask: true });
|
|
|
- try {
|
|
|
- const res = await common_vendor.index.request({
|
|
|
- url: "http://localhost:3333/user/login",
|
|
|
- method: "POST",
|
|
|
- data: {
|
|
|
- phone: this.phone,
|
|
|
- code: this.code
|
|
|
- },
|
|
|
- header: { "content-type": "application/json" }
|
|
|
- });
|
|
|
- common_vendor.index.hideLoading();
|
|
|
- if (res.statusCode === 200 && res.data) {
|
|
|
- common_vendor.index.__f__("log", "at pages/login/login.vue:225", "Login success:", res.data);
|
|
|
- common_vendor.index.showToast({ title: "登录成功", icon: "success" });
|
|
|
- setTimeout(() => {
|
|
|
- common_vendor.index.switchTab({ url: "/pages/home/index" });
|
|
|
- }, 1500);
|
|
|
- } else {
|
|
|
- common_vendor.index.__f__("error", "at pages/login/login.vue:232", "Login failed:", res.data);
|
|
|
- common_vendor.index.showToast({ title: ((_a = res.data) == null ? void 0 : _a.message) || "登录失败", icon: "error" });
|
|
|
+ if (this.loginType === "phone") {
|
|
|
+ if (!this.phone || !this.code) {
|
|
|
+ common_vendor.index.showToast({ title: "请填写手机号和验证码", icon: "none" });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ common_vendor.index.showLoading({ title: "登录中...", mask: true });
|
|
|
+ try {
|
|
|
+ const res = await common_vendor.index.request({
|
|
|
+ url: "http://localhost:3333/user/login",
|
|
|
+ method: "POST",
|
|
|
+ data: {
|
|
|
+ phone: this.phone,
|
|
|
+ code: this.code
|
|
|
+ },
|
|
|
+ header: { "content-type": "application/json" }
|
|
|
+ });
|
|
|
+ common_vendor.index.hideLoading();
|
|
|
+ if (res.statusCode === 200 && res.data) {
|
|
|
+ common_vendor.index.showToast({ title: "登录成功", icon: "success" });
|
|
|
+ setTimeout(() => {
|
|
|
+ common_vendor.index.switchTab({ url: "/pages/home/index" });
|
|
|
+ }, 1500);
|
|
|
+ } else {
|
|
|
+ common_vendor.index.showToast({ title: ((_a = res.data) == null ? void 0 : _a.message) || "登录失败", icon: "error" });
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ common_vendor.index.hideLoading();
|
|
|
+ common_vendor.index.showToast({ title: "登录失败", icon: "none" });
|
|
|
+ }
|
|
|
+ } else if (this.loginType === "account") {
|
|
|
+ if (!this.username || !this.password) {
|
|
|
+ common_vendor.index.showToast({ title: "请填写账号和密码", icon: "none" });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ common_vendor.index.showLoading({ title: "登录中...", mask: true });
|
|
|
+ try {
|
|
|
+ const res = await common_vendor.index.request({
|
|
|
+ url: "http://localhost:3333/user/UserPassLogin",
|
|
|
+ method: "POST",
|
|
|
+ data: {
|
|
|
+ username: this.username,
|
|
|
+ password: this.password
|
|
|
+ },
|
|
|
+ header: { "content-type": "application/json" }
|
|
|
+ });
|
|
|
+ common_vendor.index.hideLoading();
|
|
|
+ if (res.statusCode === 200 && res.data && res.data.code === 200) {
|
|
|
+ common_vendor.index.showToast({ title: "登录成功", icon: "success" });
|
|
|
+ setTimeout(() => {
|
|
|
+ common_vendor.index.switchTab({ url: "/pages/home/index" });
|
|
|
+ }, 1500);
|
|
|
+ } else {
|
|
|
+ common_vendor.index.showToast({ title: ((_b = res.data) == null ? void 0 : _b.msg) || "登录失败", icon: "error" });
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ common_vendor.index.hideLoading();
|
|
|
+ common_vendor.index.showToast({ title: "登录失败", icon: "none" });
|
|
|
}
|
|
|
- } catch (err) {
|
|
|
- common_vendor.index.hideLoading();
|
|
|
- common_vendor.index.__f__("error", "at pages/login/login.vue:237", "Login request failed:", err);
|
|
|
- common_vendor.index.showToast({ title: "登录失败", icon: "none" });
|
|
|
}
|
|
|
},
|
|
|
toRegister() {
|
|
|
this.showRegisterPopup = true;
|
|
|
},
|
|
|
toForgot() {
|
|
|
- common_vendor.index.showToast({ title: "跳转找回密码", icon: "none" });
|
|
|
+ this.showForgotPopup = true;
|
|
|
},
|
|
|
openAgreement() {
|
|
|
common_vendor.index.navigateTo({ url: "/pages/agreement/agreement" });
|
|
@@ -204,7 +239,7 @@ const _sfc_main = {
|
|
|
common_vendor.index.hideLoading();
|
|
|
this.isSendingRegCode = false;
|
|
|
if (res.statusCode === 200 && res.data) {
|
|
|
- common_vendor.index.__f__("log", "at pages/login/login.vue:288", "Send registration code success:", res.data);
|
|
|
+ common_vendor.index.__f__("log", "at pages/login/login.vue:345", "Send registration code success:", res.data);
|
|
|
common_vendor.index.showToast({ title: "验证码已发送", icon: "success" });
|
|
|
this.regCodeTimer = 60;
|
|
|
const timerInterval = setInterval(() => {
|
|
@@ -215,13 +250,13 @@ const _sfc_main = {
|
|
|
}
|
|
|
}, 1e3);
|
|
|
} else {
|
|
|
- common_vendor.index.__f__("error", "at pages/login/login.vue:302", "Send registration code failed:", res);
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:359", "Send registration code failed:", res);
|
|
|
common_vendor.index.showToast({ title: ((_a = res.data) == null ? void 0 : _a.message) || "发送失败", icon: "none" });
|
|
|
}
|
|
|
} catch (err) {
|
|
|
common_vendor.index.hideLoading();
|
|
|
this.isSendingRegCode = false;
|
|
|
- common_vendor.index.__f__("error", "at pages/login/login.vue:309", "Send registration code request failed:", err);
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:366", "Send registration code request failed:", err);
|
|
|
common_vendor.index.showToast({ title: "发送失败", icon: "none" });
|
|
|
}
|
|
|
},
|
|
@@ -246,7 +281,7 @@ const _sfc_main = {
|
|
|
});
|
|
|
common_vendor.index.hideLoading();
|
|
|
if (res.statusCode === 200 && res.data) {
|
|
|
- common_vendor.index.__f__("log", "at pages/login/login.vue:337", "Registration success:", res.data);
|
|
|
+ common_vendor.index.__f__("log", "at pages/login/login.vue:394", "Registration success:", res.data);
|
|
|
common_vendor.index.showToast({ title: "注册成功", icon: "success" });
|
|
|
this.regPhone = "";
|
|
|
this.regCode = "";
|
|
@@ -256,14 +291,102 @@ const _sfc_main = {
|
|
|
this.showRegisterPopup = false;
|
|
|
}, 1500);
|
|
|
} else {
|
|
|
- common_vendor.index.__f__("error", "at pages/login/login.vue:349", "Registration failed:", res);
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:406", "Registration failed:", res);
|
|
|
common_vendor.index.showToast({ title: ((_a = res.data) == null ? void 0 : _a.message) || "注册失败", icon: "none" });
|
|
|
}
|
|
|
} catch (err) {
|
|
|
common_vendor.index.hideLoading();
|
|
|
- common_vendor.index.__f__("error", "at pages/login/login.vue:354", "Registration request failed:", err);
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:411", "Registration request failed:", err);
|
|
|
common_vendor.index.showToast({ title: "注册失败", icon: "none" });
|
|
|
}
|
|
|
+ },
|
|
|
+ async sendForgotCode() {
|
|
|
+ var _a;
|
|
|
+ if (this.isSendingForgotCode || this.forgotCodeTimer > 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.forgotPhone) {
|
|
|
+ common_vendor.index.showToast({ title: "请输入手机号", icon: "none" });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.isSendingForgotCode = true;
|
|
|
+ common_vendor.index.showLoading({ title: "发送中...", mask: true });
|
|
|
+ try {
|
|
|
+ const res = await common_vendor.index.request({
|
|
|
+ url: "http://localhost:3333/user/code",
|
|
|
+ method: "POST",
|
|
|
+ data: {
|
|
|
+ phone: this.forgotPhone
|
|
|
+ },
|
|
|
+ header: { "content-type": "application/json" }
|
|
|
+ });
|
|
|
+ common_vendor.index.hideLoading();
|
|
|
+ this.isSendingForgotCode = false;
|
|
|
+ if (res.statusCode === 200 && res.data) {
|
|
|
+ common_vendor.index.__f__("log", "at pages/login/login.vue:441", "Send forgot code success:", res.data);
|
|
|
+ common_vendor.index.showToast({ title: "验证码已发送", icon: "success" });
|
|
|
+ this.forgotCodeTimer = 60;
|
|
|
+ const timerInterval = setInterval(() => {
|
|
|
+ this.forgotCodeTimer--;
|
|
|
+ if (this.forgotCodeTimer <= 0) {
|
|
|
+ clearInterval(timerInterval);
|
|
|
+ this.forgotCodeTimer = 0;
|
|
|
+ }
|
|
|
+ }, 1e3);
|
|
|
+ } else {
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:453", "Send forgot code failed:", res);
|
|
|
+ common_vendor.index.showToast({ title: ((_a = res.data) == null ? void 0 : _a.message) || "发送失败", icon: "none" });
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ common_vendor.index.hideLoading();
|
|
|
+ this.isSendingForgotCode = false;
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:459", "Send forgot code request failed:", err);
|
|
|
+ common_vendor.index.showToast({ title: "发送失败", icon: "none" });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async doResetPassword() {
|
|
|
+ var _a;
|
|
|
+ if (!this.forgotPhone || !this.forgotCode || !this.newPassword || !this.confirmPassword) {
|
|
|
+ common_vendor.index.showToast({ title: "请填写所有信息", icon: "none" });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.newPassword !== this.confirmPassword) {
|
|
|
+ common_vendor.index.showToast({ title: "两次密码输入不一致", icon: "none" });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ common_vendor.index.showLoading({ title: "修改中...", mask: true });
|
|
|
+ try {
|
|
|
+ const res = await common_vendor.index.request({
|
|
|
+ url: "http://localhost:3333/user/ForgetPass",
|
|
|
+ method: "POST",
|
|
|
+ data: {
|
|
|
+ phone: this.forgotPhone,
|
|
|
+ code: this.forgotCode,
|
|
|
+ newPassword: this.newPassword
|
|
|
+ },
|
|
|
+ header: { "content-type": "application/json" }
|
|
|
+ });
|
|
|
+ common_vendor.index.hideLoading();
|
|
|
+ if (res.statusCode === 200 && res.data) {
|
|
|
+ common_vendor.index.__f__("log", "at pages/login/login.vue:491", "Reset password success:", res.data);
|
|
|
+ common_vendor.index.showToast({ title: "密码修改成功", icon: "success" });
|
|
|
+ this.forgotPhone = "";
|
|
|
+ this.forgotCode = "";
|
|
|
+ this.newPassword = "";
|
|
|
+ this.confirmPassword = "";
|
|
|
+ setTimeout(() => {
|
|
|
+ this.showForgotPopup = false;
|
|
|
+ this.loginType = "account";
|
|
|
+ }, 1500);
|
|
|
+ } else {
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:507", "Reset password failed:", res);
|
|
|
+ common_vendor.index.showToast({ title: ((_a = res.data) == null ? void 0 : _a.message) || "修改失败", icon: "none" });
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ common_vendor.index.hideLoading();
|
|
|
+ common_vendor.index.__f__("error", "at pages/login/login.vue:512", "Reset password request failed:", err);
|
|
|
+ common_vendor.index.showToast({ title: "修改失败", icon: "none" });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -314,6 +437,23 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
N: common_vendor.o((...args) => $options.doRegister && $options.doRegister(...args)),
|
|
|
O: common_assets._imports_1,
|
|
|
P: common_vendor.o(($event) => $data.showRegisterPopup = false)
|
|
|
+ } : {}, {
|
|
|
+ Q: $data.showForgotPopup
|
|
|
+ }, $data.showForgotPopup ? {
|
|
|
+ R: $data.forgotPhone,
|
|
|
+ S: common_vendor.o(($event) => $data.forgotPhone = $event.detail.value),
|
|
|
+ T: $data.forgotCode,
|
|
|
+ U: common_vendor.o(($event) => $data.forgotCode = $event.detail.value),
|
|
|
+ V: common_vendor.t($data.forgotCodeTimer > 0 ? $data.forgotCodeTimer + "s" : "获取验证码"),
|
|
|
+ W: common_vendor.o((...args) => $options.sendForgotCode && $options.sendForgotCode(...args)),
|
|
|
+ X: $data.forgotCodeTimer > 0 || $data.isSendingForgotCode,
|
|
|
+ Y: $data.newPassword,
|
|
|
+ Z: common_vendor.o(($event) => $data.newPassword = $event.detail.value),
|
|
|
+ aa: $data.confirmPassword,
|
|
|
+ ab: common_vendor.o(($event) => $data.confirmPassword = $event.detail.value),
|
|
|
+ ac: common_vendor.o((...args) => $options.doResetPassword && $options.doResetPassword(...args)),
|
|
|
+ ad: common_assets._imports_1,
|
|
|
+ ae: common_vendor.o(($event) => $data.showForgotPopup = false)
|
|
|
} : {});
|
|
|
}
|
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|