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

<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/newstyle.css">
</head>
<style>
    .num3 {
        background: green;
        color: #fff;
        padding: 1px 6px;
        border-radius: 10px;
    }
</style>

<body>
<header>
    <!--<a th:href="@{/customer/myWaitCallCustomer}" class="btn-a-back"><i class="iconfont">-->
    <div class="header">
        <a href="javascript:history.go(-1)" class="btn-a-back"><i class="iconfont">&#xe61f;</i></a>
        <h2>待回访客户</h2>
    </div>
</header>


<!--我的客户-->
<div class="my-client">
    <!--<div class="weui-cells__title">今天</div>-->
    <div th:each="customer : ${listData}">
        <div th:if="${customer.belongToday == '1'}">
            <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_access" th:onclick="'javascript:customerInfo(\'' +${customer.id}+ '\',\'' +${customer.name}+'\',\'' +${customer.phone}+'\',\'' +${customer.managerName}+'\',\'' +${customer.buyIntention}+'\',
                            \'' +${customer.singupTime}+'\',\'' +${customer.actSource}+'\',
                            \'' +${#dates.format(customer.bindTime.time, 'yyyy-MM-dd HH:mm:ss')}+'\',\'' +${customer.latestSource}+'\',\'' +${customer.isPrivate}+'\',\'' +${customer.privateId}+'\');'">
                    <div class="weui-cell__hd">
                        <p class="tu-text"
                           th:text="${#strings.substring(customer.name,0,#strings.length(customer.name)>3?3:#strings.length(customer.name))}"></p>
                    </div>
                    <div class="weui-cell__bd">
                        <div class="top clearfix">
                            <div class="fl">
                                <span class="my-client__tel">
                                    <a th:href="|tel:${customer.phone}|" th:text="${customer.phone}"></a>
                                </span>
                                <span th:if="${customer.isPrivate} eq '1'" class="num3">私</span>
                            </div>
                            <div class="client-list-r">
                                <i class="iconfont">&#xe603;</i>
                                <p th:text="${#dates.format(customer.bindTime.time, 'MM-dd HH:mm')}"></p></em>
                            </div>
                        </div>

                        <div class="bototm">
                            <div class="fl my-client__tag">
                                <span><i class="iconfont">&#xe6ea;</i><em th:text="${customer.managerName}"></em></span>
                            </div>
                            <div class="client-list-r">
                                <p>来源：<span th:text="${customer.latestSource}"></span></p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--<div class="weui-cells__title">昨天</div>-->
    <div th:each="customer : ${listData}">
        <div th:if="${customer.belongYestoday == '1'}">
            <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_access" th:onclick="'javascript:customerInfo(\'' +${customer.id}+ '\',\'' +${customer.name}+'\',\'' +${customer.phone}+'\',\'' +${customer.managerName}+'\',\'' +${customer.buyIntention}+'\',
                            \'' +${customer.singupTime}+'\',\'' +${customer.actSource}+'\',
                            \'' +${#dates.format(customer.bindTime.time, 'yyyy-MM-dd HH:mm:ss')}+'\',\'' +${customer.latestSource}+'\',\'' +${customer.isPrivate}+'\',\'' +${customer.privateId}+'\');'">
                    <div class="weui-cell__hd">
                        <p class="tu-text"
                           th:text="${#strings.substring(customer.name,0,#strings.length(customer.name)>3?3:#strings.length(customer.name))}"></p>
                    </div>
                    <div class="weui-cell__bd">
                        <div class="top clearfix">
                            <div class="fl">
                                <span class="my-client__tel">
                                    <a th:href="|tel:${customer.phone}|" th:text="${customer.phone}"></a>
                                </span>
                                <span th:if="${customer.isPrivate} eq '1'" class="num3">私</span>
                            </div>
                            <div class="client-list-r">
                                <i class="iconfont">&#xe603;</i>
                                <p th:text="${#dates.format(customer.bindTime.time, 'MM-dd HH:mm')}"></p>
                            </div>
                        </div>

                        <div class="bototm">
                            <div class="fl my-client__tag">
                                <span><i class="iconfont">&#xe6ea;</i><em th:text="${customer.managerName}"></em></span>
                            </div>
                            <div class="client-list-r">
                                <p>来源：<span th:text="${customer.latestSource}"></span></p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--<div class="weui-cells__title">2天以前</div>-->
    <div th:each="customer : ${listData}">
        <div th:if="${customer.belongSince == '1'}">
            <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_access" th:onclick="'javascript:customerInfo(\'' +${customer.id}+ '\',\'' +${customer.name}+'\',\'' +${customer.phone}+'\',\'' +${customer.managerName}+'\',\'' +${customer.buyIntention}+'\',
                            \'' +${customer.singupTime}+'\',\'' +${customer.actSource}+'\',
                            \'' +${#dates.format(customer.bindTime.time, 'yyyy-MM-dd HH:mm:ss')}+'\',\'' +${customer.latestSource}+'\',\'' +${customer.isPrivate}+'\',\'' +${customer.privateId}+'\');'">
                    <div class="weui-cell__hd">
                        <p class="tu-text"
                           th:text="${#strings.substring(customer.name,0,#strings.length(customer.name)>3?3:#strings.length(customer.name))}"></p>
                    </div>
                    <div class="weui-cell__bd">
                        <div class="top clearfix">
                            <div class="fl">
                                <span class="my-client__tel">
                                    <a th:href="|tel:${customer.phone}|" th:text="${customer.phone}"></a>
                                </span>
                                <span th:if="${customer.isPrivate} eq '1'" class="num3">私</span>
                            </div>
                            <div class="client-list-r">
                                <i class="iconfont">&#xe603;</i>
                                <p th:text="${#dates.format(customer.bindTime.time, 'MM-dd HH:mm')}"></p></em>
                            </div>
                        </div>

                        <div class="bototm">
                            <div class="fl my-client__tag">
                                <span><i class="iconfont">&#xe6ea;</i><em th:text="${customer.managerName}"></em></span>
                            </div>
                            <div class="client-list-r">
                                <p>来源：<span th:text="${customer.latestSource}"></span></p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!--我的客户 end-->
<div id="loadingToast" style="opacity: 0; display: none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast">
        <i class="weui-loading weui-icon_toast"></i>
        <p class="weui-toast__content">数据加载中</p>
    </div>
</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/history.js"></script>
<script type="text/javascript">
    var handler = null,
        page = 2, tmpPage,
        isLoading = false;

    $(function () {
        $(document).on('scroll', onScroll);
    });

    function customerInfo(id, name, customerPhone, managerName, buyIntention, singupTime, actSource, bindTime, latestSource, isPrivate, privateId) {
        window.location.href = "/customer/waitCustomerDetail?customerId=" + id + "&customerName=" + name + "&customerPhone=" + customerPhone + "&managerName=" + managerName + "&buyIntention=" + buyIntention
            + "&bindTime=" + bindTime + "&latestSource=" + latestSource + "&singupTime=" + singupTime + "&actSource=" + actSource + "&isPrivate=" + isPrivate + "&privateId=" + privateId;
    }

    function onScroll(event) {
        if (!isLoading) {
            var closeToBottom = ($(window).scrollTop() + $(window).height() > $(document).height() - 100);
            if (closeToBottom && page > 0) {

                var $loadingToast = $('#loadingToast');
                if ($loadingToast.css('display') != 'none') return;
                $loadingToast.fadeIn(100);

                loadData();
            }
        }
    }

    function loadData() {
        isLoading = true;
        $.ajax({
            url: "/customer/myWaitCallCustomerCell", //buyIntention startDate endDate traceStatus projectStatus
            data: {
                page: page
            }, // Page parameter to make sure we load new data
            success: onLoadData
        });
    }

    function onLoadData(data) {
        // Increment page index for future calls.
        page++;
        var html = '';
        var i = 0, length = data.length, image;
        //data.length:192
        if (!length || length <= 220) {
            tmpPage = page;
            page = -1;
            data = '';
        }
        $(".my-client :last").after(data);
        // Create HTML for the images.
        isLoading = false;

        var $loadingToast = $('#loadingToast');
        $loadingToast.fadeOut(100);
    }

</script>
</body>

</html>
