Usage
1. Get Current Lottery List
Use getLotteryList to retrieve the list of all currently available lottery activities.
API Method: getLotteryList(): LotteryBasicData[]
Return Value Description: List of lottery activities, type LotteryBasicData[]
Example:
const lotteryList = lotteryTarget.getLotteryList();
console.log('当前抽奖活动列表', lotteryList);
2. Get Lottery Details
Use getLotteryDetail to get detailed information about a specific lottery activity.
API Method: getLotteryDetail(options: LotteryBasicOptions): Promise<undefined | LotteryDetail>
Parameter Description:
- options: Retrieval parameters, including lottery ID and lottery conditions, type
LotteryBasicOptions, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
lotteryId |
- | string |
Yes | - |
subLotteryId |
- | string |
No | - |
lotteryCondition |
- | LotteryCondition |
No | - |
Return Value Description: Lottery details, type Promise<undefined | LotteryDetail>
Example:
const detail = await lotteryTarget.getLotteryDetail({ lotteryId: 'xxxx' });
console.log('抽奖详情', detail);
3. Get Lottery Result
After the lottery has drawn the winning results, this method can be called to get the winning result for the specified lotteryId.
API Method: getLotteryResult(options: LotteryBasicOptions): Promise<undefined | LotteryResult>
Parameter Description:
- options: Retrieval parameters, including lottery ID and lottery conditions, type
LotteryBasicOptions, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
lotteryId |
- | string |
Yes | - |
subLotteryId |
- | string |
No | - |
lotteryCondition |
- | LotteryCondition |
No | - |
Return Value Description: Lottery result, type Promise<undefined | LotteryResult>
Example:
const lotteryResult = await lotteryTarget.getLotteryResult({ lotteryId: 'xxxx' });
console.log('抽奖结果', lotteryResult);
console.log('是否中奖', lotteryResult.isWinner);
console.log('奖品信息', lotteryResult.prizeInfo);
4. Send Comment for Comment Lottery
Use sendComment to send the comment content for a comment lottery.
API Method: sendComment(): Promise<void>
Example:
await lotteryTarget.sendComment();
console.log('评论已发送');
5. Check if Comment Meets Comment Lottery Conditions
Use checkComment to check if the comment content meets the conditions for a comment lottery.
API Method: checkComment(comment: string): Promise<void>
Parameter Description:
- comment: The content of the comment, type
string, required
Example:
await lotteryTarget.checkComment('这是一条评论');
console.log('评论检查完成');
6. Complete Comment Lottery
Use finishComment to complete the comment lottery process.
API Method: finishComment(): Promise<void>
Example:
await lotteryTarget.finishComment();
console.log('评论抽奖已完成');
7. Start Answering Questions
Use startAnswer to start the quiz lottery process.
API Method: startAnswer(): Promise<StartLotteryAnswerResult>
Return Value Description: Quiz start result, type Promise<StartLotteryAnswerResult>
Example:
const result = await lotteryTarget.startAnswer();
console.log('答题开始,当前正在答题的题目 id', result.questionId);
8. Get Latest Quiz Result
Use getLastAnswerResult to get the result of the most recent quiz.
API Method: getLastAnswerResult(): Promise<undefined | AnswerResultData>
Return Value Description: Quiz result, type Promise<undefined | AnswerResultData>
Example:
const result = await lotteryTarget.getLastAnswerResult();
console.log('最近答题结果', result);
console.log('是否正确', result.result);
9. Submit Answers
Use submitAnswer to submit the answers for a quiz lottery.
API Method: submitAnswer(params: SubmitAnswerParams): Promise<SubmitAnswerResult>
Parameter Description:
- params: Submission parameters for answering, type
SubmitAnswerParams, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
questionId |
Question ID | string |
Yes | - |
answer |
Answer | string |
Yes | - |
Return Value Description: Answer submission result, type Promise<SubmitAnswerResult>
Example:
const result = await lotteryTarget.submitAnswer({
questionId: 'xxxx',
answer: 'ab'
});
console.log('答题提交结果', result);
console.log('是否正确', result.result);
10. Get Personal Winning Records
Use getPersonalWinning to get the current viewer's winning list and display it on the page.
API Method: getPersonalWinning(options?: PageOptions): Promise<PageContent<LotteryRecordData>>
Parameter Description:
- options: Pagination options, type
PageOptions, optional, default{}. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
pageNumber |
Page number | number |
No | - |
pageSize |
Page size | number |
No | - |
Return Value Description: List of winning records, type Promise<PageContent<LotteryRecordData>>. Detailed type description is as follows:
| Property Name | Description | Type |
|---|---|---|
pageNumber |
Current page number | number |
pageSize |
Items per page | number |
totalItems |
Total records | number |
totalPages |
Total pages | number |
contents |
Content list | I[] |
Example:
const data = await lotteryTarget.getPersonalWinning({ pageNumber: 1 });
console.log('中奖记录列表', data.contents);
11. Get Prize Claim Information
Use lotteryId to get the winning information for that lottery, used to display interactions such as information forms, QR codes, links, etc.
API Method: getLotteryReceive(options: Object): Promise<LotteryReceiveData>
Parameter Description:
- options: Retrieval parameters, type
Object, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
lotteryId |
Lottery ID | string |
Yes | - |
Return Value Description: Prize claim information, type Promise<LotteryReceiveData>. Detailed type description is as follows:
| Property Name | Description | Type |
|---|---|---|
prizeInfo |
Prize information | LotteryPrizeInfo |
acceptType |
Claim method | PrizeAcceptType |
formList |
Form list | LotteryReceiveFormItem[] |
received |
Whether claimed | boolean |
lotteryId |
Lottery ID | string |
lotteryCondition |
Lottery condition | LotteryCondition |
prizeUrl |
Prize claim URL | null | string |
qrCode |
QR code URL | string |
qrCodeTips |
QR code prompt | string |
winnerCode |
Redemption code | string |
showWinnerCode |
Whether to display redemption code | boolean |
overTime |
Claim information submission deadline | null | number |
Example:
import { PrizeAcceptType } from '@polyv/iar-lottery-sdk';
const receiveData = await lotteryTarget.getLotteryReceive({ lotteryId: 'xxxx' });
console.log('领取方式:', receiveData.acceptType);
console.log('表单结构与中奖截止时间:', receiveData.formList, receiveData.overTime);
console.log('领取链接:', receiveData.prizeUrl);
console.log('二维码信息:', receiveData.qrCode, receiveData.qrCodeTips);
12. Submit Claim Information
When the lottery requires collecting winner information, use submitReceive to submit the winner's claim information.
API Method: submitReceive(options: SubmitReceiveOptions): Promise<void>
Parameter Description:
- options: Submission parameters, type
SubmitReceiveOptions, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
lotteryId |
Lottery ID | string |
Yes | - |
winnerCode |
Redemption code | string |
Yes | - |
receiveInfo |
Claim information | LotteryReceiveFormItem[] |
Yes | - |
Example:
const receiveInfo = [
{ field: '姓名', value: '张三' },
{ field: '手机', value: '18012345678' },
{ field: '地址', value: '广东省广州市番禺区xxxx' }
];
await lotteryTarget.submitReceive({
lotteryId: 'xxxx',
winnerCode: 'xxxx',
receiveInfo,
});
toast('提交成功');
13. Get Winner Group List
Use getLotteryWinnersGroup to get the list of winner groups for display on the page.
API Method: getLotteryWinnersGroup(options: Object): Promise<LotteryWinnersGroup[]>
Parameter Description:
- options: Retrieval parameters, type
Object, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
lotteryId |
- | string |
Yes | - |
Return Value Description: List of winner groups, type Promise<LotteryWinnersGroup[]>
Example:
const data = await lotteryTarget.getLotteryWinnersGroup({ lotteryId: 'xxxx' });
console.log('中奖者分组列表', data);
// 通过分组 id 获取中奖者列表
const winners = await lotteryTarget.getLotteryWinners({ lotteryId: 'xxxx', groupId: data[0].id });
console.log('中奖者列表', winners.contents);
14. Get Winner List
Use getLotteryWinners to get the list of winners for a specific lottery activity.
API Method: getLotteryWinners(options: GetLotteryWinnersOptions): Promise<PageContent<LotteryWinnersData>>
Parameter Description:
- options: Retrieval parameters, including lottery ID, group ID, page number, and items per page, type
GetLotteryWinnersOptions, required. Detailed type description is as follows:
| Parameter Name | Description | Type | Required | Default Value |
|---|---|---|---|---|
pageNumber |
Page number | number |
No | - |
pageSize |
Page size | number |
No | - |
lotteryId |
Lottery ID | string |
Yes | - |
groupId |
Group ID | number |
No | - |
Return Value Description: List of winners, type Promise<PageContent<LotteryWinnersData>>. Detailed type description is as follows:
| Property Name | Description | Type |
|---|---|---|
pageNumber |
Current page number | number |
pageSize |
Items per page | number |
totalItems |
Total records | number |
totalPages |
Total pages | number |
contents |
Content list | I[] |
Example:
const data = await lotteryTarget.getLotteryWinners({ lotteryId: 'xxxx' });
console.log('中奖者列表', data.contents);
