index.html 3.3 KB
<!DOCTYPE html>
<html lang="en">

{include file="public/head"/}
<link rel="stylesheet" href="__CDN__/assets/advertising/css/index.css">
<style>
    body,
    html {
        background-color: #f9f9f9;
    }

    .content_list {
        margin-top: 0;
    }
</style>
<body>
    <div class="collect">
        <div class="content_list" id="dom">
            {foreach name="$data" item="vo"}
            <div class="content_single">
                <div class="single_title">{$vo.goods_name}</div>
                <div class="single_coupon">{$vo.exp}红包券</div>
                <div class="layout justify flex_row align_center">
                    <div class="single_date">截止日期: {$vo.end_time}</div>
                    <a class="single_btn" href="{:url('home/goods/detail',array('goods_id'=>$vo['id']))}">查看详情</a>
                </div>
            </div>
            {/foreach}
        </div>
    </div>
    {empty name="$data"}
    <div class="empty_data">
        暂无数据
    </div>
    {/empty}
    {notempty name="$data"}
    <div class="load_more layout align_center justify_center">
        <div>加载更多</div>
        <div class="layout align_center justify_center">
            <img src="__CDN__/assets/advertising/img/right.png" alt="">
        </div>
    </div>
    <!--当前页-->
    <input type="hidden" id="page" value="1"/>
    {/notempty}
    {include file="public/js" /}
    <script>
        //加载更多
        $(".load_more").click(function () {
            var page = $('#page').val();
            var user_id = "{$user.id}";
            page++;
            $.ajax({
                url:"{:url('home/collect/more')}",
                type:"POST",
                data:{'page':page,'user_id':user_id},
                success:function(res){
                    if(res.code == 1){
                        if(res.data == ''){
                            $('.justify_center').html("<div>没有更多了~</div>");
                            toast('没有更多了~');
                            return;
                        }
                        var html = "";
                        $(res.data).each(function (key, vo) {
                            html += "<div class=\"content_single\">\n" +
                                "                <div class=\"single_title\">"+vo.goods_name+"</div>\n" +
                                "                <div class=\"single_coupon\">"+vo.exp+"红包券</div>\n" +
                                "                <div class=\"layout justify flex_row align_center\">\n" +
                                "                    <div class=\"single_date\">截止日期: "+vo.end_time+"</div>\n" +
                                "                    <a class=\"single_btn\" href=\"{:url('home/goods/detail',array('goods_id'=>$vo['id']))}\">查看详情</a>\n" +
                                "                </div>\n" +
                                "            </div>";
                        });
                        $('#dom').append(html);
                        $('#page').val(page);
                    }else{
                        toast('与服务器断开连接');
                    }
                },
                error:function(){
                    toast('与服务器断开连接');
                }
            })
        })
    </script>
</body>

</html>