@@ -14,6 +14,8 @@ type ProductCarouselProps = {
|
||||
* 依赖 swiper 原生 auto-height:海报有多高,轮播就有多高,无裁切。
|
||||
*/
|
||||
imageFit?: 'cover' | 'contain' | 'adaptive';
|
||||
/** 预览相册(默认等于 images);门店详情可传入封面+环境图合并列表 */
|
||||
previewUrls?: string[];
|
||||
};
|
||||
|
||||
/** 商品/门店轮播(对齐 h5 ProductCarousel 三变体) */
|
||||
@@ -23,6 +25,7 @@ export default function ProductCarousel({
|
||||
variant = 'detail',
|
||||
previewable = false,
|
||||
imageFit = 'cover',
|
||||
previewUrls,
|
||||
}: ProductCarouselProps) {
|
||||
const slides = images.length > 0 ? images : [''];
|
||||
const [activeIndex, setActiveIndex] = useState(0);
|
||||
@@ -33,10 +36,10 @@ export default function ProductCarousel({
|
||||
const wrapClass = `${prefix}-wrap${isContain ? ` ${prefix}-wrap--contain` : ''}${isAdaptive ? ` ${prefix}-wrap--adaptive` : ''}`;
|
||||
|
||||
function previewAt(index: number) {
|
||||
const urls = slides.filter(Boolean);
|
||||
if (!urls.length) return;
|
||||
const current = slides[index] || urls[0];
|
||||
Taro.previewImage({ current, urls }).catch(() => undefined);
|
||||
const album = (previewUrls?.length ? previewUrls : slides).filter(Boolean);
|
||||
if (!album.length) return;
|
||||
const current = slides[index] || album[0];
|
||||
Taro.previewImage({ current, urls: album }).catch(() => undefined);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user