<!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 {
            height: 100%;
            background: linear-gradient(to bottom, #ff933c 0%, #ff0000 100%);
            overflow: hidden;
            position: fixed;
        }

        html,
        body {
            margin: 0 auto;
            padding: 0;
            max-width: 450px;
            font-size: 100px;
        }

        a {
            color: currentColor;
            text-decoration: none;
        }

        p {
            margin: 0;
        }

        .main_box {
            font-size: 0;
            /* position: relative; */
            height: 100%;
        }

        .main_box img {
            width: 100%;
        }

        .recharge-list {
            position: absolute;
            width: 90%;
            top: 22%;
            left: 50%;
            transform: translateX(-50%);
            background: white;
            padding: 0.1rem 0;
            height: 10rem;
            border-radius: 0.15rem;
        }

        .active-time {
            font-size: 0.13rem;
            color: #ff6060;
            font-weight: bold;
            text-align: center;
            padding: 0.15rem 0;
        }

        .recharge-item-box {
            display: flex;
        }

        .recharge-item {
            margin-bottom: 0.2rem;
            display: block;
            color: #1b5c00;
            width: 100%;
            height: 0.75rem;
            background: center / contain url(https://cdn-novel.iycdm.com/h5/activity-newuserv2/btn1.png) no-repeat;
            -webkit-tap-highlight-color: transparent;
        }

        .small-bt-left {
            margin-left: 0.15rem;
            margin-right: 0.05rem;
        }

        .small-bt-right {
            margin-right: 0.15rem;
            margin-left: 0.05rem;
        }

        .item2 {
            background-image: url(https://cdn-novel.iycdm.com/h5/activity-newuserv2/btn2.png);
        }

        .item3 {
            background-image: url(https://cdn-novel.iycdm.com/h5/activity-newuserv2/btn3.png);
        }

        .item4 {
            background-image: url(https://cdn-novel.iycdm.com/h5/activity-newuserv2/btn4.png);
        }

        .item1.cur {
            background-image: url(https://cdn-novel.iycdm.com/h5/activity-newuserv2/btn1-active.png);
        }

        .item2.cur {
            background-image: url(https://cdn-novel.iycdm.com/h5/activity-newuserv2/btn2-active.png);
        }

        .item3.cur {
            background-image: url(https://cdn-novel.iycdm.com/h5/activity-newuserv2/btn3-active.png);
        }

        .item4.cur {
            background-image: url(https://cdn-novel.iycdm.com/h5/activity-newuserv2/btn4-active.png);
        }

        .item5 {
            background-image: url(https://cdn-novel.iycdm.com/h5/activity-newuserv2/btn5.png);
        }

        .item5.cur {
            background-image: url(https://cdn-novel.iycdm.com/h5/activity-newuserv2/btn5-active.png);
        }

        .recharge-item span {
            color: #ff6000;
        }

        .recharge-now {
            margin: 0 auto;
            margin-top: 0.4rem;
            width: 100%;
        }

        .recharge-operator {
            font-size: 0.2rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .recharge-operator a {
            color: #0f5eba;
            font-size: 0.16rem;
            border-radius: 0.4rem;
            border: 2px solid #0f5eba;
            padding: 0.1rem 0.2rem;
            text-align: center;
            width: 33%;
        }

        .recharge-operator .to-read {
            background: #0f5eba;
            color: #fff;
        }

        .tips-box {
            position: absolute;
            width: 100%;
            top: 24%;
            left: 50%;
            transform: translateX(-50%);
            font-weight: bold;
        }

        .tips-box .tips-time,
        .tips-box .no-first {
            font-size: 0.14rem;
            text-align: center;
            margin-top: 5px;
            color: #183c6e;
        }

        .bottom-tips {
            color: #183c6e;
            font-size: 0.14rem;
            text-align: center;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .bottom-tips .tips-title {
            margin: 0px 10px;
        }

        .bottom-tips:before {
            content: "";
            display: block;
            width: 35px;
            height: 2px;
            background: #183c6e;
        }

        .bottom-tips:after {
            content: "";
            display: block;
            width: 35px;
            height: 2px;
            background: #183c6e;
        }

        .notice {
            font-size: 0.12rem;
            color: #fcd7a1;
            text-align: center;
        }

        .notice .surplus-time {
            font-size: 0.14rem;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .surplus-time span {
            color: #ffb73a;
            font-size: 0.18rem;
            font-weight: bolder;
            margin: 0 0.05rem;
        }

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

<body>
<main class="main_box">
        <img src="https://cdn-novel.iycdm.com/h5/activity-newuserv2/beij2.png" alt="" />
        <div class="recharge-list">

            <div class="active-time">有效时间:{{$start_time}}至{{$end_time}}</div>
            <div class="recharge-item-box">
                <div class="small-bt-left recharge-item item1" data-href="{{$url['charge'][0]['url']}}"></div>

                <div class="small-bt-right recharge-item item2 cur" data-href="{{$url['charge'][1]['url']}}"></div>
            </div>
            <div class="recharge-item-box">
                <div class="small-bt-left recharge-item item3" data-href="{{$url['charge'][2]['url']}}"></div>
                <div class="small-bt-right recharge-item item4" data-href="{{$url['charge'][3]['url']}}"></div>
            </div>
            @if(isset($url['year']))
                <div style="padding: 0 .1rem">
                    <div class="recharge-item item5" data-href="{{$url['year']['url']}}"></div>
                </div>
            @endif

            <div class="recharge-now">
                @if($code == 0)
                    <a href="{{$url['charge'][1]['url']}}" id="pay" class="pay">
                        <img src="https://cdn-novel.iycdm.com/h5/new-user-20180816/doing.png" alt="">
                    </a>
                @else
                    <a href="#" id="over" class="over">
                        <img src="https://cdn-novel.iycdm.com/h5/new-user-20180816/over.png" alt="">
                    </a>
                @endif
            </div>
        </div>
        <input type="hidden" name="" id="cssurl" value="https://cdn-novel.iycdm.com/h5/activity-newuserv2">
    </main>
</body>
<script>
    var utils = {
        hasClass(el, className) {
            var reg = new RegExp("(^|\\s)" + className + "(\\s|$)");
            return reg.test(el.className);
        },
        addClass(el, className) {
            if (this.hasClass(el, className)) {
                return;
            }
            var newClass = el.className.split(" ");
            newClass.push(className);
            el.className = newClass.join(" ");
        },
        removeClass(el, className) {
            if (!this.hasClass(el, className)) {
                return;
            }
            var reg = new RegExp("(^|\\s)" + className + "(\\s|$)", "g");
            el.className = el.className.replace(reg, " ");
        }
    };

    function clearSelect(target) {
        for (var i = 0; i < target.length; i++) {
            utils.removeClass(target[i], "cur");
        }
    }

    // 选中点击的充值项
    function rechargeSelect() {
        var items = document.querySelectorAll(".recharge-item");
        for (var i = 0; i < items.length; i++) {
            (function(index) {
                items[index].addEventListener(
                        "click",
                        function() {
                            clearSelect(items);
                            utils.addClass(this, "cur");
                            // 返回点击的index 根据这个index做对应的充值操作吧
                            var href = this.getAttribute("data-href");
                            document.querySelector("#pay").setAttribute("href", href);
                        },
                        false
                );
            })(i);
        }
    }

    function init() {
        rechargeSelect();
    }

    function preImage() {
        var prefix = document.querySelector("#cssurl").value;
        for (var i = 0; i < 5; i++) {
            new Image().src = prefix + "/btn" + (i + 1) + ".png";
            new Image().src = prefix + "/btn" + (i + 1) + "-active.png";
        }
    }
    preImage();

    init();
</script>

</html>