修复审核不通过的代码
This commit is contained in:
@@ -42,12 +42,20 @@ export default function request(url, data = {}, method = "GET") {
|
||||
|
||||
const resData = res.data || {};
|
||||
|
||||
// token 过期
|
||||
// token 过期 — 清除登录态,提示用户,但不强制跳转(用户可继续浏览非敏感页面)
|
||||
if (resData.code === 401) {
|
||||
uni.showToast({ title: '登录过期,请重新登录', icon: 'none' });
|
||||
uni.clearStorageSync('token');
|
||||
uni.showToast({ title: '登录已过期,请重新登录', icon: 'none', duration: 2000 });
|
||||
uni.removeStorageSync('token');
|
||||
uni.removeStorageSync('userId');
|
||||
// 使用 navigateTo 而非 reLaunch,用户可通过返回按钮退出登录页
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' });
|
||||
uni.navigateTo({
|
||||
url: '/pageSubPack/loginSub/pwd-login',
|
||||
fail: () => {
|
||||
// 如果 navigateTo 失败(如页面栈满),则用 reLaunch
|
||||
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' });
|
||||
}
|
||||
});
|
||||
}, 1500);
|
||||
reject({ msg: '登录过期', code: 401 });
|
||||
return;
|
||||
@@ -102,4 +110,4 @@ export const upload = (filePath, url) => {
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user