feat(新内容格式化工具): 奖励内容格式化工具
This commit is contained in:
parent
2c38e6a0d7
commit
953db2ed3f
22
src/utils/rewardFormatter.js
Normal file
22
src/utils/rewardFormatter.js
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 奖励内容格式化工具
|
||||
*/
|
||||
|
||||
/**
|
||||
* 格式化奖励的展示信息
|
||||
* @param {string} type - 奖励类型 (GOLD, DIAMOND, GIFT, FRAGMENTS, DOLLARS 等)
|
||||
* @param {object} reward - 奖励对象
|
||||
* @returns {string} 格式化后的奖励展示文本
|
||||
*/
|
||||
export const formatRewardDisplay = (type, reward) => {
|
||||
const showAmountTypes = ['GOLD', 'DIAMOND', 'GIFT', 'FRAGMENTS', 'TICKET']
|
||||
|
||||
if (showAmountTypes.includes(type)) {
|
||||
return reward.content || ''
|
||||
} else if (type === 'DOLLARS') {
|
||||
return `$${reward.content}`
|
||||
} else {
|
||||
// 默认返回数量加天数格式
|
||||
return `${reward.quantity}Days`
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user