34 lines
728 B
JavaScript
34 lines
728 B
JavaScript
import { loginAuth, checkPhone, bindPhone } from "@/manager/LoginManager";
|
|
|
|
// 跳转登录
|
|
export const goLogin = () => uni.reLaunch({ url: "/pages/login/index" });
|
|
|
|
// 登录逻辑
|
|
export const onLogin = (e) => {
|
|
const { code } = e.detail;
|
|
console.info("onLogin code: ", code);
|
|
|
|
loginAuth().then(async () => {
|
|
// 检测是否绑定手机号
|
|
const res = await checkPhone();
|
|
|
|
if (res.data) return;
|
|
|
|
const params = { wechatPhoneCode: code, clientId: "2" };
|
|
|
|
// 绑定手机号
|
|
bindPhone(params);
|
|
});
|
|
};
|
|
|
|
// 检测token
|
|
export const checkToken = async () => {
|
|
return new Promise((resolve) => {
|
|
const token = uni.getStorageSync("token");
|
|
|
|
if (!token) return;
|
|
|
|
resolve(token);
|
|
});
|
|
};
|