import baseurl from './baseurl.js' var request = function(config) { return new Promise((resolve, rejected) => { uni.showLoading({ title: '' }); uni.request({ url: baseurl + config.url, data: config.data, method: config.method, timeout: 10000, header: { Authorization: 'Bearer' + ' ' + uni.getStorageSync('token') }, success(res) { if (res.data.code == 9999) { uni.removeStorageSync('token'); // uni.reLaunch({ // url: '/pages/login/login' // }) uni.showModal({ title: "登录提示", content: '登录失效,请重新登录', success(res1) { if (res1.confirm) { uni.navigateTo({ url: '/pages/login/login' }) } else if (res1.cancel) { uni.reLaunch({ url: '/pages/homepage/homepage' }) } }, fail(err1) { uni.reLaunch({ url: '/pages/homepage/homepage' }) } }) } uni.hideLoading(); resolve(res.data) }, fail(err) { uni.hideLoading(); rejected(err) } }) }) } export default request