From 0c02f1bf5f00e6de2c379dc121047b84a5b7c153 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期一, 29 七月 2024 17:50:46 +0800
Subject: [PATCH] ‘’

---
 wechat_staff/utils/request.js |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/wechat_staff/utils/request.js b/wechat_staff/utils/request.js
index 2eda17e..87ecfb4 100644
--- a/wechat_staff/utils/request.js
+++ b/wechat_staff/utils/request.js
@@ -1,8 +1,10 @@
-import { baseUrl } from "./config" 
-export function request(options){
+import { baseUrl } from "./config"
+let number = 0
+export function request(options) {
   let loading = options.loading || '1' // 榛樿鍊�1鏄剧ず锛屽惁鍒欎笉鏄剧ず
-  if(loading == '1'){
+  if (loading == '1') {
     wx.showLoading()
+    number++
   }
   return new Promise(resolve => {
     wx.request({
@@ -18,7 +20,7 @@
         if (res.data.code === 200) {
           resolve(res.data || true)
         } else {
-          if(res.data.code && (res.data.code == 5112 || res.data.code == 5111)){ 
+          if (res.data.code && (res.data.code == 5112 || res.data.code == 5111)) {
             wx.navigateTo({
               url: '/pages/login/index',
             })
@@ -30,18 +32,21 @@
         }
       },
       fail(err) {
-        console.log('err', err);
+        console.log('err', err)
         err.message && wx.showToast({
           title: err.message || '鍙戠敓閿欒',
           icon: 'none'
         })
       },
       complete() {
-        if(loading == '1'){
-          wx.hideLoading()
+        if (loading == '1') {
+          number--
+          if (number == 0) {
+            wx.hideLoading()
+          }
         }
       }
     })
-  } )
+  })
 }
 

--
Gitblit v1.9.3