From 7664b8a3d661d23ca115dc4e496842c3be95c5c5 Mon Sep 17 00:00:00 2001 From: chaining Date: Mon, 9 Jan 2023 02:59:27 +0000 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E4=BB=A4?= =?UTF-8?q?=E7=89=8C=E8=BF=87=E6=9C=9F=E6=97=A0=E6=B3=95=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E4=BB=A4=E7=89=8C=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chaining --- yudao-ui-app/api/auth.js | 2 +- yudao-ui-app/store/getters.js | 1 + yudao-ui-app/utils/request/responseInterceptors.js | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/yudao-ui-app/api/auth.js b/yudao-ui-app/api/auth.js index 54799eb9c..a2b04e8e7 100644 --- a/yudao-ui-app/api/auth.js +++ b/yudao-ui-app/api/auth.js @@ -10,6 +10,6 @@ export const smsLogin = data => http.post('/member/auth/sms-login', data) //微信小程序的一键登录 export const weixinMiniAppLogin = data => http.post('/member/auth/weixin-mini-app-login', data) //刷新令牌 -export const refreshToken = data => http.post('/member/auth/refresh-token', data) +export const refreshToken = data => http.post('/member/auth/refresh-token', {data}) //退出登录 export const logout = data => http.post('/member/auth/logout', data) diff --git a/yudao-ui-app/store/getters.js b/yudao-ui-app/store/getters.js index 720a48620..e7ba287be 100644 --- a/yudao-ui-app/store/getters.js +++ b/yudao-ui-app/store/getters.js @@ -1,5 +1,6 @@ const getters = { accessToken: state => state.user.accessToken, + refreshToken: state => state.user.refreshToken, userInfo: state => state.user.userInfo, hasLogin: state => !!state.user.accessToken } diff --git a/yudao-ui-app/utils/request/responseInterceptors.js b/yudao-ui-app/utils/request/responseInterceptors.js index aa8c73a11..1fa99d13d 100644 --- a/yudao-ui-app/utils/request/responseInterceptors.js +++ b/yudao-ui-app/utils/request/responseInterceptors.js @@ -36,7 +36,10 @@ module.exports = vm => { } // 2. 进行刷新访问令牌 try { - const refreshTokenRes = await refreshToken() + let param = {} + let refreshToken = uni.getStorageSync('REFRESH_TOKEN'); + param.refreshToken = refreshToken; + const refreshTokenRes = await refreshToken(param) // 2.1 刷新成功,则回放队列的请求 + 当前请求 vm.$store.commit('SET_TOKEN', refreshTokenRes.data) requestList.forEach(cb => cb())