import Request from '@/common/libs/luch-request/index.js' import App from '@/app.config.js' const http = new Request() http.setConfig(config => { config.baseURL = App.BASE_URL return config }) function Token () { return uni.getStorageSync('token') || '' } http.interceptors.request.use(config => { config.header = { ...config.header, token: Token } return config }, config => { return Promise.reject(config) }) http.interceptors.response.use((response) => { const data = response.data if(/([1345]\d*)/.test(data.code)) { uni.showToast({ icon: 'none', title: data.msg }) return Promise.reject(response) } return response }, (response) => { return Promise.reject(response) }) export default http