lex 2 lat temu
rodzic
commit
9635a40ccf

+ 0 - 1
src/views/login/components/login/index.tsx

@@ -29,7 +29,6 @@ export default defineComponent({
     tabType(val: string) {
       // 切换登录类型时需要清除定时器
       if (val != 'qrLogin') {
-        sessionStorage.removeItem('scanCode')
         clearInterval(state.loginPopupTimer)
       }
     }

+ 6 - 9
src/views/login/components/qr-login/index.tsx

@@ -43,12 +43,7 @@ export default defineComponent({
   async mounted() {
     try {
       const scanCode = sessionStorage.getItem('scanCode')
-      if (scanCode) {
-        this.scanCode = scanCode
-        sessionStorage.removeItem('scanCode')
-      } else {
-        await this.getCode()
-      }
+      await this.getCode(scanCode)
       const str = this.loginType === 'TEACHER' ? 'teacher' : 'student'
       this.qrCode = `${getCodeBaseUrl(`/${str}`)}/#/scanLogin?code=${
         this.scanCode
@@ -62,12 +57,13 @@ export default defineComponent({
     }
   },
   methods: {
-    async getCode() {
+    async getCode(code?: string) {
       try {
         const res = await request.get('/api-auth/getQRLoginCode', {
           params: {
             clientId: 'website',
-            clientSecret: 'website'
+            clientSecret: 'website',
+            code
           }
         })
         this.scanCode = res.data.code
@@ -185,7 +181,8 @@ export default defineComponent({
                     size="small"
                     onClick={async () => {
                       this.codeTimerOut = false
-                      await this.getCode()
+                      const scanCode = sessionStorage.getItem('scanCode')
+                      await this.getCode(scanCode)
                       state.loginPopupTimer = setInterval(async () => {
                         await this.getList()
                       }, 5000)