优化返回页面

This commit is contained in:
pengxiaolong
2025-05-22 22:05:55 +08:00
parent 6ca66f45d4
commit c55be10783
59 changed files with 3428 additions and 44 deletions

31
components/VerifyLogin.js Normal file
View File

@@ -0,0 +1,31 @@
function VerifyLogin() {
return new Promise((resolve, reject) => {
uni.getStorage({
key: "userinfo",
success: (res) => {
if (res.data) {
if (res.data.nickName) {
resolve(true);
} else {
uni.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
uni.reLaunch({ url: "/pages/UserInformation/UserInformation" });
resolve(false);
}
} else {
uni.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
uni.navigateTo({ url: '/pages/login/login' });
resolve(false);
}
},
fail: (err) => {
console.error("获取用户信息失败", err);
uni.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
uni.navigateTo({ url: '/pages/login/login' });
reject(err);
}
});
});
}
export default VerifyLogin;