- 正在抽取三等奖
+ 正在抽取
+ {{ config.draw_prize.name }}
+ 中奖名单
-
+
-
奖品:{{ config.draw_prize.name }}
-
赞助商 : 泽科信息科技(苏州)有限公司
+
奖品: {{ config.draw_prize.name }}
+
赞助商: {{ config.draw_prize.apply }}
-
+
@@ -32,16 +58,19 @@
import bkg from "@/assets/mdLotteryDraw/bkg.png";
import { draw, drawConfig } from "@/api/mdLotteryDraw";
import { throttle } from "@/utils";
+import { drawLog } from "@/api/activity/drawPrize";
export default {
data() {
return {
bkg,
+ flag: false, //是否开始
+ timer: null,
config: {
draw_prize: {},
- numbers_list: []
+ numbers_list: [],
},
resultNumbers: [],
- }
+ };
},
methods: {
init() {
@@ -50,37 +79,92 @@ export default {
const scale = document.documentElement.clientWidth / 1920;
dom.style.fontSize = baseSize * Math.min(scale, 2) + "px";
},
- async getConfig () {
+ async getConfig() {
const res = await drawConfig({
- id: this.$route.params.id
- })
- console.log(res)
- this.config = res
+ id: this.$route.params.id,
+ });
+ this.config = res;
+ },
+ async getResult() {
+ const res = await drawLog(
+ {
+ page: 1,
+ page_size: 9999,
+ activity_list_id: 8,
+ },
+ false
+ );
+ console.log(res);
+
+ this.resultNumbers = res.data
+ .filter((i) => i.draw_prize_id == this.$route.params.id)
+ .map((i) => Number(i.mobile));
},
- draw: throttle(function () {
- this.resultNumbers = [1,10,30,60]
+
+ draw: throttle(async function () {
+ if (!this.flag) {
+ console.log("开始抽奖");
+ try {
+ const result = await draw({
+ id: this.$route.params.id,
+ });
+ console.log(result);
+ this.flag = true;
+
+ this.timer = setInterval(() => {
+ let set = new Set();
+ while (set.size < result.draw_numbers.length) {
+ let num = Math.floor(
+ Math.random() * this.config.numbers_list.length
+ );
+ set.add(this.config.numbers_list[num]);
+ }
+
+ this.resultNumbers = Array.from(set);
+
+ if (!this.flag) {
+ clearInterval(this.timer);
+ setTimeout(() => {
+ this.resultNumbers = result.draw_numbers;
+ }, 500);
+ }
+ }, 500);
+ } catch (err) {
+ console.log(err);
+ }
+ } else {
+ this.flag = false;
+ console.log("结束抽奖");
+ }
}),
},
computed: {
- numbers () {
+ numbers() {
+ if (this.$route.query.result) {
+ return this.resultNumbers;
+ }
if (this.config.numbers_list) {
- return this.config.numbers_list.sort(() => Math.random() - 0.5)
+ return this.config.numbers_list.sort(() => Math.random() - 0.5);
} else {
- return []
+ return [];
}
- }
+ },
},
created() {
- this.getConfig()
+ this.getConfig();
+
+ if (this.$route.query.result == 1) {
+ this.getResult();
+ }
},
mounted() {
this.init();
window.onresize = () => {
this.init();
- }
- }
-}
+ };
+ },
+};