修复审核不通过的代码

This commit is contained in:
zhouyanli
2026-07-24 08:36:00 +08:00
parent 0cd2323bc2
commit ace7d969ac
7 changed files with 339 additions and 293 deletions

View File

@@ -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) => {
}
});
});
};
};