choujiang.vue
8.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<template>
<div class="containerbox">
<div class="title">唐元集</div>
<div class="titlename">好礼送女神</div>
<div class="engname">New users will have a lucky draw, only once</div>
<div class="chouimg">
<div class="chouname">您有一次抽奖的机会</div>
<img src="../../../assets/chouimg.png" alt />
<div class="box">
<div @click="cj" class="list listk" :class="cjChange > 0 ? 'grey' : ''">
<img src="../../../assets/beginchou.png" alt />
</div>
<div
class="list"
:class="cjChange == item.index ? 'change_in' : ''"
v-for="(item,index) in prizeList"
:key="index"
>
<div class="list_t">
<img :src="item.imgsrc" alt />
</div>
<!-- <div class="list_b">{{item.prizeName}}</div> -->
</div>
</div>
</div>
<div class="register" v-if="hideshow">
<div class="lingimg">
<img src="../../../assets/daijinquan.png" alt />
<div class="money">200</div>
<div class="riqi">
<div class="youxiaodate">有效时间</div>
<div class="youxiaodate">2020.6.15 12:10-6.31</div>
</div>
</div>
<div class="chaimg" @click="closeimg">
<img src="../../../assets/chaimg.png" alt />
</div>
</div>
<!-- <div class="choujiangimg">
<img src="../../../assets/chujiangimg.png" alt />
</div>-->
<div class="uppage">上一页</div>
</div>
</template>
<script>
let timer;
let cjIn = false;
let cjChange = 0; //抽奖过程KEY
export default {
data() {
return {
closeimg: false,
prizeList: [
{ id: '001', index: 1, imgsrc: 'https://www.baidu.com/img/bd_logo1.png', prizeName: '奖品名称111' },
{ id: '002', index: 2, imgsrc: 'https://www.baidu.com/img/bd_logo1.png', prizeName: '奖品名称222' },
{ id: '003', index: 3, imgsrc: 'https://www.baidu.com/img/bd_logo1.png', prizeName: '奖品名称333' },
{ id: '004', index: 4, imgsrc: 'https://www.baidu.com/img/bd_logo1.png', prizeName: '奖品名称444' },
{ id: '005', index: 5, imgsrc: 'https://www.baidu.com/img/bd_logo1.png', prizeName: '奖品名称555' },
{ id: '006', index: 6, imgsrc: 'https://www.baidu.com/img/bd_logo1.png', prizeName: '奖品名称666' },
{ id: '007', index: 7, imgsrc: 'https://www.baidu.com/img/bd_logo1.png', prizeName: '奖品名称777' },
{ id: '008', index: 8, imgsrc: 'https://www.baidu.com/img/bd_logo1.png', prizeName: '奖品名称88888888888888' },
],
cjChange: null, //抽奖过程KEY
prizeResult: null, //抽奖结果KEY
prizeName: null, //抽奖结果KEY对应的奖品名称
showAgain: false, //是否抽奖后显示再抽一次按钮
}
},
methods: {
closeimg() {
this.closeimg = false
},
cj() {
console.log(9998)
if (cjIn) {
return;
} else {
cjIn = true;
}
let This = this;
clearInterval(timer);
timer = setInterval(This.changePrize, 80);
// test start
let res = {
stutus: 1,
prizeResult: 8,
prizeName: '奖品名称88888888888888',
}
if (res.stutus == 1) {
setTimeout(function () {
clearInterval(timer);
timer = setInterval(This.changePrize, 160);
setTimeout(function () {
clearInterval(timer);
timer = setInterval(This.changePrize, 300);
setTimeout(function () {
This.prizeResult = res.prizeResult
This.prizeName = res.prizeName
}, 1000)
}, 1000)
}, 2000)
}
// test end
},
//抽奖过程奖品切换
changePrize() {
cjChange++;
cjChange = cjChange > 8 ? 1 : cjChange;
let This = this;
This.cjChange = cjChange
if (This.prizeResult == cjChange) {
clearInterval(timer);
This.showAgain = true
console.log('获得奖品:' + This.prizeName)
}
},
//点击再抽一次按钮
againBtn() {
cjIn = false;
cjChange = 0; //抽奖过程KEY
let This = this;
This.setData({
cjChange: null, //抽奖过程KEY
prizeResult: null, //抽奖结果KEY
prizeName: null, //抽奖结果KEY对应的奖品名称
showAgain: false, //是否抽奖后显示再抽一次按钮
});
},
}
}
</script>
<style scoped>
.lingimg {
width: 7.5rem;
height: 8.5rem;
font-size: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.riqi {
position: absolute;
top: 4.9rem;
left: 50%;
transform: translateX(-50%);
}
.youxiaodate {
color: #437b6a;
font-size: 0.28rem;
text-align: center;
}
.chaimg {
width: 0.48rem;
height: 0.48rem;
font-size: 0;
position: absolute;
bottom: 1.82rem;
left: 3.52rem;
}
.money {
color: #0a5b5c;
font-size: 1.2rem;
position: absolute;
top: 3.6rem;
left: 3rem;
}
.chouname {
color: #39683c;
font-size: 0.32rem;
font-weight: bold;
position: absolute;
top: 0.65rem;
left: 50%;
transform: translateX(-50%);
}
.uppage {
position: fixed;
bottom: 0.4rem;
left: 0.32rem;
width: 6.86rem;
height: 0.88rem;
border: 0.02rem solid #ffffff;
border-radius: 0.08rem;
color: #fff;
font-size: 0.34rem;
text-align: center;
line-height: 0.88rem;
}
.choujiangimg {
width: 5.94rem;
height: 5.94rem;
font-size: 0;
margin: 0.2rem auto 0;
}
.chouimg {
width: 7.36rem;
height: 7.36rem;
margin: 0.2rem auto 0;
position: relative;
}
.titlename {
color: #fff;
font-size: 1.04rem;
text-align: center;
font-weight: bold;
margin-top: 0.22rem;
}
.engname {
color: #ffffff;
font-size: 0.24rem;
text-align: center;
margin-top: 0.1rem;
}
.title {
color: #fff;
font-size: 0.3rem;
position: relative;
text-align: center;
margin-top: 0.42rem;
margin-bottom: 0.22rem;
}
.title::before {
content: "";
position: absolute;
display: block;
left: 46%;
top: 50%;
-webkit-transform: translate3d(-50%, -50%, 0);
transform: translate3d(-50%, -50%, 0);
border-top: 0.02rem solid #fff;
width: 1.44rem;
}
.title::after {
content: "";
position: absolute;
display: block;
left: 56%;
top: 50%;
-webkit-transform: translate3d(-50%, -50%, 0);
transform: translate3d(-50%, -50%, 0);
border-top: 0.02rem solid #fff;
width: 1.44rem;
}
.title::before {
margin-left: -1.2rem;
}
.title::after {
margin-left: 1.2rem;
}
body,
html {
height: 100%;
background: #5e955d !important;
}
.containerbox {
height: 100%;
background: #5e955d;
overflow: hidden;
}
#app {
height: 100%;
background: #5e955d;
box-sizing: border-box;
padding-top: 0.25rem;
}
.box {
width: 5.5rem;
height: 4.2rem;
margin: 0 auto;
box-sizing: border-box;
position: relative;
/* -webkit-box-shadow: 0.08rem 0.08rem 0 rgba(0, 0, 0, 0.2);
box-shadow: 0.08rem 0.08rem 0 rgba(0, 0, 0, 0.2); */
position: absolute;
left: 50%;
top: 55%;
transform: translate(-50%, -50%);
}
.list {
width: 1.6rem;
height: 1.2rem;
position: absolute;
/* background-color: #fff; */
display: flex;
flex-direction: column;
/* flex-wrap: wrap; */
justify-content: center;
align-content: center;
align-items: center;
/* border: 1px solid red; */
display: flex;
justify-content: center;
align-items: center;
}
/* 抽奖过程中选定样式 */
.list.change_in {
color: #fff;
background-color: #5e955d;
}
.list_t {
width: 1.1rem;
height: 0.8rem;
font-size: 0;
}
.list_t image {
width: 100%;
height: 100%;
}
.list_b {
width: 90%;
height: 0.4rem;
line-height: 0.4rem;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 0.32rem;
}
.listk {
width: 1.7rem;
height: 1.4rem;
top: 51% !important;
}
/* 根据TOP */
.list:nth-child(1) {
left: 50%;
top: 50%;
color: #fff;
background-color: #1cbbb4;
display: flex;
justify-content: center;
align-content: center;
align-items: center;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.list.grey:nth-child(1) {
background-color: #5f9ea0;
}
.list:nth-child(2),
.list:nth-child(3),
.list:nth-child(4) {
top: 0;
}
.list:nth-child(6),
.list:nth-child(7),
.list:nth-child(8) {
bottom: 0;
}
.list:nth-child(5),
.list:nth-child(9) {
top: 50%;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
/* 根据LEFT */
.list:nth-child(2),
.list:nth-child(8),
.list:nth-child(9) {
left: 0;
}
.list:nth-child(3),
.list:nth-child(7) {
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
}
.list:nth-child(4),
.list:nth-child(5),
.list:nth-child(6) {
right: 0;
}
</style>
<style>
</style>