Browse Source

fix:获取绑定空间失败的时候重新调接口

chenzhen2 1 year ago
parent
commit
71e9a81d4e
1 changed files with 21 additions and 3 deletions
  1. 21 3
      src/views/home/index.vue

+ 21 - 3
src/views/home/index.vue

@@ -82,6 +82,7 @@ import { Form, Field, CellGroup, Button, Toast } from "vant";
 import { getCookieMac, setToken } from "@/utils/cookies";
 import { getPadQrCodeStatus, queryWorkSpace } from "@/apis/envmonitor";
 import { UserMutationTypes } from "@/store/modules/user/mutation-types";
+import { setTimeout, clearTimeout } from 'timers';
 
 export default defineComponent({
   components: {
@@ -97,7 +98,7 @@ export default defineComponent({
       if (to.query.type !== "logoOut") {
         next((e: any) => {
           console.log(e);
-          e.queryWorkSpace();
+          e.queryPageWorkSpace();
         });
       } else {
         next((e: any) => {
@@ -120,12 +121,14 @@ export default defineComponent({
     const store = useStore();
     const codeStatus: any = {};
     const timer: any = null;
+    const spaceTimer:any=null;
     const orgin: any = location.origin;
     const proxyData = reactive({
       parseImgUrl: parseImgUrl,
       codeValue: `${orgin}/sgipad/home`,
       showLogin: false,
       size: 134,
+      spaceTimer:spaceTimer,
       type: 1, // 1:二维码登录 2:用户密码登录
       userInfo: userInfo,
       checkLoginType() {
@@ -165,9 +168,13 @@ export default defineComponent({
         });
       },
       // 查询工作空间
-      queryWorkSpace() {
+      queryPageWorkSpace() {
         if (!proxyData.userInfo.mac) {
-          proxyData.showLogin = true;
+          // proxyData.showLogin = true;
+          // next("/error");
+          router.push({
+            name:'error'
+          })
         } else {
           let params: any = {
             criteria: {
@@ -202,10 +209,19 @@ export default defineComponent({
                 }
               } else {
                 proxyData.showLogin = true;
+                proxyData.spaceTimer=setTimeout(()=>{
+                proxyData.queryPageWorkSpace();
+                clearTimeout(proxyData.spaceTimer);
+              },5000)
               }
             })
             .catch(() => {
               proxyData.showLogin = true;
+              proxyData.spaceTimer=setTimeout(()=>{
+                proxyData.queryPageWorkSpace();
+                clearTimeout(proxyData.spaceTimer);
+              },5000)
+            
             });
         }
       },
@@ -281,6 +297,8 @@ export default defineComponent({
       if (proxyData.timer) {
         clearTimeout(proxyData.timer);
         proxyData.timer = null;
+        clearTimeout(proxyData.spaceTimer);
+        proxyData.spaceTimer=null;
       }
     });
     onMounted(() => {