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、duration | Array | [] |
| current | 当前页索引(受控),滑动后经 update:current 上抛 | number | 0 |
| autoplay | 是否自动轮播 | boolean | true |
| interval | 自动轮播间隔(毫秒) | number | 3000 |
| showIndex | 是否显示右上角「当前 / 总数」 | boolean | true |
| showIndicator | 是否显示底部圆点指示器 | boolean | true |
| height | 轮播高度(px);0 时按 1:1 取 750rpx | number | 0 |
| 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
代码示例
<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。