Yue 2 лет назад
Родитель
Сommit
643e2cd6b0
1 измененных файлов с 8 добавлено и 2 удалено
  1. 8 2
      src/pages/index/index.vue

+ 8 - 2
src/pages/index/index.vue

@@ -14,6 +14,7 @@ function jumpMap() {
   route.navigate("map")
 }
 const companyInfo = ref<Array<any>>([])
+let timer: any = 0
 function getCompany() {
   apis.mobileApi.getCompanyDevice(user.value.companyId).then((res) => {
     if (res.data.monitor1 && res.data.monitor1.length) {
@@ -38,6 +39,8 @@ function getCompany() {
       }
     }
   })
+  clearTimeout(timer)
+  timer = setTimeout(getCompany, 60 * 1000)
 }
 
 function init() {
@@ -53,13 +56,16 @@ function init() {
       } else if (user.value.userType == 2) {
         showLogo.value = false
         showCompany.value = true
-        getCompany()
       }
       uni.showTabBar()
     }, 1000)
   }
 }
-
+onShow(() => {
+  if (user.value.userType == 2) {
+    getCompany()
+  }
+})
 onLoad(init)
 </script>