diff --git a/src/pages/tabbar/my.vue b/src/pages/tabbar/my.vue index 4ff853f..0d97c75 100644 --- a/src/pages/tabbar/my.vue +++ b/src/pages/tabbar/my.vue @@ -127,29 +127,29 @@ const doLogin = async (loginType: number, token: string, accountId: string | nul // authData = response.data break case 2: - // if (isEmpty(tokenStorage) || isEmpty(userStorage)) { - try { - uni.showLoading({ - title: "登录中...", - mask: true, - }) - const res = await userApi.auth(token) - if (res?.code === 0) { - uni.setStorageSync(tokenKey, res.data) + if (isEmpty(tokenStorage) || isEmpty(userStorage)) { + try { + uni.showLoading({ + title: "登录中...", + mask: true, + }) + const res = await userApi.auth(token) + if (res?.code === 0) { + uni.setStorageSync(tokenKey, res.data) + uni.hideLoading() + uni.showToast({ title: "登录成功", icon: "none" }) + const { data: userData } = await userApi.userInfo() + uni.setStorageSync(userInfoKey, userData) + getStorageUserInfo() + } else { + uni.hideLoading() + uni.showToast({ title: "获取浙政钉用户信息失败", icon: "none" }) + } + } catch (error) { uni.hideLoading() - uni.showToast({ title: "登录成功", icon: "none" }) - const { data: userData } = await userApi.userInfo() - uni.setStorageSync(userInfoKey, userData) - getStorageUserInfo() - } else { - uni.hideLoading() - uni.showToast({ title: "获取浙政钉用户信息失败", icon: "none" }) + uni.showToast({ title: "错误", icon: "none" }) } - } catch (error) { - uni.hideLoading() - uni.showToast({ title: "错误", icon: "none" }) } - // } break default: uni.showToast({ title: "当前登录环境未知", icon: "none" })