fix: 修复登录状态判断逻辑以避免重复登录
修复了在用户已登录时重复触发登录逻辑的问题。通过引入 `isLogin` 变量,确保只有在用户未登录时才执行登录操作并跳转页面。
This commit is contained in:
parent
e895e5619c
commit
67addd582f
|
@ -46,14 +46,17 @@ onMounted(() => {
|
||||||
watch(
|
watch(
|
||||||
() => wxStore.userid,
|
() => wxStore.userid,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (newVal && !ab98UserStore.isLogin) {
|
const isLogin = ab98UserStore.isLogin;
|
||||||
|
if (newVal) {
|
||||||
tokenLogin(ab98UserStore.tokenLogin, newVal, wxStore.openid).then(res => {
|
tokenLogin(ab98UserStore.tokenLogin, newVal, wxStore.openid).then(res => {
|
||||||
if (res?.code === 0 && res.data?.success) {
|
if (res?.code === 0 && res.data?.success) {
|
||||||
ab98UserStore.setTel(res.data.tel)
|
ab98UserStore.setTel(res.data.tel)
|
||||||
ab98UserStore.setUserInfo(res.data)
|
ab98UserStore.setUserInfo(res.data)
|
||||||
|
if (!isLogin) {
|
||||||
ab98UserStore.setIsLogin(true)
|
ab98UserStore.setIsLogin(true)
|
||||||
router.push('/')
|
router.push('/')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue