import { loginAuth, bindPhone } from "@/manager/LoginManager"; // 引入base.js中的clientId import { clientId } from "@/constant/base"; // 跳转登录 export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" }); // 登录成功后,返回上一页 export const goBack = () => uni.navigateBack({ delta: 1 }); // 登录逻辑 export const onLogin = async (e) => { return new Promise(async (resolve) => { await loginAuth().then(async () => { const { code } = e.detail; console.info("onLogin code: ", code); // 绑定手机号 const params = { wechatPhoneCode: code, clientId: clientId }; const res = await bindPhone(params); if (res.data) { resolve(); } }); }); }; // 检测token export const checkToken = async () => { return new Promise((resolve) => { const token = uni.getStorageSync("token"); if (!token) { console.log("token不存在,重新登录"); loginAuth().then(() => { resolve(); }); return; } resolve(); }); };