|
|
@@ -15,6 +15,7 @@ export const useAuthStore = defineStore('auth', {
|
|
|
userId: 0,
|
|
|
userInfo: null as null|UserInfo,
|
|
|
loginType: -1,
|
|
|
+ loginMp: false,
|
|
|
}),
|
|
|
actions: {
|
|
|
async loadLoginState() {
|
|
|
@@ -28,6 +29,7 @@ export const useAuthStore = defineStore('auth', {
|
|
|
this.expireAt = authInfo.expireAt;
|
|
|
this.userInfo = authInfo.userInfo;
|
|
|
this.loginType = authInfo.loginType ?? -1;
|
|
|
+ this.loginMp = authInfo.loginMp ?? false;
|
|
|
this.shareLoginInfo();
|
|
|
|
|
|
//检查登录是否过期
|
|
|
@@ -37,6 +39,7 @@ export const useAuthStore = defineStore('auth', {
|
|
|
this.token = '';
|
|
|
this.userId = 0;
|
|
|
this.userInfo = null;
|
|
|
+ this.loginMp = false;
|
|
|
|
|
|
console.log('loadLoginState', error);
|
|
|
}
|
|
|
@@ -58,6 +61,7 @@ export const useAuthStore = defineStore('auth', {
|
|
|
} else {
|
|
|
this.loginType = LOGIN_TYPE_USER;
|
|
|
}
|
|
|
+ this.loginMp = true;
|
|
|
this.loginResultHandle(loginResult, this.loginType);
|
|
|
},
|
|
|
async loginMobile(mobile: string, password: string) {
|
|
|
@@ -65,6 +69,7 @@ export const useAuthStore = defineStore('auth', {
|
|
|
mobile,
|
|
|
password,
|
|
|
})
|
|
|
+ this.loginMp = false;
|
|
|
this.loginResultHandle(loginResult);
|
|
|
},
|
|
|
async loginCollect(mobile: string, password: string, loginType: number) {
|
|
|
@@ -81,6 +86,7 @@ export const useAuthStore = defineStore('auth', {
|
|
|
})
|
|
|
} else
|
|
|
throw 'login type error';
|
|
|
+ this.loginMp = false;
|
|
|
this.loginResultHandle(loginResult, loginType);
|
|
|
},
|
|
|
async loginResultHandle(loginResult: LoginResult, loginType: number = -1) {
|
|
|
@@ -117,11 +123,14 @@ export const useAuthStore = defineStore('auth', {
|
|
|
this.token = '';
|
|
|
this.userId = 0;
|
|
|
this.userInfo = null;
|
|
|
-
|
|
|
+ this.loginMp = false;
|
|
|
uni.removeStorage({ key: STORAGE_KEY });
|
|
|
}
|
|
|
},
|
|
|
getters: {
|
|
|
+ isLoginMp(state) {
|
|
|
+ return state.loginMp;
|
|
|
+ },
|
|
|
isLogged(state) {
|
|
|
return state.token != '' && state.userId != 0
|
|
|
},
|