| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- 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
- }
|