01
基础用法
给出奖品数据,接住开始与结果事件;完整字段见 04 段。
<cu-bingo-lotto-roll
:prize-list="prizeList"
@start="onStart"
@end="onEnd"
></cu-bingo-lotto-roll>
1–5 列奖品纵向滚动,逐列错峰停止;中心行拼出最终结果,行高由 item-height 常量直接计算,不读 DOM。
营销组件放在独立模块 colorui-bingo 里,依赖 colorui-x 的主题 token;两个目录一并放进工程的 uni_modules/ 即可,easycom 按标签逐个解析,不写 import,也没有全局注册这一步。本仓不是 npm 包,不提供 npm 安装命令。
your-project/
└── uni_modules/
├── colorui-x/
└── colorui-bingo/
<cu-bingo-lotto-roll
:prize-list="prizeList"
></cu-bingo-lotto-roll>
奖品字段、活动与抽奖响应的示例见 数据与接口规范(仓库内 docs/01-交付与接入/Bingo-数据与接口规范.md)。组件本身不连后端,落点与结果由宿主决定。
| 能力 | App-Android | H5 预览 | 微信 / 支付宝小程序 | iOS |
|---|---|---|---|---|
| 基础渲染 / 点击 | 支持 | 支持 | 编译门 | 未验收 |
| JS ticker 动画 | 支持 | 支持 | 编译门 | 未验收 |
| Canvas(转盘 / 刮卡) | 支持 | 支持 | 编译门 | 未验收 |
| 真实摇一摇 | 不支持(加速度计 API 不可用) | 可选 devicemotion,需 HTTPS / 权限 | 未验收 | 未验收 |
| 震动反馈 | 不支持(类型层无 API) | 未验收 | 未验收 | 未验收 |
| 3D 翻转 / 3D 骰子 | 不支持 | 不支持(统一 2D) | 不支持 | 不支持 |
「编译门」只表示已被编译流程覆盖,不构成真机渲染承诺;「未验收」不写支持。摇一摇的宿主接线见 平台与限制 与组件 05 段说明。
给出奖品数据,接住开始与结果事件;完整字段见 04 段。
<cu-bingo-lotto-roll
:prize-list="prizeList"
@start="onStart"
@end="onEnd"
></cu-bingo-lotto-roll>
用 ref 拿到组件实例后直接调方法;签名与返回值见 04 段 Methods 表。
<cu-bingo-lotto-roll ref="boardRef" :prize-list="prizeList"></cu-bingo-lotto-roll>
import type { CuBingoLottoRollComponentPublicInstance } from './uni_modules/colorui-bingo/components/cu-bingo-lotto-roll/cu-bingo-lotto-roll.uvue'
const boardRef = ref<CuBingoLottoRollComponentPublicInstance | null>(null)
function callStart(): void {
const inst = boardRef.value
if (inst == null) { return }
inst.start()
}
function callReset(): void {
const inst = boardRef.value
if (inst == null) { return }
inst.reset()
}
页面根节点挂主题类和 Bingo 风格类;风格 A–F 由 store/style.uts 切换。
<template>
<view :class="'cu-page ' + themeClass + ' ' + styleClass">
<cu-bingo-lotto-roll :prize-list="prizeList"></cu-bingo-lotto-roll>
</view>
</template>
<script setup lang="uts">
import { cuThemeRootClass } from '../../uni_modules/colorui-x/store/theme.uts'
import { cuBingoStyleRootClass, setBingoStyle } from '../../uni_modules/colorui-bingo/store/style.uts'
const themeClass = computed((): string => cuThemeRootClass())
const styleClass = computed((): string => cuBingoStyleRootClass())
setBingoStyle('f') // a–f 六套风格,演示页顶部分段器可切换
</script>
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| prize-list | 奖品池;元素为 { id, name, image, color } | Array | [] |
| prize-index | 所有列的统一落点;-1 或越界时随机 | Number | -1 |
| prize-index-list | 逐列落点,优先级高于 prize-index;不足的列继续向下回退 | Array | [] |
| reel-count | 列数 1–5;超出范围按 1 / 5 截断 | Number | 3 |
| visible-count | 可见行数,最小 1;中心行 = floor((visibleCount - 1) / 2) | Number | 3 |
| item-height | 每行高(px),动画位移按该常量计算 | String | '60px' |
| reel-width | 每列宽(px);整体宽 = reel-count × reel-width | String | '80px' |
| duration | 第 1 列滚动时长(ms) | Number | 6000 |
| stagger | 相邻列的停止间隔(ms);第 i 列时长 = duration + i × stagger | Number | 2000 |
| turns-number | 落点前额外滚过的整圈数 | Number | 3 |
| disabled | 禁用开始 | Boolean | false |
| 事件 | 说明 | 载荷 |
|---|---|---|
| @start | 开始滚动;index 为第 1 列落点 | { index } |
| @end | 最后一列停稳后触发一次;indices / prizes 为逐列落点与奖品副本 | { index, prize, indices, prizes } |
| 方法 | 签名 | 说明 |
|---|---|---|
| start | start(indices: number[] = []): boolean | 程序化开始;indices 优先于 prize-index-list / prize-index;运行中或禁用返回 false |
| reset | reset(): void | 停表并回到静止态(首项居中),不改 props |
本件没有插槽。
运行中再次 start() 或点开始会被忽略,不重置动画、不补发事件。
end.prizes 是逐列深拷贝,消费方可直接序列化,不会因多列引用同一对象而出错。
App 端动画时钟必须用原始值 ref(clock),不要退回「每帧写数组 ref」的写法,否则 VDOM 不重绘。
item-height / reel-width 只支持 px 数值串;非数值或 <= 0 时分别回退 60 / 80。