bug修复
This commit is contained in:
1 parent
654d08c8c8
commit
659ff74568
18 files changed
+182
-19
No files matched your search
+10
-4
@@ -490,6 +490,9 @@ function Collection({
|
||||
/** B2B 商品详情主体,集中展示主图、核心信息、参数、详情和询盘入口。 */
|
||||
function ProductDetailView({ data: d }: { data: Record<string, any> }) {
|
||||
const [inquiryOpen, setInquiryOpen] = useState(false);
|
||||
const productImages = d.images?.length ? d.images : d.coverMediaUrl ? [{mediaCode:d.coverMediaCode,url:d.coverMediaUrl}] : [];
|
||||
const [selectedImage, setSelectedImage] = useState(0);
|
||||
useEffect(() => setSelectedImage(0), [d.productCode]);
|
||||
useEffect(() => {
|
||||
if (!inquiryOpen) return;
|
||||
const closeOnEscape = (event: KeyboardEvent) => {
|
||||
@@ -505,10 +508,13 @@ function ProductDetailView({ data: d }: { data: Record<string, any> }) {
|
||||
return <article className="detail product-detail">
|
||||
<Crumbs current={String(d.productName || "Product")}/>
|
||||
<section className="product-overview">
|
||||
<div className="product-media">
|
||||
{d.coverMediaUrl
|
||||
? <img src={assetUrl(d.coverMediaUrl)} alt={d.productName || "Product image"}/>
|
||||
: <div className="product-image-placeholder"><ImageIcon size={48}/><span>Product image coming soon</span></div>}
|
||||
<div className="product-gallery">
|
||||
<div className="product-media">
|
||||
{productImages[selectedImage]?.url
|
||||
? <img src={assetUrl(productImages[selectedImage].url)} alt={`${d.productName || "Product"} ${selectedImage + 1}`}/>
|
||||
: <div className="product-image-placeholder"><ImageIcon size={48}/><span>Product image coming soon</span></div>}
|
||||
</div>
|
||||
{productImages.length>1&&<div className="product-thumbnails">{productImages.map((image:any,index:number)=><button type="button" className={`product-thumbnail${index===selectedImage?' active':''}`} key={image.mediaCode||index} onClick={()=>setSelectedImage(index)}><img src={assetUrl(image.url)} alt={`${d.productName || "Product"} thumbnail ${index+1}`}/></button>)}</div>}
|
||||
</div>
|
||||
<div className="product-summary">
|
||||
<p className="eyebrow">PRODUCT</p>
|
||||
|
||||
Reference in new issue
Block a user