| | |
| | | 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({ |
| | |
| | | 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', |
| | | }) |
| | |
| | | } |
| | | }, |
| | | 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() |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } ) |
| | | }) |
| | | } |
| | | |