Procházet zdrojové kódy

Merge branch 'iteratoin-20240627-changeRote' into jenkins

lex před 1 rokem
rodič
revize
3c927b55cb
1 změnil soubory, kde provedl 28 přidání a 13 odebrání
  1. 28 13
      src/components/col-header/modals/loganInfo.tsx

+ 28 - 13
src/components/col-header/modals/loganInfo.tsx

@@ -11,7 +11,8 @@ import {
   ElDropdown,
   ElDropdownItem,
   ElDropdownMenu,
-  ElMessageBox
+  ElMessageBox,
+  ElMessage
 } from 'element-plus'
 import classes from './index.module.less'
 import teacherHeader from '@/common/images/icon_teacher.png'
@@ -145,18 +146,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 =
+            userType === 'TEACHER'
+              ? '/api-website/teacher/queryUserInfo'
+              : '/api-website/student/queryUserInfo'
+          const { data } = await request.get(url)
+          console.log(data, userType)
+
+          if (data.lockFlag) {
+            // 账号已锁定
+            ElMessage.error(`无法切换,${str}账号异常`)
+          } else {
+            setAuth(
+              JSON.stringify({
+                token,
+                loginUserType: userType
+              })
+            )
+            router.push({ path: '/' }).then(() => {
+              window.location.reload()
+            })
+          }
+        } catch {
+          // state.user.status = 'init'
+        }
       })
     }
     const logout = async () => {