| | |
| | | import axios from 'axios'; |
| | | import { getStore, setStore } from './storage'; |
| | | import { getStore, setStore,getSessionStore,setSessionStore} from './storage'; |
| | | import { router } from '../router/index'; |
| | | import { Message } from 'view-design'; |
| | | import Cookies from 'js-cookie'; |
| | |
| | | case 401: |
| | | // 未登录 清除已登录状态 |
| | | Cookies.set('userInfo', ''); |
| | | setStore('accessToken', ''); |
| | | setSessionStore('accessToken', ''); |
| | | if (router.history.current.name != "login") { |
| | | if (data.message !== null) { |
| | | Message.error(data.message); |
| | |
| | | }); |
| | | |
| | | export const getRequest = (url, params, responseType = null) => { |
| | | let accessToken = getStore('accessToken'); |
| | | let accessToken = getSessionStore('accessToken'); |
| | | return axios({ |
| | | method: 'get', |
| | | url: `${baseApi}${url}`, |
| | |
| | | }); |
| | | }; |
| | | export const getmethod = (url, params) => { |
| | | let accessToken = getStore('accessToken'); |
| | | let accessToken = getSessionStore('accessToken'); |
| | | return axios({ |
| | | method: 'get', |
| | | url: `${baseApi}${url}`, |
| | |
| | | }; |
| | | |
| | | export const postRequest = (url, params) => { |
| | | let accessToken = getStore("accessToken"); |
| | | let accessToken = getSessionStore("accessToken"); |
| | | return axios({ |
| | | method: 'post', |
| | | url: `${baseApi}${url}`, |
| | |
| | | }; |
| | | |
| | | export const putRequest = (url, params) => { |
| | | let accessToken = getStore("accessToken"); |
| | | let accessToken = getSessionStore("accessToken"); |
| | | return axios({ |
| | | method: 'put', |
| | | url: `${baseApi}${url}`, |
| | |
| | | }; |
| | | |
| | | export const postBodyRequest = (url, params) => { |
| | | let accessToken = getStore('accessToken'); |
| | | let accessToken = getSessionStore('accessToken'); |
| | | return axios({ |
| | | method: 'post', |
| | | url: `${baseApi}${url}`, |
| | |
| | | |
| | | /** |
| | | * 无需token验证的GET请求 避免旧token过期导致请求失败 |
| | | * @param {*} url |
| | | * @param {*} params |
| | | * @param {*} url |
| | | * @param {*} params |
| | | */ |
| | | export const getNoAuthRequest = (url, params) => { |
| | | return axios({ |