diff --git a/src/api/API.js b/src/api/API.js index 6c2db42..d6e2372 100644 --- a/src/api/API.js +++ b/src/api/API.js @@ -28,3 +28,12 @@ export const getGetPrizeUserListApi = function (params) { data: params, }); }; + +// 开始抽奖 +export const startLotteryApi = function (params) { + return request({ + url: `/Api/api/lottery/start`, + method: "POST", + data: params, + }); +}; diff --git a/src/views/choujiang/hxl-cj/cj.vue b/src/views/choujiang/hxl-cj/cj.vue index a5707c2..33cdca1 100644 --- a/src/views/choujiang/hxl-cj/cj.vue +++ b/src/views/choujiang/hxl-cj/cj.vue @@ -150,6 +150,7 @@ import { getPrizeListApi, getUserListApi, getGetPrizeUserListApi, + startLotteryApi, } from "../../../api/API"; // 常量 @@ -194,7 +195,7 @@ const prizes = ref([]); let EACH_COUNT = []; const users = ref([]); - +const getPrizeUsers = ref([]); //判断是否正在抽奖 let isLotting = false; const setLotteryStatus = (status = false) => { @@ -249,7 +250,7 @@ const openGetPrize = async () => { } }); let scroll = document.getElementById("prizeBar"); - scroll.style.height = "110px"; + // scroll.style.height = "110px"; }; const closeGetPrize = () => { @@ -261,8 +262,8 @@ const closeGetPrize = () => { box.style.display = "flex"; } }); - let scroll = document.getElementById("prizeBar"); - scroll.style.height = "650px"; + // let scroll = document.getElementById("prizeBar"); + // scroll.style.height = "650px"; }; //揭示奖品 @@ -462,7 +463,7 @@ const initCards = () => { renderer = new CSS3DRenderer(); renderer.setSize(window.innerWidth * 1, window.innerHeight * 0.9); - renderer.domElement.style.margin = "7% 0 0 0"; + renderer.domElement.style.margin = "7% 0 0 1%"; // document.getElementById("container").appendChild(renderer.domElement); if (threeContainer.value) { @@ -1069,8 +1070,25 @@ const lotteryBtn = () => { return; } + getPrizeUsers.value = []; + let params = { + gradeName: currentPrize.value.gradeName, + prizeName: currentPrize.value.prizeName, + perWin: currentPrize.value.perWin, + }; + // 异步调用API,不阻塞后续代码执行 + startLotteryApi(params) + .then((res) => { + // API返回结果时赋值 + getPrizeUsers.value = res.data || []; + console.log("API返回结果:", res.data); + }) + .catch((err) => { + console.error("API调用失败:", err); + getPrizeUsers.value = []; + }); + setLotteryStatus(true); - // 每次抽奖前先保存上一次的抽奖数据 //更新剩余抽奖数目的数据显示 changePrize(); resetCard().then((res) => { @@ -1081,7 +1099,7 @@ const lotteryBtn = () => { console.log("currentPrize", currentPrize.value); const text = "正在抽取[" + currentPrize.value.prizeName + "],调整好姿势"; -// addQipao(text); + // addQipao(text); }; /** * 抽奖 @@ -1094,15 +1112,9 @@ const lottery = () => { currentLuckys = []; selectedCardIndex = []; // 当前同时抽取的数目,当前奖品抽完还可以继续抽,但是不记录数据 - let perCount = EACH_COUNT[currentPrizeIndex]; //当前奖品一次抽奖的人数 - console.log("perCount", perCount, "currentPrizeIndex", currentPrizeIndex); - - for (let i = 0; i < perCount; i++) { - let user = ["洪锡林", "洪锡林", "洪锡林"]; - let index = user[0] + i; - user[0] = index; - user[1] = index; - currentLuckys.push(user); + + for (let i = 0; i < getPrizeUsers.value; i++) { + currentLuckys.push(getPrizeUsers.value[i]); currentPrize.value.hasCount--; //避免中奖者出现在同一个卡片上 @@ -1522,7 +1534,7 @@ a { } #prizeBar { - height: 650px; + max-height: 60vh; width: 330px; overflow-x: hidden; @@ -1597,14 +1609,14 @@ a { .open { position: absolute; - top: -45px; + top: -42px; animation: bounce1 2s ease-in-out infinite; transform: rotate(180deg); } .close { position: absolute; - top: -40px; + top: -32px; animation: bounce2 2s ease-in-out infinite; cursor: pointer; } diff --git a/vite.config.js.timestamp-1753077096347-78067037e45f7.mjs b/vite.config.js.timestamp-1753077096347-78067037e45f7.mjs new file mode 100644 index 0000000..2fbdffa --- /dev/null +++ b/vite.config.js.timestamp-1753077096347-78067037e45f7.mjs @@ -0,0 +1,22 @@ +// vite.config.js +import { defineConfig } from "file:///E:/hxl/gitFile/activityLink/node_modules/vite/dist/node/index.js"; +import vue from "file:///E:/hxl/gitFile/activityLink/node_modules/@vitejs/plugin-vue/dist/index.mjs"; +var vite_config_default = defineConfig({ + plugins: [ + vue() + ], + server: { + proxy: { + "/Api": { + target: "https://dbqb.nfdxy.net/devLotApi", + // target: 'http://localhost:8080', + changeOrigin: true, + rewrite: (path) => path.replace(/^\/Api/, "") + } + } + } +}); +export { + vite_config_default as default +}; +//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcuanMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCJFOlxcXFxoeGxcXFxcZ2l0RmlsZVxcXFxhY3Rpdml0eUxpbmtcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZmlsZW5hbWUgPSBcIkU6XFxcXGh4bFxcXFxnaXRGaWxlXFxcXGFjdGl2aXR5TGlua1xcXFx2aXRlLmNvbmZpZy5qc1wiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9pbXBvcnRfbWV0YV91cmwgPSBcImZpbGU6Ly8vRTovaHhsL2dpdEZpbGUvYWN0aXZpdHlMaW5rL3ZpdGUuY29uZmlnLmpzXCI7aW1wb3J0IHsgZGVmaW5lQ29uZmlnIH0gZnJvbSAndml0ZSdcbmltcG9ydCB2dWUgZnJvbSAnQHZpdGVqcy9wbHVnaW4tdnVlJ1xuXG4vLyBodHRwczovL3ZpdGUuZGV2L2NvbmZpZy9cbi8vIGV4cG9ydCBkZWZhdWx0IGRlZmluZUNvbmZpZyh7XG4vLyAgIHBsdWdpbnM6IFt2dWUoKV0sXG4vLyB9KVxuXG5leHBvcnQgZGVmYXVsdCBkZWZpbmVDb25maWcoe1xuICBwbHVnaW5zOiBbXG4gICAgdnVlKCksXG4gIF0sXG4gIHNlcnZlcjoge1xuICAgIHByb3h5OiB7XG4gICAgICAnL0FwaSc6IHtcbiAgICAgICAgdGFyZ2V0OiAnaHR0cHM6Ly9kYnFiLm5mZHh5Lm5ldC9kZXZ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