diff --git a/src/api/APIindex.js b/src/api/APIindex.js index 77b4f9e..f06727d 100644 --- a/src/api/APIindex.js +++ b/src/api/APIindex.js @@ -12,15 +12,16 @@ axios.interceptors.request.use(function (config) { // 添加headers到post请求中 // config.headers.post['Content-Type'] = 'application/json;charset=utf-8'; - // let usname = JSON.parse(locasto.getItem('login')); - - // if (usname) { - // config.headers.userName = usname['username']; - // } + // let USERNO = JSON.parse(locasto.getItem('USERNO')); + let USERNO = locasto.getItem('USERNO'); + console.log(USERNO) + if (USERNO) { + config.headers.USERNO = USERNO; + } // if (!store.getters.disting) { - // store.commit('system/loading', true); + // // store.commit('system/loading', true); // } - // // 在发送请求之前做些什么 + // 在发送请求之前做些什么 return config; }, function (error) { // 对请求错误做些什么 @@ -50,7 +51,7 @@ // 'duration': 5000 // }); // store.commit('system/loading', false); - return Promise.reject(error); + // return Promise.reject(error); }); diff --git a/src/api/APIindex.js b/src/api/APIindex.js index 77b4f9e..f06727d 100644 --- a/src/api/APIindex.js +++ b/src/api/APIindex.js @@ -12,15 +12,16 @@ axios.interceptors.request.use(function (config) { // 添加headers到post请求中 // config.headers.post['Content-Type'] = 'application/json;charset=utf-8'; - // let usname = JSON.parse(locasto.getItem('login')); - - // if (usname) { - // config.headers.userName = usname['username']; - // } + // let USERNO = JSON.parse(locasto.getItem('USERNO')); + let USERNO = locasto.getItem('USERNO'); + console.log(USERNO) + if (USERNO) { + config.headers.USERNO = USERNO; + } // if (!store.getters.disting) { - // store.commit('system/loading', true); + // // store.commit('system/loading', true); // } - // // 在发送请求之前做些什么 + // 在发送请求之前做些什么 return config; }, function (error) { // 对请求错误做些什么 @@ -50,7 +51,7 @@ // 'duration': 5000 // }); // store.commit('system/loading', false); - return Promise.reject(error); + // return Promise.reject(error); }); diff --git a/src/components/index.vue b/src/components/index.vue index 786d1fd..a3a0a0e 100644 --- a/src/components/index.vue +++ b/src/components/index.vue @@ -216,6 +216,7 @@ //添加菜单 // this.LoadMenu(); // this.loadLoginName(); + localStorage.setItem("USERNO", "Admin"); } };