purchase-let/unpackage/dist/dev/mp-weixin/pages/login/login.js

188 lines
6.4 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const api_user = require("../../api/user.js");
const store_user = require("../../store/user.js");
require("../../utils/request.js");
require("../../config/app.js");
if (!Array) {
const _easycom_up_navbar2 = common_vendor.resolveComponent("up-navbar");
const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
const _easycom_up_button2 = common_vendor.resolveComponent("up-button");
const _easycom_up_transition2 = common_vendor.resolveComponent("up-transition");
const _easycom_up_input2 = common_vendor.resolveComponent("up-input");
const _easycom_up_code2 = common_vendor.resolveComponent("up-code");
(_easycom_up_navbar2 + _easycom_up_icon2 + _easycom_up_button2 + _easycom_up_transition2 + _easycom_up_input2 + _easycom_up_code2)();
}
const _easycom_up_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
const _easycom_up_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_up_button = () => "../../uni_modules/uview-plus/components/u-button/u-button.js";
const _easycom_up_transition = () => "../../uni_modules/uview-plus/components/u-transition/u-transition.js";
const _easycom_up_input = () => "../../uni_modules/uview-plus/components/u-input/u-input.js";
const _easycom_up_code = () => "../../uni_modules/uview-plus/components/u-code/u-code.js";
if (!Math) {
(_easycom_up_navbar + _easycom_up_icon + _easycom_up_button + _easycom_up_transition + _easycom_up_input + _easycom_up_code)();
}
const _sfc_main = {
__name: "login",
setup(__props) {
store_user.useUserStore();
const showWeixin = common_vendor.ref(true);
const isAgree = common_vendor.ref(false);
const weixinLogin = () => {
if (!isAgree.value)
return common_vendor.index.$u.toast("请先阅读并同意协议");
common_vendor.index.showLoading({
title: "登录中"
});
common_vendor.index.login({
provider: "weixin",
success: (res) => {
return console.log(res);
},
fail: (err) => {
console.log(err);
common_vendor.index.$u.toast("登录失败");
}
});
};
common_vendor.ref(null);
const loginForm = common_vendor.ref({
phone: "15366662222",
code: ""
});
const isPhone = () => {
loginForm.value.phone = loginForm.value.phone.replace(/\s*/g, "");
return !/^1[3456789]\d{9}$/.test(loginForm.value.phone);
};
const codeLogin = () => {
if (!isAgree.value)
return common_vendor.index.$u.toast("请先阅读并同意协议");
if (isPhone())
return common_vendor.index.$u.toast("请输入正确的手机号码");
console.log("登录");
api_user.userLoginApi({
account: "17811111111",
password: "1111",
terminal: 3,
scene: 1
}).then((res) => {
console.log(res);
});
};
const tips = common_vendor.ref("");
const seconds = common_vendor.ref(60);
const uCodeRef = common_vendor.ref(null);
const codeChange = (text) => {
tips.value = text;
};
const getCode = () => {
if (!isAgree.value)
return common_vendor.index.$u.toast("请先阅读并同意协议");
if (uCodeRef.value.canGetCode) {
if (isPhone())
return common_vendor.index.$u.toast("请输入正确的手机号码");
common_vendor.index.showLoading({
title: "正在获取验证码"
});
setTimeout(() => {
common_vendor.index.hideLoading();
common_vendor.index.$u.toast("验证码已发送");
uCodeRef.value.start();
}, 2e3);
} else {
common_vendor.index.$u.toast("倒计时结束后再发送");
}
};
const navBack = () => {
if (showWeixin.value == false) {
showWeixin.value = true;
return true;
} else
common_vendor.index.navigateBack();
};
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.o(navBack),
b: common_vendor.p({
title: "登录",
autoBack: false,
placeholder: true,
bgColor: "rgba(0,0,0,0)"
}),
c: showWeixin.value
}, showWeixin.value ? {
d: common_vendor.p({
name: "weixin-fill",
color: "#fff",
size: "28"
}),
e: common_vendor.o(weixinLogin),
f: common_vendor.p({
color: "#20B128",
size: "large"
}),
g: common_vendor.o(($event) => showWeixin.value = false),
h: common_vendor.p({
color: "#ECFFEE",
size: "large"
}),
i: common_vendor.p({
show: showWeixin.value
})
} : {
j: common_vendor.o(($event) => loginForm.value.phone = $event),
k: common_vendor.p({
customStyle: {
height: "100%"
},
placeholderClass: "place",
border: "none",
placeholder: "请输入手机号",
type: "number",
modelValue: loginForm.value.phone
}),
l: common_vendor.sr(uCodeRef, "23c3038c-8,23c3038c-7", {
"k": "uCodeRef"
}),
m: common_vendor.o(codeChange),
n: common_vendor.p({
seconds: seconds.value
}),
o: common_vendor.t(tips.value),
p: common_vendor.o(getCode),
q: common_vendor.o(($event) => loginForm.value.code = $event),
r: common_vendor.p({
customStyle: {
height: "100%"
},
maxlength: 4,
placeholderClass: "place",
border: "none",
placeholder: "请输入验证码",
type: "number",
modelValue: loginForm.value.code
}),
s: common_vendor.o(codeLogin),
t: common_vendor.p({
color: "#20B128",
size: "large"
}),
v: common_vendor.p({
show: !showWeixin.value
})
}, {
w: !isAgree.value
}, !isAgree.value ? {
x: common_vendor.o(($event) => isAgree.value = true),
y: common_assets._imports_1
} : {
z: common_vendor.o(($event) => isAgree.value = false),
A: common_assets._imports_0
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/里海数字乡村/purchase-let/pages/login/login.vue"]]);
wx.createPage(MiniProgramPage);