demingshangjia/common/http.interceptor.js

24 lines
595 B
JavaScript
Raw Normal View History

2020-07-16 10:02:57 +08:00
const install = (Vue, vm) => {
// 此为自定义配置参数,具体参数见上方说明
Vue.prototype.$u.http.setConfig({
2020-08-18 15:31:03 +08:00
baseUrl: 'https://mall.dmygkeji.com/storeapi',
2020-07-16 10:02:57 +08:00
loadingText: '努力加载中~',
loadingTime: 800,
2020-07-29 09:37:59 +08:00
originalData: true,
2020-07-16 11:20:59 +08:00
});
Vue.prototype.$u.http.interceptor.request = (config) => {
const token = uni.getStorageSync('token');
config.header.Authorization = 'Bearer' + " " + token;
return config;
2020-07-29 09:37:59 +08:00
}
Vue.prototype.$u.http.interceptor.response = (res) => {
// todo 判断状态码
return res.data;
}
2020-07-16 10:02:57 +08:00
}
export default {
install
2020-07-16 09:47:53 +08:00
}