You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
3.4 KiB
107 lines
3.4 KiB
"use strict";
|
|
const common_vendor = require("../../../common/vendor.js");
|
|
const common_assets = require("../../../common/assets.js");
|
|
const config_api = require("../../../config/api.js");
|
|
require("../../../uni_modules/uview-plus/index.js");
|
|
const store_index = require("../../../store/index.js");
|
|
const uni_modules_uviewPlus_libs_function_index = require("../../../uni_modules/uview-plus/libs/function/index.js");
|
|
if (!Array) {
|
|
const _easycom_oneBtn2 = common_vendor.resolveComponent("oneBtn");
|
|
_easycom_oneBtn2();
|
|
}
|
|
const _easycom_oneBtn = () => "../../../components/oneBtn/oneBtn.js";
|
|
if (!Math) {
|
|
(_easycom_oneBtn + privacyRadion)();
|
|
}
|
|
const privacyRadion = () => "../../../components/privacyRadion/privacyRadion.js";
|
|
const _sfc_main = {
|
|
__name: "login",
|
|
setup(__props) {
|
|
common_vendor.ref({
|
|
phone: "",
|
|
code: ""
|
|
});
|
|
let isCheck = common_vendor.ref(false);
|
|
function handleBtnClick() {
|
|
uni_modules_uviewPlus_libs_function_index.toast("请先勾先勾选用户协议与隐私政策");
|
|
}
|
|
function changeRadio(val) {
|
|
common_vendor.index.hideKeyboard();
|
|
isCheck.value = val;
|
|
}
|
|
function loginFn() {
|
|
return new Promise((resolve, reject) => {
|
|
common_vendor.index.login({
|
|
provider: "weixin",
|
|
success: (loginRes) => {
|
|
if (loginRes.code) {
|
|
console.log("loginRes.code");
|
|
console.log(loginRes.code);
|
|
resolve(loginRes.code);
|
|
} else {
|
|
console.error("微信登录失败");
|
|
}
|
|
},
|
|
fail: (err) => {
|
|
reject(null);
|
|
console.error("微信登录失败", err);
|
|
common_vendor.index.hideLoading();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
async function getPhoneNumber(e) {
|
|
if (!isCheck.value)
|
|
return uni_modules_uviewPlus_libs_function_index.toast("请勾选产品协议与隐私政策");
|
|
let phoneCode = e.detail.code;
|
|
common_vendor.index.showLoading({
|
|
title: "正在加载..."
|
|
});
|
|
console.log(e.detail.errMsg);
|
|
console.log(e.detail);
|
|
const loginCode = await loginFn();
|
|
if (!loginCode || !phoneCode)
|
|
return;
|
|
let obj = {
|
|
phoneCode,
|
|
socialCode: loginCode
|
|
};
|
|
const {
|
|
data: res
|
|
} = await config_api.weixinLogin(obj);
|
|
const counterStore = store_index.userStore();
|
|
await counterStore.upDateToken(res.accessToken);
|
|
await counterStore.upDateLoginInfo(res);
|
|
common_vendor.index.hideLoading();
|
|
common_vendor.index.$u.toast("登录成功");
|
|
setTimeout(() => {
|
|
common_vendor.index.switchTab({
|
|
url: "/pages/tabbar/index/index"
|
|
});
|
|
}, 1500);
|
|
}
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_assets._imports_0$1,
|
|
b: !common_vendor.unref(isCheck)
|
|
}, !common_vendor.unref(isCheck) ? {
|
|
c: common_vendor.o(handleBtnClick),
|
|
d: common_vendor.p({
|
|
text: "手机号快捷登录"
|
|
})
|
|
} : {
|
|
e: common_vendor.o(getPhoneNumber),
|
|
f: common_vendor.p({
|
|
text: "手机号快捷登录"
|
|
})
|
|
}, {
|
|
g: common_vendor.o(changeRadio),
|
|
h: common_vendor.p({
|
|
isCheck: common_vendor.unref(isCheck)
|
|
})
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-f8b2b374"]]);
|
|
wx.createPage(MiniProgramPage);
|