activationCode.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  6. <title>激活码领取页</title>
  7. <link rel="icon" href="../static/img/favicon2.ico" type="img/x-ico">
  8. <link rel="stylesheet" href="../static/js/vender/toastr/toastr.min.css">
  9. <link rel="stylesheet" href="../static/css/activationCode.css">
  10. <script src="../static/js/vender/jquery-3.4.1.min.js"></script>
  11. <script src="../static/js/vender/toastr/toastr.min.js"></script>
  12. <script src="../static/js/vender/config.js"></script>
  13. </head>
  14. <body>
  15. <div class="code-container">
  16. <div class="bottom-content">
  17. <img class="img-container" src="../static/img/gifContent.png" />
  18. <div class="btn-content">
  19. <img class="get-gif" src="../static/img/getGif.png" />
  20. <img class="try-play" src="../static/img/tryPlay.png" />
  21. </div>
  22. </div>
  23. <div class="mask">
  24. <div class="dialog">
  25. <div class="head-list">
  26. <div class="head-title">提示信息</div>
  27. <div class="close"></div>
  28. </div>
  29. <div class="content">恭喜您,激活码领取成功!</div>
  30. <div id="copy-code">P005242s5c</div>
  31. <div class="btn-list">
  32. <div class="close-text">关闭</div>
  33. <img class="copy-btn" src="../static/img/copy.png" />
  34. </div>
  35. </div>
  36. </div>
  37. <div class="copy-success">
  38. <img class="success-img" src="../static/img/success.png" />
  39. <div class="success-text">复制成功</div>
  40. </div>
  41. <input type="text" style="opacity: 0;z-index: -10;position: fixed;" id="codeCopy" value="">
  42. </div>
  43. <script>
  44. toastr.options.positionClass = 'toast-center-center';
  45. toastr.options.timeOut = '1500';
  46. </script>
  47. <script type="text/javascript">
  48. var baseUrl = 'http://14.215.128.96'
  49. let timer,flag = true;
  50. var url = window.location.href;
  51. url = url.split('/')
  52. var loc = window.location.search,
  53. n1 = loc.length,//地址的总长度
  54. n2 = loc.indexOf("="),//取得=号的位置
  55. id = loc.substr(n2 + 1, n1 - n2);//从=号后面的内容
  56. operate(3);
  57. //激活码
  58. $.ajax({
  59. url: baseUrl + '/api/public/v1/game/activationCode',
  60. type: 'get',
  61. headers: {
  62. 'Authorization': id //id
  63. },
  64. contentType: "application/json",
  65. dataType: 'json',
  66. cache: false,
  67. success: function (res) {
  68. $('#copy-code').text(res.data)
  69. },
  70. })
  71. //试玩url
  72. $.ajax({
  73. url: baseUrl + '/api/public/v1/game/url',
  74. type: 'get',
  75. headers: {
  76. 'Authorization': id //id
  77. },
  78. contentType: "application/json",
  79. dataType: 'json',
  80. cache: false,
  81. success: function (res) {
  82. $('.try-play')[0].addEventListener('click',()=>{
  83. window.location.href = !res.data.includes('http')?'http://' + res.data: res.data;
  84. operate(5);
  85. },false);
  86. },
  87. })
  88. //埋点
  89. function operate(accessType){
  90. $.ajax({
  91. url: baseUrl + '/api/public/v1/game/user/operate',
  92. type: 'post',
  93. headers: {
  94. 'Authorization': id //id
  95. },
  96. data:JSON.stringify({
  97. accessType: accessType,
  98. entrance: 3,
  99. url: window.location.href
  100. }),
  101. contentType:"application/json",
  102. dataType: 'json',
  103. cache: false,
  104. success: function (res) {
  105. console.log(res)
  106. },
  107. })
  108. }
  109. $('.get-gif')[0].addEventListener('click',handleShow,false);
  110. function handleShow() {
  111. $('.dialog').animate({top: '4.36rem'},"fast");
  112. $('.mask').show();
  113. document.documentElement.style.overflow='hidden';
  114. }
  115. $('.close')[0].addEventListener('click',handleClose,false);
  116. $('.close-text')[0].addEventListener('click',handleClose,false);
  117. function handleClose() {
  118. $('.dialog').animate({top: '-6.96rem'},"fast");
  119. $('.mask').hide();
  120. document.documentElement.style.overflow='auto';
  121. }
  122. $('.copy-btn')[0].addEventListener('click',copyCode,false);
  123. //复制按钮
  124. function copyCode() {
  125. stopManyClick(() =>{
  126. //加载数据
  127. $('#codeCopy').val($('#copy-code').text());
  128. var input = document.getElementById("codeCopy");
  129. // 选中文本
  130. input.select();
  131. // 执行浏览器复制命令
  132. document.execCommand("copy");
  133. $('.copy-success').addClass('on');
  134. operate(4);
  135. setTimeout(() => {
  136. $('.copy-success').removeClass('on');
  137. },1500)
  138. })
  139. }
  140. //防止提示一秒内重复显示
  141. function stopManyClick(fn) {
  142. if (flag) {
  143. fn();
  144. }
  145. flag = false;
  146. if(timer){clearTimeout(timer);}
  147. timer = setTimeout(() => {flag = true}, 1500);
  148. }
  149. </script>
  150. </body>
  151. </html>