| | |
| | | data, |
| | | ignoreToken, |
| | | form, |
| | | isShowLoding |
| | | isShowLoding, |
| | | timeout, |
| | | header |
| | | } = _options |
| | | const app = getApp() |
| | | // 设置请求头 |
| | | let header = {} |
| | | if (form) { |
| | | header = { |
| | | 'content-type': 'application/x-www-form-urlencoded' |
| | |
| | | 'content-type': 'application/json' //自定义请求头信息 |
| | | } |
| | | } |
| | | if (!timeout) { |
| | | timeout = 60000 |
| | | } |
| | | |
| | | if (!ignoreToken) { |
| | | // 从全局变量中获取token |
| | | let token = app.globalData.token |
| | | header.Authorization = `Bearer ${token}` |
| | | } |
| | | header.tag = app.globalData.tag; |
| | | return new Promise((resolve, reject) => { |
| | | console.log("url:" + BASEURL + url); |
| | | if (isShowLoding) { |
| | |
| | | data, |
| | | header, |
| | | method, |
| | | timeout: timeout, |
| | | success: (res) => { |
| | | let { |
| | | statusCode: code |
| | |
| | | if (isShowLoding) { |
| | | wx.hideLoading(); // 隐藏加载动画 |
| | | } |
| | | |
| | | // showToast(err.errMsg) |
| | | reject(err) |
| | | } |