<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi" />
    <meta name="screen-orientation" content="portrait">
    </meta>
    <meta name="description" content="印象之旅 11·18 无敌优惠券正在放送中,赶紧打开抢购,数量有限,先到先得。">
    <meta name="x5-orientation" content="portrait">
    </meta>
    <!--    <link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon" />-->
    <link rel="stylesheet" href="../css/GT_activities.css">
    <link rel="stylesheet" href="../css/GT_activities2.css" media="screen" type="text/css" />
    <div id='wx_pic' style='margin:0 auto;display:none;'>
        <img src='../images/18logo.png' />
    </div>
    <script type="text/javascript" src="../js/autosize2.js"></script>
    <script type="text/javascript" src="../js/jquery-1.10.2.js"></script>
    <title>印象之旅11.18同业回馈日</title>
</head>

<body>
    <div id="box">
        <div class="Noticewarp" id="demo">
            <div class="scroll" id="demo1">
            </div>
            <div id="demo2"></div>
        </div>
        <div class="wx_bg">
            <img src="../images/qsywx.png" alt="" />
        </div>
        <div class="box_title">
            <img src="../images/G@3x.png" alt="" class="G_img">
            <h5>

            </h5>
            <div style="width: 90%;height: 1px;background: #C72220;margin: 0 auto"></div>
            <div class="box_limit">
                <p class="box_text">限</p>

                <div class="dataStatistics">

                    <div class="digit_set"></div>
                    <div class="digit_set"></div>
                    <div class="digit_set"></div>
                    <div class="digit_set set_last"></div>

                </div>

                <div class="deta_replace">
                    <div class="replace_box">
                        <div class="replace_top"></div>
                        <div class="replace_bottom"></div>
                        <div class="replace_text">
                            <p>0</p>
                        </div>
                    </div>
                    <div class="replace_box">
                        <div class="replace_top"></div>
                        <div class="replace_bottom"></div>
                        <div class="replace_text">
                            <p>0</p>
                        </div>
                    </div>
                    <div class="replace_box">
                        <div class="replace_top"></div>
                        <div class="replace_bottom"></div>
                        <div class="replace_text">
                            <p>0</p>
                        </div>
                    </div>
                    <div class="replace_box">
                        <div class="replace_top"></div>
                        <div class="replace_bottom"></div>
                        <div class="replace_text">
                            <p>0</p>
                        </div>
                    </div>
                </div>

                <p class="box_text">张</p>
            </div>
        </div>

        <div class="box_content">
            <div class="margin_T" style="margin-top:1.80rem;"></div>
            <div class="box_title_2">
                <p></p>
            </div>
            <div class="box_content_t">
                <p class="t_name" id="t1"></p>
                <p class="t_name" id="p"></p>
                <p class="t_name" id="t2" style="margin-right: 0.1rem">天</p>

                <div class="time_view">
                    <p id="p1"></p>
                </div>
                <p style="font-size: 0.16rem; color: white;margin: 0 0.1rem " id="t3">:</p>
                <div class="time_view">
                    <p id="p2"></p>
                </div>
                <p style="font-size: 0.16rem; color: white;margin: 0 0.1rem" id="t4">:</p>
                <div class="time_view">
                    <p id="p3"></p>
                </div>
                <p style="font-size: 0.16rem; color: white;margin: 0 0.1rem" id="t5"></p>

            </div>
            <div class="img_bg_M">
                <div class="img_bg_text" style="width: 53%; margin-left: 45%;height: 1.18rem;display: flex;flex-direction: column;align-items: center;padding-top: 0.1rem">
                    <p class="img_bg_p1" style="font-size: 0.26rem;color: #E03234;padding-top: 0.1rem;font-weight: bold">线路抵用券</p>
                    <p class="img_bg_p2" style="font-size: 0.13rem;color: #E03234;height: 0.2rem;"></p>
                    <div class="img_btn">
                        <p></p>
                    </div>
                    <!-- <div class="img_btn">

                    </div> -->
                </div>

                <img src="../images/received@3x.png" alt="" class="received_img">
                <div class="use_oupon">
                    <div class="use_news">
                        <img src="../images/tx_bg.png" alt="">
                        <div>
                            <p class="use_o"></p>
                            <p class="use_t"></p>
                        </div>
                    </div>
                    <div class="click_use">
                        <p>我的优惠券</p>
                    </div>
                </div>

            </div>

            <div class="app_share">
                <div class="app_sharebox">
                    <p>分享到</p>
                    <img src="../images/wechat_logo@2x.png" alt="" class="app_share_hy">
                    <img src="../images/pengyouquan@2x.png" alt="" class="app_share_pyq">
                </div>
            </div>

            <div class="explain_box">
                <div class="explain">
                    <p></p>
                </div>


            </div>
        </div>
        <div id="notice">

        </div>
        <div class="notice_img">
            <img src="../images/notice_2.png" alt="">
            <p class="notice_name">尊敬的客户</p>
            <p class="notice_content"></p>
            <p class="notice_content2"></p>
            <div class="c_close">
                <p>我知道了</p>
            </div>
        </div>
    </div>


    <!--<script type="text/javascript" src="js/countdown.js"></script>-->
    <script type="text/javascript" src="../js/md5.js"></script>
    <script type="text/javascript" src="../js/mian.js"></script>
    <script src="../js/jquery.dataStatistics.js?r=1354341"></script>
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
    <script type="text/javascript" src="../js/layer/layer.js"></script>
    <script type="text/javascript" src="../js/yql.js"></script>

    <script>
        //横向滚动-->
        var demo = document.getElementById("demo");
        var demo1 = document.getElementById("demo1");
        var demo2 = document.getElementById("demo2");
        var myvar = null;
        var lastRequestTime = null;
        demo2.innerHTML = document.getElementById("demo1").innerHTML;

        function Marquee() {
            if (demo.scrollLeft - demo2.offsetWidth >= 0) {
                demo.style.display = "none";
                clearInterval(myvar);
            } else {
                demo.scrollLeft++;
            }
        }


        function getTicketList(couponId) {
            let minTimer = 1 * 60 * 1000;
            let maxTimer = 5 * 60 * 1000;
            let selectTime = -1;
            if (this.lastRequestTime) {
                selectTime = this.lastRequestTime;
            }
            let msg = {
                selectTime: selectTime,
                CouponId: couponId
            }
            $.ajax({
                type: "POST",
                url: `${getApiUrl().urlPost}`,
                contentType: "application/json",
                data: getAjaxData("sellorder_get_GetCounponOrderRedis", msg),
                async: false,
                success: function(res) {
                    if (res.resultCode === 1) {
                        let dataList = res.data;
                        let CountLen = dataList.length;
                        var TotalSecond = CountLen * 8 * 1000;
                        if (TotalSecond > maxTimer) {
                            TotalSecond = maxTimer;
                        } else if (TotalSecond < minTimer) {
                            TotalSecond = minTimer;
                        }
                        var str = ''
                        for (var i = 0; i < dataList.length; i++) {
                            if(!dataList[i].customerPhoto){
                                dataList[i].customerPhoto = '../images/tx_bg.png'
                            }
                            str += `<a href="javascript:void(0);">
                                    <img src="${dataList[i].customerPhoto}"/>
                                    ${dataList[i].customerName}抢到了优惠券
                                </a>`
                        }
                        if (str != '') {
                            $('#demo1').html(str);
                            demo.style.display = "block";
                            demo.scrollLeft -= demo1.offsetWidth;
                            myvar = setInterval(Marquee, 25);
                            console.log(demo.scrollLeft)
                        }
                        setTimeout(() => {
                            getTicketList(couponId);
                        }, TotalSecond);
                    }
                },
                error: function(res) {

                }
            })
            var date = new Date();
            var d = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
            this.lastRequestTime = d
        }

        let href = window.location.href;
        // let href='https://127.0.0.1:5500/html/GT_activities.html?customerId=1549&accountId=1182&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1NzM0NjY2NjMuMCwiZXhwIjoxNTczNTUzMDYzLjAsInVzZXJJbmZvIjp7InVpZCI6IjExODIiLCJyZXF1ZXN0RnJvbSI6NH19.hX2b2MqSWYmWS0k3YsthxW-T6UxarIm5rdbqCVQtxdQ&secretKey=5d5e16254bd741c486fe2b83b42171d2&platform=app';
        let login = true; //判断是否登录
        let userInfo = {};
        let platform = "H5";
        if (localStorage.u) {
            try {
                userInfo = JSON.parse(localStorage.u);
                if (!userInfo.customerId) {
                    userInfo = {
                        token: 'token',
                        accountId: '-1'
                    }
                    login = false
                        // window.location.href = 'https://activity.oytour.com/html/login.html';
                }
            } catch (e) {
                userInfo = {
                        token: 'token',
                        accountId: '-1'
                    }
                    // window.location.href = 'https://activity.oytour.com/html/login.html';
                login = false
            }
        } else {


            // 如果进入页面没有登录的参数 处理跳到h5页面登录
            if (href.split('?')[1]) {

                if (href.split('?')[1].indexOf('customerId') == -1 || href.split('?')[1].indexOf('accountId') == -1 ||
                    href.split('?')[1].indexOf('token') == -1 || href.split('?')[1].indexOf('secretKey') == -1 ||
                    href.split('?')[1].indexOf('platform') == -1) {
                    // window.location.href = 'https://activity.oytour.com/html/login.html';
                    userInfo = {
                        token: 'token',
                        accountId: '-1'
                    }
                    login = false
                } else {
                    let param = href.split('?')[1].split("&") ? href.split('?')[1].split("&") : null;
                    userInfo = {
                        customerId: param[0].split('=')[1],
                        accountId: param[1].split('=')[1],
                        token: param[2].split('=')[1],
                        secretKey: param[3].split('=')[1]
                    }
                    platform = param[4].split('=')[1] //获取从哪里跳过来的

                }
            } else {
                // window.location.href = 'https://activity.oytour.com/html/login.html';
                userInfo = {
                    token: 'token',
                    accountId: '-1'
                }
                login = false

            }

        }

        if(login == true){


        }
        var ua = navigator.userAgent.toLowerCase();

        if (platform == 'H5' && ua.match(/MicroMessenger/i) != "micromessenger") {
            // $('.wx_bg').css('display', "block");
        } else if (platform == 'H5') {
            this.initOpenid()
        }

        var end = '';
        var currentTime = '';
        localStorage.userInfo = JSON.stringify(userInfo)

        if (platform == 'app') {
            $('.app_share').css('display', "block");

        }
        if (login == false) {

            $('.click_use p').html('立即登录');
        }

            $.ajax({
                type: "POST",
                url: `${getApiUrl().urlJava}api/appActivity/getUserPurchaseTime`,
                contentType: "application/json",
                data: getJavaData({}),
                async: false,

                success: function(res) {
                    if (res.resultCode === 1) {
                        getTicketList(res.data.couponId);

                        let num = res.data.repertory; //优惠券总共数量
                        // let num = 5000; //优惠券总共数量
                        $('.box_title_2 p').html(res.data.redemptionPrice + '元抢购');
                        $('.box_title h5').html(res.data.remark);

                        $('.explain p').html('活动规则' + '<br/>' + res.data.instructions);
                        if (login == false) {
                            $('.use_o').html('暂无登录');
                        } else {
                            $('.use_o').html(res.data.contact);
                        }

                        $('.use_t').html(res.data.customerName);

                        let activityStartDate = new Date(res.data.activityStartDate.replace('T', ' ').replace(/-/g, '/')).getTime(); //活动开始时间
                        let activityEndDate = new Date(res.data.activityEndDate.replace('T', ' ').replace(/-/g, '/')).getTime(); //活动结束时间
                        let nowDate = new Date(res.data.currentTime.replace('T', ' ').replace(/-/g, '/')).getTime(); //服务器时间

                        $('.dataStatistics').dataStatistics({
                            max: num,
                            min: num,
                            len: 4,
                            add: true,
                            price: res.data.redemptionPrice,
                            couponId: res.data.couponId,
                            platform: platform,
                            login: login,
                            count: res.data.count, //判断是否可以抢购 0为不可以
                            activityStartDate:activityStartDate,
                            activityEndDate:activityEndDate,
                        }); //刚进入页面不执行动画




                        // let activityStartDate = new Date('2019/11/08 17:43:50').getTime();
                        // let activityEndDate = new Date('2019/11/14 11:23:00').getTime();  //活动结束时间
                        let nextActivity = res.data.nextActivity;
                        if (nextActivity != null) {

                            let nexttime = nextActivity.activityStartDate;
                            let year = nexttime.split('T')[0].split('-')[0];
                            let month = nexttime.split('T')[0].split('-')[1];
                            let day = nexttime.split('T')[0].split('-')[2];
                            let hour = nexttime.split('T')[1].split(':')[0];
                            $('.notice_content').html('下期活动将于' + year + '年' + month + '月' + day + '日' + hour + '点开始。');
                            $('.notice_content2').html('届时会有' + nextActivity.couponCount + '张价值' + nextActivity.denomination + '的折扣券等待您的抢 购(抢购价' + nextActivity.redemptionPrice + '元),请准时参加。');
                            // var time2 = setInterval(setTimer3, 1000); //计时器
                            let beforeDawn = new Date(year + '/' + month + '/' + day + ' 00:00:00').getTime()
                            let time = ((beforeDawn - nowDate) / 1000).toFixed(0);
                            runtime(time)

                        }

                        //判断当前时间是否到了抢购时间
                        if (activityStartDate >= nowDate) { //没到抢购时间 显示抢购的具体时间

                            $('#t1').html('抢购时间:');
                            $('#t2').html('');
                            let startDate = res.data.activityStartDate;
                            let month = startDate.split('T')[0].split('-')[1];
                            let day = startDate.split('T')[0].split('-')[2];
                            let hour = startDate.split('T')[1].split(':')[0];
                            $('#p1').html(month);
                            $('#p2').html(day);
                            $('#p3').html(hour);
                            $('#t3').html('月');
                            $('#t4').html('日');
                            $('#t5').html('点整');
                            $('.img_btn p').html('立即抢购');
                            $('.img_btn').css("background-image", "url(../images/nobuy_btn.png)");

                            $('.img_btn p').css("color", "#FFFFFF");
                            // $(".received_img").attr("src", "");
                            let time = ((activityStartDate - nowDate) / 1000).toFixed(0);
                            runtime(time)

                        } else if (nowDate > activityEndDate || res.data.activityIsEnding == 1) { // 活动时间已过

                            // $(".received_img").attr("src", "");
                            $('.img_bg_M').css("background-image", "url(../images/MJ_200@3x.png)");
                            $('.img_bg_p1').css("color", "#CCCCCC");
                            $('.img_bg_p2').css("color", "#CCCCCC");
                            $('.img_btn p').css("color", "#FFFFFF");
                            $('.img_btn p').html('活动结束')
                            $('.box_content_t').hide()
                            $('.img_btn').css("background-image", "url(../images/nobuy_btn.png)");

                            $('.dataStatistics').css('display', "none");
                            $('.deta_replace').css('display', "flex");
                            $('#notice').css('display', "block");
                            $('.notice_img').css('display', "block");



                        } else { // 到了抢购的时间显示距离结束时间的倒计时

                            currentTime = res.data.currentTime.replace('T', ' ').replace(/-/g, '/');
                            end = res.data.activityEndDate.replace('T', ' ').replace(/-/g, '/');
                            if (num > 0) {
                                $('#t1').html('结束倒计时:')
                                if (res.data.count != 0) {
                                    // $(".received_img").attr("src", "");

                                    $('.img_btn p').html('立即抢购');

                                } else {
                                    $('.img_btn p').html('去使用');
                                    $(".received_img").css('display', "block");
                                    $('.img_btn').css("background-image", "url(../images/buy_btn.png)");

                                }
                            } else {

                                // $(".received_img").attr("src", "");
                                $('.img_bg_M').css("background-image", "url(../images/MJ_200@3x.png)");
                                $('.img_bg_p1').css("color", "#CCCCCC");
                                $('.img_bg_p2').css("color", "#CCCCCC");
                                $('.img_btn p').css("color", "#FFFFFF");
                                $('.img_btn p').html('活动结束')
                                $('.box_content_t').hide()
                                $('.img_btn').css("background-image", "url(../images/nobuy_btn.png)");
                                $('.dataStatistics').css('display', "none");
                                $('.deta_replace').css('display', "flex");
                                $('#notice').css('display', "block");
                                $('.notice_img').css('display', "block");

                            }

                        }

                        //优惠券的有限时间
                        let expirationDate = (res.data.expirationDate).split('T')[0].replace(/-/g, '.');
                        let title = $('.img_bg_p1').text()
                        let RushbuyTime = {
                            RushbuyTime: expirationDate,
                            title: title,
                        }
                        localStorage.RushbuyTime = JSON.stringify(RushbuyTime)
                        $('.img_bg_p2').html('有效期截止:' + expirationDate)

                    } else {
                        $('.dataStatistics').dataStatistics({
                            max: 0,
                            min: 0,
                            len: 4,
                            add: true
                        }); //刚进入页面不执行动画

                    }
                    // clearInterval(xhtime)
                },
                error: function(res) {
                    layer.msg(res.message)
                    $('.dataStatistics').dataStatistics({
                        max: 0,
                        min: 0,
                        len: 4,
                        add: true
                    }); //刚进入页面不执行动画

                }
            });




        //时间为一位数时显示格式为:"0X"
        function checkTime(i) {
            if (i < 10) {
                i = "0" + i;
            }
            return i;
        }


        //服务器现在的时间(这里只是测试,就用浏览器时间代替)
        var startTime = '';
        //活动截止时间endTime(以服务器时间为标准,即给定的时间)
        // var end = '';
        var endTime = '';
        //活动截止时间(以浏览器时间为标准)
        var browserEndTime = '';
        //距离活动结束还剩余的时间(以浏览器为标准)
        // var plus = (new Date(end).getTime() - new Date(currentTime).getTime());
        var plus = '';
        //倒计时
        function setTimer() {

            if (!plus) {
                //服务器现在的时间(这里只是测试,就用浏览器时间代替)
                startTime = new Date();

                //活动截止时间endTime(预先给定的值)
                // end = end;
                endTime = new Date(end);
                //活动截止时间与当前时间的时间差
                plus = endTime - startTime;
            } else {
                //距离活动结束还剩余的时间,第二次以后就不需要再计算,直接自减即可
                plus -= 1000;
                //更新当前时间(getTime()获取时间转化成毫秒后的数值)
                // startTime = new Date(startTime.getTime() + 1000);
            }

            var day = parseInt(plus / 1000 / 60 / 60 / 24);
            var hour = parseInt(plus / 1000 / 60 / 60) - day * 24;
            var minute = parseInt(plus / 1000 / 60) - parseInt(plus / 1000 / 60 / 60) * 60;
            var second = parseInt(plus / 1000) - parseInt(plus / 1000 / 60) * 60;

            // 如果分钟或小时的值小于10,则在其值前加0,比如如果时间是下午3点20分9秒的话,则显示15:20:09
            // day = checkTime(day);
            hour = checkTime(hour);
            minute = checkTime(minute);
            second = checkTime(second);
            $('#p').html(day)
            $('#p1').html(hour)
            $('#p2').html(minute)
            $('#p3').html(second)
            if (plus <= 1) {
                clearInterval(id);
                window.location.reload()
            }
        }
        //每秒循环一次,刷新活动截止时间与当前时间的时间差
        if (end != '') {
            var id = setInterval(setTimer, 1000);
        }

        function runtime(time) {

            var timer1 = setInterval(increase, 1000);

            function increase() {
                time--;
                if (time < 1) {
                    clearInterval(timer1);
                    window.location.reload()
                    return false;

                }
            }

        }

        function initOpenid() {
            if (!localStorage.openid && window.location.href.indexOf('?') == -1) {
                let reu = encodeURIComponent(window.location.href);
                location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx44c35529819fc345&redirect_uri=${reu}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
            } else if (!localStorage.openid && window.location.href.indexOf('code') != -1) {
                let codes = href.split('?')[1].split("&");
                let url_openid = `https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx44c35529819fc345&secret=2af0d735ab66341bec6c96d97bca2e4e&code=${codes[0].split("=")[1]}&grant_type=authorization_code`
                url_openid = encodeURIComponent(url_openid);
                $.ajax({
                    type: "GET",
                    url: 'https://reborn.oytour.com/api/test/GetHtmlByUrl?urlStr=' + url_openid,
                    async: false,
                    success: function(res) {
                        if (res) {
                            let r = JSON.parse(res);
                            if (r.openid) {
                                localStorage.openid = r.openid
                            }
                        }
                    }
                });
            }
        }

        $('.c_close').click(function() {
            $('#notice').css('display', "none");
            $('.notice_img').css('display', "none");
        })

        // 跳转到我的是优惠券
        $('.click_use').click(function() {
                if (login == true) {
                    if (platform == 'app') {
                        let data = {

                            'action': 'jump', // showToast->一个提示信息 showHud->一个黑色的loading
                            'page': 'mycoupon',
                            'pageData': {

                            }
                        }
                        window.postMessage(JSON.stringify(data));
                    }
                    // 跳转到小程序
                    if (platform == 'xcx') {
                        wx.miniProgram.getEnv(function(res) {
                            window.wx.miniProgram.navigateTo({
                                url: `/pages/member/Coupon/Coupon`,
                            });
                        });
                    }
                    //跳转到h5优惠券
                    if (platform == 'H5') {
                        window.location.href = 'https://activity.oytour.com/html/coupons.html';
                    }
                } else { //  没登录去登录页面登录
                    window.location.href = 'https://activity.oytour.com/html/login.html'
                        // window.location.href = './login.html'
                }

            })
            //点击隐藏提示
            // function hideTips(){
            //     $('.wx_bg').css({'display':'none'})
            // }
        $('.app_share_hy').click(function() { //在app里分享微信好友
            let data = {
                'action': 'share',
                'shareData': {
                    shareType: '0',
                    params: {
                        type: 'news',
                        title: '印象之旅11.18同业回馈日',
                        description: '印象之旅11.18同业回馈日',
                        webpageUrl: 'https://activity.oytour.com/html/GT_activities.html',
                        thumbImage: 'http://imgfile.oytour.com/Static/app1118.png',
                    }

                }
            }

            window.postMessage(JSON.stringify(data));
        })

        $('.app_share_pyq').click(function() { //在app里分享微信朋友圈
            let data = {
                'action': 'share',
                'shareData': {
                    shareType: '1',
                    params: {
                        type: 'news',
                        title: '印象之旅11.18同业回馈日',
                        description: '印象之旅11.18同业回馈日',
                        webpageUrl: 'https://activity.oytour.com/html/GT_activities.html',
                        thumbImage: 'http://imgfile.oytour.com/Static/app1118.png',
                    }

                }
            }

            window.postMessage(JSON.stringify(data));
        })
         setInterval(() => {
             $('.digit_set').empty()
             $.ajax({
                 type: "POST",
                 url: `${getApiUrl().urlJava}api/appActivity/getUserPurchaseTime`,
                 contentType: "application/json",
                 data: getJavaData({}),
                 async: false,

                 success: function(res) {
                     if (res.resultCode === 1) {
                         getTicketList(res.data.couponId);

                         let num = res.data.repertory; //优惠券总共数量
                         // let num = 5000; //优惠券总共数量
                         $('.box_title_2 p').html(res.data.redemptionPrice + '元抢购');
                         $('.box_title h5').html(res.data.remark);

                         $('.explain p').html('活动规则' + '<br/>' + res.data.instructions);
                         if (login == false) {
                             $('.use_o').html('暂无登录');
                         } else {
                             $('.use_o').html(res.data.contact);
                         }

                         $('.use_t').html(res.data.customerName);

                         let activityStartDate = new Date(res.data.activityStartDate.replace('T', ' ').replace(/-/g, '/')).getTime(); //活动开始时间
                         let activityEndDate = new Date(res.data.activityEndDate.replace('T', ' ').replace(/-/g, '/')).getTime(); //活动结束时间
                         let nowDate = new Date(res.data.currentTime.replace('T', ' ').replace(/-/g, '/')).getTime(); //服务器时间

                         $('.dataStatistics').dataStatistics({
                             max: num,
                             min: num,
                             len: 4,
                             add: true,
                             price: res.data.redemptionPrice,
                             couponId: res.data.couponId,
                             platform: platform,
                             login: login,
                             count: res.data.count, //判断是否可以抢购 0为不可以
                             activityStartDate:activityStartDate,
                             activityEndDate:activityEndDate,
                         }); //刚进入页面不执行动画




                         // let activityStartDate = new Date('2019/11/08 17:43:50').getTime();
                         // let activityEndDate = new Date('2019/11/14 11:23:00').getTime();  //活动结束时间
                         let nextActivity = res.data.nextActivity;
                         if (nextActivity != null) {

                             let nexttime = nextActivity.activityStartDate;
                             let year = nexttime.split('T')[0].split('-')[0];
                             let month = nexttime.split('T')[0].split('-')[1];
                             let day = nexttime.split('T')[0].split('-')[2];
                             let hour = nexttime.split('T')[1].split(':')[0];
                             $('.notice_content').html('下期活动将于' + year + '年' + month + '月' + day + '日' + hour + '点开始。');
                             $('.notice_content2').html('届时会有' + nextActivity.couponCount + '张价值' + nextActivity.denomination + '的折扣券等待您的抢 购(抢购价' + nextActivity.redemptionPrice + '元),请准时参加。');
                             // var time2 = setInterval(setTimer3, 1000); //计时器
                             let beforeDawn = new Date(year + '/' + month + '/' + day + ' 00:00:00').getTime()
                             let time = ((beforeDawn - nowDate) / 1000).toFixed(0);
                             runtime(time)

                         }

                         //判断当前时间是否到了抢购时间
                         if (activityStartDate >= nowDate) { //没到抢购时间 显示抢购的具体时间

                             $('#t1').html('抢购时间:');
                             $('#t2').html('');
                             let startDate = res.data.activityStartDate;
                             let month = startDate.split('T')[0].split('-')[1];
                             let day = startDate.split('T')[0].split('-')[2];
                             let hour = startDate.split('T')[1].split(':')[0];
                             $('#p1').html(month);
                             $('#p2').html(day);
                             $('#p3').html(hour);
                             $('#t3').html('月');
                             $('#t4').html('日');
                             $('#t5').html('点整');
                             $('.img_btn p').html('立即抢购');
                             $('.img_btn').css("background-image", "url(../images/nobuy_btn.png)");

                             $('.img_btn p').css("color", "#FFFFFF");
                             // $(".received_img").attr("src", "");
                             let time = ((activityStartDate - nowDate) / 1000).toFixed(0);
                             runtime(time)

                         } else if (nowDate > activityEndDate || res.data.activityIsEnding == 1) { // 活动时间已过

                             // $(".received_img").attr("src", "");
                             $('.img_bg_M').css("background-image", "url(../images/MJ_200@3x.png)");
                             $('.img_bg_p1').css("color", "#CCCCCC");
                             $('.img_bg_p2').css("color", "#CCCCCC");
                             $('.img_btn p').css("color", "#FFFFFF");
                             $('.img_btn p').html('活动结束')
                             $('.box_content_t').hide()
                             $('.img_btn').css("background-image", "url(../images/nobuy_btn.png)");

                             $('.dataStatistics').css('display', "none");
                             $('.deta_replace').css('display', "flex");
                             $('#notice').css('display', "block");
                             $('.notice_img').css('display', "block");



                         } else { // 到了抢购的时间显示距离结束时间的倒计时

                             currentTime = res.data.currentTime.replace('T', ' ').replace(/-/g, '/');
                             end = res.data.activityEndDate.replace('T', ' ').replace(/-/g, '/');
                             if (num > 0) {
                                 $('#t1').html('结束倒计时:')
                                 if (res.data.count != 0) {
                                     // $(".received_img").attr("src", "");

                                     $('.img_btn p').html('立即抢购');

                                 } else {
                                     $('.img_btn p').html('去使用');
                                     $(".received_img").css('display', "block");
                                     $('.img_btn').css("background-image", "url(../images/buy_btn.png)");

                                 }
                             } else {

                                 // $(".received_img").attr("src", "");
                                 $('.img_bg_M').css("background-image", "url(../images/MJ_200@3x.png)");
                                 $('.img_bg_p1').css("color", "#CCCCCC");
                                 $('.img_bg_p2').css("color", "#CCCCCC");
                                 $('.img_btn p').css("color", "#FFFFFF");
                                 $('.img_btn p').html('活动结束')
                                 $('.box_content_t').hide()
                                 $('.img_btn').css("background-image", "url(../images/nobuy_btn.png)");
                                 $('.dataStatistics').css('display', "none");
                                 $('.deta_replace').css('display', "flex");
                                 $('#notice').css('display', "block");
                                 $('.notice_img').css('display', "block");

                             }

                         }

                         //优惠券的有限时间
                         let expirationDate = (res.data.expirationDate).split('T')[0].replace(/-/g, '.');
                         let title = $('.img_bg_p1').text()
                         let RushbuyTime = {
                             RushbuyTime: expirationDate,
                             title: title,
                         }
                         localStorage.RushbuyTime = JSON.stringify(RushbuyTime)
                         $('.img_bg_p2').html('有效期截止:' + expirationDate)

                     } else {
                         $('.dataStatistics').dataStatistics({
                             max: 0,
                             min: 0,
                             len: 4,
                             add: true
                         }); //刚进入页面不执行动画

                     }
                     // clearInterval(xhtime)
                 },
                 error: function(res) {
                     layer.msg(res.message)
                     $('.dataStatistics').dataStatistics({
                         max: 0,
                         min: 0,
                         len: 4,
                         add: true
                     }); //刚进入页面不执行动画

                 }
             });

         },  300000) //5分钟请求一次接口
    </script>
</body>

</html>