123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
- <title>激活码领取页</title>
- <link rel="icon" href="../static/img/favicon2.ico" type="img/x-ico">
- <link rel="stylesheet" href="../static/js/vender/toastr/toastr.min.css">
- <link rel="stylesheet" href="../static/css/activationCode.css">
- <script src="../static/js/vender/jquery-3.4.1.min.js"></script>
- <script src="../static/js/vender/toastr/toastr.min.js"></script>
- <script src="../static/js/vender/config.js"></script>
- </head>
- <body>
- <div class="code-container">
- <div class="bottom-content">
- <img class="img-container" src="../static/img/gifContent.png" />
- <div class="btn-content">
- <img class="get-gif" src="../static/img/getGif.png" />
- <img class="try-play" src="../static/img/tryPlay.png" />
- </div>
- </div>
- <div class="mask">
- <div class="dialog">
- <div class="head-list">
- <div class="head-title">提示信息</div>
- <div class="close"></div>
- </div>
- <div class="content">恭喜您,激活码领取成功!</div>
- <div id="copy-code">P005242s5c</div>
- <div class="btn-list">
- <div class="close-text">关闭</div>
- <img class="copy-btn" src="../static/img/copy.png" />
- </div>
- </div>
- </div>
- <div class="copy-success">
- <img class="success-img" src="../static/img/success.png" />
- <div class="success-text">复制成功</div>
- </div>
- <input type="text" style="opacity: 0;z-index: -10;position: fixed;" id="codeCopy" value="">
- </div>
- <script>
- toastr.options.positionClass = 'toast-center-center';
- toastr.options.timeOut = '1500';
- </script>
- <script type="text/javascript">
- // var baseUrl = 'http://14.215.128.96/'
- let timer,flag = true;
- var url = window.location.href;
- url = url.split('/')
- var loc = window.location.search,
- n1 = loc.length,//地址的总长度
- n2 = loc.indexOf("="),//取得=号的位置
- id = loc.substr(n2 + 1, n1 - n2),//从=号后面的内容
- u = navigator.userAgent,
- isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
- isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
- if(id !== ''){
- operate(3);
- }
- //点击试玩
- $('.try-play')[0].addEventListener('click',()=>{
- //是否有token
- let type = id === ''? 'noToken': 'com.xlwy.yy';
- sendParm(type);
- if(id !== ''){
- operate(5);
- }
- },false);
- //埋点
- function operate(accessType){
- $.ajax({
- url: baseUrl + '/api/public/v1/game/user/operate',
- type: 'post',
- headers: {
- 'Authorization': id //id
- },
- data:JSON.stringify({
- accessType: accessType,
- entrance: 3,
- url: window.location.href
- }),
- contentType:"application/json",
- dataType: 'json',
- cache: false,
- success: function (res) {
- console.log(res)
- },
- })
- }
- $('.get-gif')[0].addEventListener('click',getActivationCode,false);
- function handleShow(data) {
- $('#copy-code').text(data)
- $('.dialog').animate({top: '4.36rem'},"fast");
- $('.mask').show();
- document.documentElement.style.overflow='hidden';
- }
- //点击领取激活码
- function getActivationCode(){
- //是否有token
- if(id === ''){
- sendParm('noToken');
- return
- }
- $.ajax({
- url: baseUrl + '/api/public/v1/game/activationCode',
- type: 'get',
- headers: {
- 'Authorization': id //id
- },
- contentType: "application/json",
- dataType: 'json',
- cache: false,
- success: function (res) {
- if(res.status === 0){
- handleShow(res.data);
- }else{
- stopManyClick(() =>{
- toastr.error(res.msg)
- })
- }
- },
- })
- }
- $('.close')[0].addEventListener('click',handleClose,false);
- $('.close-text')[0].addEventListener('click',handleClose,false);
- function handleClose() {
- $('.dialog').animate({top: '-6.96rem'},"fast");
- $('.mask').hide();
- document.documentElement.style.overflow='auto';
- }
- $('.copy-btn')[0].addEventListener('click',copyCode,false);
- //复制按钮
- function copyCode() {
- stopManyClick(() =>{
- //加载数据
- $('#codeCopy').val($('#copy-code').text());
- var input = document.getElementById("codeCopy");
- // 选中文本
- input.select();
- // 执行浏览器复制命令
- document.execCommand("copy");
- $('.copy-success').addClass('on');
- operate(4);
- setTimeout(() => {
- $('.copy-success').removeClass('on');
- },1500)
- })
- }
- //传递参数给app
- function sendParm(type) {
- if (isAndroid) {
- window.native.toGame(type);
- }else if(isiOS){
- window.webkit.messageHandlers.getPackageName.postMessage(type);
- }else{
- stopManyClick(() =>{
- toastr.error('暂不支持当前系统')
- })
- }
- }
- //防止提示一秒内重复显示
- function stopManyClick(fn) {
- if (flag) {
- fn();
- }
- flag = false;
- if(timer){clearTimeout(timer);}
- timer = setTimeout(() => {flag = true}, 1500);
- }
- </script>
- </body>
- </html>
|