| | |
| | | |
| | | const cartApi = { |
| | | // 添加商品到购物车 |
| | | addToCart(data: any, userId: number, unitId: number): ApiPromise { |
| | | addToCart(data: any, userId: string, unitId: string): ApiPromise { |
| | | return createAxios({ |
| | | url: `${baseUrl}/add`, |
| | | method: 'post', |
| | |
| | | }, |
| | | |
| | | // 从购物车移除商品 |
| | | removeFromCart(userId: number, unitId: number, pricingId: number): ApiPromise { |
| | | removeFromCart(userId: string, unitId: string, pricingId: string): ApiPromise { |
| | | return createAxios({ |
| | | url: `${baseUrl}/remove`, |
| | | method: 'delete', |
| | |
| | | }, |
| | | |
| | | // 更新购物车商品数量 |
| | | updateCartItem(userId: number, unitId: number, pricingId: number, quantity: number): ApiPromise { |
| | | updateCartItem(userId: string, unitId: string, pricingId: number, quantity: number): ApiPromise { |
| | | return createAxios({ |
| | | url: `${baseUrl}/update`, |
| | | method: 'put', |
| | |
| | | }, |
| | | |
| | | // 获取购物车信息 |
| | | getCartInfo(userId: number, unitId: number): ApiPromise { |
| | | getCartInfo(userId: string, unitId: string): ApiPromise { |
| | | return createAxios({ |
| | | url: `${baseUrl}/info`, |
| | | method: 'get', |
| | |
| | | }, |
| | | |
| | | // 获取购物车商品列表 |
| | | getCartItems(userId: number, unitId: number): ApiPromise { |
| | | getCartItems(userId: string, unitId: string): ApiPromise { |
| | | return createAxios({ |
| | | url: `${baseUrl}/items`, |
| | | method: 'get', |
| | |
| | | }, |
| | | |
| | | // 清空购物车 |
| | | clearCart(userId: number, unitId: number): ApiPromise { |
| | | clearCart(userId: string, unitId: string): ApiPromise { |
| | | return createAxios({ |
| | | url: `${baseUrl}/clear`, |
| | | method: 'delete', |