From 1d37fbe01d1713b6aa3e97d9241c29677e127afd Mon Sep 17 00:00:00 2001 From: Ethereal <3432649580@qq.com> Date: Thu, 7 Aug 2025 16:32:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=BD=93=E6=8A=BD=E5=A5=96=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E9=83=BD=E6=8A=BD=E5=AE=8C=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E5=B7=B2=E6=8A=BD?= =?UTF-8?q?=E5=AE=8C=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/choujiang/index.vue | 77 ++++++++++++++++++------------ src/views/choujiang/lottery/PrizePanel.vue | 2 + 2 files changed, 48 insertions(+), 31 deletions(-) diff --git a/src/views/choujiang/index.vue b/src/views/choujiang/index.vue index f0d53d7..b5c100f 100644 --- a/src/views/choujiang/index.vue +++ b/src/views/choujiang/index.vue @@ -13,21 +13,9 @@ -
+
-
- -
- -
- -
-
@@ -53,7 +41,7 @@ import ControlBar from "./lottery/ControlBar.vue"; import Qipao from "./lottery/Qipao.vue"; import UserList from "./lottery/UserList.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 { useLotteryEngine } from "./lottery/lotteryEngine.js"; @@ -62,9 +50,24 @@ import { drawLottery } from "../../api/API"; const qipaoText = ref(""); 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 @@ -109,6 +112,16 @@ const lotteryEngine = useLotteryEngine(dataManager, { selectCard: (...args) => lottery3DRef.value?.selectCard?.(...args), }); +// 页面加载之前的钩子函数 +onBeforeMount(() => { + console.log("页面即将加载(onBeforeMount)"); + lastRevealed.value = -1; + lotteryState.value="idle"; + + // 可以在这里做一些初始化操作,比如重置store、准备数据等 + // 例如:lotteryStore.resetState && lotteryStore.resetState(); +}); + onMounted(async () => { isDisabled.value = true; @@ -253,10 +266,7 @@ async function handleLotteryClick() { if (waitingForNextReveal.value) { console.log("waitingForNextReveal.value", waitingForNextReveal.value); // 显示弹窗提示 - showPrizeExhaustedModal.value = true; - setTimeout(() => { - showPrizeExhaustedModal.value = false; - }, 1000); + showModal("该礼品已抽取完毕,请揭秘下一个礼品"); isDisabled.value = false; break; @@ -264,10 +274,7 @@ async function handleLotteryClick() { if (lastRevealed.value === -1) { console.log("lastRevealed.value", lastRevealed.value); - showPrizeExhaustedModal1.value = true; - setTimeout(() => { - showPrizeExhaustedModal1.value = false; - }, 1000); + showModal("请先揭秘一个礼品"); isDisabled.value = false; break; @@ -280,10 +287,7 @@ async function handleLotteryClick() { // 如果是最后一个奖品且剩余数量为0,则跳出 // const currentPrize = dataManager.state.basicData.prizes[lastRevealed.value]; // if (currentPrize && currentPrize.remainNum === 0) { - showPrizeExhaustedModal2.value = true; - setTimeout(() => { - showPrizeExhaustedModal2.value = false; - }, 1000); + showModal("该礼品已抽取完毕"); isDisabled.value = false; break; @@ -304,12 +308,23 @@ async function handleLotteryClick() { // 同时请求接口 try { - winnerList.value = await drawLottery({ + const res = await drawLottery({ perWin: prize.perWin, remainNum: prize.remainNum, gradeId: prize.gradeId, 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(() => { isDisabled.value = false; }, 2000); diff --git a/src/views/choujiang/lottery/PrizePanel.vue b/src/views/choujiang/lottery/PrizePanel.vue index 52327ce..47d76a4 100644 --- a/src/views/choujiang/lottery/PrizePanel.vue +++ b/src/views/choujiang/lottery/PrizePanel.vue @@ -447,6 +447,8 @@ onMounted(() => { updateWinners(); calculateTotalPages(); }); + + \ No newline at end of file From 5337feff47c4de59750557af5ef85b042d573983 Mon Sep 17 00:00:00 2001 From: no99 <17663930442@163.com> Date: Thu, 7 Aug 2025 17:27:32 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9C=AA=E6=8A=BD=E5=87=BA=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/choujiang/hxl-cj/cj.vue | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/views/choujiang/hxl-cj/cj.vue b/src/views/choujiang/hxl-cj/cj.vue index 1818b65..73d20bd 100644 --- a/src/views/choujiang/hxl-cj/cj.vue +++ b/src/views/choujiang/hxl-cj/cj.vue @@ -853,6 +853,7 @@ function selectCard(duration = 600) { tag++; } } else { + // console.log(currentLuckys); // 小于等于5个一排显示(与抽不足10人时的排列相同) let tag = -(pageCount - 1) / 2; for (let i = 0; i < pageCount; i++) { @@ -1178,6 +1179,14 @@ const lotteryBtn = () => { // API返回结果时赋值 getPrizeUsers.value = res.data.data || []; isBackApi.value = false; + if (res.data.data.length != 0) { + console.log("抽出用户"); + //更新剩余抽奖数目的数据显示 + changePrize(); + } else { + console.log("没抽出用户"); + getPrizeUsers.value = [{ jwcode: "恭喜所有中奖用户!", type: "over" }]; + } console.log("API返回结果:", res.data.data); }) .catch((err) => { @@ -1187,17 +1196,22 @@ const lotteryBtn = () => { }); setLotteryStatus(true); - //更新剩余抽奖数目的数据显示 - changePrize(); + resetCard().then((res) => { + if (noUserObj.value.index != -1) { + console.log("noUserObj.value", noUserObj.value); + + let card = threeDCards[noUserObj.value.index].element; + card.style.width = "7.5vw"; + card.style.height = "18.5vh"; + card.innerHTML = `
${noUserObj.value.jwcode}
`; + noUserObj.value.index = -1; + } // 抽奖 lottery(); }); console.log("currentPrize", currentPrize.value); - - const text = "正在抽取[" + currentPrize.value.prizeName + "],调整好姿势"; - // addQipao(text); }; const throttledLotteryBtn = _.throttle(lotteryBtn, 1000, { @@ -1275,6 +1289,11 @@ function changeCard(cardIndex, user) { card.innerHTML = `
${user.jwcode}
`; } +const noUserObj = ref({ + index: -1, + jwcode: "", +}); + function changeSelectedCard(cardIndex, user) { // 保存到全局变量数组 if (!globalCardIndexes.includes(cardIndex)) { @@ -1283,6 +1302,14 @@ function changeSelectedCard(cardIndex, user) { let card = threeDCards[cardIndex].element; + if (user.type == "over") { + noUserObj.value.index = cardIndex; + noUserObj.value.jwcode = card.innerHTML; + + card.style.width = "18vw"; + card.style.height = "20vh"; + } + card.innerHTML = `
${user.jwcode}
`; } /**