浏览代码

扫码授权网页登录调整

Xiao_123 1 天之前
父节点
当前提交
ce74244e04
共有 2 个文件被更改,包括 13 次插入13 次删除
  1. 11 11
      pagesB/websiteLoginVerification/index.vue
  2. 2 2
      store/user.js

+ 11 - 11
pagesB/websiteLoginVerification/index.vue

@@ -81,14 +81,6 @@ const handleToDetail = (type) => {
   })
 }
 
-const handleRemove = () => {
-  uni.removeStorageSync('wxLoginCode')
-  setTimeout(() => {
-		uni.switchTab({
-			url: '/pages/index/my'
-		})
-	}, 2000)
-}
 
 // 已登录的授权给网页
 const handleTokenLogin = async () => {
@@ -110,15 +102,23 @@ const handleTokenLogin = async () => {
 		}
 		try {
 			await weixinLoginAuthorize({ uuid: uni.getStorageSync('wxLoginCode') })
+
 			uni.showToast({ title: '授权网页登录成功', duration: 2000, icon: 'none' })
-			handleRemove()
+			uni.setStorageSync('necessaryInfoReady', necessaryInfoReady ? 'ready' : 'student')
+			setTimeout(() => {
+				uni.switchTab({
+					url: '/pages/index/my'
+				})
+			}, 2000)
+
 		} catch (error) {
 			console.log(error, '授权接口error')
-			handleRemove()
+		} finally {
+			uni.removeStorageSync('wxLoginCode')
 		}
 	}
   else showAuthModal('necessaryInfo')
-  uni.setStorageSync('necessaryInfoReady', necessaryInfoReady ? 'ready' : 'student')
+  // uni.setStorageSync('necessaryInfoReady', necessaryInfoReady ? 'ready' : 'student')
 }
 
 // 微信登录

+ 2 - 2
store/user.js

@@ -126,8 +126,8 @@ export const userStore = defineStore('user', {
 
       console.log(data, data.type === '1', '当前账号角色是否为学生')
 
-      // 是学生则跳转学生专区
-      if (jump && data && data?.type === '1') {
+      // 是学生则跳转学生专区(且不是在进行扫码授权网页登录)
+      if (jump && data && data?.type === '1' && !uni.getStorageSync('wxLoginCode')) {
         uni.navigateTo({
           url: '/pagesA/student/index'
         })