浏览代码

loading修改

1
mo 2 年之前
父节点
当前提交
b7c94ece66
共有 3 个文件被更改,包括 20 次插入5 次删除
  1. 2 1
      src/api/systemManage.js
  2. 13 3
      src/utils/request-loading.js
  3. 5 1
      src/utils/request.js

+ 2 - 1
src/api/systemManage.js

@@ -50,7 +50,8 @@ export function queryByOrganId (data) {
   return request({
     url: api + '/cooperationOrgan/queryByOrganId',
     method: 'get',
-    params: data
+    params: data,
+    hideLoading:true
   })
 }
 

+ 13 - 3
src/utils/request-loading.js

@@ -10,16 +10,26 @@ export async function showFullScreenLoading(store) {
     await store.dispatch('app/setLoadStatus', true)
     load.startLoading()
   } else {
-    await store.dispatch('app/setLoadCount', 1)
-    clearTimeout(timer)
-    timer = null
+    if(store.getters.loadCount < 0){
+      await store.dispatch('app/resetLoadCount')
+      await store.dispatch('app/setLoadCount', 1)
+      clearTimeout(timer)
+      timer = null
+    }else{
+      await store.dispatch('app/setLoadCount', 1)
+      clearTimeout(timer)
+      timer = null
+    }
+
   }
 
 
 }
 
 export async function tryHideFullScreenLoading(store) {
+  console.log(store.getters.loadCount)
   await store.dispatch('app/setLoadCount', -1)
+
   if (store.getters.loadCount <= 0 && store.getters.isLoading) {
     if(timer)return
     timer = setTimeout(async () => {

+ 5 - 1
src/utils/request.js

@@ -74,7 +74,11 @@ const service = axios.create({
 service.interceptors.request.use(
   async config => {
     // do something before request is sent
-    await showFullScreenLoading(store);
+    let hideLoading = config.hideLoading || false;
+    if (!hideLoading) {
+      await showFullScreenLoading(store);
+    }
+
     if (store.getters.token) {
       // let each request carry token
       // ['X-Token'] is a custom headers key