const net = { request(url, method, data) { return new Promise((resolve, reject) => { my.showLoading({ content: '加载中...' }); my.request({ url, method, data, success(res) { my.hideLoading(); if (res.data.code == 200) { resolve(res.data) } else { my.showToast({ type: 'fail', content: res.data.msg, duration: 3000 }); } }, fail(res) { my.hideLoading(); my.showToast({ type: 'fail', content: '请求失败!请检查网络设置!', duration: 3000 }); reject(res) } }) }) } } export default net