Browse Source

当抽奖用户都抽完的时候,添加用户已抽完提示

wangyi/feature-20250710191445-抽奖
Ethereal 1 week ago
parent
commit
1d37fbe01d
  1. 77
      src/views/choujiang/index.vue
  2. 2
      src/views/choujiang/lottery/PrizePanel.vue

77
src/views/choujiang/index.vue

@ -13,21 +13,9 @@
<Mascot /> <Mascot />
<!-- 透明弹窗 --> <!-- 透明弹窗 -->
<div v-if="showPrizeExhaustedModal" class="prize-exhausted-modal">
<div v-if="modalConfig.show" class="prize-exhausted-modal">
<div class="modal-content"> <div class="modal-content">
<p class="modal-text">该礼品已抽取完毕请揭秘下一个礼品</p>
</div>
</div>
<div v-if="showPrizeExhaustedModal1" class="prize-exhausted-modal">
<div class="modal-content">
<p class="modal-text">请先揭秘一个礼品</p>
</div>
</div>
<div v-if="showPrizeExhaustedModal2" class="prize-exhausted-modal">
<div class="modal-content">
<p class="modal-text">该礼品已抽取完毕</p>
<p class="modal-text">{{ modalConfig.text }}</p>
</div> </div>
</div> </div>
@ -53,7 +41,7 @@ import ControlBar from "./lottery/ControlBar.vue";
import Qipao from "./lottery/Qipao.vue"; import Qipao from "./lottery/Qipao.vue";
import UserList from "./lottery/UserList.vue"; import UserList from "./lottery/UserList.vue";
import Mascot from "./lottery/Mascot.vue"; import Mascot from "./lottery/Mascot.vue";
import { ref, onMounted, nextTick, computed, watch } from "vue";
import { ref, onMounted, onBeforeMount, nextTick, computed, watch } from "vue";
import { useDataManager } from "./lottery/dataManager.js"; import { useDataManager } from "./lottery/dataManager.js";
import { useLotteryEngine } from "./lottery/lotteryEngine.js"; import { useLotteryEngine } from "./lottery/lotteryEngine.js";
@ -62,9 +50,24 @@ import { drawLottery } from "../../api/API";
const qipaoText = ref(""); const qipaoText = ref("");
const showQipao = ref(false); const showQipao = ref(false);
const showPrizeExhaustedModal = ref(false);
const showPrizeExhaustedModal1 = ref(false);
const showPrizeExhaustedModal2 = ref(false);
//
const modalConfig = ref({
show: false,
text: ""
});
//
function showModal(text, duration = 1000) {
modalConfig.value = {
show: true,
text: text
};
setTimeout(() => {
modalConfig.value.show = false;
}, duration);
}
// const lotteryState = ref('idle'); // idle, ready, rotating, result // const lotteryState = ref('idle'); // idle, ready, rotating, result
@ -109,6 +112,16 @@ const lotteryEngine = useLotteryEngine(dataManager, {
selectCard: (...args) => lottery3DRef.value?.selectCard?.(...args), selectCard: (...args) => lottery3DRef.value?.selectCard?.(...args),
}); });
//
onBeforeMount(() => {
console.log("页面即将加载(onBeforeMount)");
lastRevealed.value = -1;
lotteryState.value="idle";
// store
// lotteryStore.resetState && lotteryStore.resetState();
});
onMounted(async () => { onMounted(async () => {
isDisabled.value = true; isDisabled.value = true;
@ -253,10 +266,7 @@ async function handleLotteryClick() {
if (waitingForNextReveal.value) { if (waitingForNextReveal.value) {
console.log("waitingForNextReveal.value", waitingForNextReveal.value); console.log("waitingForNextReveal.value", waitingForNextReveal.value);
// //
showPrizeExhaustedModal.value = true;
setTimeout(() => {
showPrizeExhaustedModal.value = false;
}, 1000);
showModal("该礼品已抽取完毕,请揭秘下一个礼品");
isDisabled.value = false; isDisabled.value = false;
break; break;
@ -264,10 +274,7 @@ async function handleLotteryClick() {
if (lastRevealed.value === -1) { if (lastRevealed.value === -1) {
console.log("lastRevealed.value", lastRevealed.value); console.log("lastRevealed.value", lastRevealed.value);
showPrizeExhaustedModal1.value = true;
setTimeout(() => {
showPrizeExhaustedModal1.value = false;
}, 1000);
showModal("请先揭秘一个礼品");
isDisabled.value = false; isDisabled.value = false;
break; break;
@ -280,10 +287,7 @@ async function handleLotteryClick() {
// 0 // 0
// const currentPrize = dataManager.state.basicData.prizes[lastRevealed.value]; // const currentPrize = dataManager.state.basicData.prizes[lastRevealed.value];
// if (currentPrize && currentPrize.remainNum === 0) { // if (currentPrize && currentPrize.remainNum === 0) {
showPrizeExhaustedModal2.value = true;
setTimeout(() => {
showPrizeExhaustedModal2.value = false;
}, 1000);
showModal("该礼品已抽取完毕");
isDisabled.value = false; isDisabled.value = false;
break; break;
@ -304,12 +308,23 @@ async function handleLotteryClick() {
// //
try { try {
winnerList.value = await drawLottery({
const res = await drawLottery({
perWin: prize.perWin, perWin: prize.perWin,
remainNum: prize.remainNum, remainNum: prize.remainNum,
gradeId: prize.gradeId, gradeId: prize.gradeId,
prizeId: prize.prizeId, prizeId: prize.prizeId,
}); });
console.log("res是", res);
winnerList.value = res;
if(res.data.round === false && res.data.data.length === 0){
isDisabled.value = true;
console.log("isDisabled.value是", isDisabled.value);
showModal("用户已抽完",100000);
break;
}
setTimeout(() => { setTimeout(() => {
isDisabled.value = false; isDisabled.value = false;
}, 2000); }, 2000);

2
src/views/choujiang/lottery/PrizePanel.vue

@ -447,6 +447,8 @@ onMounted(() => {
updateWinners(); updateWinners();
calculateTotalPages(); calculateTotalPages();
}); });
</script> </script>
<style scoped> <style scoped>

Loading…
Cancel
Save