抽奖相关

This commit is contained in:
zhx 2026-06-18 22:42:04 +08:00
parent e06d013ddd
commit 00cdea1a49
3 changed files with 104 additions and 7 deletions

View File

@ -370,7 +370,20 @@
type="button"
@click="startLottery"
>
{{ t('drawAgain') }}
<span
v-if="rewardTotalValue(active.currentReward) > 0"
class="again-total"
>
<img :src="asset('gold_new.png')" alt="" />
<span
class="again-total-value"
v-text="rewardTotalText(active.currentReward)"
></span>
</span>
<span
class="again-label"
v-text="t('drawAgain')"
></span>
</button>
</div>
</section>

View File

@ -604,14 +604,31 @@
}
function rewardDisplayValue(reward) {
var metadata = parseJSON(
firstPresentValue(reward, ['metadataJson', 'metadata_json'])
);
return Number(
firstPresentValue(reward, [
'value',
'displayValue',
'display_value',
'displayGoldAmount',
'goldAmount',
'rewardValue',
'reward_value',
'rewardCoins',
'reward_coins',
'amount',
]) || 0
]) ||
firstPresentValue(metadata, [
'display_value',
'displayValue',
'coin_price',
'coinPrice',
'price',
'value',
]) ||
0
);
}
@ -856,6 +873,35 @@
asset: function (name) {
return ASSET_BASE + name;
},
rewardTotalValue: function (drawResult) {
drawResult = drawResult || {};
var directValue = Number(
firstPresentValue(drawResult, [
'rewardValue',
'reward_value',
'totalValue',
'total_value',
]) || 0
);
if (directValue > 0) return directValue;
// 弹窗展示必须以当前聚合奖品为准:多抽会先合并相同资源,兜底重算可覆盖旧接口未返回总价值的情况。
return (drawResult.rewards || []).reduce(function (sum, item) {
return (
sum + rewardDisplayValue(item) * rewardCountValue(item)
);
}, 0);
},
formatRewardValue: function (value) {
var number = Number(value || 0);
return Number.isFinite(number)
? Math.floor(number).toLocaleString('en-US')
: '0';
},
rewardTotalText: function (drawResult) {
return this.formatRewardValue(
this.rewardTotalValue(drawResult)
);
},
ensurePreviewPlayer: function () {
var target = this.$refs.previewEffect;
if (!target || !window.HyAppEffectPlayer) return null;

View File

@ -837,21 +837,60 @@ button {
}
.again-btn {
display: block;
display: flex;
flex: 0 0 auto;
align-items: center;
justify-content: center;
flex-direction: column;
gap: calc(2 * var(--wheel-vw));
width: 85%;
height: calc(48 * var(--wheel-vw));
height: calc(56 * var(--wheel-vw));
margin: calc(8 * var(--wheel-vw)) auto 0;
color: #fff;
font-size: calc(16 * var(--wheel-vw));
font-weight: 700;
line-height: calc(48 * var(--wheel-vw));
line-height: 1.05;
text-align: center;
border: calc(2 * var(--wheel-vw)) solid #fff;
border-radius: calc(10 * var(--wheel-vw));
background: linear-gradient(to right, #1897ff, #2472ff);
}
.again-total {
display: flex;
align-items: center;
justify-content: center;
max-width: 92%;
gap: calc(4 * var(--wheel-vw));
overflow: hidden;
color: #fff35a;
font-size: calc(13 * var(--wheel-vw));
font-weight: 800;
line-height: 1;
text-shadow: 0 calc(1 * var(--wheel-vw)) calc(2 * var(--wheel-vw))
rgba(116, 38, 0, 0.7);
}
.again-total img {
width: calc(16 * var(--wheel-vw));
height: calc(16 * var(--wheel-vw));
flex: 0 0 auto;
}
.again-total span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.again-label {
display: block;
max-width: 92%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.wheel-luxury .rule-content {
padding: calc(40 * var(--wheel-vw)) calc(20 * var(--wheel-vw))
calc(20 * var(--wheel-vw));
@ -990,8 +1029,7 @@ button {
}
.wheel-luxury .again-btn {
height: calc(38 * var(--wheel-vw));
line-height: calc(38 * var(--wheel-vw));
height: calc(50 * var(--wheel-vw));
background: linear-gradient(to bottom, #ff85b4, #db2e6c);
}