feat: 接口

This commit is contained in:
2026-04-27 14:39:59 +08:00
parent b04bcb5918
commit a385aba49f
7 changed files with 234 additions and 89 deletions

View File

@@ -1,9 +1,20 @@
import { Https } from "@/tool/https"
// 编辑时根据ID获取信息
export const fetchListingDetailById = (id) => {
return Https.axiosGet("/seller/listing/detail", { params: { id } })
}
interface SketchIDs {
designItemIds: Array
}
export const fetchSketchDetail = (data: SketchIDs) => {
interface DetailReturns {
clothes: string[]
designItemId: number
toProductImageUrls: string[]
}
// 获取designItemId对应的产品图
export const fetchSketchDetail = (data: SketchIDs): Array<DetailReturns> => {
let params = "?"
data.forEach((id, index) => {
if (index === data.length - 1) {
@@ -15,10 +26,40 @@ export const fetchSketchDetail = (data: SketchIDs) => {
return Https.axiosGet(`/api/seller/sketchDetail${params}`)
}
interface ImageObj {
id: number // 图片id,有值会更新,没有会自动新增
category: "cover" | "main_product" | "product" | "sketch" | "apparel" // 图片类型
}
interface DetailData {
id: number | string // 商品Id
title: string // 商品名
description: string // 商品描述
price: number // 价格
stock?: number // 库存
viewCount?: number // 浏览量
status: 0 | 1 | 2 // 0草稿 1发布 2删除
images: ImageObj[]
designFor: "male" | "female"
productCategory: "outwear" | "trousers" | "blouse" | "dress" | "skirt" | "accessories"
}
// 保存/更新表单
export const fetchUpdateListing = (data: DetailData) => {
return Https.axiosPost("/seller/listing/batch", data)
}
interface StatusData {
id: number | string
status: 0 | 1 | 2 // 0草稿 1发布 2删除
}
// 设置商品状态
export const fetchChangeStatus = (data: StatusData) => {
return Https.axiosPut("/seller/listing/status", data)
}
export const uploadFile = (file) => {
const formData = new FormData()
formData.append("file", file)
return Https.axiosPost("/seller/file/ upload", formData, {
return Https.axiosPost("/seller/file/upload", formData, {
headers: { "Content-Type": "multipart/form-data", Accept: "*/*" }
})
}