diff --git a/sheep/request/index.js b/sheep/request/index.js index 166cf86..038ad4a 100644 --- a/sheep/request/index.js +++ b/sheep/request/index.js @@ -152,6 +152,32 @@ http.interceptors.response.use( if (response.data.code === 401) { return refreshToken(response.config); } + // 特殊:商户端接口返回 code=1013000009 且 msg="无权操作该门店"时,自动踢出商户端,回到用户端首页 + const appStore = $store('app'); + const isMerchant = appStore?.bizMode === 'merchant'; + const codeRaw = Number(response.data.code ?? -1); + const msg = String(response.data.msg || ''); + const isUnauthStore = + isMerchant && + codeRaw === 1013000009 && + msg.indexOf('无权操作该门店') >= 0; + if (isUnauthStore) { + try { + appStore.setBizMode('user'); + } catch (e) {} + const selectedKey = 'merchant.pickup.selectedStoreId'; + try { uni.removeStorageSync(selectedKey); } catch (e) {} + uni.showToast({ + title: msg || '无权操作该门店', + icon: 'none', + mask: true, + duration: 2000, + }); + setTimeout(() => { + uni.reLaunch({ url: '/pages/index/index' }); + }, 500); + return Promise.reject(response.data); + } // 特殊:处理分销用户绑定失败的提示 if ((response.data.code + '').includes('1011007')) { console.error(`分销用户绑定失败,原因:${response.data.msg}`);