修复一些问题以及优惠券管理功能
This commit is contained in:
+28
-10
@@ -367,6 +367,15 @@ export const adminTagApi = {
|
||||
},
|
||||
listTagsByShopId: (shopId: number) => {
|
||||
return adminApi.get<any[]>('/tag/list/by-shop/' + shopId)
|
||||
},
|
||||
createTag: (data: any) => {
|
||||
return adminApi.post('/tag/create', data)
|
||||
},
|
||||
updateTag: (id: number, data: any) => {
|
||||
return adminApi.put(`/tag/update/${id}`, data)
|
||||
},
|
||||
deleteTag: (id: number) => {
|
||||
return adminApi.delete(`/tag/delete/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,20 +386,29 @@ export const adminArtistApi = {
|
||||
}
|
||||
|
||||
export const adminCouponApi = {
|
||||
listAllCoupons: () => {
|
||||
return adminApi.get<any[]>('/coupon/list', { params: { page: 1, size: 100 } })
|
||||
listAllCoupons: (shopId?: number) => {
|
||||
return adminApi.get<any[]>('/coupon/list', { params: { page: 1, size: 100, shopId } })
|
||||
},
|
||||
createCoupon: (data: any) => {
|
||||
return adminApi.post('/coupon/create', data)
|
||||
createCoupon: (data: any, shopId: number) => {
|
||||
return adminApi.post('/coupon/create', data, { params: { shopId } })
|
||||
},
|
||||
updateCoupon: (id: number, data: any) => {
|
||||
return adminApi.put(`/coupon/update/${id}`, data)
|
||||
updateCoupon: (id: number, data: any, shopId: number) => {
|
||||
return adminApi.put(`/coupon/update/${id}`, data, { params: { shopId } })
|
||||
},
|
||||
deleteCoupon: (id: number) => {
|
||||
return adminApi.delete(`/coupon/delete/${id}`)
|
||||
deleteCoupon: (id: number, shopId: number) => {
|
||||
return adminApi.delete(`/coupon/delete/${id}`, { params: { shopId } })
|
||||
},
|
||||
distributeCoupon: (data: { couponId: number; userIds: number[]; quantity: number }) => {
|
||||
return adminApi.post('/coupon/distribute', data)
|
||||
distributeCoupon: (data: { couponId: number; userIds: number[]; quantity: number }, shopId: number) => {
|
||||
const params: any = {
|
||||
couponId: data.couponId,
|
||||
quantity: data.quantity,
|
||||
shopId: shopId
|
||||
};
|
||||
// 处理userIds数组,确保它能被后端正确解析
|
||||
data.userIds.forEach((userId, index) => {
|
||||
params[`userIds[${index}]`] = userId;
|
||||
});
|
||||
return adminApi.post('/coupon/distribute', null, { params })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export const authApi = {
|
||||
},
|
||||
|
||||
adminLogin: (data: LoginRequest) => {
|
||||
return api.post<LoginResponse>('/admin/api/auth/login', data)
|
||||
return api.post<LoginResponse>('/admin/auth/login', data)
|
||||
},
|
||||
|
||||
register: (data: RegisterRequest) => {
|
||||
|
||||
@@ -53,13 +53,13 @@ const handleTokenExpired = () => {
|
||||
sessionStorage.removeItem('accessToken')
|
||||
showError('登录已过期,请重新登录')
|
||||
try {
|
||||
router.push('/auth').catch(err => {
|
||||
router.push('/').catch(err => {
|
||||
console.error('跳转到登录页失败:', err)
|
||||
window.location.href = '/auth'
|
||||
window.location.href = '/'
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('跳转到登录页异常:', err)
|
||||
window.location.href = '/auth'
|
||||
window.location.href = '/'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user