123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import { config } from '@/common/config.js';
- const install = (Vue, vm) => {
- Vue.prototype.$u.http.setConfig({
- baseUrl: config.baseUrl,
-
-
-
-
-
-
-
- });
-
- Vue.prototype.$u.http.interceptor.request = (config) => {
-
-
-
-
-
- if(vm.vuex_token){config.header.Authorization = `Bearer ${vm.vuex_token}`;}
-
-
-
-
-
-
-
-
-
-
-
-
- let noTokenList = ['/wechat/h5/user','/client/auth/verifyCode'];
- if(noTokenList.includes(config.url)) config.header.noToken = true;
-
-
-
- return config;
- }
-
- Vue.prototype.$u.http.interceptor.response = (res) => {
-
-
-
- if(res.code == 200) {
-
- return res;
- } else if(res.msg == "令牌不能为空"||res.code == 401){
-
- alert('还未登录,即将跳转登录');
- setTimeout(()=>{location.href = location.origin+'/#/pages/login/login';});
- }else return false;
- }
- }
- export default {
- install
- }
|