Browse Source

完成闪烁

songtongtong/feature-20250717104937-众筹
pangluotong 1 month ago
parent
commit
442867840f
  1. 40
      src/views/choujiang/lottery/Lottery3D.vue
  2. 9
      src/views/choujiang/lottery/PrizePanel.vue

40
src/views/choujiang/lottery/Lottery3D.vue

@ -18,6 +18,7 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted, onBeforeUnmount, defineExpose, watch } from "vue"; import { ref, onMounted, onBeforeUnmount, defineExpose, watch } from "vue";
import * as THREE from "three"; import * as THREE from "three";
import { import {
@ -30,6 +31,8 @@ import { NUMBER_MATRIX } from "../../../utils/config.js";
import CardItem from "./CardItem.vue"; import CardItem from "./CardItem.vue";
import { createApp } from "vue"; import { createApp } from "vue";
import { getUserList } from "../../../api/API"; import { getUserList } from "../../../api/API";
const swapInterval = ref(null);
const swapIntervalTime = ref(200)
const threeContainer = ref(null); const threeContainer = ref(null);
let renderer, scene, camera, animationId; let renderer, scene, camera, animationId;
// let controls; // controls // let controls; // controls
@ -49,7 +52,39 @@ const targets = {
table: [], table: [],
sphere: [], sphere: [],
}; };
function swapCardContents() {
//
if (threeDCards.length < 2 || globalCardIndexes.length > 0) return;
//
let indexA = Math.floor(Math.random() * threeDCards.length);
let indexB = Math.floor(Math.random() * threeDCards.length);
while (indexA === indexB) {
indexB = Math.floor(Math.random() * threeDCards.length);
}
const cardA = threeDCards[indexA].element;
const cardB = threeDCards[indexB].element;
// ()
if (!cardA.dataset.originalContent) {
cardA.dataset.originalContent = cardA.innerHTML;
}
if (!cardB.dataset.originalContent) {
cardB.dataset.originalContent = cardB.innerHTML;
}
//
[cardA.innerHTML, cardB.innerHTML] = [cardB.innerHTML, cardA.innerHTML];
cardA.classList.add('swap-animation');
cardB.classList.add('swap-animation');
//
setTimeout(() => {
cardA.classList.remove('swap-animation');
cardB.classList.remove('swap-animation');
}, 500);
}
function createElement(css = "", text = "") { function createElement(css = "", text = "") {
const dom = document.createElement("div"); const dom = document.createElement("div");
dom.className = css; dom.className = css;
@ -768,6 +803,7 @@ function getTotalCards() {
}, 500); }, 500);
window.addEventListener("resize", onWindowResize); window.addEventListener("resize", onWindowResize);
swapInterval.value = setInterval(swapCardContents, swapIntervalTime.value);
}); });
onBeforeUnmount(() => { onBeforeUnmount(() => {
@ -778,6 +814,10 @@ onBeforeUnmount(() => {
clearTimeout(highlightTimeout); clearTimeout(highlightTimeout);
highlightTimeout = null; highlightTimeout = null;
} }
if (swapInterval.value) {
clearInterval(swapInterval.value);
swapInterval.value = null;
}
}); });
function render() { function render() {

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

@ -36,6 +36,9 @@
<span class="progress-bar-text"> <span class="progress-bar-text">
{{ getLeftCount(prize) }}/{{ prize.count }} {{ getLeftCount(prize) }}/{{ prize.count }}
</span> </span>
</div> </div>
</div> </div>
</div> </div>
@ -482,7 +485,7 @@ function getProgressPercent(prize) {
.arrow-down { .arrow-down {
position: fixed; position: fixed;
top: 120px; top: 120px;
left: 165px;
left: 181px;
width: 36px; width: 36px;
height: 38px; height: 38px;
margin-bottom: 4px; margin-bottom: 4px;
@ -494,7 +497,7 @@ function getProgressPercent(prize) {
} }
.winner-btn { .winner-btn {
background: rgba(255, 210, 131, 0.8); background: rgba(255, 210, 131, 0.8);
color: #fff;
color: #da1616;
border: #fff; border: #fff;
border-radius: 8px; border-radius: 8px;
padding: 15px 79px; padding: 15px 79px;
@ -506,7 +509,7 @@ function getProgressPercent(prize) {
.winner-modal-mask { .winner-modal-mask {
position: fixed; position: fixed;
top: 155px; top: 155px;
left:10px;
left:33px;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
background: rgba(0, 0, 0, 0.01); background: rgba(0, 0, 0, 0.01);

Loading…
Cancel
Save