lottery.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>抽奖</title>
  8. <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
  9. <style>
  10. body {
  11. margin: 0;
  12. padding: 0;
  13. }
  14. .background {
  15. width: 100%;
  16. height: auto;
  17. }
  18. .pool {
  19. position: absolute;
  20. width: 84%;
  21. height: auto;
  22. left: 7%;
  23. top: 250px;
  24. }
  25. .container {
  26. display: flex;
  27. flex-wrap: wrap;
  28. justify-content: space-around;
  29. position: absolute;
  30. width: 76%;
  31. height: 90%;
  32. left: 11%;
  33. }
  34. .item {
  35. border-radius: 18px;
  36. width: 32%;
  37. }
  38. .active {
  39. box-shadow : 0 0 0 2px aqua;
  40. }
  41. .title{
  42. width: 100%;
  43. text-align: center;
  44. font-size: 20px;
  45. font-weight: 700;
  46. position: absolute;
  47. }
  48. .tips{
  49. color: #470C82;
  50. position: absolute;
  51. width: 90%;
  52. left: 5%;
  53. }
  54. .mask{
  55. position: absolute;
  56. top: 0;
  57. height: 100%;
  58. width: 100%;
  59. background-color: rgba(0, 0, 0, 0.7);
  60. z-index: 10;
  61. }
  62. .result{
  63. position: absolute;
  64. width: 100%;
  65. left: 0;
  66. top: 0;
  67. z-index: 11;
  68. }
  69. .result_failed_button{
  70. position: absolute;
  71. left: 24%;
  72. width: 52%;
  73. z-index: 12;
  74. }
  75. .result_failed_text{
  76. position: absolute;
  77. width: 100%;
  78. text-align: center;
  79. z-index: 13;
  80. color: white;
  81. font-size: 20px;
  82. }
  83. .result_success_title{
  84. position: absolute;
  85. width: 100%;
  86. text-align: center;
  87. z-index: 12;
  88. color: orange;
  89. font-size: 20px;
  90. }
  91. .result_success_logo{
  92. position: absolute;
  93. width: 30%;
  94. left: 35%;
  95. z-index: 12;
  96. }
  97. input{
  98. position: absolute;
  99. left: 24%;
  100. width: 45%;
  101. z-index: 12;
  102. height: 40px;
  103. border: orange solid 3px;
  104. border-radius: 40px;
  105. padding-left: 20px;
  106. }
  107. .result_success_button{
  108. position: absolute;
  109. left: 24%;
  110. width: 52%;
  111. z-index: 12;
  112. }
  113. /*滚动*/
  114. .case {
  115. position: absolute;
  116. width: 95%;
  117. left: 5%;
  118. height: 70px;
  119. overflow: hidden;
  120. }
  121. .case .part2 {
  122. float: left;
  123. width: 93%;
  124. height: 70px;
  125. text-indent: 1em;
  126. overflow: hidden;
  127. }
  128. #part2 ul {
  129. width: 100%;
  130. height: auto;
  131. list-style: none;
  132. padding: 0;
  133. margin: 0;
  134. }
  135. #part2 ul li {
  136. width: 100%;
  137. height: 30px;
  138. font-size: 16px;
  139. line-height: 30px;
  140. color: white;
  141. overflow: hidden;
  142. white-space: nowrap;
  143. text-overflow: ellipsis;
  144. }
  145. </style>
  146. <script type="text/javascript">
  147. var current = 0;
  148. var last = 0;
  149. var threshold = 0;
  150. var speed = 1;
  151. var enable = true;
  152. $(function () {
  153. //进入和窗口缩放时重新设置内容位置
  154. setPosition();
  155. $(window).resize(function () {
  156. setPosition();
  157. });
  158. //点击抽奖
  159. $(".button").click(function () {
  160. if(enable == true){
  161. alert("抽奖开始");
  162. //进入不可点击状态
  163. enable = false;
  164. //设置初始速度
  165. speed = 60;
  166. //设置要中奖的位置
  167. threshold = 7;
  168. //配置移动次数
  169. last = 56 + threshold - current;
  170. setTimeout(function(){next(current)}, 1000);
  171. }
  172. });
  173. //谢谢惠顾后点击的按钮
  174. $(".result_failed_button").click(function () {
  175. alert("点击了再玩一次");
  176. });
  177. });
  178. //重新设置内容位置
  179. function setPosition() {
  180. $(".pool").css("top", $(document).width() / 1.9);
  181. $(".container").css("top", $(document).width() / 1.75).css("height", $(document).width() / 1.6);
  182. $(".item").css("height", $(".container").width() / 3.9);
  183. $(".title").css("top", $(".container").width() * 2.35);
  184. $(".tips").css("top", $(".container").width() * 2.45);
  185. $(".mask").css("height", $(document).height());
  186. $(".result_failed_button").css("top", $(".container").width() * 1.6);
  187. $(".result_success_title").css("top", $(".container").width() * 0.66);
  188. $(".result_success_logo").css("top", $(".container").width() * 0.9);
  189. $(".result_success_name").css("top", $(".container").width() * 1.35);
  190. $(".result_success_phone").css("top", $(".container").width() * 1.59);
  191. $(".result_success_button").css("top", $(".container").width() * 1.82);
  192. $(".case").css("top", $(".container").width() * 1.9);
  193. }
  194. //激活移动
  195. function next() {
  196. $(".item" + current).removeClass("active");
  197. $(".item" + (current + 1) % 8).addClass("active");
  198. current = (current + 1) % 8;
  199. //10以下开始减速
  200. if(last < 10){
  201. speed += 60;
  202. }
  203. //剩余次数8以下并且到了号时
  204. if(!(last-- < 8 && current == threshold)){
  205. setTimeout(function(){next()}, speed);
  206. }else{
  207. setTimeout(function(){
  208. alert("抽奖完毕,抽到了" + threshold + "号");
  209. enable = true;
  210. }, 1500);
  211. }
  212. }
  213. //中奖之后
  214. function success(){
  215. $(".mask").show();
  216. $(".success").show();
  217. $(".result_success_title").show();
  218. $(".result_success_logo").show();
  219. $(".result_success_name").show();
  220. $(".result_success_phone").show();
  221. $(".result_success_button").show();
  222. }
  223. //谢谢惠顾
  224. function failed(){
  225. $(".mask").show();
  226. $(".failed").show();
  227. $(".result_failed_button").show();
  228. }
  229. </script>
  230. </head>
  231. <body>
  232. <img class="background" src="images/lottery_background.png">
  233. <img class="pool" src="images/lottery_pool.png">
  234. <div class="container">
  235. <img class="item item0 active" src="images/reward_book.png">
  236. <img class="item item1" src="images/reward_soap.png">
  237. <img class="item item2" src="images/reward_oil10.png">
  238. <img class="item item7" src="images/reward_oil5.png">
  239. <img class="item button" src="images/lottery_button.png">
  240. <img class="item item3" src="images/reward_oil5.png">
  241. <img class="item item6" src="images/reward_oil60.png">
  242. <img class="item item5" src="images/reward_soap.png">
  243. <img class="item item4" src="images/reward_null.png">
  244. </div>
  245. <span class="title"><span style="color: #FF356B">活动</span>说明</span>
  246. <span class="tips">1.中奖者留下姓名和电话,在活动结束后会联系邮寄奖品;<br>
  247. 2.微博参与抽奖方式:<br>
  248. 关注@贝蒂斯橄榄油官方微博,转发或评论置顶微博并上传“游戏结果海报”。
  249. </span>
  250. <div class="case">
  251. <div class="part2" id="part2">
  252. <div id="scroll1">
  253. <ul>
  254. <li>恭喜XXXX获得YYYY</li>
  255. <li>恭喜XXXX获得YYYY</li>
  256. <li>恭喜XXXX获得YYYY</li>
  257. <li>恭喜XXXX获得YYYY</li>
  258. <li>恭喜XXXX获得YYYY</li>
  259. <li>恭喜XXXX获得YYYY</li>
  260. <li>恭喜XXXX获得YYYY</li>
  261. <li>恭喜XXXX获得YYYY</li>
  262. <li>恭喜XXXX获得YYYY</li>
  263. <li>恭喜XXXX获得YYYY</li>
  264. <li>恭喜XXXX获得YYYY</li>
  265. <li>恭喜XXXX获得YYYY</li>
  266. <li>恭喜XXXX获得YYYY</li>
  267. <li>恭喜XXXX获得YYYY</li>
  268. <li>恭喜XXXX获得YYYY</li>
  269. <li>恭喜XXXX获得YYYY</li>
  270. <li>恭喜XXXX获得YYYY</li>
  271. <li>恭喜XXXX获得YYYY</li>
  272. <li>恭喜XXXX获得YYYY</li>
  273. </ul>
  274. </div>
  275. <div id="scroll2"></div>
  276. </div>
  277. </div>
  278. <script type="text/javascript">
  279. var PartArea = document.getElementById('part2');
  280. var Scroll1 = document.getElementById('scroll1');
  281. var Scroll2 = document.getElementById('scroll2');
  282. Scroll2.innerHTML = Scroll1.innerHTML;
  283. function roll() {
  284. if(Scroll2.offsetHeight - PartArea.scrollTop <= 0) {
  285. PartArea.scrollTop -= Scroll1.offsetHeight;
  286. } else {
  287. PartArea.scrollTop++;
  288. }
  289. }
  290. var StopRoll = setInterval(roll, 60);
  291. PartArea.onmouseover = function () {
  292. clearInterval(StopRoll);
  293. }
  294. PartArea.onmouseout = function () {
  295. StopRoll = setInterval(roll, 60);
  296. }
  297. </script>
  298. <div class="mask" style="display: none;"></div>
  299. <img class="result success" src="images/result_success.png" style="display: none;">
  300. <p class="result_success_title" style="display: none;">输入个人信息进行领奖</p>
  301. <img class="result_success_logo" src="images/reward_oil10_2.png" style="display: none;">
  302. <input class="result_success_name" type="text" placeholder="姓名" style="display: none;">
  303. <input class="result_success_phone" type="text" placeholder="手机号" style="display: none;">
  304. <img class="result_success_button" src="images/result_success_button.png" style="display: none;">
  305. <img class="result failed" src="images/result_failed.png" style="display: none;">
  306. <img class="result_failed_button" src="images/result_failed_button.png" style="display: none;">
  307. </body>
  308. </html>