export default (params) => { return new Promise((relove, reject) => { function qinqiu(){ let token = '' if(params.isfa){ token = 'Bearer '+ uni.getStorageSync('token'); } uni.request({ url: params.url, data: params.data, method: params.method, dataType: "json", header: { // "content-type": "application/json", "Accept": "application/json", Authorization:token } }).then(res => { // console.log(res); let data = res.data; // console.log(data.code); switch (data.code) { case 200: relove(data); break; case 1002: uni.showModal({ title: '提示', content: '您还未登录,是否前往登录?', success: function (res) { if (res.confirm) { uni.navigateTo({ url: '/pages/login/login' }) } else if (res.cancel) { console.log('用户点击取消'); } } }); break; case 500: relove(data); break; case 1000: uni.setStorageSync('token',data.data.token) qinqiu(); break; default: relove(data) break } }); } qinqiu() }) }