fix:token从storage读取+NEED_LOGIN弹窗增加去登录按钮

This commit is contained in:
97694732@qq.com 2026-06-04 18:01:48 +08:00
parent ac471925ef
commit 8cc51e3f20
2 changed files with 18 additions and 8 deletions

View File

@ -1402,11 +1402,16 @@ export default {
console.error('加载仓库失败:', e)
const errMsg = e.message || String(e)
if (errMsg.includes('NEED_LOGIN')) {
const displayMsg = errMsg.replace('NEED_LOGIN:', '')
uni.showModal({
title: '系统提示',
content: displayMsg,
showCancel: false
content: 'PSI系统登录已过期请重新登录',
confirmText: '去登录',
cancelText: '取消',
success: (modalRes) => {
if (modalRes.confirm) {
uni.navigateTo({ url: '/pages/login/login' })
}
}
})
}
} finally {
@ -1464,11 +1469,16 @@ export default {
console.error('加载货位失败:', e)
const errMsg = e.message || String(e)
if (errMsg.includes('NEED_LOGIN')) {
const displayMsg = errMsg.replace('NEED_LOGIN:', '')
uni.showModal({
title: '系统提示',
content: displayMsg,
showCancel: false
content: 'PSI系统登录已过期请重新登录',
confirmText: '去登录',
cancelText: '取消',
success: (modalRes) => {
if (modalRes.confirm) {
uni.navigateTo({ url: '/pages/login/login' })
}
}
})
}
this.popupLocationList = this.popupAllLocationList

View File

@ -150,8 +150,8 @@ function requestWithRetry(requestFn, apiName) {
return requestFn(getAuthToken()).catch((err) => {
const errMsg = err.message || String(err)
console.error(`${apiName}】请求失败:`, errMsg)
if (errMsg.includes('401') || errMsg.includes('无效的认证令牌') || errMsg.includes('未登录')) {
throw new Error('NEED_LOGIN:PSI系统登录已过期请在登录页重新登录')
if (errMsg.includes('401') || errMsg.includes('无效的认证令牌')) {
throw new Error('NEED_LOGIN:PSI系统登录已过期请在登录页重新登录')
}
throw err
})