01 / Overview
cu-shop-comment
单条评论卡片:头像、昵称、星级与正文组成头部,图片按「单行横滑」或「三列九宫格」展示,视频以「深色块 + 播放字符」占位;追评独立成灰底区块,商家回复灰底展示,底部按 `operation` 渲染操作条。
商品与导购
12 条 props
4 事件
已实现
02 / Demo
实时预览
演示页:/pages/shop/comment。右侧的预览由站点脚本把 H5 演示页装进 iframe;数据与交互在演示页内操作,不在此处留静态截图。
依赖
- 基础件:无
- Shop 共享件:
locale/index.uts(cuShopT) - 实体:
ShopComment(字段见docs/01-交付与接入/电商数据字典.md;follow取同实体的appendContent/appendImages)
03 / Props · Events · Slots
全量契约
props
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| type | 头部样式:default 仅昵称 + 星级;complex 另显示时间与规格,头像加大 | string | 'default' |
| imagesRows | 图片排布:one 单行横滑;multi 三列九宫格 | string | 'one' |
| lines | 正文最大行数(按 40rpx 行高换算最大高度);0 及以下不截断 | number | 2 |
| videos | 视频 URL 数组;本件不播放,只渲染占位块 | Array | [] |
| images | 图片 URL 数组,最多取 9 张展示 | Array | [] |
| info | 评论实体(ShopComment) | Object | {} |
| follow | 追评内容;读 appendContent / appendImages | Object | {} |
| operation | 底部按钮配置,按数组顺序渲染;未知类型原样显示 | Array | ['reply', 'like', 'more'] |
| customStyle | 根节点自定义样式 | Object | {} |
| customClass | 根节点自定义类名 | string | '' |
| url | 透传字段,本件未接线 | string | '' |
| linkType | 透传字段,本件未接线 | string | 'navigateTo' |
events
| 事件 | 说明 | 载荷 |
|---|---|---|
| @clickOperate | 操作条按钮点击,type 同 operation 中的值 | type: string |
| @click | 评论内容点击,回传评论实体 | info |
| @clickImages | 图片点击;type 固定 'image',value 为图片 URL | { type, index, value } |
| @clickVideo | 视频占位块点击,本件不内嵌播放器 | { index } |
slots
| 插槽 | 作用域 | 说明 |
|---|---|---|
| labels | 无 | 昵称右侧的用户标签位(原 commentLabels) |
| shopReply | 无 | 商家回复区块底部附加内容(原 commentShopReply) |
04 / Example
代码示例
<cu-shop-comment :type="'complex'" :imagesRows="'multi'" :lines="3"
:images="comment.images" :videos="comment.videos"
:info="comment" :follow="comment"
@clickOperate="onOperate" @clickImages="onImages" @clickVideo="onVideo" />
05 / Notes
注意事项
字典 ShopComment.videos 为 string[] 且无封面字段,视频位按深色块 + 「▶ 视频」占位,不内嵌播放器(R3-1 报告偏差)
clickImages 不处理视频;视频只发 clickVideo
星级用字符 ★ / ☆,不引图标字体;score 四舍五入取整
lines 按行高换算最大高度截断,不渲染省略号
不请求接口、不持久化、不弹 toast:点赞态由宿主持有
安装 colorui-shop 全量包与安装任意 cu-shop-* 单件包二选一,不要同时装。单件包的前提是已安装完整 colorui-x。