<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>精准导购系统企业号应用</title>
    <link rel="stylesheet" href="/static/css/wechat/weui.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/wechat/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="/static/css/wechat/style.css">
</head>

<body ontouchstart>
<header>
    <div class="header">
        <a href="/customer/sea" class="btn-a-back" th:href="@{/customer/sea}"><i class="iconfont">&#xe61f;</i></a>
        <h2>查询条件</h2>
    </div>
</header>

<form id="queryForm" action="/customer/querySea" th:action="@{/customer/querySea}" method="get">

    <div class="weui-cells weui-cells_form mt0">

        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label for="" class="weui-label">开始时间</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="date" value="2017年3月3日" name="startDate" id="startDate"
                       th:value="${(param.startDate==null)?'':param.startDate[0]}"/>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label for="" class="weui-label">结束时间</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="date" value="2017年3月3日" name="endDate" id="endDate"
                       th:value="${(param.endDate==null)?'':param.endDate[0]}"/>
            </div>
        </div>

        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd">
                <label for="" class="weui-label">购房意向</label>
            </div>
            <div class="weui-cell__bd">
                <select class="weui-select" name="buyIntention" id="buyIntention">
                    <option value="" th:selected="${(param.buyIntention==null)?'false':((#strings.isEmpty(param.buyIntention[0])))}">全部客户</option>
                    <option value="1" th:selected="${(param.buyIntention==null)?'false':('3'==param.buyIntention[0])}">
                        A
                    </option>
                    <option value="2" th:selected="${(param.buyIntention==null)?'false':('2'==param.buyIntention[0])}">
                        B
                    </option>
                    <option value="3" th:selected="${(param.buyIntention==null)?'false':('1'==param.buyIntention[0])}">
                        C
                    </option>
                    <option value="4" th:selected="${(param.buyIntention==null)?'false':('4'==param.buyIntention[0])}">
                        D
                    </option>
                    <option value="5" th:selected="${(param.buyIntention==null)?'false':('5'==param.buyIntention[0])}">
                        E
                    </option>
                    <option value="99"
                            th:selected="${(param.buyIntention==null)?'false':('99'==param.buyIntention[0])}">待定
                    </option>
                </select>
            </div>
        </div>
    </div>

    <div class="btn-modify">
        <a class="weui-btn weui-btn_blue" href="javascript:queryForm();">查询</a>
    </div>
</form>


<div id="loadingToast" style="opacity: 0; display: none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast">
        <i class="weui-icon_toast"></i>
        <p class="weui-toast__content" id="toastContent"></p>
    </div>
</div>

<div id="dialogs">
    <!--BEGIN dialog1-->
    <div class="js_dialog" id="iosDialog1" style="opacity: 0; display: none;">
        <div class="weui-mask"></div>
        <div class="weui-dialog">
            <div class="weui-dialog__hd"><strong class="weui-dialog__title">提示</strong></div>
            <div class="weui-dialog__bd" id="alertContent"></div>
            <div class="weui-dialog__ft">
                <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">确认</a>
            </div>
        </div>
    </div>
    <!--END dialog1-->
</div>

<script type="text/javascript" src="/static/js/wechat/zepto.min.js"></script>
<script type="text/javascript" src="/static/js/statistics.js"></script>
<script type="text/javascript" src="/static/js/jquery.charfirst.pinyin.js"></script>
<script type="text/javascript" src="/static/js/sort.js"></script>

<script language="JavaScript">
    function queryForm() {

        var startDateStr = $('#startDate').val();
        var endDateStr = $('#endDate').val();

        $('#dialogs').on('click', '.weui-dialog__btn', function(){
            $(this).parents('.js_dialog').fadeOut(200);
        });

        if ((startDateStr == '' || startDateStr == null || startDateStr == undefined) || (endDateStr == '' || endDateStr == null || endDateStr == undefined)){

            $("#toastContent").text("请选择结束时间和开始时间!");
            var $loadingToast = $('#loadingToast');
            if ($loadingToast.css('display') != 'none') return;
            $loadingToast.fadeIn(100);
            setTimeout(function () {
                $loadingToast.fadeOut(100);
            }, 1000);

            return false;
        }

        if (startDateStr != '' && startDateStr != null && startDateStr != undefined) {
            if (endDateStr != '' && endDateStr != null && endDateStr != undefined) {
                var startDate = eval('new Date(' + startDateStr.replace(/\d+(?=-[^-]+$)/,
                        function (a) {
                            return parseInt(a, 10) - 1;
                        }).match(/\d+/g) + ')');
                var endDate = eval('new Date(' + endDateStr.replace(/\d+(?=-[^-]+$)/,
                        function (a) {
                            return parseInt(a, 10) - 1;
                        }).match(/\d+/g) + ')');

                if (startDate > endDate) {

                    $("#toastContent").text("结束时间不能早于开始时间!");
                    var $loadingToast = $('#loadingToast');
                    if ($loadingToast.css('display') != 'none') return;
                    $loadingToast.fadeIn(100);
                    setTimeout(function () {
                        $loadingToast.fadeOut(100);
                    }, 1000);

                    return false;
                }

            }
        }

        $("#queryForm").submit();
    }
</script>

</body>


</html>
