<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <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;
            text-align: center;
        }

        .main_box {
            font-size: 0;
            position: relative;
        }

        .main_box img {
            width: 100%;
        }

        .main_box .intro {
            font-size: 0.18rem;
            line-height: 0.22rem;
            color: #612e24;
            text-indent: 2em;
            margin: 0.1rem;
            /*font-weight: 600;*/
            text-align: left;
        }

        .main_box .coupon {
            width: 90%;
            margin: 0 auto;
        }
        .main_box .coupon img{
            pointer-events: none;
        }
        .main_box .gray {
            color: #b4b4b4;
            font-size: 0.14rem;
        }

        .main_box .gray span {
            color: #ff3728;
            font-weight: bolder;
        }

        .purchase {
            display: block;
            width: 90%;
            margin: 0 auto 0.2rem;
        }

        .main_box .strong {
            font-size: 0.16rem;
            font-weight: 800;
            color: #fe7b27;
            margin: 0.1rem;
        }

        .book-list {
            padding: 0.2rem 0;
            background: #fff5f4;
        }

        .book-list h3 {
            font-size: 0.16rem;
            color: #000;
            display: flex;
            justify-content: flex-start;
            align-items: center;
        }

        h3::before {
            content: "";
            display: inline-block;
            vertical-align: sup;
            width: 0.04rem;
            height: 0.16rem;
            border-radius: 4px;
            background: #ff7326;
            margin-right: 0.1rem;
        }

        h3 span {
            font-size: 0.14rem;
            color: #fe4c3f;
            margin-left: 0.1rem
        }

        .book-list__container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-flow: row wrap;
            padding: 0 0.1rem;
        }

        .book-item {
            width: 28%;
            margin-bottom: 0.1rem;
        }

        .book-item span {
            background: #ffe0e1;
            color: #ff7474;
            font-size: 0.12rem;
            margin-right: 0.05rem;
            padding: 0.02rem 0.06rem;
            border-radius: 20px;
            display: inline-block;
            margin-top: 0.1rem;
        }
    </style>
</head>

<body>
<main class="main_box">
    <div class="banner">
        <img src="https://cdn-novel.iycdm.com/h5/activity-2018-09-14/banner.jpg" alt="">
    </div>
    <p class="intro">
        365天内，全站小说任你畅读！一站式阅读所有小说，无需额外付费！不是每个人都像你这么幸运哦，时间有限，快使用优惠券成为最尊贵的VIP吧~
    </p>
    <input type="hidden" name="is_get" value="{{$is_get}}">
    @if($code == 0 && isset($is_get) && !empty($is_get))
        <div class="coupon" data-active="1">
            <!-- 已领取领取 -->
            @if($discount == 50)
                {{--//http://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/h5/activity-2018-05-25/2.png--}}
                <img src="https://cdn-novel.iycdm.com/h5/activity-2018-09-14/2.png" alt="">
            @elseif($discount == 80)
                <img src="https://cdn-novel.iycdm.com/h5/activity-2018-09-14/5.png" alt="">
            @else
                <img src="https://cdn-novel.iycdm.com/h5/activity-2018-09-14/2.png" alt="">
            @endif
        </div>
    @elseif($code == 3 && isset($is_get) && !empty($is_get))
        <div class="coupon" data-active="1">
            <!-- 已领取领取 -->
            @if($discount == 50)
                {{--//http://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/h5/activity-2018-05-25/2.png--}}
                <img src="https://cdn-novel.iycdm.com/h5/activity-2018-09-14/2.png" alt="">
            @elseif($discount == 80)
                <img src="https://cdn-novel.iycdm.com/h5/activity-2018-09-14/5.png" alt="">
            @else
                <img src="https://cdn-novel.iycdm.com/h5/activity-2018-09-14/2.png" alt="">
            @endif
        </div>
    @elseif($code == 0)
        <div class="coupon" data-active="0">
            <!-- 待领取 -->
            @if($discount == 50)
                {{--//http://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/h5/activity-2018-05-25/2.png--}}
                <img src="https://cdn-novel.iycdm.com/h5/activity-2018-09-14/1.png" alt="">
            @elseif($discount == 80)
                <img src="https://cdn-novel.iycdm.com/h5/activity-2018-09-14/4.png" alt="">
            @else
                <img src="https://cdn-novel.iycdm.com/h5/year_coupon_unpick_change.png" alt="">
            @endif
        </div>
    @else
        <div class="coupon" data-active="1">
            <!-- 待领取 -->
            @if($discount == 50)
                {{--//http://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/h5/activity-2018-05-25/2.png--}}
                <img src="https://cdn-novel.iycdm.com/h5/activity-2018-09-14/1.png" alt="">
            @elseif($discount == 80)
                <img src="https://cdn-novel.iycdm.com/h5/activity-2018-09-14/4.png" alt="">
            @else
                <img src="https://cdn-novel.iycdm.com/h5/year_coupon_unpick_change.png" alt="">
            @endif
        </div>
    @endif
    @if($discount == 50)
        <p class="gray">原价365元，领券立减50元，仅需<span>315</span>元</p>
        <p class="strong">每天0.8元，全年免费看</p>
    @elseif($discount == 80)
        <p class="gray">原价365元，领券立减80元，仅需<span>285</span>元</p>
        <p class="strong">每天0.7元，全年免费看</p>
    @endif
    <div>
        @if($code == 0)
            <!-- 活动进行中 -->
            <a class="purchase doing" href="{{$url}}" id="js-purchase-doing">
               {{-- <img src="https://cdn-novel.iycdm.com/h5/year_doing.png" alt="">--}}
                <img src="https://cdn-novel.iycdm.com/h5/activity-2018-09-14/button.png" alt="">
            </a>
        @elseif($code == 1)
            <!-- 活动未开始 -->
            <a class="purchase undone " href="#">
                <img src="https://cdn-novel.iycdm.com/h5/year_undone.png" alt="">
            </a>
        @elseif($code == 2)
            <!-- 活动结束 -->
            <a class="purchase over " href="#">
                <img src="https://cdn-novel.iycdm.com/h5/year_over.png" alt="">
            </a>
        @elseif($code == 3)
            <!-- 已订购 -->
            <a class="purchase done " href="#">
                <img src="https://cdn-novel.iycdm.com/h5/year_done.png" alt="">
            </a>
        @endif

    </div>
    <div class="book-list">
        <h3>榜单精选
            <span>海量小说任意看</span>
        </h3>
        <div class="book-list__container">
            @foreach($books as $book)
                <a class="book-item" href="/detail?id={{$book['book_id']}}">
                    <img src="{{$book['cover_url']}}" alt="">
                    <span>{{$book['book_category']}}</span>
                </a>
            @endforeach
        </div>
    </div>
</main>
</body>
<script src="//apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
    var is_get = {{$is_get}};

    $('#js-purchase-doing').on('click',function () {
        if(is_get != 1){
            alert('亲还未领取50元书券哦,领券支付更优惠!');
            return false;
        }
    })
    var coupon = document.querySelector('.coupon');
    coupon.addEventListener('click', function () {
        _this = this
        var active = parseInt(this.getAttribute('data-active'));
        if (!active) {
            $.ajax({
                'url':'/api/activity/getCoupons',
                'type':'post',
                'data':{'activity_id':"{{$activity_id}}"},
                'success':function(res){
                    var type = {{$discount}}
                    if(type == 50){
                        _this.children[0].setAttribute('src', 'https://cdn-novel.iycdm.com/h5/activity-2018-09-14/2.png');
                    }else{
                        _this.children[0].setAttribute('src', 'https://cdn-novel.iycdm.com/h5/activity-2018-09-14/5.png');
                    }
                    _this.setAttribute('data-active', 1);
                    is_get = 1;
                    $('#js-purchase-doing').attr('href',"{!! $coupons_url !!}");
                    //location.reload()
                }
            });
        }
    }, false)
</script>

</html>