服务器之家:专注于服务器技术及软件下载分享
分类导航

node.js|vue.js|jquery|angularjs|React|json|js教程|

服务器之家 - 编程语言 - JavaScript - jQuery实现移动端扭蛋机抽奖

jQuery实现移动端扭蛋机抽奖

2021-11-09 16:29码奴生来只知道前进~ JavaScript

这篇文章主要为大家详细介绍了jQuery实现移动端扭蛋机抽奖,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了jQuery实现移动端扭蛋机抽奖的具体代码,供大家参考,具体内容如下

?
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="apple-touch-fullscreen" content="YES" />
<meta name="format-detection" content="telephone=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="pragram" content="no-cache" />
 
<link href="css/style.css" type="text/css" rel="stylesheet"/>
 
<title>扭蛋机</title>
<!--移动端版本兼容 -->
<script type="text/javascript">
 var phoneWidth = parseInt(window.screen.width);
 var phoneScale = phoneWidth/640;
 var ua = navigator.userAgent;
 if (/Android (\d+\.\d+)/.test(ua)){
 var version = parseFloat(RegExp.$1);
 // andriod 2.3
 if(version>2.3){
  document.write('<meta name="viewport" content="width=640, minimum-scale = '+phoneScale+', maximum-scale = '+phoneScale+', target-densitydpi=device-dpi">');
 // andriod 2.3以上
 }else{
  document.write('<meta name="viewport" content="width=640, target-densitydpi=device-dpi">');
 }
 // 其他系统
 } else {
 document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">');
 }
 //微信去掉下方刷新栏
 if(RegExp("MicroMessenger").test(navigator.userAgent)){
 document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
  WeixinJSBridge.call('hideToolbar');
 });
 }
</script>
 
 <script src="js/jquery1.8.3.min.js"></script>
 
</head>
<body>
 
<div class="niu_danji">
 <!--机器-->
 <div class="game_qu">
 <!--go-->
 <div class="game_go">100/次</div>
  <div class="wdjifen">10000</div>
 </div>
 
 <!--球-->
 <div class="dan_gund">
 <span class="qiu_1 diaol_1"></span>
 <span class="qiu_2 diaol_2"> </span>
 <span class="qiu_3 diaol_3"></span>
 
 <span class="qiu_4 diaol_4"></span>
 <span class="qiu_5 diaol_5"></span>
 <span class="qiu_6 diaol_6"></span>>
 
 <span class="qiu_7 diaol_7"></span>
 <span class="qiu_8 diaol_8"></span>
 
 
 <span class="qiu_9 diaol_9"></span>
 <span class="qiu_10 diaol_10"></span>
 <span class="qiu_11 diaol_11"></span>
  
 </div>
 
 <!--中奖掉落-->
 <div class="medon"><img src="images/mendong.png"/></div>
 <div class="zjdl ">
 <span></span>
 </div>
 
 </div>
 
 
 
 
<!--中奖 获得一等奖-->
<div class="zonj_zezc none" id="jianpin_one">
 <div class="jpzs aiqiyi tc_anima">
 <em><img src="images/close.png"/></em>
 <h2>
  <b>恭喜你!<br>获得一等奖!</b>
 </h2>
 </div></div>
 
<!--中奖获得二等奖-->
<div class="zonj_zezc none" id="jianpin_two">
 <div class="jpzs aiqiyi tc_anima">
 <em><img src="images/close.png"/></em>
 <h2>
  <b>恭喜你!<br>获得二等奖!</b>
 </h2>
 </div>
</div>
 
<!--中奖 获得三等奖-->
<div class="zonj_zezc none" id="jianpin_three">
 <div class="jpzs aiqiyi tc_anima">
 <em><img src="images/close.png"/></em>
 <h2>
  <b>恭喜你!<br>获得三等奖!</b>
 </h2>
 </div>
</div>
 
 
<!--没有中奖-->
<div class="zonj_zezc none" id="jianpin_kong">
 <div class="jpzs aiqiyi tc_anima">
 <em><img src="images/close.png"/></em>
 <h2>
  咦?没有抽中?
 </h2>
 </div>
</div>
 
 
<!--积分不足-->
<div class="zonj_zezc none" id="no_jifeng">
 <div class="jpzs aiqiyi tc_anima">
 <em><img src="images/close.png"/></em>
 <h2>
  对不起,积分不足!
 </h2>
 </div>
</div>
<script>
 
$(document).ready(function(e) {
 //一等奖 关闭
 $("#jianpin_one em img").click(function(){
 $("#jianpin_one").hide();
 }
 );
 //二等奖 关闭
 $("#jianpin_two em img").click(function(){
 $("#jianpin_two").hide();
 }
 );
 //三等奖 关闭
 $("#jianpin_three em img").click(function(){
 $("#jianpin_three").hide();
 }
 );
 //没有中奖 关闭
 $("#jianpin_kong em img").click(function(){
 $("#jianpin_kong").hide();
 }
 );
 //积分不足 关闭
 $("#no_jifeng em img").click(function(){
 $("#no_jifeng").hide();
 }
 );
 
var score=470;
$(".wdjifen").html(score);
 
 
$(".game_go").click(function(){
 score-=100;
 if(score<0){
 for(i=1;i<=11;i++){
 $(".qiu_"+i).removeClass("wieyi_"+i);
 }
 $("#no_jifeng").show();
 }else{
 draw()
 }
 });
 
 
function draw(){
 var number =Math.floor(4*Math.random()+1);
 
 for(i=1;i<=11;i++){
 $(".qiu_"+i).removeClass("diaol_"+i);
 $(".qiu_"+i).addClass("wieyi_"+i);
 };
 
 setTimeout(function (){
 for(i=1;i<=11;i++){
 $(".qiu_"+i).removeClass("wieyi_"+i);
 }
 },1100);
 setTimeout(function(){
 switch(number){
 case 1:$(".zjdl").children("span").addClass("diaL_one");break;
 case 2:$(".zjdl").children("span").addClass("diaL_two");break;
 case 3:$(".zjdl").children("span").addClass("diaL_three");break;
 case 4:$(".zjdl").children("span").addClass("diaL_four");break;
 }
 $(".zjdl").removeClass("none").addClass("dila_Y");
 setTimeout(function (){
 switch(number){
 case 1:$("#jianpin_one").show();break;
 case 2:$("#jianpin_two").show();break;
 case 3:$("#jianpin_three").show();break;
 case 4:$("#jianpin_kong").show();break;
 }
 },900);
 },1100)
 
 //取消动画
 setTimeout(function (){
 $(".zjdl").addClass("none").removeClass("dila_Y");
 $(".wdjifen").html(score);
 $(".zjdl").children("span").removeAttr('class');
 
 },2500)
 
}
});
 
 
</script>
 
 
</body>
</html>

 jQuery实现移动端扭蛋机抽奖

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/tanqingfu1/article/details/109531957

延伸 · 阅读

精彩推荐