lucky-lottery 平台抽奖
更新时间:2025-07-03 14:46:06
一、介绍
平台抽奖组件用于直播间的平台抽奖功能,支持九宫格和大转盘两种抽奖样式。组件包含抽奖活动列表、抽奖详情、奖品列表、奖品领取等功能。
组件提供多种不同的入口组件:
MobileLuckyLotteryList- 移动端抽奖活动列表组件MobileLuckyLotteryDetail- 移动端抽奖详情组件LuckyLotteryPendant- 抽奖挂件组件MobileLuckyLotteryPrizeList- 移动端奖品列表组件MobileLuckyLotteryReceive- 移动端奖品领取组件LuckyLotteryDetail- 抽奖详情组件
二、引入
2.1 UMD 方式
其中 mobile-lucky-lottery-detail.umd.js 是移动端抽奖详情组件,lucky-lottery-pendant.umd.js 是抽奖挂件组件。
<script src="https://websdk.videocc.net/iar-lucky-lottery-ui/rc-20250612/mobile-lucky-lottery-detail.umd.js"></script>
<script>
const { MobileLuckyLotteryDetail, LuckyLotteryPendant, MobileLuckyLotteryList } = window.PolyvIarLuckyLotteryUi;
</script>
2.2 NPM 方式
// 安装依赖
pnpm add @polyv/iar-lucky-lottery-ui
// 引入组件
import {
MobileLuckyLotteryList,
MobileLuckyLotteryDetail,
LuckyLotteryDetail,
LuckyLotteryPendant,
MobileLuckyLotteryPrizeList,
MobileLuckyLotteryReceive
} from '@polyv/iar-lucky-lottery-ui';
三、代码示例
<template>
<div>
<!-- 移动端抽奖详情 -->
<MobileLuckyLotteryDetail
ref="lotteryDetailRef"
:lucky-lottery-target="luckyLotterySDK"
:lottery-activity="lotteryActivity"
@to-show="onToShow"
@to-hide="onToHide"
/>
<!-- 抽奖挂件 -->
<LuckyLotteryPendant
ref="lotteryPendantRef"
:lucky-lottery-target="luckyLotterySDK"
@to-show="onToShow"
@to-hide="onToHide"
/>
</div>
</template>
<script setup>
import { MobileLuckyLotteryDetail, LuckyLotteryPendant } from '@polyv/iar-lucky-lottery-ui';
import { LuckyLottery } from '@polyv/iar-lucky-lottery-sdk';
// 初始化平台抽奖 SDK
const luckyLotterySDK = new LuckyLottery(iarCore);
// 抽奖活动数据
const lotteryActivity = ref(null);
// 事件处理
const onToShow = () => {
console.log('显示抽奖弹窗');
};
const onToHide = () => {
console.log('隐藏抽奖弹窗');
};
</script>
四、API
4.1 Props
| 参数 | 说明 | 类型 | 默认值 | 必填 |
|---|---|---|---|---|
| luckyLotteryTarget | 平台抽奖 SDK 实例 | LuckyLottery |
- | 是 |
| lotteryActivity | 抽奖活动数据 | LuckyLotteryActivityDetailData |
- | 否 |
| preview | 预览模式 | boolean |
false |
否 |
4.2 Events
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| to-show | 显示抽奖弹窗时触发 | () => void |
| to-hide | 隐藏抽奖弹窗时触发 | () => void |
4.3 方法
通过 ref 可以调用组件的方法:
| 方法名 | 说明 | 参数 | 返回值 |
|---|---|---|---|
| show | 显示组件 | - | void |
| hide | 隐藏组件 | - | void |
| startLottery | 开始抽奖 | - | Promise<void> |
