const app = getApp(); let request = (_url, _method, _data, callback, failcallback ) => { wx.showLoading() wx.request({ url: _url, method: _method, data: _data, header: { 'content-type': 'application/json', 'appletId': '', 'token': '' }, success: ((res) => { wx.hideLoading() console.log(res.statusCode) if ((res.statusCode == 200 || res.statusCode == 201) && callback) { callback(res) }else{ if(failcallback){ failcallback(res) }else{ wx.showToast({ title: '服务器开小差', icon: 'none' }) } } }), fail: ((res) => { wx.hideLoading() failcallback(res) wx.showToast({ title: '服务器开小差', icon: 'none' }) }) }) } module.exports = { request: request }