23 lines
973 B
TypeScript
23 lines
973 B
TypeScript
import { get, post } from '../utils/request'
|
|
import type { Product, Category, DetailParameterConfig, SpecData } from '../types'
|
|
|
|
/** 获取商品列表 */
|
|
export const getProducts = (params?: { categoryId?: number; page?: number; pageSize?: number }) =>
|
|
get<{ list: Product[]; total: number }>('/api/products', params as Record<string, unknown>)
|
|
|
|
/** 获取商品详情 */
|
|
export const getProductDetail = (id: number) =>
|
|
get<Product>(`/api/products/${id}`)
|
|
|
|
/** 获取商品详细参数选项 */
|
|
export const getProductSpecs = (id: number) =>
|
|
get<DetailParameterConfig>(`/api/products/${id}/specs`)
|
|
|
|
/** 根据参数组合获取规格数据列表 */
|
|
export const getSpecDataList = (id: number, params: { fineness: string; mainStone: string; ringSize: string }) =>
|
|
post<SpecData[]>(`/api/products/${id}/spec-data`, params as unknown as Record<string, unknown>)
|
|
|
|
/** 获取商品分类列表 */
|
|
export const getCategories = () =>
|
|
get<Category[]>('/api/categories')
|