demingshangjia/common/http.interceptor.js

23 lines
584 B
JavaScript
Raw Permalink Normal View History

2020-07-16 10:02:57 +08:00
const install = (Vue, vm) => {
// 此为自定义配置参数,具体参数见上方说明
Vue.prototype.$u.http.setConfig({
2020-07-16 11:20:59 +08:00
baseUrl: 'https://dmmall.sdbairui.com//storeapi',
2020-07-16 10:02:57 +08:00
loadingText: '努力加载中~',
loadingTime: 800,
// 设置自定义头部content-type
// header: {
2020-07-16 11:20:59 +08:00
// "Authorization" : "122"
2020-07-16 10:02:57 +08:00
// }
// ......
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-16 10:02:57 +08:00
}
export default {
install
2020-07-16 09:47:53 +08:00
}