index.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  5. <!-- viewport的<meta>标签,这个标签可以修改在大部分的移动设备上面的显示,为了确保适当的绘制和触屏缩放。-->
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>大转盘抽奖</title>
  8. <link rel="stylesheet" href="css/demo.css" type="text/css"/>
  9. <link rel="stylesheet" type="text/css" href="css/style.css">
  10. <script type="text/javascript" src="js/jquery.min.js"></script>
  11. <script type="text/javascript" src="js/awardRotate.js"></script>
  12. <script type="text/javascript" src="js/scroll.js"></script>
  13. <script type="text/javascript" src="./js/jqhttpsdk.js"></script>
  14. <script type="text/javascript" src="./js/jquery_cookie_min.js"></script>
  15. <style type="text/css">
  16. .quan {
  17. width: 100%;
  18. height: 100%;
  19. background: rgba(0, 0, 0, 0.5);
  20. position: absolute;
  21. top: 0px;
  22. z-index: 99;
  23. display: none;
  24. }
  25. .quan1 {
  26. width: 300px;
  27. height: 200px;
  28. background: #fff;
  29. margin: 0 auto;
  30. margin-top: 300px;
  31. border-radius: 10px;
  32. border: 4px solid #666;
  33. }
  34. .qian2 {
  35. float: left;
  36. height: 50px;
  37. width: 196px;
  38. line-height: 50px;
  39. text-align: center;
  40. font-size: 18px;
  41. margin-top: 50px;
  42. background: #fff;
  43. border: 2px solid #fff100;
  44. margin-left: 50px;
  45. }
  46. .queding {
  47. float: left;
  48. width: 70px;
  49. height: 24px;
  50. background: #fff;
  51. border: 2px solid #ccc;
  52. border-radius: 5px;
  53. margin-top: 50px;
  54. margin-left: 115px;
  55. text-align: center;
  56. line-height: 24px;
  57. cursor: pointer;
  58. }
  59. .dis {
  60. color: #000;
  61. font-size: 100px;
  62. font-weight: bold;
  63. position: absolute;
  64. left: 50%;
  65. margin-left: -90px;
  66. top: 100px;
  67. line-height: 30px;
  68. }
  69. .xianjin {
  70. width: 280px;
  71. height: 50px;
  72. background: #fff;
  73. position: absolute;
  74. border-radius: 10px;
  75. top: 248px;
  76. left: 200px;
  77. line-height: 50px;
  78. text-align: center;
  79. }
  80. .jjc {
  81. width: 500px;
  82. height: 500px;
  83. background: url(images/paoma1.gif);
  84. background-size: 100% 100%;
  85. position: absolute;
  86. top: -250px;
  87. left: 500%;
  88. font-size: 35px;
  89. line-height: 700px;
  90. text-align: center;
  91. color: #fff;
  92. }
  93. </style>
  94. </head>
  95. <body>
  96. <div style="display:none; text-align:center;margin:10px 0; font:normal 14px/24px 'MicroSoft YaHei';">
  97. <p>适用浏览器:360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗. 不支持IE8及以下浏览器。</p>
  98. </div>
  99. <div style="height: 30px; line-height: 30px; background: #28BD19; display: none; text-align: center; color: white;" id="error">错误提示</div>
  100. <!--进来抽奖的界面-->
  101. <div style="display: none;" id="drawTab">
  102. <div class="turntable-bg">
  103. <div class="pointer"><img src="images/pointer.png" alt="pointer" style="width:100%;height:100%;"></div>
  104. <div class="rotate"><img id="rotate" src="images/turntable.png" alt="turntable" style="width:100%;height:100%;">
  105. </div>
  106. </div>
  107. <div style="display: none;" id="to_drawTab">
  108. <div style='padding-top: 30px;text-align: center;color: white;'>用户名:<span id="username"></span>
  109. <a onclick='DetailsTab()'>中奖记录</a>
  110. </div>
  111. </div>
  112. <div id="loginFormID" style="display: block;text-align: center; color: #90807b;">
  113. <div style="margin-top: 40px;"><input type="text" id="phone" maxlength="11" placeholder="输入手机号码"
  114. value="" style="height: 30px; width: 250px;"><span
  115. id="get_code" style="position: absolute;right: 75px;line-height: 30px;">获取验证码</span></div>
  116. <div style="margin-top: 10px;"><input type="text" id="code" maxlength="6" placeholder="验证码"
  117. style="height: 30px; width: 250px;"></div>
  118. <div style="margin-top: 10px; margin-bottom: 15px;" id="go_ok">
  119. <div id="loginId"
  120. style="margin: 0 auto; color:white; line-height: 30px; background: #f39c4c; height: 30px; width: 120px; border-radius: 5px;">
  121. 绑定抽奖
  122. </div>
  123. </div>
  124. <div style=" font-size: 15px; color: white;">
  125. <p style="margin-bottom: 5px;">—————— 活动细则 ———————</p>
  126. <div id="" style="text-align: left; margin-left: 30px;">
  127. <p style="margin-bottom: 5px;">每个手机用户可有抽奖机会一次</p>
  128. <p>中奖用户需填写联系信息(姓名、电话、收货地址),以方便邮寄给您。</p>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. <!--中奖的界面-->
  134. <div style="display: none;" id="detailsTab">
  135. <div style="color: white; font-size: 30px; margin-top: 30px; text-align: center; margin-bottom: 50px;">恭喜您! 您中奖了
  136. </div>
  137. <div style="text-align: center;">
  138. <div style="margin-top: 10px;">
  139. <input type="text" id="rec_name" placeholder="输入收货人姓名" style="height: 30px; width: 250px;">
  140. </div>
  141. <div style="margin-top: 10px;">
  142. <input type="text" id="rec_phone" placeholder="输入收货人手机" style="height: 30px; width: 250px;">
  143. </div>
  144. <div style="margin-top: 10px;">
  145. <input type="text" id="rec_addr" placeholder="输入收货人地址" style="height: 30px; width: 250px;">
  146. </div>
  147. <div style="margin-top: 20px; margin-bottom: 50px;" id="go_site">
  148. <div style="margin: 0 auto; color:white; line-height: 30px; background: #f39c4c; height: 30px; width: 70px; border-radius: 5px;">
  149. 提交
  150. </div>
  151. </div>
  152. <div style=" font-size: 15px; color: white;">
  153. <p style="margin-bottom: 5px;">—————— 活动细则 ———————</p>
  154. <div id="" style="text-align: left; margin-left: 30px;">
  155. <p style="margin-bottom: 5px;">每个手机用户可有抽奖机会一次</p>
  156. <p>中奖用户需填写联系信息(姓名、电话、收货地址),以方便邮寄给您。</p>
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. <script type="text/javascript">
  162. $(document).ready(function () {
  163. $('.list_lh li:even').addClass('lieven');
  164. });
  165. </script>
  166. <script type="text/javascript">
  167. setTimeout('$("#drawTab").fadeIn(1500);', 10);
  168. let draw_status = 0; //中奖状态
  169. function setCookie(key, val, seconds) {
  170. var date = new Date();
  171. date.setTime(date.getTime() + seconds * 1000);//只能这么写,10表示10秒钟
  172. console.log(key);
  173. console.log(val);
  174. $.cookie(key, val, {expires: date});
  175. }
  176. function InitIndex() {
  177. let cookie = $.cookie('access_token');
  178. if (cookie) {
  179. let post_data = {'token': cookie}
  180. // 初始化目录
  181. $.postJSON(
  182. http_ip_prot + 'lottery/index', JSON.stringify(post_data),
  183. function (data) {
  184. if (data['code'] == 0) {
  185. console.log('初始化成功')
  186. console.log(data['res'])
  187. draw_status = data['res']['status']; //中奖状态
  188. let phone_list = data['res']['phone_list']; //已经中奖的手机号码
  189. let user = data['res']['user']; // 当前用户名
  190. let addr = data['res']['addr']; // 当前收货地址
  191. //$('#loginFormID').hide()
  192. $("#username").html(user);
  193. $("#loginFormID").hide();
  194. $('#to_drawTab').show();
  195. DetailsTab();
  196. let addrJson = JSON.parse(addr)
  197. console.log(addrJson)
  198. if (addrJson) {
  199. $("#rec_name").val(addrJson['rec_name'])
  200. $("#rec_phone").val(addrJson['rec_phone'])
  201. $("#rec_addr").val(addrJson['rec_addr'])
  202. }
  203. } else {
  204. alert(data['msg'])
  205. }
  206. }
  207. );
  208. } else {
  209. //没有token唤醒登录界面
  210. }
  211. }
  212. function DetailsTab() {
  213. if (draw_status == 1 || draw_status == 2) {
  214. alert('恭喜你');
  215. $('#drawTab').hide();
  216. $('#detailsTab').show();
  217. } else {
  218. alert( '很遗憾,你没有中奖');
  219. // $("#error").html("很遗憾,你没有中奖");
  220. // setTimeout('$("#error").fadeIn(1);', 100);
  221. // setTimeout('$("#error").fadeOut(2000);', 100);
  222. }
  223. }
  224. var phone_countdown=60;
  225. function phone_settime() {
  226. if(phone_countdown == 0) {
  227. $("#get_code").html("获取验证码");
  228. phone_countdown = 60;
  229. return;
  230. } else {
  231. $("#get_code").html("重新发送(" + phone_countdown + ")");
  232. phone_countdown--;
  233. }
  234. setTimeout(function() {
  235. phone_settime()
  236. }, 1000)
  237. }
  238. //获取验证码方法
  239. function authCode() {
  240. let phone = $('#phone').val();
  241. if(phone==""){
  242. alert("手机不可以为空!");
  243. $('#phone').focus();
  244. return;
  245. }else if(!/^1[0-9]{10}$/.test(phone)){
  246. alert("手机不正确!");
  247. $('#phone').focus();
  248. return;
  249. }
  250. let post_data = {'phone': phone}
  251. // 初始化目录
  252. $.postJSON(
  253. http_ip_prot + 'lottery/authcode', JSON.stringify(post_data),
  254. function (data) {
  255. if (data['code'] == 0) {
  256. phone_settime();
  257. } else {
  258. alert(data['msg'])
  259. }
  260. }
  261. );
  262. }
  263. // 登录
  264. function doAuthLogin() {
  265. let phone = $('#phone').val();
  266. let authcode = $('#code').val();
  267. if(phone==""){
  268. alert("手机不可以为空!");
  269. $('#phone').focus();
  270. return;
  271. }else if(!/^1[0-9]{10}$/.test(phone)){
  272. alert("手机不正确!");
  273. $('#phone').focus();
  274. return;
  275. }
  276. if(authcode==""){
  277. alert("验证码不可以为空!");
  278. $('#code').focus();
  279. return;
  280. }
  281. let post_data = {
  282. 'phone': phone,
  283. 'authcode': authcode
  284. }
  285. $.postJSON(
  286. http_ip_prot + 'lottery/login', JSON.stringify(post_data),
  287. function (data) {
  288. if (data['code'] == 0) {
  289. //登录成功
  290. setCookie('access_token', data['res']['access_token'], data['res']['access_expire'])
  291. setCookie('refresh_token', data['res']['refresh_token'], data['res']['refresh_expire'])
  292. // InitIndex()
  293. $("#username").html(phone);
  294. $("#loginFormID").hide();
  295. $('#to_drawTab').show();
  296. } else {
  297. alert(data['msg'])
  298. }
  299. }
  300. );
  301. }
  302. //抽奖
  303. function doDraw() {
  304. let token = $.cookie('access_token')
  305. let post_data = {
  306. 'token': token
  307. }
  308. $.postJSON(
  309. http_ip_prot + 'lottery/draw', JSON.stringify(post_data),
  310. function (data) {
  311. if (data['code'] == 0) {
  312. //抽奖请求成功
  313. //中奖状态 1:c611,2:c612 ,3:不中奖
  314. let status = data['res']['status']
  315. if (status == 1) {
  316. console.log('中奖c611')
  317. } else if (status == 2) {
  318. console.log('中奖c612')
  319. } else if (status == 3) {
  320. console.log('很遗憾没有中奖')
  321. }
  322. doDrawRollAction(status)
  323. } else if(data['code']==309) {
  324. alert('请绑定手机再来抽奖吧!');
  325. } else{
  326. alert(data['msg']);
  327. }
  328. },
  329. false,//异步
  330. );
  331. }
  332. //设置收货地址
  333. function setAddr() {
  334. let token = $.cookie('access_token')
  335. let rec_name = $('#rec_name').val()
  336. let rec_phone = $('#rec_phone').val()
  337. let rec_addr = $('#rec_addr').val()
  338. if (rec_addr && rec_phone && rec_addr) {
  339. let addr = JSON.stringify({
  340. 'rec_name': rec_name,
  341. 'rec_phone': rec_phone,
  342. 'rec_addr': rec_addr,
  343. });
  344. let post_data = {
  345. 'token': token,
  346. 'addr': addr
  347. };
  348. $.postJSON(
  349. http_ip_prot + 'lottery/setAddr', JSON.stringify(post_data),
  350. function (data) {
  351. if (data['code'] == 0) {
  352. //设置请求成功
  353. alert(data['msg'])
  354. } else {
  355. alert(data['msg'])
  356. }
  357. }
  358. );
  359. }
  360. }
  361. //获取验证码
  362. $('#get_code').click(function () {
  363. if (phone_countdown == 60){
  364. authCode();
  365. }else{
  366. confirm("不要频繁点击获取验证码!");
  367. }
  368. });
  369. //# 登录
  370. $('#loginId').click(function () {
  371. doAuthLogin()
  372. });
  373. //# 登录
  374. $('#go_site').click(function () {
  375. setAddr()
  376. });
  377. InitIndex()
  378. var bRotate = false;
  379. var rotateFn = function (awards, angles, txt) {
  380. bRotate = !bRotate;
  381. $('#rotate').stopRotate();
  382. $('#rotate').rotate({
  383. angle: 0,
  384. animateTo: angles + 1800,
  385. duration: 8000,
  386. callback: function () {
  387. //alert("¥" + txt);
  388. alert(txt)
  389. bRotate = !bRotate;
  390. }
  391. })
  392. };
  393. // 0 2 5 不中奖
  394. // 1 3 c612
  395. // 4 6 c611
  396. $('.pointer').click(function () {
  397. //var a = [0, 1, 2, 3, 4, 5, 6];
  398. doDraw()
  399. });
  400. function doDrawRollAction(status) {
  401. //抽奖值
  402. //var item = 0
  403. let rotate_data = {
  404. '1': [4, 6],
  405. '2': [1, 3],
  406. '3': [0, 2, 5],
  407. };
  408. let rotate = rotate_data[status]
  409. let item = rotate[Math.floor((Math.random() * rotate.length))];
  410. var a = [
  411. '很遗憾没中奖',
  412. '恭喜中奖c612',
  413. '很遗憾没中奖',
  414. '恭喜中奖c612',
  415. '恭喜中奖c611',
  416. '很遗憾没中奖',
  417. '恭喜中奖c611',
  418. ]
  419. //if (bRotate) return;
  420. switch (item) {
  421. case 0:
  422. //var angle = [26, 88, 137, 185, 235, 287, 337];
  423. rotateFn(0, 332, a[0]);
  424. var ss = Number($("#xianjin").val());
  425. var cc = ss + a[0];
  426. $("#xianjin").val(cc);
  427. setTimeout(function () {
  428. $(".xianjin").html(cc);
  429. }, 8000);
  430. $(".qian2").html(cc);
  431. break;
  432. case 1:
  433. //var angle = [88, 137, 185, 235, 287];
  434. rotateFn(1, 24, a[1]);
  435. var ss = Number($("#xianjin").val());
  436. var cc = ss + a[1];
  437. $("#xianjin").val(cc);
  438. setTimeout(function () {
  439. $(".xianjin").html(cc);
  440. }, 8000);
  441. $(".qian2").html(cc);
  442. break;
  443. case 2:
  444. //var angle = [137, 185, 235, 287];
  445. rotateFn(2, 77, a[2]);
  446. var ss = Number($("#xianjin").val());
  447. var cc = ss + a[2];
  448. $("#xianjin").val(cc);
  449. setTimeout(function () {
  450. $(".xianjin").html(cc);
  451. }, 8000);
  452. $(".qian2").html(cc);
  453. break;
  454. case 3:
  455. //var angle = [137, 185, 235, 287];
  456. rotateFn(3, 129, a[3]);
  457. var ss = Number($("#xianjin").val());
  458. var cc = ss + a[3];
  459. $("#xianjin").val(cc);
  460. setTimeout(function () {
  461. $(".xianjin").html(cc);
  462. }, 8000);
  463. $(".qian2").html(cc);
  464. break;
  465. case 4:
  466. //var angle = [185, 235, 287];
  467. rotateFn(4, 180, a[4]);
  468. var ss = Number($("#xianjin").val());
  469. var cc = ss + a[4];
  470. $("#xianjin").val(cc);
  471. setTimeout(function () {
  472. $(".xianjin").html(cc);
  473. }, 8000);
  474. $(".qian2").html(cc);
  475. break;
  476. case 5:
  477. //var angle = [185, 235, 287];
  478. rotateFn(5, 231, a[5]);
  479. var ss = Number($("#xianjin").val());
  480. var cc = ss + a[5];
  481. $("#xianjin").val(cc);
  482. setTimeout(function () {
  483. $(".xianjin").html(cc);
  484. }, 8000);
  485. $(".qian2").html(cc);
  486. break;
  487. case 6:
  488. //var angle = [235, 287];
  489. rotateFn(6, 280, a[6]);
  490. var ss = Number($("#xianjin").val());
  491. var cc = ss + a[6];
  492. $("#xianjin").val(cc);
  493. setTimeout(function () {
  494. $(".xianjin").html(cc);
  495. }, 8000);
  496. $(".qian2").html(cc);
  497. break;
  498. }
  499. }
  500. </script>
  501. <!--<script type="text/javascript">
  502. var ua = navigator.userAgent.toLowerCase();
  503. var isWeixin = ua.indexOf('micromessenger') != -1;
  504. var isAndroid = ua.indexOf('android') != -1;
  505. var isIos = (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1);
  506. if (!isWeixin) {
  507. document.head.innerHTML = '<title>抱歉,出错了</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"><link rel="stylesheet" type="text/css" href="weua.css">';
  508. document.body.innerHTML = '<div class="weui_msg"><div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div><div class="weui_text_area"><h4 class="weui_msg_title">请在微信客户端打开链接</h4></div></div>';
  509. }
  510. </script>-->
  511. </body>
  512. </html>