feat: 登录逻辑的调整
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { loginAuth, bindPhone } from "@/manager/LoginManager";
|
||||
// 引入base.js中的clientId
|
||||
import { clientId } from "@/constant/base";
|
||||
|
||||
import { clientId } from "@/constant/base";
|
||||
import { useAppStore } from "@/store";
|
||||
|
||||
// 跳转登录
|
||||
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
|
||||
|
||||
@@ -14,7 +14,7 @@ export const onLogin = async (e) => {
|
||||
await loginAuth().then(async () => {
|
||||
const { code } = e.detail;
|
||||
console.info("onLogin code: ", code);
|
||||
|
||||
|
||||
// 绑定手机号
|
||||
const params = { wechatPhoneCode: code, clientId: clientId };
|
||||
const res = await bindPhone(params);
|
||||
@@ -26,14 +26,13 @@ export const onLogin = async (e) => {
|
||||
};
|
||||
|
||||
// 检测token
|
||||
export const checkToken = async () => {
|
||||
export const checkToken = () => {
|
||||
return new Promise((resolve) => {
|
||||
const token = uni.getStorageSync("token");
|
||||
if (!token) {
|
||||
console.log("token不存在,重新登录");
|
||||
loginAuth().then(() => {
|
||||
resolve();
|
||||
});
|
||||
const appStore = useAppStore();
|
||||
console.log("appStore.hasToken: ", appStore.hasToken);
|
||||
if (!appStore.hasToken) {
|
||||
console.log("没有token,跳转到登录页");
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
|
||||
Reference in New Issue
Block a user