新增功能:收银台

This commit is contained in:
2024-08-05 01:33:10 +08:00
parent 05f890f343
commit 1d81fa9270
37 changed files with 3655 additions and 74 deletions
+47 -2
View File
@@ -1,6 +1,6 @@
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api';
import type { Cart, CartParam } from './model';
import { Cart, CartParam, CartVo } from './model';
import { MODULES_API_URL } from '@/config/setting';
/**
@@ -23,7 +23,7 @@ export async function pageCart(params: CartParam) {
* 查询购物车列表
*/
export async function listCart(params?: CartParam) {
const res = await request.get<ApiResult<Cart[]>>(
const res = await request.get<ApiResult<CartVo>>(
MODULES_API_URL + '/shop/cart',
{
params
@@ -104,3 +104,48 @@ export async function getCart(id: number) {
}
return Promise.reject(new Error(res.data.message));
}
/**
* 挂单
* @param data
*/
export async function packCart(data: Cart) {
const res = await request.post<ApiResult<unknown>>(
MODULES_API_URL + '/shop/cart/packCart',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 减少数量
* @param data
*/
export async function subCartNum(data: Cart) {
const res = await request.put<ApiResult<unknown>>(
MODULES_API_URL + '/shop/cart/subCartNum',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 增加数量
* @param data
*/
export async function addCartNum(data: Cart) {
const res = await request.put<ApiResult<unknown>>(
MODULES_API_URL + '/shop/cart/addCartNum',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
+38 -2
View File
@@ -1,17 +1,45 @@
import type { PageParam } from '@/api';
export interface CartVo {
// 店铺列表
shops?: CartShopVo[];
// 购物车总金额
totalPrice?: number;
// 宝贝总数量
totalNums?: number;
// 已选宝贝
selectNums?: number;
// 是否全选
selectAll?: boolean;
}
export interface CartShopVo {
// 店铺ID
shopId?: number;
// 店铺名称
shopName?: string;
// 店铺LOGO
shopLogo?: string;
// 购物车商品列表
carts?: Cart[];
}
/**
* 购物车
*/
export interface Cart {
// 购物车表ID
id?: string;
id?: number;
// 类型 0商城 1预定
type?: number;
// 商品ID
goodsId?: string;
goodsId?: number;
// 商品名称
goodsName?: string;
// 唯一标识
code?: string;
// 是否多规格
specs?: number;
// 商品规格
spec?: string;
// 商品数量
@@ -36,6 +64,14 @@ export interface Cart {
createTime?: string;
// 修改时间
updateTime?: string;
// 商品图片
image?: string;
// 商品价格
price?: number;
// 加载完成
loading?: boolean;
// 收银员ID
adminId?: number;
}
/**