电商组件 / 商品与导购 / cu-shop-goods-gallery 商品主图
01 / Overview

cu-shop-goods-gallery

商品详情的图片 / 视频混合轮播:图片项点击发预览、视频项显示封面与居中播放按钮,右上角可挂当前序号,底部圆点指示器可关。高度不传时按 1:1 铺满。

商品与导购 11 条 props 4 事件 已实现
02 / Demo

实时预览

演示页:/pages/shop/goods-gallery。右侧的预览由站点脚本把 H5 演示页装进 iframe;数据与交互在演示页内操作,不在此处留静态截图。

依赖

  • 基础件:无(平台原生 swiper / swiper-item)
  • Shop 共享件:locale/index.uts(cuShopT)
  • 实体:ShopGoodsMedia(字段见 docs/01-交付与接入/电商数据字典.md)
03 / Props · Events · Slots

全量契约

props

参数说明类型默认值
media媒体数组;项含 type(image / video)、url、coverUrl、durationArray[]
current当前页索引(受控),滑动后经 update:current 上抛number0
autoplay是否自动轮播booleantrue
interval自动轮播间隔(毫秒)number3000
showIndex是否显示右上角「当前 / 总数」booleantrue
showIndicator是否显示底部圆点指示器booleantrue
height轮播高度(px);0 时按 1:1 取 750rpxnumber0
customStyle根节点自定义样式Object{}
customClass根节点自定义类名string''
url透传字段,本件未接线string''
linkType透传字段,本件未接线string'navigateTo'

events

事件说明载荷
@update:current滑动换页;与 current 不等时才发number
@click任意媒体项点击{ index }
@preview图片项点击(在 click 之后发){ index }
@play视频项点击或居中播放按钮点击{ index }

slots

插槽作用域说明
overlay无轮播上层的角标区
04 / Example

代码示例

uvue
<cu-shop-goods-gallery :media="media" :current="current" :autoplay="true"
	@update:current="onCurrent" @preview="onPreview" @play="onPlay" />
05 / Notes

注意事项

单张媒体时隐藏圆点与序号

视频项:coverUrl 作为封面,未给封面时不渲染图片底、只显示播放按钮;封面右下角显示「视频」标

height 传值时按 height × 2rpx 作为轮播高度;不传时 750rpx(正方形)

不请求接口、不持久化:媒体数据全部由 media prop 驱动,播放与预览由宿主接线

未使用 cu-swiper:参考件需要内容层角标与视频播放按钮,cu-swiper 只有指示器插槽,故改用平台原生 swiper(偏差已登记)

安装 colorui-shop 全量包与安装任意 cu-shop-* 单件包二选一,不要同时装。单件包的前提是已安装完整 colorui-x。