优化代码

This commit is contained in:
pengxiaolong
2025-09-29 20:48:31 +08:00
parent 0a721e99f8
commit 0044f8f334
63 changed files with 667 additions and 137 deletions

View File

@@ -0,0 +1,93 @@
"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 stores_counter = require("../../stores/counter.js");
const counter = stores_counter.useCounterStore();
const _sfc_main = {
data() {
return {
title: "Hello",
EmailOrAccount: "",
Password: ""
};
},
onLoad() {
},
methods: {
// 登录
onLogin() {
const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,16}$/;
if (!passwordRegex.test(this.Password)) {
common_vendor.index.showToast({
title: "密码必须包含大小写字母和数字长度6-16位",
icon: "none"
});
return;
}
common_vendor.index.showLoading({
title: "登录中...",
mask: true
});
components_request.request({
url: "user/loginWithMail",
method: "POST",
data: {
userNameOrEmail: this.EmailOrAccount,
password: this.Password
},
userInfo: false
}).then((res) => {
common_vendor.index.hideLoading();
common_vendor.index.__f__("log", "at pages/loginWithEmailOrAccount/loginWithEmailOrAccount.vue:74", res);
this.info = res;
const now = Date.now();
common_vendor.index.setStorageSync("last_clean_time", now);
counter.$patch({ myitem: this.info.data });
if (res.code === 200) {
common_vendor.index.setStorageSync("userinfo", this.info.data);
common_vendor.index.setStorageSync("token", this.info.data.token);
components_goEasyTool_tool.goEasylogin(
this.$goeasy,
String(this.info.data.id),
this.info.data.headerIcon,
this.info.data.nickName
);
common_vendor.index.reLaunch({
url: this.lastPage || "/pages/Home/Home"
});
} else {
common_vendor.index.showToast({
title: res.msg,
icon: "none"
});
}
}).catch((err) => {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: err.msg,
icon: "none"
});
});
},
// 返回上一页
onBack() {
common_vendor.index.navigateBack({
delta: 1
});
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.o((...args) => $options.onBack && $options.onBack(...args)),
b: $data.EmailOrAccount,
c: common_vendor.o(($event) => $data.EmailOrAccount = $event.detail.value),
d: $data.Password,
e: common_vendor.o(($event) => $data.Password = $event.detail.value),
f: common_vendor.o((...args) => $options.onLogin && $options.onLogin(...args))
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-4471409d"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/loginWithEmailOrAccount/loginWithEmailOrAccount.js.map