01
基础用法
给出奖品数据,接住开始与结果事件;完整字段见 04 段。
<cu-bingo-hiteggs
:prize-list="prizeList"
@hit="onHit"
@start="onStart"
@end="onEnd"
></cu-bingo-hiteggs>
点中一枚金蛋后,锤子往返抖动、蛋壳裂开,奖品文字落定。一次只处理一枚,破壳态保持到重置。
营销组件放在独立模块 colorui-bingo 里,依赖 colorui-x 的主题 token;两个目录一并放进工程的 uni_modules/ 即可,easycom 按标签逐个解析,不写 import,也没有全局注册这一步。本仓不是 npm 包,不提供 npm 安装命令。
your-project/
└── uni_modules/
├── colorui-x/
└── colorui-bingo/
<cu-bingo-hiteggs
:prize-list="prizeList"
></cu-bingo-hiteggs>
奖品字段、活动与抽奖响应的示例见 数据与接口规范(仓库内 docs/01-交付与接入/Bingo-数据与接口规范.md)。组件本身不连后端,落点与结果由宿主决定。
| 能力 | App-Android | H5 预览 | 微信 / 支付宝小程序 | iOS |
|---|---|---|---|---|
| 基础渲染 / 点击 | 支持 | 支持 | 编译门 | 未验收 |
| JS ticker 动画 | 支持 | 支持 | 编译门 | 未验收 |
| Canvas(转盘 / 刮卡) | 支持 | 支持 | 编译门 | 未验收 |
| 真实摇一摇 | 不支持(加速度计 API 不可用) | 可选 devicemotion,需 HTTPS / 权限 | 未验收 | 未验收 |
| 震动反馈 | 不支持(类型层无 API) | 未验收 | 未验收 | 未验收 |
| 3D 翻转 / 3D 骰子 | 不支持 | 不支持(统一 2D) | 不支持 | 不支持 |
「编译门」只表示已被编译流程覆盖,不构成真机渲染承诺;「未验收」不写支持。摇一摇的宿主接线见 平台与限制 与组件 05 段说明。
给出奖品数据,接住开始与结果事件;完整字段见 04 段。
<cu-bingo-hiteggs
:prize-list="prizeList"
@hit="onHit"
@start="onStart"
@end="onEnd"
></cu-bingo-hiteggs>
用 ref 拿到组件实例后直接调方法;签名与返回值见 04 段 Methods 表。
<cu-bingo-hiteggs ref="boardRef" :prize-list="prizeList"></cu-bingo-hiteggs>
import type { CuBingoHiteggsComponentPublicInstance } from './uni_modules/colorui-bingo/components/cu-bingo-hiteggs/cu-bingo-hiteggs.uvue'
const boardRef = ref<CuBingoHiteggsComponentPublicInstance | 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-hiteggs :prize-list="prizeList"></cu-bingo-hiteggs>
</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 | 奖池;蛋数 = 列表长度(最多 12),空列表渲染 1 个占位蛋 | Array | [] |
| prize-index | 预置中奖蛋位;-1 时点哪枚出哪枚的奖品 | Number | -1 |
| columns | 每行蛋数;间距用 margin,不用 gap | Number | 3 |
| egg-width | 单枚蛋宽 | String | '80px' |
| egg-height | 单枚蛋高 | String | '80px' |
| intact-image | 完整蛋图;空串用 CSS 蛋形兜底 | String | '' |
| broken-image | 破壳图;空串用内置裂纹层 | String | '' |
| hammer-image | 锤子图;空串不显示锤子,直接裂开 | String | '' |
| duration | 单次砸蛋总时长(ms) | Number | 600 |
| disabled | 整组禁用 | Boolean | false |
| 事件 | 说明 | 载荷 |
|---|---|---|
| @hit | 用户点中某枚蛋的瞬间 | { index } |
| @start | 动画开始;用户点击时与 hit 同帧,程序化 start() 时只发它 | { index } |
| @end | 破壳完成,奖品落定;空奖池为 null | { index, prize } |
| 方法 | 签名 | 说明 |
|---|---|---|
| start | start(index: number = -1): boolean | 程序化砸一枚;index 越界或已破壳时回退随机一枚未破的蛋;运行中、disabled 或无完整蛋返回 false |
| reset | reset(): void | 全部复原、清锤子与锁定 |
本件没有插槽。
running 期间的重复点击由组件自身挡住,不排队、不叠加。
一次只处理一枚,破壳态保持到 reset()。
页面卸载时组件会取消内部 ticker;页面隐藏不强停,由宿主决定是否 reset()。
页面根节点需同时挂主题类与风格类,否则暗黑与风格 A–F 不生效。