|  |  | 
 |  |  | import { baseUrl } from "./config" | 
 |  |  | import { | 
 |  |  |   baseUrl | 
 |  |  | } from "./config" | 
 |  |  | let number = 0 | 
 |  |  | export function request(options){ | 
 |  |  | export function request(options) { | 
 |  |  |   let loading = options.loading || '1' // 默认值1显示,否则不显示 | 
 |  |  |   if(loading == '1'){ | 
 |  |  |     wx.showLoading({mask: true}) | 
 |  |  |     number ++  | 
 |  |  |   if (loading == '1') { | 
 |  |  |     wx.showLoading({ | 
 |  |  |       mask: true | 
 |  |  |     }) | 
 |  |  |     number++ | 
 |  |  |   } | 
 |  |  |   return new Promise(resolve => { | 
 |  |  |     wx.request({ | 
 |  |  | 
 |  |  |         if (res.data.code === 200) { | 
 |  |  |           resolve(res.data || true) | 
 |  |  |         } else { | 
 |  |  |           if(res.data.code == 5111 || res.data.code == 5112){ | 
 |  |  |             wx.switchTab({ | 
 |  |  |               url: '/pages/index/index', | 
 |  |  |           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 || '发生错误', | 
 |  |  | 
 |  |  |         }) | 
 |  |  |       }, | 
 |  |  |       complete() { | 
 |  |  |         if(loading == '1'){ | 
 |  |  |           number -- | 
 |  |  |           if(number == 0){ | 
 |  |  |         if (loading == '1') { | 
 |  |  |           number-- | 
 |  |  |           if (number == 0) { | 
 |  |  |             wx.hideLoading() | 
 |  |  |           } | 
 |  |  |         } | 
 |  |  |       } | 
 |  |  |     }) | 
 |  |  |   } ) | 
 |  |  | } | 
 |  |  |  | 
 |  |  |   }) | 
 |  |  | } |