Files
frontend-app/unpackage/dist/dev/mp-weixin/pages/login/login.js
T
2025-03-23 20:36:06 +08:00

248 lines
7.9 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_enumUtils = require("../../utils/enumUtils.js");
const api_common = require("../../api/common.js");
const api_auth = require("../../api/auth.js");
const utils_auth = require("../../utils/auth.js");
const InputCodeComm = () => "../../components/code-comm/code-comm.js";
const _sfc_main = {
components: {
InputCodeComm
},
data() {
return {
form: {
name: null,
password: null,
code: null
},
inputCss: {
"height": "80rpx",
"background": "#F3F3F3FF",
"border-radius": "30rpx",
"border": "0rpx",
"padding-left": "16px"
},
loginWay: "password",
isShow: false,
// 是否显示
isPolicy: false,
// 是否同意
countdown: false,
// 清空倒计时
butLoading: false
};
},
methods: {
jumpHome() {
common_vendor.index.switchTab({
url: "/pages/home/home"
});
},
async loginFun() {
const then = this;
const form = this.form;
const params = {};
if (!this.isPolicy) {
this.$refs.uToastRef.show({
type: "error",
message: "请阅读完相关协议以及政策,并且勾选同意选项"
});
return;
}
this.butLoading = true;
let response = {};
if (this.loginWay === "password") {
params.mobile = form.name;
params.password = form.password;
response = await api_auth.loginbypw(params);
} else {
params.mobile = form.name;
params.smsCode = form.code;
response = await api_auth.loginbysms(params);
}
const data = response.data;
utils_auth.setStorageFun(utils_auth.TOKEN_NAME, data.token);
utils_auth.setStorageFun(utils_auth.USER_KEY, "");
const userInfo = {
avatar: data.avatarUrl,
name: data.name,
userId: data.userId,
grade: data.grade,
inviteCode: data.inviteCode
};
utils_auth.setStorageFun(utils_auth.USER_DATA, userInfo);
let currentTimeStamp = (/* @__PURE__ */ new Date()).getTime();
utils_auth.setStorageFun(utils_auth.USER_LOGIN_TIME, currentTimeStamp);
this.butLoading = false;
this.$refs.uToastRef.show({
type: "success",
message: response.msg
});
setTimeout(() => {
then.jumpHome();
}, 2e3);
},
checkNameParam(val) {
},
checkParam(val) {
},
/**
* 获取手机验证码
*/
async getMobileCode() {
const form = this.form;
if (!form.name) {
this.$refs.uToastRef.show({
type: "error",
message: "请输入账号"
});
return;
}
this.countdown = true;
const params = {
mobile: form.name,
type: utils_enumUtils.SMS_TYPE.LOGIN
};
const response = await api_common.getUserList(params);
common_vendor.index.__f__("log", "at pages/login/login.vue:208", "responseresponseresponse", response);
if (response && response.bizcode === 100) {
this.$refs.uToastRef.show({
type: "success",
message: response.msg
});
} else {
this.countdown = false;
}
},
jumpRegister() {
common_vendor.index.navigateTo({
url: "/pages/register/register"
});
}
}
};
if (!Array) {
const _easycom_up_image2 = common_vendor.resolveComponent("up-image");
const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
const _easycom_up_count_down2 = common_vendor.resolveComponent("up-count-down");
const _easycom_up_loading_icon2 = common_vendor.resolveComponent("up-loading-icon");
const _easycom_up_checkbox2 = common_vendor.resolveComponent("up-checkbox");
const _easycom_up_toast2 = common_vendor.resolveComponent("up-toast");
(_easycom_up_image2 + _easycom_up_input2 + _easycom_up_count_down2 + _easycom_up_loading_icon2 + _easycom_up_checkbox2 + _easycom_up_toast2)();
}
const _easycom_up_image = () => "../../uni_modules/uview-plus/components/u-image/u-image.js";
const _easycom_up_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js";
const _easycom_up_count_down = () => "../../uni_modules/uview-plus/components/u-count-down/u-count-down.js";
const _easycom_up_loading_icon = () => "../../uni_modules/uview-plus/components/u-loading-icon/u-loading-icon.js";
const _easycom_up_checkbox = () => "../../uni_modules/uview-plus/components/u-checkbox/u-checkbox.js";
const _easycom_up_toast = () => "../../uni_modules/uview-plus/components/u-toast/u-toast.js";
if (!Math) {
(_easycom_up_image + _easycom_up_input + _easycom_up_count_down + _easycom_up_loading_icon + _easycom_up_checkbox + _easycom_up_toast)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: common_vendor.p({
src: "/static/logo.png",
width: "90",
height: "90",
bgColor: "#f1f6ff00",
radius: "10"
}),
b: common_vendor.p({
src: "/static/logo_z.png",
width: "100",
height: "40",
bgColor: "#f1f6ff00"
}),
c: common_vendor.o($options.checkNameParam),
d: common_vendor.o(($event) => $data.form.name = $event),
e: common_vendor.p({
placeholder: "请输入手机号/账户名称",
border: "surround",
customStyle: $data.inputCss,
modelValue: $data.form.name
}),
f: $data.loginWay === "password"
}, $data.loginWay === "password" ? common_vendor.e({
g: $data.isShow
}, $data.isShow ? {
h: common_vendor.o(($event) => {
$data.isShow = false;
}),
i: common_vendor.p({
src: "/static/login/show.png",
width: "20",
height: "20",
bgColor: "#f1f6ff00"
})
} : {
j: common_vendor.o(($event) => {
$data.isShow = true;
}),
k: common_vendor.p({
src: "/static/login/hidden.png",
width: "20",
height: "20",
bgColor: "#f1f6ff00"
})
}, {
l: common_vendor.o($options.checkParam),
m: common_vendor.o(($event) => $data.form.password = $event),
n: common_vendor.p({
placeholder: "请输入密码",
border: "surround",
customStyle: $data.inputCss,
type: $data.isShow ? "text" : "password",
modelValue: $data.form.password
})
}) : common_vendor.e({
o: $data.countdown
}, $data.countdown ? {
p: common_vendor.o(($event) => $data.countdown = false),
q: common_vendor.p({
time: 60 * 1e3,
format: "ss"
})
} : {
r: common_vendor.o((...args) => $options.getMobileCode && $options.getMobileCode(...args))
}, {
s: common_vendor.o(($event) => $data.form.code = $event),
t: common_vendor.p({
placeholder: "请输入验证码",
border: "surround",
customStyle: $data.inputCss,
modelValue: $data.form.code
})
}), {
v: common_vendor.p({
color: "#FFFFFF",
show: $data.butLoading
}),
w: common_vendor.o((...args) => $options.loginFun && $options.loginFun(...args)),
x: $data.loginWay === "password"
}, $data.loginWay === "password" ? {
y: common_vendor.o(($event) => $data.loginWay = "code")
} : {}, {
z: $data.loginWay === "code"
}, $data.loginWay === "code" ? {
A: common_vendor.o(($event) => $data.loginWay = "password")
} : {}, {
B: common_vendor.o((...args) => $options.jumpRegister && $options.jumpRegister(...args)),
C: common_vendor.o(($event) => $data.isPolicy = $event),
D: common_vendor.p({
name: "isCheck",
usedAlone: true,
shape: "circle",
activeColor: "#FF7C41",
size: "19",
iconSize: "18",
checked: $data.isPolicy
}),
E: common_vendor.sr("uToastRef", "e4e4508d-10")
});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-e4e4508d"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/login/login.js.map