<!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 .coupon-box {
            background: #fff5f4;
        }

        .main_box .intro {
            font-size: 0.12rem;
            line-height: 0.2rem;
            color: #c9391c;
            text-indent: 2em;
            padding: 0.1rem;
            text-align: center;
            margin-bottom: 0.1rem;
        }

        .intro span {
            font-size: 0.16rem;
            display: block;
        }

        .intro span.weight {
            font-weight: bolder;
            margin-top: 0.05rem;
        }

        .main_box .coupon {
            width: 90%;
            margin: 0 auto;
        }

        .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.1rem 0;
            background: #fff;
        }

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

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

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

        .book-list__container {
            padding: 0 0.1rem;
            font-size: 0.14rem;
        }

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

        .book-item h3 {
            font-weight: normal;
            font-size: 0.16rem;
        }

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

        .book-item .book-intro {
            text-align: left;
            color: #999;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
        }

        .jiezhang {
            height: 0.8rem;
        }

        .jiezhang-box {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 0.6rem;
            background: #fff;
            font-size: 0.14rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            z-index: 9;
        }

        .jiezhang-box .pay-money {
            flex: 1;
            display: flex;
            justify-content: space-around;
            align-items: center;
            border-top: 1px solid #d7d7d7;
        }

        .pay-money .m {
            font-size: 0.2rem;
            font-weight: bold;
            color: #ff4a27;
        }

        .pay-money .u {
            color: #999;
        }

        .pay-money i {
            font-style: normal;
            color: #ff4a27;
            font-weight: bold;
        }

        .pay-money .m span {
            font-size: 0.14rem;
            margin-right: 0.05rem;
        }

        .pay-money .u span {
            width: 0.18rem;
            height: 0.18rem;
            display: inline-block;
            border: 1px solid #ff4a27;
            border-radius: 50%;
            position: relative;
            vertical-align: text-bottom;
        }

        .pay-money .u span.cur:after {
            content: "";
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 0.14rem;
            height: 0.14rem;
            border-radius: 50%;
            background: #ff3728;
        }

        .pay-money,
        .pay {
            height: inherit;
        }

        .jiezhang-box .pay {
            width: 30%;
            background: #ff4a27;
            color: #fff;
            font-size: 0.16rem;
            font-weight: bold;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        .pay span {
            font-size: 0.12rem;
            border: 1px solid #fff;
            border-radius: 20px;
            padding: 0 0.1rem;
        }

        .coupon-dialog {
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            background: rgba(0, 0, 0, 0.3);
            overflow: hidden;
            z-index: 99;
        }

        .dialog-box {
            position: absolute;
            width: 90%;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        .dialog-box img {
            width: 100%;
        }

        .dialog-box .close {
            background: url(https://cdn-novel.iycdm.com/h5/activity-2018-10-26/close.png) center / contain no-repeat;
            width: 0.32rem;
            height: 0.32rem;
            margin: 0 auto;
        }

        .book-item__multi {
            display: flex;
            justify-content: flex-start;
            align-items: flex-start;
            border-bottom: 1px solid #d7d7d7;
            padding: 0 0 0.2rem;
        }

        .book-item__multi img {
            width: 30%;
        }

        .book-item__multi .book-intro__multi {
            padding-left: 0.2rem;
        }

        .book-item__multi .multi-intro {
            line-height: 1.6;
            -webkit-line-clamp: 3;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            overflow: hidden;
            color: #999;
        }

        .d-none {
            display: none;
        }
    </style>
</head>

<body>
<main class="main_box">
    <div class="banner">
        <img src="https://cdn-novel.iycdm.com/h5/activity-2018-10-26/banner.jpg" alt="">
    </div>
    <div class="coupon-box">
        <p class="intro">
            <span>原价365，领券立减50元，仅需315元</span>
            <span class="weight">每天0.8元，全年免费看</span>
        </p>
        <div class="coupon" data-value="{{$discount}}">
                @if($discount == 50)
                    <img src="https://cdn-novel.iycdm.com/h5/activity-2018-10-26/coupon_pick.png" alt="">
                @else
                    <img src="https://cdn-novel.iycdm.com/h5/activity-2018-10-26/coupon_pick_80.png" alt="">
                @endif
        </div>
    </div>
    <div class="coupon-box">
        <img src="https://cdn-novel.iycdm.com/h5/activity-2018-10-26/banner2.png" alt="" style="padding-bottom:0.2rem">
    </div>
    <div class="book-list">
        <h3 class="book-list__title">榜单精选
            <span>海量小说任意看</span>
        </h3>
        <div class="book-list__container">
            <div class="book-item book-item__multi">
                <img src="{{$books[0]['cover_url']}}" alt="">
                <div class="book-intro__multi">
                    <h3>{{$books[0]['book_name']}}</h3>
                    <p class="multi-intro">
                        {{$books[0]['book_summary']}}
                    </p>
                </div>
            </div>
            @foreach($books as $k=>$v)
                @if($k>=1)
                <div class="book-item">
                    <h3><span>{{$v['book_category']}}</span>{{$v['book_name']}}</h3>
                    <p class="book-intro">{{$v['book_summary']}}</p>
                </div>
                @endif
            @endforeach
        </div>
    </div>
    <div class="jiezhang">
        <div class="jiezhang-box">
            <div class="pay-money">
                <p class="m"><span>¥</span>365</p>
                <p class="u"><span></span> 使用<i>{{$discount}}</i>元优惠券</p>
            </div>
            <div class="pay">
                <p>立即订购</p>
            </div>
        </div>
    </div>
</main>
<div class="coupon-dialog" style="display:none">
    <div class="dialog-box">
        @if($discount == 80)
            <img src="https://cdn-novel.iycdm.com/h5/activity-2018-10-26/dialog80.png" alt="">
        @else
            <img src="https://cdn-novel.iycdm.com/h5/activity-2018-10-26/dialog50.png" alt="">
        @endif
        <div class="close"></div>
    </div>
</div>
</body>
<script>
    var isget = {{$is_get}}
        isget = parseInt(isget)
    var doc = document
    var d = doc.querySelector('.coupon-dialog')
    var c = doc.querySelector('.close')
    var m = doc.querySelector('.m')
    var v = doc.querySelector('.coupon')
    var u = doc.querySelector('.u')
    var e = doc.querySelector('.u span')
    var p = doc.querySelector('.pay')
    c.addEventListener('click', function (e) {
        e.stopPropagation()
        d.style.display = 'none'
        closeDialog()
    }, false)

    // 是否使用优惠券
    u.addEventListener('click', function () {
        if (e.classList.value) {
            e.classList = ''
            m.innerHTML = '<span>¥</span>365'
        } else {
            e.classList = 'cur'
            var l = 365 - v.getAttribute('data-value')
            m.innerHTML = '<span>¥</span>' + l
        }
    }, false)

    // 订购
    p.addEventListener('click', function () {
        if (e.classList.value) {
            // 使用优惠券
            var  url = "{!! $coupons_url !!}"
            if(url){
                location.href = url;
            }
            console.log('use')
        } else {
            // 不使用优惠券
            var  url = "{!! $url !!}"
            if(url){
                location.href = url;
            }
            console.log('dont')
        }
    }, false)

    function showDialog() {
        var s = document.body.style
        s.overflow = 'hidden'
        d.style.display = 'block'
        // ajax 自动打开领取框
    }
    function closeDialog() {
        document.body.style.overflow = ''
    }
    if(!isget){
        showDialog()
    }
</script>

</html>