<%-- 微信 来访我的 --%>

<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="/ssTag" prefix="ss" %>
<%@ page import="base.WechatC" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <link rel="stylesheet" href="/skin/easy/Main.css?v=1.0.0">
    <script type="text/javascript" src="/ss/jquery/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="/ss/js/base.js"></script>
    <script type="text/javascript" src="/ss/js/common.js"></script>
    <script type="text/javascript" src="/ss/js/display.js"></script>
    <script type="text/javascript" src="/ss/js/edit.js"></script>

    <title>我的</title>
    <style>
        .mobileSearch-div{
            margin: 1rem auto;
        }
        .mobileAdd-button{
            width: 1.3rem;
            height:1.3rem;
            background: transparent;
            margin-right: 0.3rem;
        }
        .mobileAdd-button::after{
            filter: none;
        }
        .mobileAdd-button:active{
            background: transparent;
        }
    </style>


    

</head>

<body class="mobileApply-bg">
    <%-- ${data}--%>
    <%-- <a href="<ss:serv name='lf_mine_ck' dest='lf_mine_info' />&lp=d27f08d10cb64d6591c5f556dd880090">跳到来访查看</a>  --%>

    <div class="mobileSearch-div" style="display:flex;justify-content:flex-end;padding-right: 0.5rem;">
        <!-- <div class="mobileSearch-input-div">
             <input type="text">
             <span class="mobileSearch-icon"></span>
         </div> -->

        <button class="mobileSearch-button" style="height: 36px;" onclick="goLink('<%=WechatC.HOST_byWechat%>/extRoot?type=22&biz=lf_inp')" ><span class="mobileAdd-button" ></span>增加</button>
    </div>
    <div id="mobileLf-div" style="padding-right: 0.5rem;">

           
           <!--   <div class="mobileLf-card">
                <div class="mobileLf-card-ing-tag">审核中</div>
                <p class="mobileLf-title">住宿餐饮</p>
                <p>姓名：李四</p>
                <p>个人电话：13800138000</p>
                <p>预约开始时间：2024/08/10 18:33</p>
            </div>
           <div class="mobileLf-card">
                
                <p class="mobileLf-title">住宿餐饮<span class="mobileLf-card-agree-tag">同意</span></p>
                <p>姓名：李四</p>
                <p>个人电话：13800138000</p>
                <p>预约开始时间：2024/08/10 18:33</p>
            </div> 
            <div class="mobileLf-card">
                
                <p class="mobileLf-title">住宿餐饮<span class="mobileLf-card-refuse-tag">退回</span></p>
                <p>姓名：李四</p>
                <p>个人电话：13800138000</p>
                <p>预约开始时间：2024/08/10 18:33</p>
            </div>   -->
    </div>
     <%--<% String sharedValue = "2"; %>
    <%@ include file="/page/ext_lf_index_footer.jsp" %> --%>


    <script>
        
        
        
    </script>
    <script>

       
        let pageNumber = 1;
        let isLoading = false;
        let hasMoreData = true;
        let gr = document.createDocumentFragment();
        
        // 渲染列表项的函数
        function renderItem(item) {
            var div = document.createElement('div');
            div.className = 'mobileLf-card';
            div.onclick = function () {
                location.href = `<ss:serv name='lf_lfryMine_ck' dest='lf_mine_info' />&lp=` + item.wblp;
            };

            if(item.lczt == '录入'){
                item.lczt = '审核中';
                item.lcztm = '11';
            }
            
            div.innerHTML = (item.lcztm == '11' && item.is_late == '0'
                ? '<div class="mobileLf-card-ing-tag">' + item.lczt + '</div>'
                : '') +
                '<p class="mobileLf-title">' +
                item.lflb +
                (item.lcztm == '51'
                    ? '<span class="mobileLf-card-agree-tag">' + item.lczt + '</span>'
                    : item.lcztm == '55' 
                        ? '<span class="mobileLf-card-refuse-tag">' + item.lczt + '</span>' 
                        : (item.lcztm == '11' && item.is_late == '1')
                            ? '<span class="mobileLf-card-expired-tag">已过期</span>'
                            : item.lcztm == '59'
                                ? '<span class="mobileLf-card-refuse-tag">退回</span>'
                                : '') +
                '</p>' +
                (item.jfrxm ? '<p>受访人：' + item.jfrxm + '</p>' : '') +
                '<p>预约开始时间：' + item.yykssj + '</p>';
            
            return div;
        }

        // 获取下一页数据
        function getNextPageData(pageNum){
            if (isLoading || !hasMoreData) return;
            
            isLoading = true;
            $.ajax({
                url: "<ss:serv name='lf_initLfryMineByAjax'/>",
                type: "post",
                dataType: "json",
                data: {
                    'pageNum': pageNum
                },
                success: function(result) {
                    if (result.ssCode == 1) {
                        const data = result.data;
                        if (!data || data.length === 0) {
                            hasMoreData = false;
                            return;
                        }
                        
                        let fragment = document.createDocumentFragment();
                        data.forEach(function(item) {
                            fragment.appendChild(renderItem(item));
                        });
                        document.getElementById('mobileLf-div').appendChild(fragment);
                        
                        pageNumber++;
                    } else {
                        window.document.location.href = window.location.origin + '/page/ext_lf_wechatIndex.jsp';
                    }
                },
                complete: function() {
                    isLoading = false;
                }
            });
        }

        // 初始加载第一页
        getNextPageData(pageNumber);

        // 节流函数
        function throttle(func, wait) {
            let timeout = null;
            let previous = 0;
            
            return function() {
                let now = Date.now();
                let remaining = wait - (now - previous);
                
                if (remaining <= 0 || remaining > wait) {
                    if (timeout) {
                        clearTimeout(timeout);
                        timeout = null;
                    }
                    previous = now;
                    func.apply(this, arguments);
                } else if (!timeout) {
                    timeout = setTimeout(() => {
                        previous = Date.now();
                        timeout = null;
                        func.apply(this, arguments);
                    }, remaining);
                }
            }
        }

        // 滚动检查函数
        function checkScrollAndLoad() {
            // 获取页面总高度、视窗高度、滚动位置
            const scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
            const scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
            const clientHeight = window.innerHeight || document.documentElement.clientHeight;
            
            // 当距离底部还有10%的距离时触发加载
            const threshold = scrollHeight * 0.1;
            
            if (scrollHeight - scrollTop - clientHeight <= threshold) {
                getNextPageData(pageNumber);
            }
        }

        // 添加滚动监听，使用节流函数控制触发频率（这里设置为500ms）
        window.addEventListener('scroll', throttle(checkScrollAndLoad, 500));



        function goLink(value){
            window.location.href = value
        }

        function goIndex(value){
            
            window.document.location.href = window.location.origin + '/page/ext_lf_index.jsp?t='+value
            
        }
        function closePage() {

            // 定义关闭页面的函数
            function closeWindow() {
                if (typeof WeixinJSBridge == "undefined") {
                    // 监听WeixinJSBridgeReady事件
                    document.addEventListener('WeixinJSBridgeReady', function () {
                        WeixinJSBridge.call('closeWindow');
                    }, false);
                } else {
                    // 如果是微信浏览器，直接调用
                    WeixinJSBridge.call('closeWindow');
                }
            }

            // 调用关闭页面函数
            closeWindow();

            // 如果不是微信浏览器，尝试使用window.close()关闭
            if (!/MicroMessenger/i.test(navigator.userAgent)) {
                window.close();
                window.history.back();
                
            }
        }
    </script>


</body>

</html>