const baseUrl = "https://pdjh.shizhi.tv/prod-api" // const baseUrl = "http://192.168.1.24:8080" const request = function (datas) { let url = datas.url.indexOf('http') != -1 ? datas.url : baseUrl + datas.url let method = datas.method || "GET" let header = datas.header || {} let data = datas.data || "" return new Promise((resolve, rejects) => { wx.request({ url: url, method: method, data: data, header: header, success: (res) => { if (res.statusCode === 200) { resolve(res.data) } else { resolve({ code: res.statusCode, msg: res.errMsg }) } }, fail: (err) => { resolve({ code: 1000, msg: "服务器未响应" }) } }) }) } export default request