购物车和订单中心以及优惠券相关功能初版
This commit is contained in:
@@ -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')
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user