import type { Media } from '../../types/props.js'; import type { Product } from '../Listing/types/product.js'; /** * 礼品货架产品项(简化版产品信息) */ export interface GiftShelfProduct { /** 产品 SKU */ sku: string; /** 产品名称 */ name: string; /** 产品图片 URL */ image: string; /** 产品值/标识 (通常与 handle 相同) */ value: string; /** 产品 handle (URL slug) */ handle: string; /** Shopify 产品 ID */ shopify_id: string; /** 自定义库存 */ custom_inventory?: number; /** 自定义价格 */ custom_price?: number; /** 自定义产品描述 */ custom_description?: string | null; } /** * 倒计时配置接口 */ export interface CountdownConfig { /** 倒计时开始时间,支持 ISO 8601 字符串(如 "2026-02-10T04:00:00.000Z")或时间戳(毫秒) */ startTime: string | number; /** 每轮倒计时时长(天),默认为 1 天 */ durationDays?: number; /** 倒计时轮次,默认为 1 */ rounds?: number; } /** * 响应式背景图片类型 * 支持 5 个断点的图片配置 */ export interface ResponsiveBackgroundImage { /** 默认图片 (<768px 移动端) */ default?: Media; /** tablet 断点图片 (≥768px) */ tablet?: Media; /** laptop 断点图片 (≥1025px) */ laptop?: Media; /** desktop 断点图片 (≥1440px) */ desktop?: Media; /** lg-desktop 断点图片 (≥1920px) */ lgDesktop?: Media; } /** * 礼品卡片项数据接口 */ export interface GiftShelfItem { /** 卡片倒计时配置(可选) */ countdown?: CountdownConfig; /** 产品列表 */ products: GiftShelfProduct[]; /** 响应式背景图片(支持 5 个断点) */ backgroundImage?: ResponsiveBackgroundImage; /** Code 前缀,后缀会根据当前轮次自动生成(MMDD 格式) */ codePrefix?: string; } /** * 礼品货架组件数据接口 */ export interface GiftShelfData { /** 礼品卡片列表 */ items: GiftShelfItem[]; /** 主题模式,默认为 light */ theme?: 'light' | 'dark'; /** 购买按钮文本 */ buttonText: string; /** 购买按钮链接 */ buttonLink?: string; /** 剩余数量提示文本,支持模板变量 {inventory} 和 {quantity} */ remainText?: string; /** 低库存提示文本 */ lowStockText?: string; /** 售罄按钮文本 */ soldOutButtonText?: string; /** 折扣文案(可选) */ discountText?: string; /** 倒计时文案 */ countdownText?: string; /** 最后一轮提示文案 */ lastRoundText?: string; /** 开始前提示文案 */ beforeStartText?: string; /** 即将开始按钮文案 */ comingSoonButtonText?: string; /** 倒计时图标 */ countdownIcon?: Media; } /** * 语义化类名 */ export type GiftShelfSemanticName = 'root' | 'card' | 'countdown' | 'button'; /** * 礼品货架组件 Props */ export interface GiftShelfProps extends React.HTMLAttributes { /** 业务数据 */ data: GiftShelfData; /** 构建时数据(产品列表等) */ buildData?: { products: Product[]; }; /** 语义化类名 */ classNames?: Partial>; /** 按钮点击回调,code 为当前轮次的完整 Code(前缀 + MMDD 后缀) */ onButtonClick?: ({ product, code }: { product: GiftShelfProduct; code: string; }) => void; /** 按钮加载状态 */ loading?: boolean; }