| import { baseUrl } from "./config" | 
|   | 
| export function request(options){ | 
|   let loading = options.loading || '1' // 默认值1显示,否则不显示 | 
|   if(loading == '1'){ | 
|     wx.showLoading() | 
|   } | 
|   return new Promise(resolve => { | 
|     wx.request({ | 
|       url: baseUrl + options.url, | 
|       data: options.data || {}, | 
|       method: options.method || "GET", | 
|       header: { | 
|         'content-type': 'application/json;charset=utf-8', | 
|         'token': wx.getStorageSync('token') || '' | 
|       }, | 
|       timeout: 12000, | 
|       success: (res) => { | 
|         if (res.data.code === 200) { | 
|           resolve(res.data || true) | 
|         } else { | 
|           if(res.data.code && res.data.code == 5112){ | 
|             wx.navigateTo({ | 
|               url: '/pages/auth/auth', | 
|             }) | 
|           } | 
|           res.data.message && wx.showToast({ | 
|             title: res.data.message || '发生错误', | 
|             icon: 'none' | 
|           }) | 
|         } | 
|       }, | 
|       fail(err) { | 
|         console.log('err', err); | 
|         err.message && wx.showToast({ | 
|           title: err.message || '发生错误', | 
|           icon: 'none' | 
|         }) | 
|       }, | 
|       complete() { | 
|         if(loading == '1'){ | 
|           wx.hideLoading() | 
|         } | 
|       } | 
|     }) | 
|   } ) | 
| } |