<!DOCTYPE html>
<html>
<head>
    <meta charset="gb2312">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="description" content="租售宝优惠券限时疯抢">
    <meta name="keyword" content="租售宝优惠券限时疯抢">
    <title>租售宝优惠券限时疯抢</title>
    <link rel="stylesheet" href="<?php echo $static; ?>/css/index.css">
    <link rel="shortcut icon" type="image/vnd.microsoft.icon" href="<?php echo $static; ?>/favicon.ico">
    <style>
        .fail p {
            padding: 0 50px;
        }

        .rule > ul {
            bottom: 10%;
        }
    </style>
</head>
<body>
<div class="main">
    <img src="<?php echo $static; ?>/img/top.jpg">
    <div class="reset">
        <img src="<?php echo $static; ?>/img/sta.png">
        <div class="ten">
            璀璨十周年，365淘房合肥二手房超越自我，感恩回馈！为房产经纪人送上更专业的丰厚好礼，即日起，每日上午10点至11点，参加本活动，限时秒杀抢租售宝优惠券，你只需动动手指，好礼点到即得！天天抢不停！
        </div>
        <p class="time">· 每日上午 10:00-11:00</p>
        <p class="set">· 面值50元、100元、200元租售宝优惠券</p>
    </div>
    <div class="game">
        <div class="pad">
            <div class="zhuan cf">
                <div class="zp">
                    <img src="<?php echo $static; ?>/img/zp.png" id="rotaryArrow">
                    <img src="<?php echo $static; ?>/img/arr.png" id="poo" class="pointer">
                    <img src="<?php echo $static; ?>/img/s.png">
                    <!--//2017-6-22 多次点击 go-->
                    <div class="poocover"></div>
                </div>
                <div class="list">
                    <img src="<?php echo $static; ?>/img/reward.png">
                    <?php if (empty($winner)): ?>
                        <p>还没出现中奖者，期待您赢取大奖！</p>
                    <?php else: ?>
                        <div class="cong">
                            <ul>
                                <?php foreach ($winner as $value): ?>
                                    <li>
                                        <span>恭喜 <?php echo $value['mobile']; ?></span>
                                        <span class="get">获得 <?php echo $value['award_name']; ?></span>
                                    </li>
                                <?php endforeach; ?>
                            </ul>
                        </div>
                    <?php endif; ?>
                    <div class="ac">
                        <button class="tbtn" onclick="ShowPop('normalpop')">查看我的奖品</button>
                    </div>
                </div>
            </div>
            <div class="rule">
                <img src="<?php echo $static; ?>/img/rule.jpg">
                <ul>
                    <li>1.此活动优惠券仅用于半年或半年以上账户套餐，每份合同最多<br>可使用300元优惠券</li>
                    <li>2.此活动优惠券有效期即日起至2017年8月31日</li>
                    <li>3.此活动优惠券，仅用于购买合肥站租售宝套餐</li>
                    <li>4.此活动最终解释权归365淘房二手房所有</li>
                </ul>
            </div>
        </div>
    </div>
    <p class="pub">365淘房二手房出品</p>
</div>
<div class="flow">
    <div class="suc">
        <img src="<?php echo $static; ?>/img/suc.png">
        <i>&nbsp;</i>
        <div class="sus">
            <span>恭喜你抽中</span>
            <p>租售宝优惠券200元</p>
        </div>
        <input type="text" class="name" value="请填写真实姓名" onfocus="if(this.value=='请填写真实姓名'){this.value=''};"
               onblur="if(this.value==''){this.value='请填写真实姓名'}">
        <input type="tel" class="tel" value="请填写手机号码" onfocus="if(this.value=='请填写手机号码'){this.value=''};"
               onblur="if(this.value==''){this.value='请填写手机号码'}">
        <input type="text" class="cop" value="请填写您的公司名称" onfocus="if(this.value=='请填写您的公司名称'){this.value=''};"
               onblur="if(this.value==''){this.value='请填写您的公司名称'}">
        <a></a>
    </div>
    <div class="fail">
        <img src="<?php echo $static; ?>/img/fail.png">
        <i>&nbsp;</i>
        <div class="fa">
            <span>很遗憾</span>
            <p>你未中奖</p>
        </div>
    </div>
</div>
<div class="cover"></div>
<div class="normalpop" style="display: none;">
    <div class="popwap cf">
        <div class="poplist">
            <!--2017-6-23 添加搜索框-->
            <div class="spop">
                <input type="text" value="请填写手机号码" onfocus="if(this.value=='请填写手机号码'){this.value=''};"
                       onblur="if(this.value==''){this.value='请填写手机号码'}" id="mobile"/>
                <button id="search">搜索</button>
            </div>
            <ul>
                <!--                --><?php //if (empty($winner)): ?>
                <!--                    <li class="cf"><span class="fl">很遗憾，您没有中奖</span><span class="fr">2017-6-23</span></li>-->
                <!--                --><?php //else: ?>
                <!--                    --><?php //foreach ($mine as $value): ?>
                <!--                        <li class="cf"><span class="fl">-->
                <?php //echo $value['award_name']; ?><!--</span><span class="fr">2017-6-23</span></li>-->
                <!--                    --><?php //endforeach; ?>
                <!--                --><?php //endif; ?>
            </ul>
        </div>
        <span class="hidepop" onclick="HidePop('normalpop')"></span>
    </div>
</div>
</body>
</html>
<!--[if lt IE 9]>
<script src="<?php echo $static; ?>/js/html5shiv.js"></script>
<![endif]-->
<script src="<?php echo $static; ?>/js/jquery-1.8.2.min.js"></script>
<script src="<?php echo $static; ?>/js/jquery.rotate.min.js"></script>
<script type="text/javascript">
    $(function () {
        var $rotaryArrow = $('#rotaryArrow');
        var $poo = $('#poo');
        var flag = 0;
        $poo.on("click", function () {
            $.ajax({
                url: "/lottery/ajaxRun",
                type: "post",
                dataType: "json",
                error: function () {
                    alert("网络错误，请重试");
                },
                success: function (result) {
                    if (result.status === 0) {
                        //2017-6-21 黑色遮罩
                        var bh = $(window).height();
                        var bw = $(window).width();
                        $(".flow").css({
                            height: 2 * bh,
                            width: bw,
                            display: "block"
                        });
                        //2017-6-21 黑色遮罩
                        $(".suc,.fail").hide();
                        $(".fail span").html("");
                        $(".fail p").html(result.message);
                        $(".fail").fadeIn();
                        return;
                    }
                    if (result.status === 1) {
//                        var data = [1, 2, 3, 4, 5, 6, 6];
//                        var ii = Math.round(Math.random() * 6);
//                        data = data[ii];
                        $(".poocover").show();//2017-6-22 多次点击 go
                        $(this).css("opacity", 0.5);
                        setTimeout(function () {
                            $poo.css("opacity", 1);
                        }, 3500);
                        var data = result.data;
                        switch (data) {
                            case 1:
                                rotateFunc(1, 60, '租售宝优惠券50元');
                                break;
                            case 2:
                                rotateFunc(2, 120, '谢谢');
                                break;
                            case 3:
                                rotateFunc(3, 180, '租售宝优惠券200元');
                                break;
                            case 4:
                                rotateFunc(4, 240, '谢谢');
                                break;
                            case 5:
                                rotateFunc(5, 300, '租售宝优惠券50元');
                                break;
                            case 6:
                                rotateFunc(6, 360, '租售宝优惠券100元');
                                break;
                        }
                    }
                }
            });
        });
        var rotateFunc = function (awards, angle, text) {  //awards:奖项，angle:奖项对应的角度
            $rotaryArrow.stopRotate();
            $rotaryArrow.rotate({
                angle: 0,
                duration: 5000,
                animateTo: angle + 1440,  //angle是图片上各奖项对应的角度，1440是让指针固定旋转4圈
                callback: function () {
                    //2017-6-21 黑色遮罩
                    var bh = $(window).height();
                    var bw = $(window).width();
                    $(".flow").css({
                        height: 2 * bh,
                        width: bw,
                        display: "block"
                    });
                    //2017-6-21 黑色遮罩
                    $(".suc,.fail").hide();
                    if (awards == 1 || awards == 3 || awards == 5 || awards == 6) {
                        $(".suc").fadeIn();
                        $(".sus > p").text(text);
                    } else {
                        $(".fail").fadeIn();
                    }
                    flag = 1;
                }
            });
        };
        $(".suc i, .fail i").click(function () {
            $(".flow").hide();
            $(".poocover").hide();//2017-6-22 多次点击 go
        });
        $(".suc a").click(function () {//表单提交
            var inputName = $.trim($(".name").val());
            var inputMobile = $.trim($(".tel").val());
            var inputCompany = $.trim($(".cop").val());
            if (inputName === "") {
                alert("请填写真实姓名");
                return;
            }
            if (inputMobile === "") {
                alert("请填写手机号码");
                return;
            }
            if (inputMobile.length !== 11) {
                alert("请填写正确的手机号码");
                return;
            }
            if (inputMobile.substring(0, 1) !== "1") {
                alert("请填写正确的手机号码");
                return;
            }
            if (inputCompany === "") {
                alert("请填写公司名称");
                return;
            }
            $.ajax({
                url: "/lottery/ajaxBook",
                type: "post",
                dataType: "json",
                data: {
                    name: inputName,
                    mobile: inputMobile,
                    company: inputCompany
                },
                error: function () {
                    alert("网络错误，请重试");
                },
                success: function (result) {
                    if (result.status === 1) {
                        $(".flow").hide();
                        $(".poocover").hide();//2017-6-22 多次点击 go
                        $(".suc,.fail").hide();
                        window.location.reload();
                        return;
                    }
                    alert(result.message);
                }
            });
        });
        $("#search").on("click", function () {
            var mobileNumber = $.trim($("#mobile").val());
            if (mobileNumber.length !== 11 || mobileNumber.substring(0, 1) !== "1") {
                $(".poplist ul").html('<li class="cf"><span class="fl">请输入正确的手机号</span><span class="fr"></span></li>');
                return;
            }
            $.ajax({
                url: "/lottery/ajaxMine",
                type: "post",
                dataType: "json",
                data: {
                    mobile: mobileNumber
                },
                error: function () {

                },
                success: function (result) {
                    var dataLength = result.data.length;
                    if (dataLength > 0) {
                        var html = "";
                        for (var index = 0; index < dataLength; index++) {
                            html += '<li class="cf"><span class="fl">' + result.data[index]['award_name'] + '</span><span class="fr">' + result.data[index]['time'] + '</span></li>';
                        }
                        $(".poplist ul").html(html);
                    } else {
                        $(".poplist ul").html('<li class="cf"><span class="fl">很遗憾，您没有中奖</span><span class="fr"></span></li>');
                    }
                }
            });
        });
        if ("<?php echo $status; ?>" !== "1") {
            $poo.css("opacity", 0.5);
        }
    });

    function ShowPop(show) {
        var bh = $(window).height();
        var bw = $(window).width();
        $(".cover").css({
            height: 2 * bh,
            width: bw,
            display: "block"
        });
        var name = show;
        var t = 612;
        var l = 750;
        $("." + show).css({
            "top": (bh - t) / 2,
            "left": (bw - l) / 2
        });
        $("." + show).fadeIn(500);

    }

    function HidePop(show) {
        $(".cover").fadeOut(100);
        $("." + show).fadeOut(500);
    }
</script>