var app = getApp(); // const baseURL = 'http://8.140.133.55:8096'; // 赛思维正式环境 const baseURL = 'http://101.201.121.115:8096'; // 赛思维测试环境 /** * POST请求, * URL:接口 * postData:参数,json类型 * doSuccess:成功的回调函数 * doFail:失败的回调函数 */ const http = ({ url = '', param = {}, ...other } = {}) => { return new Promise((resolve, reject) => { wx.request({ url: baseURL + url, data: param, header: { 'content-type': 'application/json' // 默认值 ,另一种是 "content-type": "application/x-www-form-urlencoded" }, ...other, complete: (res) => { if (res.statusCode === 200) { resolve(res.data) } else { reject(res) } } }) }) }; // get方法 const get = (url, param = {}) => {return http({url,param,method: 'GET'})} // post方法 const post = (url, param = {}) => {return http({url,param,method: 'POST'}) } module.exports = { get, post, baseURL }