fix: 多门店切换修改

This commit is contained in:
GaoHao 2025-04-09 10:46:56 +08:00
parent 1cc9949cd8
commit 373fd88226
2 changed files with 9 additions and 5 deletions

View File

@ -53,7 +53,10 @@ async function geiShopList() {
async function handleCommand(command) {
console.log(command)
let res = state.branchList.filter(v => v.shopId == command)[0]
// localStorage.setItem("shopId", res.shopId )
// localStorage.getItem("shopId")
if (localStorage.getItem("shopId") == command) {
return
}
await ShopApi.getBranchChange(res.shopId)
// localStorage.setItem("branch_shopId", res.shopId)
localStorage.setItem("shopName", res.shopName)

View File

@ -38,7 +38,7 @@ export const useUserStore = defineStore("user", () => {
setToken(token);
setRefreshToken(token);
localStorage.setItem("shopId", "" + data.shopInfo.id);
localStorage.setItem("branch_shopId",data.shopInfo.id)
localStorage.setItem("branch_shopId", data.shopInfo.id)
resolve();
})
.catch((error) => {
@ -52,16 +52,17 @@ export const useUserStore = defineStore("user", () => {
*
* @returns {UserInfo}
*/
function getUserInfo() {
function getUserInfo(shopId?: string | number) {
return new Promise<UserInfo>((resolve, reject) => {
ShopApi.get({ id: userInfo.value.shopId })
ShopApi.get({ id: shopId || userInfo.value.shopId })
.then((data) => {
if (!data) {
reject("Verification failed, please Login again.");
return;
}
console.log(userInfo)
localStorage.setItem("shopId", "" + userInfo.value.shopId);
console.log(data)
localStorage.setItem("shopId", "" + data.id);
Object.assign(userInfo.value, { ...data, roles: [], promissionList: [], shopId: userInfo.value.shopId });
resolve(userInfo.value);
})