12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { config } from '@/common/config.js';
- import store from '../store/index.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.url = config.url + '?t=' + Date.now()
-
- 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){
- localStorage.setItem('backUrl', location.href)
- const loginUrl = 'phoneLogin'
- console.log(loginUrl.indexOf(location.href))
- if (loginUrl.indexOf(location.href) > 0) {
- console.log(loginUrl.indexOf(location.href))
- } else {
- alert('还未登录,即将跳转登录');
- uni.navigateTo({
- url: "/pages/center/phoneLogin/phoneLogin"
- })
- }
-
- }else return res;
- }
- }
- export default {
- install
- }
|