From 95cb69b9f79893d7cd1319d754064c93e3fa4e2f Mon Sep 17 00:00:00 2001 From: seatonwan9 Date: 星期二, 19 八月 2025 18:15:56 +0800 Subject: [PATCH] 提交源码 --- src/api/cartApi.ts | 63 +++++++++++++++++++++++++++++++ 1 files changed, 63 insertions(+), 0 deletions(-) diff --git a/src/api/cartApi.ts b/src/api/cartApi.ts new file mode 100644 index 0000000..2d46ee8 --- /dev/null +++ b/src/api/cartApi.ts @@ -0,0 +1,63 @@ +import createAxios from '@/utils/axios' + +// 璐墿杞︾鐞� API +const baseUrl = '/admin/api/cart' + +const cartApi = { + // 娣诲姞鍟嗗搧鍒拌喘鐗╄溅 + addToCart(data: any, userId: number, unitId: number): ApiPromise { + return createAxios({ + url: `${baseUrl}/add`, + method: 'post', + data, + params: { userId, unitId } + }) as ApiPromise + }, + + // 浠庤喘鐗╄溅绉婚櫎鍟嗗搧 + removeFromCart(userId: number, unitId: number, pricingId: number): ApiPromise { + return createAxios({ + url: `${baseUrl}/remove`, + method: 'delete', + params: { userId, unitId, pricingId } + }) as ApiPromise + }, + + // 鏇存柊璐墿杞﹀晢鍝佹暟閲� + updateCartItem(userId: number, unitId: number, pricingId: number, quantity: number): ApiPromise { + return createAxios({ + url: `${baseUrl}/update`, + method: 'put', + params: { userId, unitId, pricingId, quantity } + }) as ApiPromise + }, + + // 鑾峰彇璐墿杞︿俊鎭� + getCartInfo(userId: number, unitId: number): ApiPromise { + return createAxios({ + url: `${baseUrl}/info`, + method: 'get', + params: { userId, unitId } + }) as ApiPromise + }, + + // 鑾峰彇璐墿杞﹀晢鍝佸垪琛� + getCartItems(userId: number, unitId: number): ApiPromise { + return createAxios({ + url: `${baseUrl}/items`, + method: 'get', + params: { userId, unitId } + }) as ApiPromise + }, + + // 娓呯┖璐墿杞� + clearCart(userId: number, unitId: number): ApiPromise { + return createAxios({ + url: `${baseUrl}/clear`, + method: 'delete', + params: { userId, unitId } + }) as ApiPromise + } +} + +export default cartApi -- Gitblit v1.8.0