Browse Source

Update loganInfo.tsx

lex 1 year ago
parent
commit
55e7d39515
1 changed files with 26 additions and 12 deletions
  1. 26 12
      src/components/col-header/modals/loganInfo.tsx

+ 26 - 12
src/components/col-header/modals/loganInfo.tsx

@@ -145,18 +145,32 @@ export default defineComponent({
       }
       ElMessageBox.confirm(`是否确定切换到${str}?`, '提示', {
         type: 'warning'
-      }).then(() => {
-        setAuth(
-          JSON.stringify({
-            token,
-            loginUserType: userType
-          })
-        )
-        router.push({ path: '/' })
-        // router.push({ path: nowPath, query: { ...route.query } })
-        setTimeout(() => {
-          window.location.reload()
-        }, 500)
+      }).then(async () => {
+        try {
+          const url =
+            states.userType === 'TEACHER'
+              ? '/api-website/teacher/queryUserInfo'
+              : '/api-website/student/queryUserInfo'
+          const { data } = await request.get(url)
+
+          if (data.userType.indexOf(userType) != -1) {
+            setAuth(
+              JSON.stringify({
+                token,
+                loginUserType: userType
+              })
+            )
+            router.push({ path: '/' })
+            // router.push({ path: nowPath, query: { ...route.query } })
+            setTimeout(() => {
+              window.location.reload()
+            }, 500)
+          } else {
+            // 账号已锁定
+          }
+        } catch {
+          // state.user.status = 'init'
+        }
       })
     }
     const logout = async () => {