| | |
| | | |
| | | 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, productId:string, pricingId: string): ApiPromise { |
| | | return createAxios({ |
| | | url: `${baseUrl}/remove`, |
| | | method: 'delete', |
| | | params: { userId, unitId, pricingId } |
| | | params: { userId, unitId, productId,pricingId } |
| | | }) as ApiPromise |
| | | }, |
| | | |
| | | // 更新购物车商品数量 |
| | | updateCartItem(userId: number, unitId: number, pricingId: number, quantity: number): ApiPromise { |
| | | updateCartItem(userId: string, unitId: string,productId: string, pricingId: number, quantity: number): ApiPromise { |
| | | return createAxios({ |
| | | url: `${baseUrl}/update`, |
| | | method: 'put', |
| | | params: { userId, unitId, pricingId, quantity } |
| | | params: { userId, unitId, productId,pricingId, quantity } |
| | | }) as ApiPromise |
| | | }, |
| | | |
| | | // 更新购物车年限 |
| | | updateCartItemDuration(userId: string, unitId: string,productId: string, pricingId: number, duration: number): ApiPromise { |
| | | return createAxios({ |
| | | url: `${baseUrl}/update/duration`, |
| | | method: 'put', |
| | | params: { userId, unitId, productId,pricingId, duration } |
| | | }) as ApiPromise |
| | | }, |
| | | |
| | | // 获取购物车信息 |
| | | 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,productId: string): ApiPromise { |
| | | return createAxios({ |
| | | url: `${baseUrl}/items`, |
| | | method: 'get', |
| | | params: { userId, unitId } |
| | | params: { userId, unitId, productId } |
| | | }) as ApiPromise |
| | | }, |
| | | |
| | | // 清空购物车 |
| | | clearCart(userId: number, unitId: number): ApiPromise { |
| | | clearCart(userId: string, unitId: string, productId: string): ApiPromise { |
| | | return createAxios({ |
| | | url: `${baseUrl}/clear`, |
| | | method: 'delete', |
| | | params: { userId, unitId } |
| | | params: { userId, unitId, productId } |
| | | }) as ApiPromise |
| | | } |
| | | } |