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) { async function handleCommand(command) {
console.log(command) console.log(command)
let res = state.branchList.filter(v => v.shopId == command)[0] 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) await ShopApi.getBranchChange(res.shopId)
// localStorage.setItem("branch_shopId", res.shopId) // localStorage.setItem("branch_shopId", res.shopId)
localStorage.setItem("shopName", res.shopName) localStorage.setItem("shopName", res.shopName)

View File

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