Przeglądaj źródła

未登录转到云就业

lrf 1 rok temu
rodzic
commit
4a7c904d43
2 zmienionych plików z 13 dodań i 7 usunięć
  1. 7 7
      store/setting.js
  2. 6 0
      utils/axios-wrapper.js

+ 7 - 7
store/setting.js

@@ -1,7 +1,8 @@
 import Vue from 'vue';
 import Vuex from 'vuex';
 import _ from 'lodash';
-import axios from 'axios';
+// import axios from 'axios';
+import AxiosWrapper from '../utils/axios-wrapper';
 Vue.use(Vuex);
 const api = {
   interface: `/api/train/setting/findone`,
@@ -17,12 +18,11 @@ const actions = {
     return res;
   },
   async fetch({ commit }, payload) {
-    const res = await axios.get(api.interface);
-    if (res.status == 200) {
-      if (res.data && res.data.errcode == 0) {
-        commit('setDefOpt', res.data.data, { root: true });
-        return res.data;
-      }
+    const axios = new AxiosWrapper({ baseUrl: process.env.VUE_APP_AXIOS_BASE_URL, unwrap: true });
+    const res = await axios.$get(api.interface);
+    if (res.errcode == 0) {
+      commit('setDefOpt', res.data, { root: true });
+      return res;
     }
   },
   async checkCache({ rootState, commit, dispatch }) {

+ 6 - 0
utils/axios-wrapper.js

@@ -78,6 +78,7 @@ export default class AxiosWrapper {
       if (user) {
         axios.defaults.headers.common.Authorization = encodeURI(user);
       }
+      axios.defaults.headers.common.dtype = 'pc';
       let res = await axios.request({
         method: isNullOrUndefined(data) ? 'get' : 'post',
         url,
@@ -89,6 +90,11 @@ export default class AxiosWrapper {
       const { errcode, errmsg, details } = res;
       if (errcode) {
         console.warn(`[${uri}] fail: ${errcode}-${errmsg} ${details}`);
+        if (errcode === -7) {
+          window.location.replace('https://zhjy.jilinjobs.cn:8080/dist/school.html#/navi');
+          // console.log(uri);
+          return;
+        }
         return res;
       }
       // unwrap data