1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
| import createAxios from '@/utils/axios'
|
| // 购物车管理 API
| const baseUrl = '/admin/api/cart'
|
| const cartApi = {
| // 添加商品到购物车
| addToCart(data: any, userId: string, unitId: string): ApiPromise {
| return createAxios({
| url: `${baseUrl}/add`,
| method: 'post',
| data,
| params: { userId, unitId }
| }) as ApiPromise
| },
|
| // 从购物车移除商品
| removeFromCart(userId: string, unitId: string, pricingId: string): ApiPromise {
| return createAxios({
| url: `${baseUrl}/remove`,
| method: 'delete',
| params: { userId, unitId, pricingId }
| }) as ApiPromise
| },
|
| // 更新购物车商品数量
| updateCartItem(userId: string, unitId: string, pricingId: number, quantity: number): ApiPromise {
| return createAxios({
| url: `${baseUrl}/update`,
| method: 'put',
| params: { userId, unitId, pricingId, quantity }
| }) as ApiPromise
| },
|
| // 获取购物车信息
| getCartInfo(userId: string, unitId: string): ApiPromise {
| return createAxios({
| url: `${baseUrl}/info`,
| method: 'get',
| params: { userId, unitId }
| }) as ApiPromise
| },
|
| // 获取购物车商品列表
| getCartItems(userId: string, unitId: string): ApiPromise {
| return createAxios({
| url: `${baseUrl}/items`,
| method: 'get',
| params: { userId, unitId }
| }) as ApiPromise
| },
|
| // 清空购物车
| clearCart(userId: string, unitId: string): ApiPromise {
| return createAxios({
| url: `${baseUrl}/clear`,
| method: 'delete',
| params: { userId, unitId }
| }) as ApiPromise
| }
| }
|
| export default cartApi
|
|