123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /* wx.request */
- const BASE_API = 'https://itt.chl6zk.store/api'
- import itt from '../utils/util'
- const app = getApp()
- export const wxRequest = (url,data) => {
- return new Promise((resolve, reject) => {
- wx.showLoading({
- title: '加载中...',
- mask: true
- })
- wx.request({
- url: BASE_API + url,
- data: data,
- header: {
- systemData:JSON.stringify({
- requestId: itt.getUUID(),
- loginToken: app.globalData.accessToken,
- timestamp: new Date().getTime()
- })
- },
- method: 'POST',
- success (response) {
- if (response.statusCode !== 200) {
- wx.showToast({
- title: response.errMsg || '请求错误',
- icon: 'error',
- duration: 2500,
- mask: true
- })
- } else {
- if (response.data.code !== '000') {
- 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()
- }
- })
- })
- }
|