fix: 订单类型请求去掉 phone,区分 JWT 401 与业务错误
kfhqptddlx 只带 JWT;响应拦截器仅在 token 失效时清登录态。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -35,9 +35,19 @@ service.interceptors.response.use(
|
||||
if (error.response) {
|
||||
const status = error.response.status
|
||||
if (status === 401) {
|
||||
const data = error.response.data
|
||||
const isJwtAuthFailure =
|
||||
!data ||
|
||||
data.detail !== undefined ||
|
||||
data.code === 'token_not_valid' ||
|
||||
data.code === 'authentication_failed'
|
||||
if (isJwtAuthFailure && !error.config?.skipAuthRedirect) {
|
||||
localStorage.removeItem('token')
|
||||
router.push('/login')
|
||||
ElMessage.error('登录已过期,请重新登录')
|
||||
} else if (!error.config?.skipErrorToast) {
|
||||
ElMessage.error(data?.msg || '认证失败')
|
||||
}
|
||||
} else if (status === 403) {
|
||||
if (!error.config?.skipErrorToast) {
|
||||
ElMessage.error('没有权限')
|
||||
|
||||
@@ -282,8 +282,7 @@ const fetchClubs = async () => {
|
||||
// ---------- 2. 获取订单类型 ----------
|
||||
const fetchOrderTypes = async () => {
|
||||
try {
|
||||
const username = localStorage.getItem('username')
|
||||
const res = await request.post('/yonghu/kfhqptddlx', { phone: username })
|
||||
const res = await request.post('/yonghu/kfhqptddlx', {}, { skipErrorToast: true })
|
||||
if (res.code === 0) {
|
||||
orderTypes.value = res.data || []
|
||||
// 默认选中全部(空字符串)
|
||||
|
||||
@@ -203,9 +203,7 @@ const getFullImageUrl = (relativeUrl) => {
|
||||
// 订单类型接口(未改动)
|
||||
const fetchOrderTypes = async () => {
|
||||
try {
|
||||
const res = await request.post('/yonghu/kfhqptddlx', {
|
||||
phone: localStorage.getItem('username')
|
||||
})
|
||||
const res = await request.post('/yonghu/kfhqptddlx', {}, { skipErrorToast: true })
|
||||
if (res.code === 0) {
|
||||
orderTypes.value = res.data || []
|
||||
if (!currentType.value) currentType.value = ''
|
||||
|
||||
@@ -207,9 +207,7 @@ const getFullImageUrl = (relativeUrl) => {
|
||||
// 获取订单类型(未改动,仍用 phone)
|
||||
const fetchOrderTypes = async () => {
|
||||
try {
|
||||
const res = await request.post('/yonghu/kfhqptddlx', {
|
||||
phone: localStorage.getItem('username')
|
||||
})
|
||||
const res = await request.post('/yonghu/kfhqptddlx', {}, { skipErrorToast: true })
|
||||
if (res.code === 0) {
|
||||
orderTypes.value = res.data || []
|
||||
if (!currentType.value) currentType.value = ''
|
||||
|
||||
Reference in New Issue
Block a user