index.html 9.93 KB
<!DOCTYPE html >
<html>
<head>
    <meta charset="UTF-8">
    <title>{$redname}</title>
    <include file="public/header"/>
    <link rel="stylesheet" href="__STATIC__/css/redbag.css?v=2018031001" type="text/css">

<body>
<div class="redware" style="padding-bottom: 0;">
    <div class="ofn">由{$tpshop_config['shop_info_store_title']}发起抢红包</div>
    <a class="redbag_ware" href="javascript:void(0);">
        <img class="redbag_btn" src="__STATIC__/images/redbag/redbag_btn.png" alt="">
    </a>
    <div style="position: relative">
        <img class="redbagtit" src="__STATIC__/images/redbag/indexbot.png" alt="">
        <div class="itmeboxwz">离活动开始时间还有</div>
        <ul class="timeboxware" id="fday">
            <li><img class="timebox" src="__STATIC__/images/redbag/timebox.png" alt=""><span class="num" id="day">00天</span></li>
            <li><img class="timebox" src="__STATIC__/images/redbag/timebox.png" alt=""><span class="num" id="hour">00时</span></li>
            <li><img class="timebox" src="__STATIC__/images/redbag/timebox.png" alt=""><span class="num" id="mini">00分</span></li>
            <li><img class="timebox" src="__STATIC__/images/redbag/timebox.png" alt=""><span class="num" id="sec">00秒</span></li>
        </ul>
    </div>
</div>
</body>
<script>
    var Tday = new Array();
    var daysms = 24 * 60 * 60 * 1000
    var hoursms = 60 * 60 * 1000
    var Secondms = 60 * 1000
    var microsecond = 1000
    var DifferHour = -1
    var DifferMinute = -1
    var DifferSecond = -1
    function clock11(key) {
        var time = new Date()
        var hour = time.getHours()
        var minute = time.getMinutes()
        var second = time.getSeconds()
        var timevalue = "" + ((hour > 12) ? hour - 12 : hour)
        timevalue += ((minute < 10) ? ":0" : ":") + minute
        timevalue += ((second < 10) ? ":0" : ":") + second
        timevalue += ((hour > 12 ) ? " PM" : " AM")
        var convertHour = DifferHour
        var convertMinute = DifferMinute
        var convertSecond = DifferSecond
        var Diffms = Tday[key].getTime() - time.getTime()
        DifferHour = Math.floor(Diffms / daysms)
        Diffms -= DifferHour * daysms
        DifferMinute = Math.floor(Diffms / hoursms)
        Diffms -= DifferMinute * hoursms
        DifferSecond = Math.floor(Diffms / Secondms)
        Diffms -= DifferSecond * Secondms
        var dSecs = Math.floor(Diffms / microsecond)

        if (convertHour != DifferHour) e = "<li><img class='timebox' src='__STATIC__/images/redbag/timebox.png' alt=''><span class='num' id='day'>" + DifferHour + "天</span></li>";
        if (convertMinute != DifferMinute) f ="<li><img class='timebox' src='__STATIC__/images/redbag/timebox.png' alt=''><span class='num' id='day'>" + DifferMinute + "时</span></li>";
        if (convertSecond != DifferSecond) g = "<li><img class='timebox' src='__STATIC__/images/redbag/timebox.png' alt=''><span class='num' id='day'>" + DifferSecond + "分</span></li>";
        h = "<li><img class='timebox' src='__STATIC__/images/redbag/timebox.png' alt=''><span class='num' id='day'>" + dSecs + "秒</span></li>";
        if (DifferHour > 0) { e = e}
        else {  e = '' }
        document.getElementById(key).innerHTML = e + f + g + h;
    }
</script>
<script type="text/javascript">
    $(function () {
        var k_rednum={$k_rednum};
        var getwks={$wks};
        var gethdend="{$hdend}";
//
        if (gethdend==0) {
            if (getwks == 1) {
                Tday['fday'] = new Date('{$red_res.start_time|date="Y/m/d H:i:s",###}');
                $(".itmeboxwz").html("离活动开始时间还有");
            } else {
                Tday['fday'] = new Date('{$red_res.end_time|date="Y/m/d H:i:s",###}');
                $(".itmeboxwz").html("离活动结束时间还有");
            }
            window.setInterval(function () {
                clock11('fday');
            }, 1000);
        }

        //页面层
        $(".redbag_ware").click(function () {

           if (getwks==1)
           {
               layer.open({content: "活动未开始!", time: 1});
               return false;
           }

            var getredid="{$red_res.id}";
            var getk_rednum1="{$k_rednum1}";
            var getstoid="{$stoid}";
            if (gethdend==1)
            {
                layer.open({content: "活动已结束或未启用!", time: 1});
                return false;
            }
            if (getk_rednum1==1)
            {
                layer.open({
                    type: 1,
                    content: '<div class="layhb">    <img class="hbtit" src="__STATIC__/images/redbag/hbtit2.png" alt=""><div class="msg">来晚了,红包总金额已抢空</div><a href="/index.php/mobile/Redbag/redrec/stoid/'+getstoid+'/rec_id/'+getredid+'.html"><div class="go">看看大家的手气></div></a></div>',
                    anim: 'up',
                    style: 'position:fixed; top:15%; left:50%; margin-left:-160px; width:320px; height: auto; padding:10px 0; border:none;background-color:rgba(255,255,255,0);'
                });
                return false;
            }
            if (k_rednum==0)
            {
                layer.open({
                    type: 1,
                    content: '<div class="layhb">    <img class="hbtit" src="__STATIC__/images/redbag/hbtit2.png" alt=""><div class="msg">手慢了,红包抢完了</div><a href="/index.php/mobile/Redbag/redrec/stoid/'+getstoid+'/rec_id/'+getredid+'.html"><div class="go">看看大家的手气></div></a></div>',
                    anim: 'up',
                    style: 'position:fixed; top:15%; left:50%; margin-left:-160px; width:320px; height: auto; padding:10px 0; border:none;background-color:rgba(255,255,255,0);'
                });

                return false;
            }
            if (k_rednum==2)
            {
                layer.open({
                    type: 1,
                    content: '<div class="layhb">    <img class="hbtit" src="__STATIC__/images/redbag/hbtit2.png" alt=""><div class="msg">您抢红包的次数已用完</div><a href="/index.php/mobile/Redbag/redrec/stoid/'+getstoid+'/rec_id/'+getredid+'.html"><div class="go">看看大家的手气></div></a></div>',
                    anim: 'up',
                    style: 'position:fixed; top:15%; left:50%; margin-left:-160px; width:320px; height: auto; padding:10px 0; border:none;background-color:rgba(255,255,255,0);'
                });

                return false;
            }



            if (getredid<=0)
            {
                layer.open({content: "参数有误,无法抢红包!", time: 1});
                return false;
            }
            layer.open({type:2});
            $.ajax({
                type: "GET",
                dataType: 'json',
                url: "/index.php?m=Mobile&c=Redbag&a=robred&stoid=" + getstoid+"&redid="+getredid,
                success: function (data) {
                    layer.closeAll();
                    if(data.code==1) {

                        var usermoney=data.usermoney;
                        var rec_id=data.frombillid;
                        var getbgimg="__STATIC__/images/redbag/hbtit.png";
                        var getanurl='<a href="/index.php/mobile/Redbag/redlist/stoid/'+getstoid+'/rec_id/'+rec_id+'.html"><img class="srhb" src="__STATIC__/images/redbag/srhb.png" alt=""></a>';
                        if (usermoney==0)
                        {
                            getbgimg="__STATIC__/images/redbag/hbtit2.png";
                            getanurl='<a href="/index.php/mobile/Redbag/index/stoid/'+getstoid+'/rec_id/'+rec_id+'.html"><img class="srhb" src="__STATIC__/images/redbag/srhb2.png" alt=""></a>';
                            usermoney="";
                        }

                        layer.open({
                            type: 1,
                            content: '<div class="layhb">    <img class="hbtit" src="'+getbgimg+'" alt="">'+getanurl+'<div class="price">'+usermoney+'</div></div>',
                            anim: 'up',
                            style: 'position:fixed; top:15%; left:50%; margin-left:-160px; width:320px; height: auto; padding:10px 0; border:none;background-color:rgba(255,255,255,0);'
                        });

                    }else if (data.code==-2){
                        layer.open({
                            type: 1,
                            content: '<div class="layhb">    <img class="hbtit" src="__STATIC__/images/redbag/hbtit2.png" alt=""><div class="msg">'+data.msg+'</div><a href="/index.php/mobile/Redbag/redrec/stoid/'+getstoid+'/rec_id/'+getredid+'.html"><div class="go">看看大家的手气></div></a></div>',
                            anim: 'up',
                            style: 'position:fixed; top:15%; left:50%; margin-left:-160px; width:320px; height: auto; padding:10px 0; border:none;background-color:rgba(255,255,255,0);'
                        });
                        setTimeout(function () {
                            location.href=location.href;
                        },2000);
                        //layer.open({content:data.msg,time:1});
                    }
                    else
                    {
                        layer.open({
                            type: 1,
                            content: '<div class="layhb">    <img class="hbtit" src="__STATIC__/images/redbag/hbtit2.png" alt=""><div class="msg">'+data.msg+'</div><a href="/index.php/mobile/Redbag/redrec/stoid/'+getstoid+'/rec_id/'+getredid+'.html"><div class="go">看看大家的手气></div></a></div>',
                            anim: 'up',
                            style: 'position:fixed; top:15%; left:50%; margin-left:-160px; width:320px; height: auto; padding:10px 0; border:none;background-color:rgba(255,255,255,0);'
                        });
                    }
                },
                error: function () {
                    layer.open({content:'网络繁忙,请重试',time:1});
                }
            })








        })
    })


</script>

</html>