// const baseUrl = "http://192.168.1.43:8080" const baseUrl = "https://smzc.shizhi.tv" export default function request(data) { if (data.file) { return new Promise((resolve, reject) => { wx.uploadFile({ url: baseUrl + data.url, filePath: data.path, name: 'file', formData: data.data, success(res) { if (res.statusCode == 200) { resolve(res.data) } else { reject(res) } }, fail(err) { resolve(err) } }) }) } else { return new Promise((resolve, reject) => { wx.request({ url: baseUrl + data.url, method: data.method || 'GET', data: data.data || {}, header: data.header || {}, success: (res) => { if (res.statusCode == 200) { resolve(res.data) } else { reject(res) } }, fail: (err) => { reject(err) } }) }) } }