<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta
          name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no0"
  />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <title>全本免费看</title>
  <style>
    html,
    body {
      margin: 0 auto;
      padding: 0;
      /* max-width: 450px; */
      font-size: 100px;
    }

    p {
      margin: 0;
      padding: 0;
    }

    main {
      font-size: 0;
      position: relative;
    }

    main img {
      width: 100%;
    }

    .section-box {
      width: 95%;
      margin: 0 auto;
    }

    .welfare-box {
      font-size: 0.14rem;
      margin-bottom: 0.14rem;
      color: #282828;
    }

    .welfare-box span {
      display: inline-block;
    }

    .welfare-box .label {
      background: #ff4223;
      color: #fff;
      padding: 0.05rem 0.1rem;
      font-weight: bold;
      border-radius: 2px;
    }

    .welfare-box .strong {
      color: #5235ff;
      font-size: 0.18rem;
      font-weight: bold;
    }

    .down-for-free {
      background: linear-gradient(
              0deg,
              rgba(243, 57, 31, 1),
              rgba(255, 122, 100, 1)
      );
      box-shadow: 0px 5px 9px 0px rgba(255, 85, 62, 0.3);
      border-radius: 23px;
      font-size: 0.16rem;
      font-weight: bold;
      color: #fff;
      text-align: center;
      padding: 0.14rem 0;
      width: 80%;
      margin: 0.24rem auto;
      cursor: pointer;
    }

    .disable-status {
      background: #ccc;
      box-shadow: none;
    }

    .rules-box {
      background: #f7f7f7;
      padding: 0.1rem 0.16rem;
      font-size: 0.13rem;
      color: #666;
      line-height: 0.2rem;
    }

    .rules-box .rule-title {
      font-weight: bold;
      color: #333;
    }

    .mask {
      position: fixed;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      background: rgba(0, 0, 0, 0.8);
    }

    .mask img {
      width: 100%;
    }

    @media screen and (max-width: 360px) {
      .welfare-box {
        font-size: 0.12rem;
      }

      .welfare-box .strong {
        font-size: 0.16rem;
      }

      .down-for-free {
        padding: 0.1rem 0;
      }

      .rules-box {
        font-size: 0.12rem;
      }
    }
  </style>
</head>
<body>
<main>
  <img src="/static/img/banner.jpg" alt="米读App" />
  <div class="section-box">
    <p class="welfare-box">
      <span class="label">微信内福利</span>
      <span class="text">《{{$params['book_name']}}》</span>
      <span class="strong">全本免费看</span>
    </p>
    <p class="welfare-box">
      <span class="label">米读内福利</span>
      <span class="text">免费抽取iPhone XS</span>
    </p>
    <!-- 按钮变灰使用class disable-status -->
    <div class="down-for-free">立即下载</div>

    <div class="rules-box">
      <p class="rule-title">规则</p>
      <p class="rule-item">1. App下载注册成功后福利兑现</p>
      <p class="rule-item">2. 微信内福利在当前服务号兑现</p>
      <p class="rule-item">3. 米读内福利下载成功后兑现</p>
    </div>
  </div>
</main>
<div class="mask" style="display: none">
  <img src="/static/img/mask.png" alt="" />
</div>
</body>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script>
    var u = navigator.userAgent.toLowerCase();
    var uid="{{$params['uid']}}";
    var bid="{{$params['bid']}}";
    var ad_id="{{$ads['id']}}";
    var sign="{{$params['my_sign']}}";
    var timestamp="{{$params['timestamp']}}";
    var isWechat = u.match(/MicroMessenger/i) == "micromessenger";
    // 按钮状态 1-可以点击下载 0-无法点击下载
    var btn_status = 1;
    var btn = document.querySelector(".down-for-free");
    var mask = document.querySelector(".mask");
    btn.addEventListener(
        "click",
        function() {

            // 判断是否在微信内
            // 判断是否在微信内
            if (isWechat) {
                mask.style.display = "block";
                $.ajax({
                    url:'/advertise/recieveUserBehavior',
                    type:'post',
                    data:{
                        'uid':uid,
                        'bid':bid,
                        'position':'DOWNLOAD_BTN'
                    }
                })
                return;
            }
            // 执行下载操作
            location.href='/advertise/jump?uid='+uid+'&bid='+bid+'&ad='+ ad_id +'&sign=' +sign+ '&timestamp=' + timestamp;
        },
        false
    );
    mask.addEventListener("click", function() {
        mask.style.display = "none";
    }, false)
</script>
</html>
