|
@@ -1,83 +0,0 @@
|
|
|
-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.code == 401 || res.code == 400){
|
|
|
- const backUrl = location.href
|
|
|
- const loginUrl = 'phoneLogin'
|
|
|
- if (backUrl.indexOf(loginUrl) > 0) {
|
|
|
- localStorage.clear()
|
|
|
- } else {
|
|
|
- localStorage.setItem('backUrl', location.href)
|
|
|
- localStorage.removeItem('lifeData')
|
|
|
- uni.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '未查询到登录信息或信息已失效, 请重新登录',
|
|
|
- showCancel: false,
|
|
|
- success: function(res) {
|
|
|
- if (res.confirm) {
|
|
|
- uni.navigateTo({
|
|
|
- url: "/pages/center/phoneLogin/phoneLogin"
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: res.msg || '程序错误!',
|
|
|
- duration: 2000,
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- };
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-export default {
|
|
|
- install
|
|
|
-}
|