demingshangjia/common/http.interceptor.js
2020-08-18 15:31:03 +08:00

24 lines
595 B
JavaScript

const install = (Vue, vm) => {
// 此为自定义配置参数,具体参数见上方说明
Vue.prototype.$u.http.setConfig({
baseUrl: 'https://mall.dmygkeji.com/storeapi',
loadingText: '努力加载中~',
loadingTime: 800,
originalData: true,
});
Vue.prototype.$u.http.interceptor.request = (config) => {
const token = uni.getStorageSync('token');
config.header.Authorization = 'Bearer' + " " + token;
return config;
}
Vue.prototype.$u.http.interceptor.response = (res) => {
// todo 判断状态码
return res.data;
}
}
export default {
install
}