购物车和订单中心以及优惠券相关功能初版

This commit is contained in:
xiaowang
2026-02-27 16:44:41 +08:00
parent 3529a73d84
commit 43f31eed53
36 changed files with 1785 additions and 24 deletions
+33
View File
@@ -0,0 +1,33 @@
import api from './index'
interface CartItem {
productId: number
quantity: number
}
export const cartApi = {
// 添加商品到购物车
addToCart: (item: CartItem) => {
return api.post('/cart/add', item)
},
// 从购物车移除商品
removeFromCart: (productId: number) => {
return api.delete(`/cart/remove/${productId}`)
},
// 更新购物车商品数量
updateCartQuantity: (item: CartItem) => {
return api.put('/cart/update', item)
},
// 获取购物车列表
getCartList: () => {
return api.get('/cart/list')
},
// 清空购物车
clearCart: () => {
return api.delete('/cart/clear')
}
}