123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- "use strict";
- import axios from "axios"
- import { browser } from '@/common/common'
- let config = {
-
-
-
-
-
-
-
-
-
-
-
-
- };
- const _axios = axios.create(config);
- _axios.interceptors.request.use(
- function(config) {
-
-
- if(browser().android || browser().iPhone) {
- let userInfo = localStorage.getItem('Authorization')
- if(userInfo) {
- config.headers['Authorization'] = userInfo
- }
- } else {
- let auth = localStorage.getItem('userInfo')
- if(auth) {
- config.headers['Authorization'] = auth
- }
- }
- return config;
- },
- function(error) {
-
- return Promise.reject(error);
- }
- );
- _axios.interceptors.response.use(
- function(response) {
-
- if(response.data.code == 403) {
- window.localStorage.removeItem('userInfo')
- window.localStorage.removeItem('Authorization')
-
- if(browser().android) {
- DAYA.postMessage(JSON.stringify({api: 'login'}))
- } else if(browser().iPhone) {
- window.webkit.messageHandlers.DAYA.postMessage(JSON.stringify({api: 'login'}))
- }
- }
- return response;
- },
- function(error) {
-
- return Promise.reject(error);
- }
- );
- export default _axios
|