|
@@ -11,6 +11,14 @@ interface SpecOption {
|
|
|
image?: string
|
|
image?: string
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+interface GoodsFromApi {
|
|
|
|
|
+ id: number
|
|
|
|
|
+ name: string
|
|
|
|
|
+ price: number
|
|
|
|
|
+ stock: number
|
|
|
|
|
+ imageFile?: { fullUrl: string }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
interface SpecSelectorProps {
|
|
interface SpecSelectorProps {
|
|
|
visible: boolean
|
|
visible: boolean
|
|
|
onClose: () => void
|
|
onClose: () => void
|
|
@@ -61,7 +69,7 @@ export function GoodsSpecSelector({
|
|
|
if (response.status === 200) {
|
|
if (response.status === 200) {
|
|
|
const data = await response.json()
|
|
const data = await response.json()
|
|
|
// 将子商品数据转换为规格选项格式
|
|
// 将子商品数据转换为规格选项格式
|
|
|
- const childGoodsAsSpecs: SpecOption[] = data.data.map((goods) => ({
|
|
|
|
|
|
|
+ const childGoodsAsSpecs: SpecOption[] = data.data.map((goods: GoodsFromApi) => ({
|
|
|
id: goods.id, // 子商品ID
|
|
id: goods.id, // 子商品ID
|
|
|
name: goods.name, // 子商品名称作为规格名称
|
|
name: goods.name, // 子商品名称作为规格名称
|
|
|
price: goods.price,
|
|
price: goods.price,
|