{% extends 'base_m.html.twig' %}

{% block container %}
    <div class="am-container">
        <form id="cv_search_form" method="post" class="am-form cv-mt-20">
            <div class="input-control control-right">
                <input name="k" value="{{ keyword }}" type="text" class="am-form-field"><i class="sui-icon icon-touch-magnifier"></i>
                <input id="search_t" type="hidden" name="t" value="{% if type in defined and type is not empty %}{{ type }}{% else %}art{% endif %}" />
                <input id="search_p" type="hidden" name="p" value="1" />
            </div>
        </form>
    </div>
    <div class="cv-search-box">
        <div class="title">
            <div class="am-container">
                <a id="art" href="javascript:switchT('art')">新闻</a>
                <a id="pro" href="javascript:switchT('pro')">产品</a>
                <a id="cas" href="javascript:switchT('cas')">案例</a>
            </div>
        </div>

        <div data-am-widget="list_news" class="am-list-news am-list-news-default" >
            <div class="am-list-news-bd">
                <p class="total">找到<span>{{ total }}</span>个结果</p>
                <ul class="am-list" style="margin-top: 0;">
                    {% for item in items %}
                    <li class="am-g am-list-item-dated">
                        <a href="{{ item.url }}" class="am-list-item-hd ">{{ item.title }}</a>
                        <span class="am-list-date">{{ item.create_time|date('m-d') }}</span>
                    </li>
                    {% endfor %}
                </ul>
            </div>

        </div>

        <ul class="am-pagination cv-center">
            {% if has_last_page %}
                <li><a href="javascript:page({{ last_page }})">&laquo; 上一页</a></li>
            {% endif %}
            {% if has_next_page %}
                <li><a href="javascript:page({{ next_page }})">下一页 &raquo;</a></li>
            {% endif %}
        </ul>

    </div>
{% endblock %}

{% block js %}
    <script type="text/javascript">
        function switchT(v) {
            var t = $('#search_t');
            t.val(v);
            $('#search_p').val(1);
            $('#cv_search_form').submit();
        }
        $(function () {
            $('#{{ type }}').addClass('sc')
        });
        function page(v) {
            $('#search_p').val(v);
            $('#cv_search_form').submit();
        }
    </script>
{% endblock %}