12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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}`;}
- config.header.timestamp = new Date().getTime();
- config.header.nonce = vm.$u.guid(20);
-
- config.header.signature = vm.$u.guid(20);
-
-
-
-
-
-
-
-
-
-
-
-
- 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
- }
|