feat:支持再来一次的按钮
This commit is contained in:
parent
b959e634d2
commit
ac497ce163
@ -54,7 +54,21 @@
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<view class="action-area">
|
||||
<view class="claim-btn" @tap="handleClose">
|
||||
<!-- 如果使用次数卡,显示"再来一次"按钮 -->
|
||||
<view v-if="showRetryButton" class="retry-buttons">
|
||||
<view class="retry-btn" @tap="handleRetry">
|
||||
<view class="btn-glow"></view>
|
||||
<view class="btn-inner">
|
||||
<text class="btn-icon">🔄</text>
|
||||
<text class="btn-text">再来一次</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="secondary-btn" @tap="handleClose">
|
||||
<text class="btn-text">知道了</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 普通情况显示单个按钮 -->
|
||||
<view v-else class="claim-btn" @tap="handleClose">
|
||||
<view class="btn-glow"></view>
|
||||
<view class="btn-inner">
|
||||
<text class="btn-icon">✨</text>
|
||||
@ -71,10 +85,11 @@ import { computed } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
visible: { type: Boolean, default: false },
|
||||
results: { type: Array, default: () => [] }
|
||||
results: { type: Array, default: () => [] },
|
||||
showRetryButton: { type: Boolean, default: false } // 是否显示"再来一次"按钮
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:visible', 'close'])
|
||||
const emit = defineEmits(['update:visible', 'close', 'retry'])
|
||||
|
||||
function cleanUrl(u) {
|
||||
if (!u) return '/static/logo.png'
|
||||
@ -147,6 +162,11 @@ function handleClose() {
|
||||
emit('close')
|
||||
}
|
||||
|
||||
function handleRetry() {
|
||||
emit('update:visible', false)
|
||||
emit('retry')
|
||||
}
|
||||
|
||||
function previewImage(url) {
|
||||
if (url) uni.previewImage({ urls: [url], current: url })
|
||||
}
|
||||
@ -373,12 +393,54 @@ function previewImage(url) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
|
||||
&:active .btn-inner {
|
||||
transform: scale(0.96);
|
||||
}
|
||||
}
|
||||
|
||||
.retry-buttons {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.retry-btn {
|
||||
position: relative;
|
||||
flex: 2;
|
||||
height: 110rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active .btn-inner {
|
||||
transform: scale(0.96);
|
||||
}
|
||||
}
|
||||
|
||||
.secondary-btn {
|
||||
flex: 1;
|
||||
height: 110rpx;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border: 2rpx solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 55rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
transform: scale(0.96);
|
||||
}
|
||||
|
||||
.btn-text {
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-glow {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
|
||||
@ -60,7 +60,9 @@
|
||||
<LotteryResultPopup
|
||||
v-model:visible="showResultPopup"
|
||||
:results="drawResults"
|
||||
:show-retry-button="lastDrawUsedGamePass"
|
||||
@close="onResultClose"
|
||||
@retry="onRetryDraw"
|
||||
/>
|
||||
|
||||
<PaymentPopup
|
||||
@ -175,6 +177,8 @@ const drawLoading = ref(false)
|
||||
const showDrawLoading = ref(false)
|
||||
const drawProgress = ref(0)
|
||||
const drawTotal = ref(1)
|
||||
const lastDrawUsedGamePass = ref(false) // 记录最后一次抽奖是否使用了次数卡
|
||||
const lastDrawCount = ref(1) // 记录最后一次抽奖的数量
|
||||
|
||||
// 支付相关
|
||||
const paymentVisible = ref(false)
|
||||
@ -223,6 +227,24 @@ function onResultClose() {
|
||||
drawResults.value = []
|
||||
}
|
||||
|
||||
function onRetryDraw() {
|
||||
// 关闭结果弹窗
|
||||
showResultPopup.value = false
|
||||
drawResults.value = []
|
||||
|
||||
// 检查是否还有剩余次数卡
|
||||
if (gamePassRemaining.value > 0) {
|
||||
// 使用次数卡直接抽奖
|
||||
useGamePassFlag.value = true
|
||||
selectedCoupon.value = null
|
||||
selectedCard.value = null
|
||||
onMachineDraw(lastDrawCount.value)
|
||||
} else {
|
||||
// 次数卡已用完,打开支付弹窗
|
||||
openPayment(lastDrawCount.value)
|
||||
}
|
||||
}
|
||||
|
||||
function openPayment(count) {
|
||||
const times = Math.max(1, Number(count || 1))
|
||||
pendingCount.value = times
|
||||
@ -419,10 +441,15 @@ async function onMachineDraw(count) {
|
||||
|
||||
// 隐藏加载弹窗
|
||||
showDrawLoading.value = false
|
||||
|
||||
|
||||
const items = mapResultsToFlipItems(resultRes, currentIssueRewards.value)
|
||||
|
||||
|
||||
drawResults.value = items
|
||||
|
||||
// 记录最后一次抽奖是否使用了次数卡,用于"再来一次"按钮
|
||||
lastDrawUsedGamePass.value = useGamePassFlag.value
|
||||
lastDrawCount.value = times
|
||||
|
||||
showResultPopup.value = true
|
||||
} catch (e) {
|
||||
showDrawLoading.value = false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user