You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
196 lines
4.8 KiB
196 lines
4.8 KiB
import apiService from './apiClient'; |
|
|
|
export interface products { |
|
"total": number, |
|
"page": number, |
|
"page_size": number, |
|
"products":Products |
|
} |
|
|
|
export interface Product { |
|
"offer_id": number, |
|
"subject": string, |
|
"subject_trans": string, |
|
"subject_trans_ar": string, |
|
"subject_trans_en": string, |
|
"product_image_urls": string[], |
|
"category_id": number, |
|
"sold_out": number, |
|
"create_date": string, |
|
"seller_open_id": string, |
|
"min_price": number, |
|
"max_price": number, |
|
"currency": string, |
|
"original_min_price": number |
|
} |
|
|
|
export type Products = Product[] |
|
|
|
|
|
export interface ProductParams { |
|
page: number; |
|
page_size: number; |
|
category_id?: number | null; |
|
keyword?: string; |
|
max_price?: number | null; |
|
min_price?: number | null; |
|
sort_order?:string; |
|
sort_by:string, |
|
language:string, |
|
user_id?:number |
|
} |
|
|
|
export interface SkuAttribute { |
|
"attribute_id": number, |
|
"attribute_name": string, |
|
"attribute_name_trans": string, |
|
"value": string, |
|
"value_trans": string, |
|
"value_trans_ar": string, |
|
"value_trans_en": string, |
|
"sku_image_url": string, |
|
'has_color'?: boolean, |
|
size?:number, |
|
list:Sku[], |
|
|
|
} |
|
|
|
export interface Sku { |
|
"sku_id": 0, |
|
"price": number, |
|
"spec_id": "string", |
|
"amount_on_sale": 0, |
|
"consign_price": 0, |
|
"cargo_number": "string", |
|
"one_piece_price": 0, |
|
"offer_price": number, |
|
"attributes": SkuAttribute[], |
|
"original_price": number, |
|
value?:string, |
|
size?:number |
|
} |
|
|
|
export interface ColorOptions { |
|
"title": string, |
|
"options": SkuAttribute[] |
|
} |
|
|
|
export interface ProductDetailParams { |
|
"offer_id": 0, |
|
"category_id": 0, |
|
"price": number | string, |
|
"subject": "string", |
|
"subject_trans": "string", |
|
"vip_discount": number, |
|
"subject_trans_ar": "string", |
|
"subject_trans_en": "string", |
|
"description": "string", |
|
"original_min_price": number, |
|
"original_price": number, |
|
"main_video": "https://example.com/", |
|
"detail_video": "https://example.com/", |
|
"product_image_urls": [ |
|
"string" |
|
], |
|
"min_order_quantity": 1, |
|
"status": "string", |
|
"create_date": "2025-03-31T15:07:27.792Z", |
|
"top_category_id": 0, |
|
"second_category_id": 0, |
|
"third_category_id": 0, |
|
"seller_open_id": "string", |
|
"sold_out": 0, |
|
"batchNumber": 0, |
|
"sale_info": { |
|
"amount_on_sale": 0, |
|
"price_range_list": [ |
|
{ |
|
"min_quantity": 0, |
|
"price": 0, |
|
"original_price": number |
|
} |
|
], |
|
"quote_type": 0, |
|
"unit_info": { |
|
"name": "string", |
|
"count": 0 |
|
}, |
|
"fenxiao_sale_info": {}, |
|
"last_update_time": "2025-03-31T15:07:27.792Z" |
|
}, |
|
"shipping_info": { |
|
"send_goods_address_text": "string", |
|
"weight_kg": 0, |
|
"width_cm": 0, |
|
"height_cm": 0, |
|
"length_cm": 0, |
|
"shipping_time_guarantee": "string" |
|
}, |
|
"attributes": [ |
|
{ |
|
"attribute_id": "string", |
|
"attribute_name": "string", |
|
"attribute_name_trans": "string", |
|
"value": "string", |
|
"value_trans": "string", |
|
"value_trans_ar": "string", |
|
"value_trans_en": "string" |
|
} |
|
], |
|
"skus": Sku[], |
|
"categories": [ |
|
{ |
|
"category_id": 0, |
|
"original_price": number, |
|
"parent_category_id": 0, |
|
"category_level": 0, |
|
"category_name": "string", |
|
"category_name_trans": "string", |
|
"language": "string", |
|
"is_leaf": true |
|
} |
|
] |
|
} |
|
|
|
export interface similar { |
|
"offer_id": number, |
|
"subject": string, |
|
"subject_trans": string, |
|
"subject_trans_ar": string, |
|
"subject_trans_en": string, |
|
"product_image_urls": string[], |
|
"category_id": number, |
|
"sold_out": number, |
|
"create_date": string, |
|
"seller_open_id": string, |
|
"min_price": number, |
|
"max_price": number |
|
} |
|
|
|
export interface ProductGroupList { |
|
attribute_name:string, |
|
has_image:boolean, |
|
attributes:SkuAttribute[], |
|
value?:string |
|
} |
|
export type Similars = similar[] |
|
|
|
|
|
// 搜索商品 |
|
export const productApi = { |
|
// 搜索商品 |
|
getSearchProducts: (params: ProductParams) => { |
|
return apiService.get<products>('/api/search/', params); |
|
}, |
|
// 获取商品详情 |
|
getProductDetail: (offer_id: string, user_id?: number) => { |
|
const url = user_id ? `/api/products/${offer_id}/?user_id=${user_id}` : `/api/products/${offer_id}/`; |
|
return apiService.get<ProductDetailParams>(url); |
|
}, |
|
// 获取相似商品 |
|
getSimilarProducts: (offer_id: string, user_id?: number) => { |
|
const url = user_id ? `/api/products/${offer_id}/similar/?limit=5&user_id=${user_id}` : `/api/products/${offer_id}/similar/?limit=5`; |
|
return apiService.get<Similars>(url); |
|
} |
|
} |
|
|
|
|