Files
tk-mini-program/components/VerifyLogin.js

31 lines
1.1 KiB
JavaScript
Raw Normal View History

2025-08-05 22:05:56 +08:00
function VerifyLogin(id) {
2025-05-22 22:05:55 +08:00
return new Promise((resolve, reject) => {
uni.getStorage({
key: "userinfo",
success: (res) => {
if (res.data) {
if (res.data.nickName) {
resolve(true);
} else {
2025-08-05 22:05:56 +08:00
uni.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route+"?inid=" + id);
2025-05-22 22:05:55 +08:00
uni.reLaunch({ url: "/pages/UserInformation/UserInformation" });
resolve(false);
}
} else {
2025-08-05 22:05:56 +08:00
uni.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route+"?inid=" + id);
2025-05-22 22:05:55 +08:00
uni.navigateTo({ url: '/pages/login/login' });
resolve(false);
}
},
fail: (err) => {
2025-08-05 22:05:56 +08:00
uni.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route+"?inid=" + id);
2025-05-22 22:05:55 +08:00
uni.navigateTo({ url: '/pages/login/login' });
reject(err);
}
});
});
}
export default VerifyLogin;