diff --git a/src/api/shop/cart/index.ts b/src/api/shop/cart/index.ts new file mode 100644 index 0000000..a385d10 --- /dev/null +++ b/src/api/shop/cart/index.ts @@ -0,0 +1,106 @@ +import request from '@/utils/request'; +import type { ApiResult, PageResult } from '@/api'; +import type { Cart, CartParam } from './model'; +import { MODULES_API_URL } from '@/config/setting'; + +/** + * 分页查询购物车 + */ +export async function pageCart(params: CartParam) { + const res = await request.get>>( + MODULES_API_URL + '/shop/cart/page', + { + params + } + ); + if (res.data.code === 0) { + return res.data.data; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 查询购物车列表 + */ +export async function listCart(params?: CartParam) { + const res = await request.get>( + MODULES_API_URL + '/shop/cart', + { + params + } + ); + if (res.data.code === 0 && res.data.data) { + return res.data.data; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 添加购物车 + */ +export async function addCart(data: Cart) { + const res = await request.post>( + MODULES_API_URL + '/shop/cart', + data + ); + if (res.data.code === 0) { + return res.data.message; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 修改购物车 + */ +export async function updateCart(data: Cart) { + const res = await request.put>( + MODULES_API_URL + '/shop/cart', + data + ); + if (res.data.code === 0) { + return res.data.message; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 删除购物车 + */ +export async function removeCart(id?: number) { + const res = await request.delete>( + MODULES_API_URL + '/shop/cart/' + id + ); + if (res.data.code === 0) { + return res.data.message; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 批量删除购物车 + */ +export async function removeBatchCart(data: (number | undefined)[]) { + const res = await request.delete>( + MODULES_API_URL + '/shop/cart/batch', + { + data + } + ); + if (res.data.code === 0) { + return res.data.message; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 根据id查询购物车 + */ +export async function getCart(id: number) { + const res = await request.get>( + MODULES_API_URL + '/shop/cart/' + id + ); + if (res.data.code === 0 && res.data.data) { + return res.data.data; + } + return Promise.reject(new Error(res.data.message)); +} diff --git a/src/api/shop/cart/model/index.ts b/src/api/shop/cart/model/index.ts new file mode 100644 index 0000000..0898bfd --- /dev/null +++ b/src/api/shop/cart/model/index.ts @@ -0,0 +1,45 @@ +import type { PageParam } from '@/api'; + +/** + * 购物车 + */ +export interface Cart { + // 购物车表ID + id?: string; + // 类型 0商城 1预定 + type?: number; + // 商品ID + goodsId?: string; + // 商品属性 + goodsAttrUnique?: string; + // 商品数量 + cartNum?: number; + // 0 = 未购买 1 = 已购买 + isPay?: string; + // 是否为立即购买 + isNew?: string; + // 拼团id + combinationId?: number; + // 秒杀产品ID + seckillId?: number; + // 砍价id + bargainId?: number; + // 用户ID + userId?: string; + // 是否删除, 0否, 1是 + deleted?: number; + // 租户id + tenantId?: number; + // 注册时间 + createTime?: string; + // 修改时间 + updateTime?: string; +} + +/** + * 购物车搜索条件 + */ +export interface CartParam extends PageParam { + id?: number; + keywords?: string; +} diff --git a/src/views/shop/cart/components/cartEdit.vue b/src/views/shop/cart/components/cartEdit.vue new file mode 100644 index 0000000..2b7e91c --- /dev/null +++ b/src/views/shop/cart/components/cartEdit.vue @@ -0,0 +1,258 @@ + + + + diff --git a/src/views/shop/cart/components/search.vue b/src/views/shop/cart/components/search.vue new file mode 100644 index 0000000..82fea9d --- /dev/null +++ b/src/views/shop/cart/components/search.vue @@ -0,0 +1,42 @@ + + + + diff --git a/src/views/shop/cart/index.vue b/src/views/shop/cart/index.vue new file mode 100644 index 0000000..4923246 --- /dev/null +++ b/src/views/shop/cart/index.vue @@ -0,0 +1,287 @@ + + + + + + +