From 7dc29ed74ebaa8a0e66f68264d9a13f95dc3af21 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 02 八月 2024 11:09:06 +0800
Subject: [PATCH] aa

---
 wechat_staff/utils/request.js |   36 ++++++++++++++++++++++--------------
 1 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/wechat_staff/utils/request.js b/wechat_staff/utils/request.js
index 7d34329..6056b6b 100644
--- a/wechat_staff/utils/request.js
+++ b/wechat_staff/utils/request.js
@@ -1,11 +1,12 @@
 import { baseUrl } from "./config"
-
-export function request(options){
+let number = 0
+export function request(options) {
   let loading = options.loading || '1' // 榛樿鍊�1鏄剧ず锛屽惁鍒欎笉鏄剧ず
-  if(loading == '1'){
-    wx.showLoading()
+  if (loading == '1') {
+    wx.showLoading({mask: true})
+    number++
   }
-  return new Promise(resolve => {
+  return new Promise(resolve=> {
     wx.request({
       url: baseUrl + options.url,
       data: options.data || {},
@@ -19,11 +20,15 @@
         if (res.data.code === 200) {
           resolve(res.data || true)
         } else {
-          if(res.data.code && res.data.code == 5112){
-            wx.navigateTo({
-              url: '/pages/auth/auth',
-            })
-          }
+          if (res.data.code && (res.data.code == 5112 || res.data.code == 5111)) {
+            if(options.data && options.data.goLogin){
+              console.log("==================")
+              wx.navigateTo({
+                        url: '/pages/login/index',
+              })
+            } 
+          } 
+          resolve(res) 
           res.data.message && wx.showToast({
             title: res.data.message || '鍙戠敓閿欒',
             icon: 'none'
@@ -31,18 +36,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