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_jiaxuan/utils/request.js |   71 ++++++++++++++---------------------
 1 files changed, 29 insertions(+), 42 deletions(-)

diff --git a/wechat_jiaxuan/utils/request.js b/wechat_jiaxuan/utils/request.js
index 25c32db..865d53a 100644
--- a/wechat_jiaxuan/utils/request.js
+++ b/wechat_jiaxuan/utils/request.js
@@ -1,10 +1,14 @@
-import { baseUrl } from "./config"
-import { wxLoginCustomer } from '../api/index'
-
-export function request(options){
+import {
+  baseUrl
+} from "./config"
+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 => {
     wx.request({
@@ -20,38 +24,19 @@
         if (res.data.code === 200) {
           resolve(res.data || true)
         } else {
-          // if(res.data.code == 5112){
-          //   wx.navigateTo({
-          //     url: '/pages/auth/auth ',
-          //   })
-          // }
-          if(res.data.code == 5111 || res.data.code == 5112){
-            wx.login({
-              timeout: 5000,
-              success(res) {
-                if (res.code) {
-                  //鍙戣捣缃戠粶璇锋眰
-                  wxLoginCustomer({
-                    code: res.code
-                  }).then(res => {
-                    console.log(res)
-                    if (res && res.data.member) {
-                      wx.setStorageSync('member', res.data.member)
-                      wx.setStorageSync('openid', res.data.member.openid)
-                      wx.setStorageSync('sessionKey', res.data.sessionKey)
-                      wx.setStorageSync('token', res.data.token)
-                    } else {
-                      console.log('鐧诲綍澶辫触锛�')
-                    }
-                  })
-                } else {
-                  console.log('鐧诲綍澶辫触锛�' + res)
-                }
-              },
-              fail(err) {
-                console.log(err)
-              }
+          if (options.data && options.data.isAuth && (res.data.code == 5111 || res.data.code == 5112 || res.data.code == 5110)) {
+            // wx.switchTab({
+            //   url: '/pages/index/index',
+            // })
+            resolve(res.data)
+            res.data.message && wx.showToast({
+              title: res.data.message || '鍙戠敓閿欒',
+              icon: 'none'
             })
+            return
+          }
+          if(res.data.code == 5111 || res.data.code == 5112 || res.data.code == 5110){
+            return
           }
           res.data.message && wx.showToast({
             title: res.data.message || '鍙戠敓閿欒',
@@ -67,11 +52,13 @@
         })
       },
       complete() {
-        if(loading == '1'){
-          wx.hideLoading()
+        if (loading == '1') {
+          number--
+          if (number == 0) {
+            wx.hideLoading()
+          }
         }
       }
     })
-  } )
-}
-
+  })
+}
\ No newline at end of file

--
Gitblit v1.9.3