// const baseURL= 'http://192.168.0.111:8088/api/'; const baseURL= "https://www.cyjyyjy.com/api/" export function $http(methods,url,params){ var header = { 'content-type': 'application/json', 'Authorization':'Bearer '+ wx.getStorageSync('token') || '', 'dept': '16' }; return new Promise((resolve,reject)=>{ wx.showLoading({ title: '正在加载中...', }) wx.request({ url: baseURL + url, method: methods, header: header, data: params || {}, success: res=> { wx.hideLoading(); if(!res.data.success && res.data.status == 401){ // console.log('登陆失效') wx.navigateTo({ url: '/pages/login/index', }) return } if(res.data.success){ resolve(res); wx.hideLoading(); } else{ wx.showToast({ title: res.data.msg, icon: 'none' }) reject(err) } }, fail: err=> { wx.hideLoading(); wx.showToast({ title: '服务器错误,请稍后再试!', icon: 'none' }) reject(err) } }) }) }