基本实现了订单、购物车、商品等模块,商城v1.0
This commit is contained in:
25
src/apis/order.ts
Normal file
25
src/apis/order.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import http from "../utils/http";
|
||||
import type {
|
||||
// OrderListItem,
|
||||
OrderDetail,
|
||||
OrderPageParams,
|
||||
OrderPageResponse,
|
||||
} from "@/types/order";
|
||||
|
||||
// 获取订单列表
|
||||
export const getOrderList = (params: OrderPageParams) => {
|
||||
return http<OrderPageResponse>({
|
||||
url: "/order/page",
|
||||
method: "get",
|
||||
params,
|
||||
});
|
||||
};
|
||||
|
||||
// 获取订单详情
|
||||
export const getOrderDetail = (id: number, userId: number) => {
|
||||
return http<OrderDetail>({
|
||||
url: `/order/${id}`,
|
||||
method: "get",
|
||||
params: { userId },
|
||||
});
|
||||
};
|
||||
@@ -1,14 +1,41 @@
|
||||
import http from "../utils/http";
|
||||
import type {
|
||||
// ProductListItem,
|
||||
ProductCategory,
|
||||
ProductDetail,
|
||||
ProductPageParams,
|
||||
ProductPageResponse,
|
||||
} from "@/types/product";
|
||||
|
||||
export const addProduct = (data: {
|
||||
name: string;
|
||||
price: number;
|
||||
description: string;
|
||||
image: string;
|
||||
}) => {
|
||||
return http({
|
||||
url: "/product",
|
||||
method: "post",
|
||||
data,
|
||||
// 获取商品列表
|
||||
export const getProductList = (params: ProductPageParams) => {
|
||||
return http<ProductPageResponse>({
|
||||
url: "/product/page",
|
||||
method: "get",
|
||||
params,
|
||||
});
|
||||
};
|
||||
|
||||
// 获取商品分类
|
||||
export const getProductCategories = () => {
|
||||
return http<ProductCategory[]>({
|
||||
url: "/product/category",
|
||||
method: "get",
|
||||
});
|
||||
};
|
||||
|
||||
// 获取子分类
|
||||
export const getProductSubCategories = (id: number) => {
|
||||
return http<ProductCategory[]>({
|
||||
url: `/product/category/${id}`,
|
||||
method: "get",
|
||||
});
|
||||
};
|
||||
|
||||
// 获取商品详情
|
||||
export const getProductDetail = (id: number) => {
|
||||
return http<ProductDetail>({
|
||||
url: `/product/${id}`,
|
||||
method: "get",
|
||||
});
|
||||
};
|
||||
|
||||
47
src/apis/shoppingcart.ts
Normal file
47
src/apis/shoppingcart.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import http from "../utils/http";
|
||||
import type { ShoppingCartItem, ShoppingCartDTO } from "@/types/shoppingcart";
|
||||
|
||||
// 获取用户购物车列表
|
||||
export const getUserCartList = (userId: number) => {
|
||||
return http<ShoppingCartItem[]>({
|
||||
url: "/cart",
|
||||
method: "get",
|
||||
params: { userId },
|
||||
});
|
||||
};
|
||||
|
||||
// 添加商品到购物车
|
||||
export const addCart = (data: ShoppingCartDTO) => {
|
||||
return http({
|
||||
url: "/cart",
|
||||
method: "post",
|
||||
data,
|
||||
});
|
||||
};
|
||||
|
||||
// 更新购物车商品数量
|
||||
export const updateCartCount = (data: ShoppingCartDTO) => {
|
||||
return http({
|
||||
url: "/cart/count",
|
||||
method: "put",
|
||||
data,
|
||||
});
|
||||
};
|
||||
|
||||
// 更新购物车商品勾选状态
|
||||
export const updateCartChecked = (data: ShoppingCartDTO) => {
|
||||
return http({
|
||||
url: "/cart/checked",
|
||||
method: "put",
|
||||
data,
|
||||
});
|
||||
};
|
||||
|
||||
// 删除购物车商品
|
||||
export const deleteCart = (id: number, userId: number) => {
|
||||
return http({
|
||||
url: `/cart/${id}`,
|
||||
method: "delete",
|
||||
params: { userId },
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user