條件抽獎
一、功能概述
本模組提供直播間抽獎相關功能,包括初始化抽獎、取得抽獎資訊、參與抽獎等功能。
二、Api 方法
2.1 初始化福利抽獎
說明: 初始化抽獎功能,取得抽獎詳情並設定相關狀態
Api 方法: initLottery(lotteryId: string): Promise<WelfareLotteryDetail>
參數說明:
- lotteryId:抽獎ID,
string類型,必傳
回傳值說明: 抽獎詳情,Promise<WelfareLotteryDetail> 類型,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
lotteryId |
抽獎 id | string |
prizeName |
獎品名稱 | string |
realPrice |
優惠價 | number |
price |
原價 | number |
thumbnail |
獎品縮圖 | string |
amount |
中獎人數 | number |
lotteryCondition |
參與條件 | WelfareLotteryCondition |
lotteryRange |
抽獎用戶範圍 | WelfareLotteryRange |
customGroupLotteryType |
分組抽獎類型 | WelfareLotteryCustomGroupType |
endTime |
開獎時間,單位:時間戳 | number |
status |
抽獎狀態 | WelfareLotteryStatus |
winnerIds |
中獎用戶id列表 | string[] |
inviteNum |
邀請人數 | number |
inviteType |
邀請類型 | WelfareLotteryInviteType |
comment |
評論抽獎關鍵字 | string |
duration |
觀看時長 | number |
hiddenWinnerAmount |
隱藏獎品數量 | YN |
viewerSize |
參與人數 | number |
hiddenAttendeeNumber |
隱藏參與人數 | YN |
範例:
// 初始化抽奖
const lotteryDetail = await watchCore.welfareLottery.initLottery('123456');
console.log('抽奖详情', lotteryDetail);
2.2 取得抽獎詳情
說明: 取得指定抽獎活動的詳細資訊
Api 方法: getLotteryDetail(lotteryId: string): Promise<WelfareLotteryDetail>
參數說明:
- lotteryId:抽獎ID,
string類型,必傳
回傳值說明: 抽獎詳情,Promise<WelfareLotteryDetail> 類型,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
lotteryId |
抽獎 id | string |
prizeName |
獎品名稱 | string |
realPrice |
優惠價 | number |
price |
原價 | number |
thumbnail |
獎品縮圖 | string |
amount |
中獎人數 | number |
lotteryCondition |
參與條件 | WelfareLotteryCondition |
lotteryRange |
抽獎用戶範圍 | WelfareLotteryRange |
customGroupLotteryType |
分組抽獎類型 | WelfareLotteryCustomGroupType |
endTime |
開獎時間,單位:時間戳 | number |
status |
抽獎狀態 | WelfareLotteryStatus |
winnerIds |
中獎用戶id列表 | string[] |
inviteNum |
邀請人數 | number |
inviteType |
邀請類型 | WelfareLotteryInviteType |
comment |
評論抽獎關鍵字 | string |
duration |
觀看時長 | number |
hiddenWinnerAmount |
隱藏獎品數量 | YN |
viewerSize |
參與人數 | number |
hiddenAttendeeNumber |
隱藏參與人數 | YN |
範例:
// 获取抽奖详情
const detail = await watchCore.welfareLottery.getLotteryDetail('123456');
console.log('抽奖详情', detail);
2.3 取得抽獎完成情況
說明: 取得用戶參與抽獎的完成情況,如觀看時長、是否評論等
Api 方法: getLotteryFinishData(lotteryId?: string): Promise<WelfareLotteryFinishData>
參數說明:
- lotteryId:undefined,
string類型,選傳
回傳值說明: 抽獎完成情況,Promise<WelfareLotteryFinishData> 類型,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
lotteryId |
抽獎 id | string |
viewerSize |
參與人數 | number |
condition |
參與條件 | WelfareLotteryCondition |
hasComment |
是否已參與評論 | YN |
duration |
已觀看時長 | number |
inviteType |
邀請類型 | WelfareLotteryInviteType |
inviteCount |
邀請人數 | number |
範例:
// 获取抽奖完成情况
const finishData = await watchCore.welfareLottery.getLotteryFinishData();
console.log('抽奖完成情况', finishData);
2.4 取得中獎列表
說明: 取得抽獎活動的中獎用戶列表
Api 方法: getLotteryWinners(options: Object): Promise<LotteryWinnersData>
參數說明:
- options:查詢參數,
Object類型,必傳,詳細類型說明如下
| 參數名 | 說明 | 類型 | 必須 | 預設值 |
|---|---|---|---|---|
pageNumber |
- | number |
否 | - |
lotteryId |
抽獎ID | string |
是 | - |
回傳值說明: 中獎名單數據,Promise<LotteryWinnersData> 類型,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
contents |
獲獎列表 | LotteryWinnerItem[] |
pageNumber |
當前頁碼 | number |
pageSize |
每頁條數 | number |
totalItems |
總條數 | number |
totalPages |
總頁數 | number |
範例:
// 获取中奖名单
const winners = await watchCore.welfareLottery.getLotteryWinners({
lotteryId: '123456'
});
console.log('中奖名单', winners);
2.5 完成評論抽獎
說明: 提交評論完成評論類型的抽獎參與條件
Api 方法: finishCommentLottery(options: Object): Promise<void>
參數說明:
- options:參數,
Object類型,必傳,詳細類型說明如下
| 參數名 | 說明 | 類型 | 必須 | 預設值 |
|---|---|---|---|---|
comment |
評論內容 | string |
是 | - |
範例:
// 提交评论参与抽奖
await watchCore.welfareLottery.finishCommentLottery({
comment: '我要参与抽奖'
});
說明: 取得抽獎活動的獎品詳細資訊
Api 方法: getLotteryPrize(lotteryId: string): Promise<WelfareLotteryPrize>
參數說明:
- lotteryId:抽獎ID,
string類型,必傳
回傳值說明: 抽獎獎品資訊,Promise<WelfareLotteryPrize> 類型,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
acceptType |
領獎方式 | PrizeAcceptType |
channelId |
頻道ID | string |
formList |
領獎表單 | PrizeFromItem[] |
hasObtain |
是否已領獎,當acceptType為form時有效 | boolean |
lotteryId |
抽獎ID | string |
prizeUrl |
領獎url | string |
recordId |
中獎ID | string |
qrCode |
領獎QR Code | string |
qrCodeTips |
領獎QR Code提示語 | string |
winnerCode |
中獎碼 | string |
範例:
// 获取抽奖奖品信息
const prizeInfo = await watchCore.welfareLottery.getLotteryPrize('123456');
console.log('抽奖奖品信息', prizeInfo);
2.6 取得抽獎記錄
說明: 取得用戶參與的抽獎活動記錄
Api 方法: getLotteryRecord(options: Object): Promise<LotteryRecordData>
參數說明:
- options:查詢參數,
Object類型,必傳,詳細類型說明如下
| 參數名 | 說明 | 類型 | 必須 | 預設值 |
|---|---|---|---|---|
pageNumber |
- | number |
否 | - |
pageSize |
- | number |
否 | - |
回傳值說明: 抽獎記錄數據,Promise<LotteryRecordData> 類型,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
contents |
獲獎列表 | LotteryRecordItem[] |
pageNumber |
當前頁碼 | number |
pageSize |
每頁條數 | number |
totalItems |
總條數 | number |
totalPages |
總頁數 | number |
範例:
// 获取抽奖记录
const records = await watchCore.welfareLottery.getLotteryRecord({
pageNumber: 1,
pageSize: 20
});
console.log('抽奖记录', records);
2.7 取得領獎資訊表單配置
說明: 取得抽獎活動的領獎資訊表單配置,用於中獎後填寫領獎資訊
Api 方法: getLotteryReceive(options: Object): Promise<LotteryReceiveData>
參數說明:
- options:查詢參數,
Object類型,必傳,詳細類型說明如下
| 參數名 | 說明 | 類型 | 必須 | 預設值 |
|---|---|---|---|---|
lotteryId |
抽獎ID | string |
是 | - |
回傳值說明: 領獎資訊表單配置,Promise<LotteryReceiveData> 類型,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
acceptType |
領獎方式 | LotteryAcceptType |
formList |
表單列表 | LotteryReceiveFormItem[] |
hasObtain |
是否已領取 | boolean |
lotteryId |
抽獎 id | string |
prizeUrl |
獎品領取地址 | null | string |
qrCode |
QR Code地址 | string |
qrCodeTips |
QR Code提示 | string |
recordId |
記錄 id | string |
winnerCode |
兌換碼 | string |
範例:
// 获取领奖信息表单
const receiveForm = await watchCore.welfareLottery.getLotteryReceive({
lotteryId: '123456'
});
console.log('领奖表单', receiveForm);
2.8 提交領獎人資訊
說明: 提交中獎者的領獎資訊,包括姓名、聯絡方式等
Api 方法: submitReceive(options: Object): Promise<void>
參數說明:
- options:提交參數,
Object類型,必傳,詳細類型說明如下
| 參數名 | 說明 | 類型 | 必須 | 預設值 |
|---|---|---|---|---|
lotteryId |
抽獎ID | string |
是 | - |
winnerCode |
中獎碼 | string |
是 | - |
receiveInfo |
領獎人資訊表單數據 | LotteryReceiveFormItem[] |
是 | - |
範例:
// 提交领奖信息
await watchCore.welfareLottery.submitReceive({
lotteryId: '123456',
winnerCode: '123456',
receiveInfo: [{
key: 'name',
value: '张三'
}]
});
2.9 取得抽獎隱私協議內容
說明: 取得抽獎活動的隱私協議內容
Api 方法: getLotteryPrivacy(): LotteryPrivacyDetail
回傳值說明: 抽獎隱私協議內容,LotteryPrivacyDetail 類型,詳細類型說明如下
| 屬性名 | 說明 | 類型 |
|---|---|---|
privacyContent |
抽獎隱私協議內容 | undefined | string |
lotteryActivityPrivacyEnabled |
抽獎活動隱私協議開關 | YN |
範例:
// 获取抽奖隐私协议内容
const privacy = await watchCore.welfareLottery.getLotteryPrivacy();
console.log('抽奖隐私协议内容', privacy);
2.10 取得抽獎分組資訊
說明: 取得抽獎活動的分組資訊
Api 方法: getLotteryWinnersGroup(options: Object): Promise<LotteryWinnerGroupItem[]>
參數說明:
- options:查詢參數,
Object類型,必傳,詳細類型說明如下
| 參數名 | 說明 | 類型 | 必須 | 預設值 |
|---|---|---|---|---|
lotteryId |
抽獎ID | string |
是 | - |
回傳值說明: 抽獎分組資訊列表,Promise<LotteryWinnerGroupItem[]> 類型
範例:
// 获取抽奖分组信息
const groupInfo = await watchCore.welfareLottery.getLotteryWinnersGroup({
lotteryId: '123456'
});
console.log('抽奖分组信息', groupInfo);
2.11 取得抽獎分組中的中獎名單
說明: 取得抽獎活動特定分組中的中獎用戶列表
Api 方法: getLotteryWinnersByGroup(options: Object): Promise<LotteryWinnersData>
參數說明:
- options:查詢參數,
Object類型,必傳,詳細類型說明如下
|
