export default function request(config = {}) { let { url, data = {}, method = "GET", header = {} } = config // 拼接url TODO 这里要修改,改成不同环境取不同的url // url = '/api' + url; url = 'http://localhost:8080' + url; // 添加token header['Authorization'] = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjIsImV4cCI6MTczNTI2MDg5M30.wfoJ22OryiQtQRwuhZNKKEvYjS-ux-bvWyluw8w6LnE'; return new Promise((resolve, reject) => { uni.request({ url, data, method, header, withCredentials: true, success: res => { if (res.data.code === '0') { resolve(res.data.data) } else if (res.data.errCode === '999') { uni.showModal({ title: "错误提示", content: res.data.msg, showCancel: false }) reject(res.data) } else { uni.showToast({ title: res.data.msg, icon: "none" }) reject(res.data) } }, fail: err => { reject(err) } }) }) }