| | |
| | | import axios from 'axios'; |
| | | import { Toast } from 'vant'; |
| | | import store from '@/store' |
| | | import router from "@/router"; |
| | | |
| | | // 创建一个 axios 实例 |
| | |
| | | // 添加响应拦截器 |
| | | service.interceptors.response.use( |
| | | (response) => { |
| | | // loading.clear(); |
| | | if (response.config.url?.indexOf('/lingyang/login') == -1 && response.config.url?.indexOf('/edgp/loginDemo') == -1 && response.config.url?.indexOf('/lingyang/loginDemo') == -1 && response.config.url?.indexOf('/edgp/login') == -1) { |
| | | loading.clear(); |
| | | } |
| | | if (response.data.code === 401) { // 处理登录过期 |
| | | Toast.fail({ message: '登录过期,准备自动重新登录', duration: 2000, forbidClick: true }) |
| | | setTimeout(() => { |
| | | router.push({ name: 'logInAgain' }) |
| | | if (store.state.env == 'DD') { |
| | | router.push({ name: 'logInAgain' }) |
| | | } else if (store.state.env == 'WX') { |
| | | let tempUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx6ea339a336f26380&redirect_url=https://www.mes.red/h5/redirect.html&response_type=code&scope=snsapi_base&state=#wechat_redirect` |
| | | window.location.replace(tempUrl) |
| | | } |
| | | }, 2000) |
| | | return |
| | | } |