index.html 20 KB

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