<!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=no"
    />
    <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;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        }

        html {
            background: #f7e7cb;
        }

        p {
            margin: 0;
        }

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

        .main_box img {
            width: 100%;
        }

        .container-wrap {
            position: absolute;
            width: 80%;
            top: 38%;
            left: 50%;
            -webkit-transform: translate(-50%, 0);
            transform: translate(-50%, 0);
        }

        .recharge-wrap {
            margin-bottom: 0.2rem;
        }

        .recharge-wrap .recharge-item:not(:last-child) {
            margin-bottom: 0.2rem;
        }
    </style>
</head>

<body>
<main class="main_box">
    <img src="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/bg.jpg" alt="" />
    <div class="container-wrap">
        <div class="recharge-wrap">
            <div class="recharge-item cur">
                <img
                        src="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/btn1-active-new.png"
                        data-src="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/btn1-new.png"
                        data-active="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/btn1-active-new.png"
                        data-active-status="1"
                        data-href="{{$url[0]}}"
                        alt=""
                />
            </div>
            <div class="recharge-item">
                <img
                        src="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/btn2.png"
                        data-src="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/btn2.png"
                        data-active="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/btn2-active.png"
                        data-active-status="0"
                        data-href="{{$url[1]}}"
                        alt=""
                />
            </div>
            <div class="recharge-item">
                <img
                        src="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/btn3.png"
                        data-src="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/btn3.png"
                        data-active="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/btn3-active.png"
                        data-active-status="0"
                        data-href="{{$url[2]}}"
                        alt=""
                />
            </div>
        </div>
        <div class="to-recharge">
            @if($code == 0)
                <img src="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/doing.png" alt="" id="pay" data-href="{{$url[0]}}"/>
            @elseif($code == -1)
                <img src="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/undo.png" alt="" />
            @else
                <img src="https://cdn-novel.iycdm.com/h5/activity-2019-07-10/done.png" alt="" />
            @endif


        </div>
    </div>
</main>
</body>
<script src="//cdn-novel.iycdm.com/static/jquery-3.4.1.min.js"></script>
<script>
    // 按钮点击
    $(".recharge-wrap").delegate("img", "click", function() {
        $(".recharge-item").removeClass("cur");
        $(this)
                .parent()
                .addClass("cur");
        var active = $(this).attr("data-active");
        var is_active = $(this).attr("data-active-status");
        if (!+is_active) {
            reset();
            $(this).attr("src", active);
            $(this).attr("data-active-status", 1);
            $("#pay").attr("data-href",$(this).attr("data-href"))
        }
    });

    // 重置
    function reset() {
        var imgs = $(".recharge-item img");
        for (var i = 0; i < imgs.length; i++) {
            (function(index) {
                var img = imgs[i];
                var src = $(img).attr("data-src");
                $(img).attr("src", src);
                $(img).attr("data-active-status", 0);
            })(i);
        }
    }

    // 重置
    $(".to-recharge").delegate("#pay", "click", function() {
        var url = $(this).attr("data-href");
        if(url){
            location.href=url
        }else{
            return false;
        }
    });
</script>
</html>
