diff --git a/.env.development b/.env.development index c5a8ac9..000a42d 100644 --- a/.env.development +++ b/.env.development @@ -2,7 +2,7 @@ VITE_ENV = 'development' VITE_OUTPUT_DIR = 'dev' # public path -VITE_PUBLIC_PATH = / +VITE_PUBLIC_PATH = /test #新数据接口 VITE_APP_API_BASE_URL = "https://dbqb.nfdxy.net/devLotApi" diff --git a/.env.production b/.env.production index 7a810b2..f5fc3a9 100644 --- a/.env.production +++ b/.env.production @@ -2,7 +2,7 @@ VITE_ENV = 'production' VITE_OUTPUT_DIR = 'dist' # public path -VITE_PUBLIC_PATH = /aixiaocaishen +VITE_PUBLIC_PATH = / # VITE_PUBLIC_PATH = / # Whether to open mock diff --git a/src/views/choujiang/hxl-cj/cj.vue b/src/views/choujiang/hxl-cj/cj.vue index fa0c0a4..89836f8 100644 --- a/src/views/choujiang/hxl-cj/cj.vue +++ b/src/views/choujiang/hxl-cj/cj.vue @@ -376,7 +376,7 @@ const initAll = async () => { prizes.value.forEach((item, index) => { item.type = index; item.count = item.amount; - item.leftCount = item.amount; //剩余次数(用于计算奖品下方的进度条的百分比) + item.leftCount = item.remainNum; //剩余次数(用于计算奖品下方的进度条的百分比) item.hasCount = item.amount; //已抽次数(用于计算出奖) item.isLook = false; // EACH_COUNT.push(item.perWin); @@ -917,7 +917,7 @@ function switchPage(direction) { const object = threeDCards[cardIndex]; const cardPage = Math.floor(index / cardsPerPage); const isVisible = cardPage === newPage; - + const wasVisible = cardPage === pageIndex.value; // 计算在当前页中的索引 const pageNowIndex = index % cardsPerPage; const pageLocate = pageLocates[cardPage][pageNowIndex]; @@ -930,11 +930,53 @@ function switchPage(direction) { // "pageLocate", // pageLocate // ); + + // 根据切换方向决定动画效果 + let targetY; + if (isVisible) { + // 当前页要显示的卡片 + if (direction === "next") { + // 索引增大:从下方飞出 + targetY = pageLocate.y; + } else { + // 索引减少:从上方飞出 + targetY = pageLocate.y; + } + } else { + // 当前页要隐藏的卡片 + if (direction === "next") { + // 索引增大:向上飞走 + targetY = pageLocate.y + 1000; + } else { + // 索引减少:向下飞走 + targetY = pageLocate.y - 1000; + } + } + + // 设置起始位置 + let startY; + if (wasVisible) { + // 当前页的卡片从当前位置开始 + startY = object.position.y; + } else { + // 非当前页的卡片从隐藏位置开始 + if (direction === "next") { + // 索引增大:从下方开始 + startY = pageLocate.y - 1000; + } else { + // 索引减少:从上方开始 + startY = pageLocate.y + 1000; + } + } + + // 先设置起始位置 + object.position.y = startY; + new TWEEN.Tween(object.position) .to( { x: pageLocate.x, - y: isVisible ? pageLocate.y : pageLocate.y + 1000, + y: targetY, z: 2100, }, duration @@ -1073,16 +1115,17 @@ const lotteryBtn = () => { getPrizeUsers.value = []; let params = { - gradeName: currentPrize.value.gradeName, - prizeName: currentPrize.value.prizeName, + gradeId: currentPrize.value.gradeId, + prizeId: currentPrize.value.prizeId, perWin: currentPrize.value.perWin, + remainNum: currentPrize.value.leftCount, }; // 异步调用API,不阻塞后续代码执行 startLotteryApi(params) .then((res) => { // API返回结果时赋值 - getPrizeUsers.value = res.data || []; - console.log("API返回结果:", res.data); + getPrizeUsers.value = res.data.data || []; + console.log("API返回结果:", res.data.data); }) .catch((err) => { console.error("API调用失败:", err); @@ -1114,7 +1157,8 @@ const lottery = () => { selectedCardIndex = []; // 当前同时抽取的数目,当前奖品抽完还可以继续抽,但是不记录数据 - for (let i = 0; i < getPrizeUsers.value; i++) { + for (let i = 0; i < getPrizeUsers.value.length; i++) { + console.log("111", getPrizeUsers.value[i]); currentLuckys.push(getPrizeUsers.value[i]); currentPrize.value.hasCount--; @@ -1164,7 +1208,7 @@ function random(num) { */ function changeCard(cardIndex, user) { let card = threeDCards[cardIndex].element; - + // console.log("user", user); card.innerHTML = `
${user.jwcode}
`; } @@ -1176,7 +1220,7 @@ function changeSelectedCard(cardIndex, user) { let card = threeDCards[cardIndex].element; - card.innerHTML = `
${user[1]}
`; + card.innerHTML = `
${user.jwcode}
`; } /** * 切换名牌背景