fix: 多门店切换修改
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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);
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user