feat: 商户端无权限提出返回到用户端

This commit is contained in:
2026-08-10 15:47:15 +08:00
parent 633977ce32
commit 14fa7b32c4
+26
View File
@@ -152,6 +152,32 @@ http.interceptors.response.use(
if (response.data.code === 401) { if (response.data.code === 401) {
return refreshToken(response.config); 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')) { if ((response.data.code + '').includes('1011007')) {
console.error(`分销用户绑定失败,原因:${response.data.msg}`); console.error(`分销用户绑定失败,原因:${response.data.msg}`);