12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- /* wx.request */
- const BASE_API = 'http://itt.chl6zk.store/api'
- export const wxRequest = (url,data) => {
- return new Promise((resolve, reject) => {
- wx.showLoading({
- title: '加载中...',
- mask: true
- })
- wx.request({
- url: BASE_API + url,
- data: data,
- method: 'POST',
- success (response) {
- if (response.statusCode !== 200) {
- wx.showToast({
- title: response.errMsg || '网络错误!',
- icon: 'error',
- duration: 2500,
- mask: true
- })
- } else {
- if (response.data.code !== '100') {
- wx.showToast({
- title: response.data.msg || '请求错误!',
- icon: 'error',
- duration: 2500,
- mask: true
- })
- } else {
- resolve(response.data)
- }
- }
- },
- fail (e) {
- wx.showToast({
- title: '请求错误!',
- icon: 'error',
- duration: 2500,
- mask: true
- })
- reject(e)
- },
- complete () {
- wx.hideLoading()
- }
- })
- })
- }
|