demingshangjia/common/http.interceptor.js

24 lines
595 B
JavaScript
Raw Permalink Normal View History

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