<!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 class="bg-white">
<input type="hidden" id="customerId" th:value="${customerId}"/>
<input type="hidden" id="buyIntention" th:value="${buyIntention}"/>
<header>
    <div class="header">
        <a href="javascript:backToUrl();" class="btn-a-back"><i class="iconfont">&#xe61f;</i></a>
        <h2>回访记录</h2>
        <a class="btn-add-visit"
           th:onclick="'goToUrl(\'' + @{/project/addvisit(customerId=${customerId},buyIntention=${buyIntention})} + '\')'">添加回访</a>
    </div>
</header>
<div id="visitCallLogs"></div>

<script type="text/html" id="weekTemplate">
    {{each weeks as week index}}
    <dl class="visit-record">
        <dt>
            <span>{{week.time}}</span>
            <i class="tri-t"></i>
        </dt>
        <dd>
            {{each week.logs as log index}}
            {{if log.callRecordId != 0}}
            <a href="#2"><p>待定</p></a>
            {{else}}
            <a href="javascript:goToUrl('/project/visitlogdetails.html?logId={{log.id}}')">
                <p>{{log.content}}</p>
                <i class="iconfont">&#xe826;</i>
            </a>
            {{/if}}
            {{/each}}
        </dd>
    </dl>
    {{/each}}
</script>
<script type="text/javascript" src="/static/js/jquery.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" src="/static/js/template.js"></script>
<script type="text/javascript" src="/static/js/utils.js"></script>
<script type="text/javascript">
    $(function () {
        loadData();
    });
    function loadData() {
        $.ajax({
            url: "/project/getvisitrecords",
            data: {
                customerId: $("#customerId").val()
            },
            type: "post",
            success: function (data) {
                if (data.data.entity == undefined) {
                    return;
                }
                var weeksHtml = template('weekTemplate', {
                    weeks: data.data.entity
                });
                $("#visitCallLogs").append(weeksHtml);

                $('.visit-record dt').on('click', function () {
                    $(this).parent('.visit-record').find('dd').toggle();
                    $(this).find('.tri-t').toggleClass('on')
                })
            }
        });
    }
</script>
</body>

</html>
