<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
        name="viewport">
    <title>{% if post.title %}{{post.title}} {% else %} {{post.name}}-{{'CMS_WEBNAME'|sysconfig}}{% endif %}
    </title>
    <meta name="keywords" content="{{post.keywords}}" />
    <meta name="description" content="{{post.description}}" />
    <link rel="stylesheet" href="{{'CMS_BASEHOST'|sysconfig}}/static/css/style.css" media="all">
    <script type="text/javascript" src="{{'CMS_BASEHOST'|sysconfig}}/static/js/ad.js"></script>
    <script type="text/javascript" src="{{'CMS_BASEHOST'|sysconfig}}/static/js/jquery.min.js"></script>
</head>

<body>
    <script>
        site();
    </script>
        {% include "/index/common/header.html" %}<div id="tad">
        <script>
            tjs();
        </script>
    </div>

    <div class="box mt10">
        <div class="fl_640">
            <div class="bread" style="padding:12px 20px;"><a href="/">{{'CMS_INDEXNAME'|sysconfig}}</a> > <a
                    href="/taglist/">标签</a> > <a
                    href="{{post.id|getTagDetailUrl}}">{{post.name}}</a>
                > </div>
            <div class="zinfo" style="padding-left:20px;padding-right:20px;">
                <h1>{{post.name}}</h1>
                {% if post.content %}<div class="zdes">{{post.content}}</div>{% endif %}
            </div>
            <div id="lad1">
                <script>
                    ljs1();
                </script>
            </div>

            <div id="arclist">
                {% for row in list %}
                <div class="list">
                    {% if row.article.litpic %}
                    <a class="limg" href="{{row.id|getArticleDetailUrl}}">
                        <img alt="{{row.title}}" src="/static{{row.article.litpic}}">
                    </a>
                    {% endif %}
                    <strong class="tit"><a href="{{row.id|getArticleDetailUrl}}">{{row.article.title}}</a></strong>
                    <p>{{row.article.description}}..</p>
                    <div class="info">
                        <span class="fl">
                            {% if row.article.writer %} 
                                <i>{{row.article.writer}}</i>
                            {% elif row.article.source %}
                                <i>{{row.article.source}}</i><em>{{row.article.update_time|date}}</em>
                        </span>
                        <span class="fr"><em>{{row.article.click}}</em>人阅读</span>
                        {% endif %}
                    </div> 
                    <div class="cl"></div>
                </div>{% endfor %} {% if list|length == 0 %}<div style="text-align:center;padding:20px;">暂无记录</div>{% endif %}</div>
            </div><!-- fl_640 end -->

            <div class="fr_300">
                <div id="rad1">
                    <script>
                        rjs1();
                    </script>
                </div>
                <div class="side">
                    <div class="stit">
                        <div class="stith"><strong>热门话题</strong></div>
                        <div class="cl"></div>
                    </div>
                    <div class="ws-tag">{% for row in tag_list %}
                        <a  href="{{row.id|getTagDetailUrl}}">{{ row.name}}</a>
                        {% endfor %}
                    </div>
                </div>

                <div class="side">
                    <div class="stit">
                        <h2>推荐阅读</h2><a href="javascript:getmore({limit:5,tuijian:1,mode:1,orderby:'rand'});"
                            class="more">换一换</a>
                        <div class="cl"></div>
                    </div>
                    <ul class="uli chs" id="xglist">{% for row in relate_zuixin_list %}
                        <li><a
                                href="{{row.id|getArticleDetailUrl}}">{{row.title}}</a>
                        </li>{% endfor %}</ul>
                    <div class="cl"></div>
                </div>

                <div class="side">
                    <div class="stit">
                        <h2>猜你喜欢</h2><a href="javascript:getmore({limit:5,mode:2,orderby:'rand'});" class="more">换一换</a>
                        <div class="cl"></div>
                    </div>
                    <div class="uli2" id="xglike">{% for row in relate_rand_list %}
                        <div class="suli">
                            {% if row.litpic %}
                            <a class="limg" href="{{row.id|getArticleDetailUrl}}">
                                <img alt="{{row.title}}" src="/static{{row.litpic}}">
                            </a>
                            {% endif %}
                            <a  href="{{row.id|getArticleDetailUrl}}">{{row.title}}</a>
                            <div class="sulii">
                                {% if row.writer %}
                                <span class="time">{{row.writer}}</span>
                                {% elif row.source %} 
                                <span class="time">{{row.source}}</span>
                                {% endif %} 
                                阅读({{ row.click}})</div>
                            <div class="cl"></div>
                        </div>{% endfor %}
                    </div>
                </div>

                <!-- <div class="side">
                    <div class="stit">
                        <div class="stith"><strong>友情链接</strong></div>
                        <div class="cl"></div>
                    </div>
                    <div class="rtags mt10">
                        {% for row in friendlink_list %}
                            <a  href="{{row.url}}">{{row.name}}</a>
                        {% endfor %}
                    </div>
                </div> -->

                <div id="rad2">

                </div>
            </div><!-- fr_300 end -->
    </div><!-- box end -->
    <script>
        function getmore(condition) {
            var url = "{{'CMS_BASEHOST'|sysconfig}}/api/article/index";
            //var typeid = "";
            $.post(url, condition, function (res) {
                if (res.code == 0) {
                    var json = res.data.list; //数组
                    var str = '';
                    console.log(res.data)
                    $.each(json, function (index) {
                        //循环获取数据
                        //var title = json[index].title;
                        if (condition.mode == 1) {
                            str = str +
                                '<li><a href=" {{getArticleDetailUrl}}' +
                                json[index].id + '">' + json[index].title + '</a></li>';
                        } else if (condition.mode == 2) {
                            var litpic = '';
                            if (json[index].litpic !== '') {
                                litpic =
                                    '<a class="limg" href="{{getArticleDetailUrl}}' +
                                    json[index].id + '"><img alt="' + json[index].title + '" src="/static' +
                                    json[index].litpic + '"></a>';
                            }
                            str = str + '<div class="suli">' + litpic +
                                '<a href="{{getArticleDetailUrl}}' +
                                json[index].id + '">' + json[index].title +
                                '</a><div class="sulii">阅读(' + json[index].click +
                                ')</div><div class="cl"></div></div>';
                        }
                    });

                    if (str != '' && str != null && condition.mode == 1) {
                        $('#xglist').html(str);
                    } else if (str != '' && str != null && condition.mode == 2) {
                        $('#xglike').html(str);
                    }
                } else {

                }
            }, 'json');
        }

        $(function () {
            var ajaxload = false;
            var maxpage = false;
            var startpage = 1;
            var totalpage = {{totalpage}};

            var tmp_url = window.location.href;
            msg = tmp_url.split("#");
            tmp_url = msg[0];

            $(window).scroll(function () {
                var listheight = $("#arclist").outerHeight();

                if ($(document).scrollTop() + $(window).height() >= listheight) {
                    if (startpage >= totalpage) {
                        //$("#submit_bt_one").html("已是最后一页，没有更多数据");
                        return false;
                    }

                    if (!ajaxload && !maxpage) {
                        ajaxload = true;
                        //$("#submit_bt_one").html("努力加载中...");
                        var url = tmp_url;
                        var nextpage = startpage + 1;

                        $.get(url, {
                            page_ajax: 1,
                            page: nextpage
                        }, function (res) {
                            if (res) {
                                $("#arclist").append(res);
                                startpage++;

                                if (startpage >= totalpage) {
                                    maxpage = true;
                                    //$("#submit_bt_one").html("已是最后一页，没有更多数据");
                                    $("#arclist").append(
                                        '<div style="text-align:center;padding:20px;">暂无记录</div>'
                                        );
                                } else {
                                    //$("#submit_bt_one").html("点击加载更多");
                                }

                                ajaxload = false;
                            } else {
                                //$("#submit_bt_one").html("请求失败，请稍后再试");
                                ajaxload = false;
                            }
                        }, 'json');
                    }
                }
            });
        });
    </script>
    {% include "/index/common/footer.html" %}
</body>

</html>