From 1a6905045d38bb50b0c6554c3440bdfd339c8d23 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 30 七月 2024 19:13:46 +0800
Subject: [PATCH] ‘’
---
wechat_jiaxuan/utils/request.js | 41 ++++++++---------------------------------
1 files changed, 8 insertions(+), 33 deletions(-)
diff --git a/wechat_jiaxuan/utils/request.js b/wechat_jiaxuan/utils/request.js
index 25c32db..d111b6c 100644
--- a/wechat_jiaxuan/utils/request.js
+++ b/wechat_jiaxuan/utils/request.js
@@ -1,10 +1,10 @@
import { baseUrl } from "./config"
-import { wxLoginCustomer } from '../api/index'
-
+let number = 0
export function request(options){
let loading = options.loading || '1' // 榛樿鍊�1鏄剧ず锛屽惁鍒欎笉鏄剧ず
if(loading == '1'){
wx.showLoading()
+ number ++
}
return new Promise(resolve => {
wx.request({
@@ -20,37 +20,9 @@
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)
- }
+ wx.switchTab({
+ url: '/pages/index/index',
})
}
res.data.message && wx.showToast({
@@ -68,7 +40,10 @@
},
complete() {
if(loading == '1'){
- wx.hideLoading()
+ number --
+ if(number == 0){
+ wx.hideLoading()
+ }
}
}
})
--
Gitblit v1.9.3