first commit
This commit is contained in:
203
unpackage/dist/dev/mp-weixin/pages/login/login.js
vendored
Normal file
203
unpackage/dist/dev/mp-weixin/pages/login/login.js
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const common_assets = require("../../common/assets.js");
|
||||
const api_index = require("../../api/index.js");
|
||||
const utils_fun = require("../../utils/fun.js");
|
||||
const uni_modules_wotDesignUni_components_composables_useCountDown = require("../../uni_modules/wot-design-uni/components/composables/useCountDown.js");
|
||||
require("../../uni_modules/wot-design-uni/locale/index.js");
|
||||
require("../../uni_modules/wot-design-uni/dayjs/index.js");
|
||||
const store_index = require("../../store/index.js");
|
||||
if (!Array) {
|
||||
const _easycom_wd_navbar2 = common_vendor.resolveComponent("wd-navbar");
|
||||
_easycom_wd_navbar2();
|
||||
}
|
||||
const _easycom_wd_navbar = () => "../../uni_modules/wot-design-uni/components/wd-navbar/wd-navbar.js";
|
||||
if (!Math) {
|
||||
_easycom_wd_navbar();
|
||||
}
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
__name: "login",
|
||||
setup(__props) {
|
||||
const store = store_index.Store();
|
||||
const { start, pause, reset, current } = uni_modules_wotDesignUni_components_composables_useCountDown.useCountDown({
|
||||
time: 60 * 1e3,
|
||||
onChange(current2) {
|
||||
},
|
||||
onFinish() {
|
||||
codeIngo.value = "重新发送";
|
||||
}
|
||||
});
|
||||
const initialRegisterInfo = {
|
||||
mobile: "",
|
||||
password: "",
|
||||
code: "",
|
||||
inviteCode: "",
|
||||
passwordNew: ""
|
||||
};
|
||||
const registerInfo = common_vendor.ref({ ...initialRegisterInfo });
|
||||
common_vendor.onLoad(() => {
|
||||
if (common_vendor.index.getStorageSync("inviteCode")) {
|
||||
registerInfo.value.inviteCode = common_vendor.index.getStorageSync("inviteCode");
|
||||
common_vendor.index.__f__("log", "at pages/login/login.vue:133", registerInfo.value.inviteCode);
|
||||
} else {
|
||||
common_vendor.index.__f__("log", "at pages/login/login.vue:135", "未取到邀请码");
|
||||
}
|
||||
});
|
||||
const resetRegisterInfo = () => {
|
||||
registerInfo.value = { ...initialRegisterInfo };
|
||||
};
|
||||
const type = common_vendor.ref("login");
|
||||
const codeIngo = common_vendor.ref("点击获取验证码");
|
||||
const activeTab = common_vendor.ref("password");
|
||||
const formData = common_vendor.ref({
|
||||
mobile: "",
|
||||
password: "",
|
||||
code: ""
|
||||
});
|
||||
const submitLoading = common_vendor.ref(false);
|
||||
const back = () => {
|
||||
common_vendor.index.navigateBack();
|
||||
};
|
||||
const switchTabs = (v) => {
|
||||
activeTab.value = v;
|
||||
formData.value = {};
|
||||
};
|
||||
const getCode = (e) => {
|
||||
if (!formData.value.mobile && e == 1) {
|
||||
utils_fun.toast("请输入手机号");
|
||||
return;
|
||||
}
|
||||
if (!registerInfo.value.mobile && e == 2) {
|
||||
utils_fun.toast("请输入手机号");
|
||||
return;
|
||||
}
|
||||
if (current.value.seconds) {
|
||||
utils_fun.toast("请等待倒计时结束");
|
||||
return;
|
||||
}
|
||||
api_index.api.smsCode({
|
||||
mobile: e == 2 ? registerInfo.value.mobile : formData.value.mobile,
|
||||
scene: 1
|
||||
}).then((res) => {
|
||||
start();
|
||||
utils_fun.toast("验证码发送成功");
|
||||
}).catch((err) => {
|
||||
common_vendor.index.__f__("log", "at pages/login/login.vue:192", err);
|
||||
utils_fun.toast("验证码发送失败");
|
||||
});
|
||||
};
|
||||
const login = () => {
|
||||
if (type.value == "register") {
|
||||
if (!registerInfo.value.mobile)
|
||||
return utils_fun.toast("请输入手机号码");
|
||||
if (!registerInfo.value.code)
|
||||
return utils_fun.toast("请输入验证码");
|
||||
if (!registerInfo.value.password)
|
||||
return utils_fun.toast("请输入密码");
|
||||
if (!registerInfo.value.passwordNew)
|
||||
return utils_fun.toast("请再次输入密码");
|
||||
if (registerInfo.value.password != registerInfo.value.passwordNew)
|
||||
return utils_fun.toast("两次密码输入不一致");
|
||||
api_index.api.registerApi(registerInfo.value).then((res) => {
|
||||
common_vendor.index.showModal({
|
||||
title: "提示",
|
||||
content: "注册成功",
|
||||
showCancel: false,
|
||||
success: (res2) => {
|
||||
type.value = "login";
|
||||
resetRegisterInfo();
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if (!formData.value.mobile)
|
||||
return utils_fun.toast("请输入手机号码");
|
||||
if (activeTab.value === "password") {
|
||||
if (!formData.value.password)
|
||||
return utils_fun.toast("请输入登录密码");
|
||||
api_index.api.loginApi(formData.value).then((res) => {
|
||||
common_vendor.index.setStorageSync("Authorization", res.accessToken);
|
||||
store.setUserId(res.userId);
|
||||
store.usersGetInfo();
|
||||
back();
|
||||
});
|
||||
} else {
|
||||
if (!formData.value.code)
|
||||
return utils_fun.toast("请输入验证码");
|
||||
api_index.api.smsLoginApi(formData.value).then((res) => {
|
||||
common_vendor.index.setStorageSync("Authorization", res.accessToken);
|
||||
store.setUserId(res.userId);
|
||||
store.usersGetInfo();
|
||||
back();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: common_assets._imports_0$3,
|
||||
b: common_vendor.o(back),
|
||||
c: common_vendor.p({
|
||||
["left-arrow"]: true,
|
||||
["custom-style"]: "background-color: transparent !important;",
|
||||
safeAreaInsetTop: true
|
||||
}),
|
||||
d: type.value == "login"
|
||||
}, type.value == "login" ? common_vendor.e({
|
||||
e: activeTab.value === "password"
|
||||
}, activeTab.value === "password" ? {} : {}, {
|
||||
f: activeTab.value === "password" ? 1 : "",
|
||||
g: common_vendor.o(($event) => switchTabs("password")),
|
||||
h: activeTab.value === "code"
|
||||
}, activeTab.value === "code" ? {} : {}, {
|
||||
i: activeTab.value === "code" ? 1 : "",
|
||||
j: common_vendor.o(($event) => switchTabs("code"))
|
||||
}) : {}, {
|
||||
k: type.value == "login"
|
||||
}, type.value == "login" ? common_vendor.e({
|
||||
l: formData.value.mobile,
|
||||
m: common_vendor.o(($event) => formData.value.mobile = $event.detail.value),
|
||||
n: activeTab.value === "password"
|
||||
}, activeTab.value === "password" ? {
|
||||
o: formData.value.password,
|
||||
p: common_vendor.o(($event) => formData.value.password = $event.detail.value)
|
||||
} : {
|
||||
q: formData.value.code,
|
||||
r: common_vendor.o(($event) => formData.value.code = $event.detail.value),
|
||||
s: common_vendor.t(common_vendor.unref(current).seconds || codeIngo.value),
|
||||
t: common_vendor.o(($event) => getCode(1))
|
||||
}) : {}, {
|
||||
v: type.value == "register"
|
||||
}, type.value == "register" ? {
|
||||
w: registerInfo.value.mobile,
|
||||
x: common_vendor.o(($event) => registerInfo.value.mobile = $event.detail.value),
|
||||
y: registerInfo.value.code,
|
||||
z: common_vendor.o(($event) => registerInfo.value.code = $event.detail.value),
|
||||
A: common_vendor.t(common_vendor.unref(current).seconds || codeIngo.value),
|
||||
B: common_vendor.o(($event) => getCode(2)),
|
||||
C: registerInfo.value.password,
|
||||
D: common_vendor.o(($event) => registerInfo.value.password = $event.detail.value),
|
||||
E: registerInfo.value.passwordNew,
|
||||
F: common_vendor.o(($event) => registerInfo.value.passwordNew = $event.detail.value),
|
||||
G: registerInfo.value.inviteCode,
|
||||
H: common_vendor.o(($event) => registerInfo.value.inviteCode = $event.detail.value)
|
||||
} : {}, {
|
||||
I: type.value == "register"
|
||||
}, type.value == "register" ? {
|
||||
J: common_vendor.o(($event) => type.value = "login")
|
||||
} : {}, {
|
||||
K: type.value == "login"
|
||||
}, type.value == "login" ? {
|
||||
L: common_vendor.o(($event) => type.value = "register")
|
||||
} : {}, {
|
||||
M: common_vendor.t(type.value == "register" ? "注册" : "登录"),
|
||||
N: submitLoading.value,
|
||||
O: submitLoading.value,
|
||||
P: common_vendor.o(login)
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-e4e4508d"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/login.js.map
|
||||
Reference in New Issue
Block a user