This commit is contained in:
2026-01-29 10:43:43 +08:00
commit 4a76df3391
426 changed files with 74975 additions and 0 deletions

106
api/shop/shopCart/index.ts Normal file
View File

@@ -0,0 +1,106 @@
import request from '@/utils/request';
import type {ApiResult, PageResult} from '@/api';
import type {ShopCart, ShopCartParam} from './model';
import {SERVER_API_URL} from "~/config";
/**
* 分页查询购物车
*/
export async function pageShopCart(params: ShopCartParam) {
const res = await request.get<ApiResult<PageResult<ShopCart>>>(
SERVER_API_URL + '/shop/shop-cart/page',
{
params
}
);
if (res.data.code === 0) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 查询购物车列表
*/
export async function listShopCart(params?: ShopCartParam) {
const res = await request.get<ApiResult<ShopCart[]>>(
SERVER_API_URL + '/shop/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 addShopCart(data: ShopCart) {
const res = await request.post<ApiResult<unknown>>(
SERVER_API_URL + '/shop/shop-cart',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 修改购物车
*/
export async function updateShopCart(data: ShopCart) {
const res = await request.put<ApiResult<unknown>>(
SERVER_API_URL + '/shop/shop-cart',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 删除购物车
*/
export async function removeShopCart(id?: number) {
const res = await request.delete<ApiResult<unknown>>(
SERVER_API_URL + '/shop/shop-cart/' + id
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 批量删除购物车
*/
export async function removeBatchShopCart(data: (number | undefined)[]) {
const res = await request.delete<ApiResult<unknown>>(
SERVER_API_URL + '/shop/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 getShopCart(id: number) {
const res = await request.get<ApiResult<ShopCart>>(
SERVER_API_URL + '/shop/shop-cart/' + id
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}

View File

@@ -0,0 +1,72 @@
import type { PageParam } from '@/api';
import type {ShopOrderInfo} from "~/api/shop/shopOrderInfo/model";
import type {Company} from "~/api/system/company/model";
/**
* 购物车
*/
export interface ShopCart {
// 购物车表ID
id?: string;
// 类型 0商城 1外卖
type?: number;
// 唯一标识
code?: string;
// 商品ID
productId?: string;
// 商品规格
spec?: string;
// 商品价格
price?: string;
// 商品数量
cartNum?: number;
// 单商品合计
totalPrice?: string;
// 0 = 未购买 1 = 已购买
isPay?: string;
// 是否为立即购买
isNew?: string;
// 拼团id
combinationId?: number;
// 秒杀产品ID
seckillId?: number;
// 砍价id
bargainId?: number;
// 是否选中
selected?: string;
// 商户ID
merchantId?: string;
// 用户ID
userId?: string;
// 租户id
tenantId?: number;
// 创建时间
createTime?: string;
// 修改时间
updateTime?: string;
// 商品封面图
image?: string;
}
/**
* 购物车搜索条件
*/
export interface ShopCartParam extends PageParam {
id?: number;
keywords?: string;
}
export interface MyCart {
appName?: string,
domain?: string,
adminUrl?: string;
menuId?: number;
num?: number,
type?: number;
payType?: number,
payPrice?: number,
month?: number,
comments?: string,
list?: Company[],
totalPrice?: number
}