fix:修复令牌过期无法刷新令牌的bug

Signed-off-by: chaining <ning.chai@qq.com>
This commit is contained in:
chaining 2023-01-09 02:59:27 +00:00 committed by Gitee
parent bbb27df5e9
commit 7664b8a3d6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 6 additions and 2 deletions

View File

@ -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 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) export const logout = data => http.post('/member/auth/logout', data)

View File

@ -1,5 +1,6 @@
const getters = { const getters = {
accessToken: state => state.user.accessToken, accessToken: state => state.user.accessToken,
refreshToken: state => state.user.refreshToken,
userInfo: state => state.user.userInfo, userInfo: state => state.user.userInfo,
hasLogin: state => !!state.user.accessToken hasLogin: state => !!state.user.accessToken
} }

View File

@ -36,7 +36,10 @@ module.exports = vm => {
} }
// 2. 进行刷新访问令牌 // 2. 进行刷新访问令牌
try { try {
const refreshTokenRes = await refreshToken() let param = {}
let refreshToken = uni.getStorageSync('REFRESH_TOKEN');
param.refreshToken = refreshToken;
const refreshTokenRes = await refreshToken(param)
// 2.1 刷新成功,则回放队列的请求 + 当前请求 // 2.1 刷新成功,则回放队列的请求 + 当前请求
vm.$store.commit('SET_TOKEN', refreshTokenRes.data) vm.$store.commit('SET_TOKEN', refreshTokenRes.data)
requestList.forEach(cb => cb()) requestList.forEach(cb => cb())