增加登录,页面刷新获取店铺详情
This commit is contained in:
@@ -3,6 +3,7 @@ import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||
import { useDictStoreHook } from "@/store/modules/dict";
|
||||
|
||||
import AuthAPI, { type loginRequest } from "@/api/account/login";
|
||||
import ShopApi from "@/api/account/shop";
|
||||
import UserAPI, { type UserInfo } from "@/api/system/user";
|
||||
|
||||
import { setToken, setRefreshToken, getRefreshToken, clearToken } from "@/utils/auth";
|
||||
@@ -12,7 +13,9 @@ export const useUserStore = defineStore("user", () => {
|
||||
const promissionList = useStorage<string[]>("promissionList", [] as string[]);
|
||||
|
||||
localStorage.setItem("shopId", "" + userInfo.value.shopId);
|
||||
|
||||
if (userInfo.value.shopId) {
|
||||
getUserInfo()
|
||||
}
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
@@ -43,13 +46,14 @@ export const useUserStore = defineStore("user", () => {
|
||||
*/
|
||||
function getUserInfo() {
|
||||
return new Promise<UserInfo>((resolve, reject) => {
|
||||
UserAPI.getInfo(userInfo.value.shopId)
|
||||
ShopApi.get({ id: userInfo.value.shopId })
|
||||
.then((data) => {
|
||||
if (!data) {
|
||||
reject("Verification failed, please Login again.");
|
||||
return;
|
||||
}
|
||||
localStorage.setItem("shopId", "" + userInfo.value.shopId);
|
||||
console.log("获取用户信息", data);
|
||||
Object.assign(userInfo.value, { ...data });
|
||||
resolve(data);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user