mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-04-07 07:29:27 +08:00
fix(lottery):完善方法
This commit is contained in:
42
src/plugins/Mys/utils/lottery.ts
Normal file
42
src/plugins/Mys/utils/lottery.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file plugins Mys utils lottery.ts
|
||||
* @description 抽奖工具类
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.1
|
||||
*/
|
||||
|
||||
import { LotteryData, LotteryCard, LotteryRewardCard, LotteryReward } from "../interface/lottery";
|
||||
|
||||
/**
|
||||
* @description 根据抽奖信息转为渲染用的抽奖信息
|
||||
* @since Alpha v0.1.1
|
||||
* @param {LotteryData} lotteryData 抽奖信息
|
||||
* @return {LotteryCard}
|
||||
*/
|
||||
export function getLotteryCard(lotteryData: LotteryData): LotteryCard {
|
||||
return {
|
||||
id: lotteryData.id,
|
||||
participantWay: lotteryData.participant_way,
|
||||
status: lotteryData.status,
|
||||
creator: lotteryData.creator,
|
||||
drawTime: lotteryData.draw_time,
|
||||
rewards: lotteryData.user_rewards.map(reward => {
|
||||
return getLotteryRewardCard(reward);
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据抽奖奖励信息转为渲染用的抽奖奖励信息
|
||||
* @since Alpha v0.1.1
|
||||
* @param {LotteryReward} lotteryReward 抽奖奖励信息
|
||||
* @return {LotteryRewardCard}
|
||||
*/
|
||||
export function getLotteryRewardCard(lotteryReward: LotteryReward): LotteryRewardCard {
|
||||
return {
|
||||
rewardName: lotteryReward.reward_name,
|
||||
winnerNumber: lotteryReward.winner_number,
|
||||
scheduledWinnerNumber: lotteryReward.scheduled_winner_number,
|
||||
users: lotteryReward.users,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user