/* wx.request */ const BASE_API = 'https://itt-worker.chl6zk.store/api' const BASE_VERSION = '/v1' import itt from '../utils/util' const app = getApp() export const wxRequest = (url,data) => { return new Promise((resolve, reject) => { wx.request({ url: BASE_API + url + BASE_VERSION, data: data, header: { systemData:JSON.stringify({ requestId: itt.getUUID(), loginToken: app.globalData.accessToken, timestamp: new Date().getTime() }) }, method: 'POST', success (response) { console.log('当前请求地址:', url); console.log('当前请求参数:', data); console.log('当前请求返回:', response.data); if (response.statusCode !== 200) { reject(response.data.msg || '请求错误') } else { if (response.data.code !== '000') { reject(response.data) } else { resolve(response.data) } } }, fail (e) { reject('网络错误') } }) }) }