From 95444a6eb5b5f902b8d38401898d19bcfdbcf477 Mon Sep 17 00:00:00 2001 From: QM303176530 <303176530@qq.com> Date: Thu, 2 Jul 2020 15:24:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=B4=E9=83=A8=E4=BF=A1=E6=81=AF=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=94=A8=E6=88=B7id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/utils/request.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/web/src/utils/request.js b/web/src/utils/request.js index 63c1e5ff..d6e7d867 100644 --- a/web/src/utils/request.js +++ b/web/src/utils/request.js @@ -21,21 +21,23 @@ const showLoading = () => { } const closeLoading = () => { - acitveAxios-- - if (acitveAxios <= 0) { - clearTimeout(timer) - loadingInstance && loadingInstance.close() - } + acitveAxios-- + if (acitveAxios <= 0) { + clearTimeout(timer) + loadingInstance && loadingInstance.close() } - //http request 拦截器 +} +//http request 拦截器 service.interceptors.request.use( config => { showLoading() const token = store.getters['user/token'] + const user = store.getters['user/userInfo'] config.data = JSON.stringify(config.data); config.headers = { 'Content-Type': 'application/json', - 'x-token': token + 'x-token': token, + 'x-user-id':user.ID } return config; },