Browse Source

完成闪烁

songtongtong/feature-20250717104937-众筹
pangluotong 4 weeks 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>
<script setup>
import { ref, onMounted, onBeforeUnmount, defineExpose, watch } from "vue";
import * as THREE from "three";
import {
@ -30,6 +31,8 @@ import { NUMBER_MATRIX } from "../../../utils/config.js";
import CardItem from "./CardItem.vue";
import { createApp } from "vue";
import { getUserList } from "../../../api/API";
const swapInterval = ref(null);
const swapIntervalTime = ref(200)
const threeContainer = ref(null);
let renderer, scene, camera, animationId;
// let controls; // controls
@ -49,7 +52,39 @@ const targets = {
table: [],
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 = "") {
const dom = document.createElement("div");
dom.className = css;
@ -768,6 +803,7 @@ function getTotalCards() {
}, 500);
window.addEventListener("resize", onWindowResize);
swapInterval.value = setInterval(swapCardContents, swapIntervalTime.value);
});
onBeforeUnmount(() => {
@ -778,6 +814,10 @@ onBeforeUnmount(() => {
clearTimeout(highlightTimeout);
highlightTimeout = null;
}
if (swapInterval.value) {
clearInterval(swapInterval.value);
swapInterval.value = null;
}
});
function render() {

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

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

Loading…
Cancel
Save