|
@@ -24,6 +24,8 @@
|
24
|
24
|
|
25
|
25
|
<script>
|
26
|
26
|
import { useModel } from '@/store'
|
|
27
|
+import { drawLottery, getPrizeList } from '@/services/person'
|
|
28
|
+import { rand } from '@/utils/math'
|
27
|
29
|
|
28
|
30
|
export default {
|
29
|
31
|
name: 'Honghe',
|
|
@@ -33,7 +35,10 @@ export default {
|
33
|
35
|
data() {
|
34
|
36
|
return {
|
35
|
37
|
indexJPG: new Array(12).fill(null),
|
36
|
|
- showPopup: false
|
|
38
|
+ showPopup: false,
|
|
39
|
+ prizeList: [],
|
|
40
|
+ clickNum: 0,
|
|
41
|
+ bingoClickNum: rand(0, 12)
|
37
|
42
|
}
|
38
|
43
|
},
|
39
|
44
|
computed: {
|
|
@@ -46,13 +51,8 @@ export default {
|
46
|
51
|
}
|
47
|
52
|
}
|
48
|
53
|
},
|
49
|
|
- watch: {
|
50
|
|
- person: {
|
51
|
|
- handler(val) {
|
52
|
|
- console.log('-----watch---person----', val)
|
53
|
|
- },
|
54
|
|
- immediate: true
|
55
|
|
- }
|
|
54
|
+ created() {
|
|
55
|
+ this.getPrizes()
|
56
|
56
|
},
|
57
|
57
|
methods: {
|
58
|
58
|
//关闭
|
|
@@ -62,6 +62,35 @@ export default {
|
62
|
62
|
baga(e) {
|
63
|
63
|
console.log(e)
|
64
|
64
|
this.showPopup = true
|
|
65
|
+
|
|
66
|
+ // 如果点击可以抽奖
|
|
67
|
+ if (this.clickNum === this.bingoClickNum) {
|
|
68
|
+ if (!this.person.personId) {
|
|
69
|
+ // 报错, 提示刷新页面
|
|
70
|
+ } else {
|
|
71
|
+ // 如果还没有参与
|
|
72
|
+ if (!this.person.isJoined) {
|
|
73
|
+ this.drawLots()
|
|
74
|
+ }
|
|
75
|
+ }
|
|
76
|
+ }
|
|
77
|
+
|
|
78
|
+ if (this.clickNum < this.bingoClickNum) {
|
|
79
|
+ this.clickNum += 1
|
|
80
|
+ }
|
|
81
|
+ },
|
|
82
|
+ // 抽奖
|
|
83
|
+ drawLots() {
|
|
84
|
+ drawLottery(this.person).then(res => {
|
|
85
|
+ // 更新人员信息
|
|
86
|
+ this.person = res
|
|
87
|
+
|
|
88
|
+ // 其他动作
|
|
89
|
+ })
|
|
90
|
+ },
|
|
91
|
+ // 获取奖品列表
|
|
92
|
+ getPrizes() {
|
|
93
|
+ getPrizeList().then(list => this.prizeList = list);
|
65
|
94
|
}
|
66
|
95
|
}
|
67
|
96
|
}
|