恢复登录页

This commit is contained in:
zhouyanli
2026-08-04 14:41:18 +08:00
parent 4d038dbaf9
commit 491c3a320a
11 changed files with 62 additions and 2897 deletions

View File

@@ -42,10 +42,21 @@ export default function request(url, data = {}, method = "GET") {
const resData = res.data || {};
// token 过期 — 静默清除登录态,不强制跳转登录页
// token 过期 — 清除登录态,提示用户,但不强制跳转(用户可继续浏览非敏感页面)
if (resData.code === 401) {
uni.showToast({ title: '登录已过期,请重新登录', icon: 'none', duration: 2000 });
uni.removeStorageSync('token');
uni.removeStorageSync('userId');
// 使用 navigateTo 而非 reLaunch,用户可通过返回按钮退出登录页
setTimeout(() => {
uni.navigateTo({
url: '/pageSubPack/loginSub/pwd-login',
fail: () => {
// 如果 navigateTo 失败(如页面栈满),则用 reLaunch
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' });
}
});
}, 1500);
reject({ msg: '登录过期', code: 401 });
return;
}