营销组件 / 跑马灯抽奖 cu-bingo-marquee

cu-bingo-marquee

8 个奖品格围成一圈,高亮格按顺时针跑动,先加速后减速,最终停在 prize-index 指定的格子并保持高亮。

新 App / H5
01 / Install

引入组件

营销组件放在独立模块 colorui-bingo 里,依赖 colorui-x 的主题 token;两个目录一并放进工程的 uni_modules/ 即可,easycom 按标签逐个解析,不写 import,也没有全局注册这一步。本仓不是 npm 包,不提供 npm 安装命令。

install
your-project/
└── uni_modules/
    ├── colorui-x/
    └── colorui-bingo/

<cu-bingo-marquee
    :prize-list="prizeList"
></cu-bingo-marquee>

奖品字段、活动与抽奖响应的示例见 数据与接口规范(仓库内 docs/01-交付与接入/Bingo-数据与接口规范.md)。组件本身不连后端,落点与结果由宿主决定。

02 / Platform

平台支持

能力App-AndroidH5 预览微信 / 支付宝小程序iOS
基础渲染 / 点击支持支持编译门未验收
JS ticker 动画支持支持编译门未验收
Canvas(转盘 / 刮卡)支持支持编译门未验收
真实摇一摇不支持(加速度计 API 不可用)可选 devicemotion,需 HTTPS / 权限未验收未验收
震动反馈不支持(类型层无 API)未验收未验收未验收
3D 翻转 / 3D 骰子不支持不支持(统一 2D)不支持不支持

「编译门」只表示已被编译流程覆盖,不构成真机渲染承诺;「未验收」不写支持。摇一摇的宿主接线见 平台与限制 与组件 05 段说明。

03 / Demo

代码演示

01

基础用法

给出奖品数据,接住开始与结果事件;完整字段见 04 段。

uvue
<cu-bingo-marquee
    :prize-list="prizeList"
    @start="onStart"
    @end="onEnd"
></cu-bingo-marquee>
02

程序控制

用 ref 拿到组件实例后直接调方法;签名与返回值见 04 段 Methods 表。

uvue
<cu-bingo-marquee ref="boardRef"     :prize-list="prizeList"></cu-bingo-marquee>

import type { CuBingoMarqueeComponentPublicInstance } from './uni_modules/colorui-bingo/components/cu-bingo-marquee/cu-bingo-marquee.uvue'

const boardRef = ref<CuBingoMarqueeComponentPublicInstance | 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()
}
03

风格与主题

页面根节点挂主题类和 Bingo 风格类;风格 A–F 由 store/style.uts 切换。

uvue
<template>
  <view :class="'cu-page ' + themeClass + ' ' + styleClass">
    <cu-bingo-marquee    :prize-list="prizeList"></cu-bingo-marquee>
  </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>
04 / Props · Events · Methods · Slots

全量 API

props

参数说明类型默认值
prize-list最多 8 项;不足 8 项时后面的格子留空但仍参与跑动Array[]
prize-index目标格 0–7;-1 随机Number-1
speed起始步进间隔(ms),越小越快Number150
circle加速段步数Number30
turns-number减速段额外整圈数Number2
width整体宽(含 8 格与中心按钮)String'300px'
height整体高String'300px'
start-text中心按钮文字,\n 换行String'开始\n抽奖'
bg-color外框底色;空串走 tokenString''
item-color格子底色;空串走内置浅金String''
active-color高亮格底色;空串走 token 主色String''
disabled禁用开始按钮Booleanfalse

events

事件说明载荷
@start开始跑动;index 为最终落点{ index }
@end停在目标格,高亮保持;prize 为空位时为 null{ index, prize }

methods

方法签名说明
startstart(index: number = -1): boolean程序化开始;index 越界按随机处理;运行中或禁用返回 false
resetreset(): void回初始格、清高亮,不改变 prize-index

slots

插槽说明
start替换中心按钮内容;提供后 start-text 不生效,点击仍由组件接管
05 / Notes

注意事项

运行中点击中心按钮不重启动画,也不发事件;程序化 start() 被忽略时返回 false。

8 格按 3×3 网格摆放(中心为按钮),375px 宽下默认 300px 三列不溢出。

start 插槽只替换按钮内容,不接受作用域参数。

页面根节点需同时挂主题类与风格类,否则暗黑与风格 A–F 不生效。