<%@ page language="java" pageEncoding="UTF-8"
         contentType="text/html; charset=UTF-8" %>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String basePath = request.getContextPath();
    String resourcePath = basePath + "/resource";
%>
<!doctype html>
<html>
<head>
    <jsp:include page="../common/head.jsp"></jsp:include>
    <meta charset="utf-8">
    <title>API开发需求</title>
</head>
<body>
<jsp:include page="../common/body_header.jsp"></jsp:include>
<div class="liutongbanner">
    <div class="bannerxuqiu"><button type="button" onclick="publish()"  class="xqbut">立即发布</button></div>
</div>
<div class="mid4">
    <div class="line"></div>
    <div class="box">
        <div class="box00">
        <div class="line00"></div>
        <div class="xuanxiang01">
            <a href="<%=basePath%>/open/apiDemand/list.htm" class="xuanxiangfont">API开发需求</a>
        </div>
        <div class="xuanxiang02">
            <a href="<%=basePath%>/open/dataRequirement/index.htm" class="xuanxiangfont">数据供给需求</a>
        </div>
        <div class="xuanxiang02">
            <a href="<%=basePath%>/open/requirementMicroapp/openList.action" class="xuanxiangfont">服务开发需求</a>
        </div>
        <div class="zhutishuju">
            <div class="xiangshu">(共${pager}项)</div>
            <div id="sortDivId">
                <span ${flag == 0 ? 'class="paixu paixu-active"' : "class='paixu'"}><a>最新发布</a></span>
                <span ${flag == 1 ? 'class="paixu paixu-active"' : "class='paixu'"}><a>最多浏览</a></span>
                <span ${flag == 2 ? 'class="paixu paixu-active"' : "class='paixu'"}><a>最多关注</a></span>
            </div>
            <div class="shuju5">
                <c:if test="${list.size()>0}">
                    <c:forEach items="${list}" var="item">
                        <div class="xuqiu1">
                            <div class="xuqiu01"><a class="qxbm" href="<%=basePath%>/open/apiDemand/view.action/${item.id}">${item.rqrmntName}</a></div>
                            <div class="xuqiu02">需求摘要：${item.rqrmntSummary}</div>
                            <div class="xuqiu03">
                                <div class="xuqiu031">
                                    <span class="fabu1">发布时间：</span>
                                    <span class="shijian1"><fmt:formatDate value="${item.publishAt}"
                                                                           pattern="yyyy-MM-dd"></fmt:formatDate></span>
                                </div>
                                <div class="xuqiu032">
                                    <span class="fabu1">截止时间：</span>
                                    <span class="shijian1"><fmt:formatDate value="${item.deadline}"
                                                                           pattern="yyyy-MM-dd"></fmt:formatDate></span>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="shoucang">
                                  <span class="imgsc">
                                      <img src="<%=resourcePath%>/images/icon_chakan.png" alt="">&nbsp;&nbsp;
                                      <c:if test="${not empty item.viewTimes}">${item.viewTimes}</c:if>
                                      <c:if test="${empty item.viewTimes}">0</c:if>
                                  </span>
                                <span>
                                        <img src="<%=resourcePath%>/images/icon_shoucang.png" alt="">&nbsp;&nbsp;
                                        <c:if test="${not empty item.followCount}">${item.followCount}</c:if>
                                     <c:if test="${empty item.followCount}">0</c:if>
                                  </span>
                            </div>
                            <c:set var="nowDate" value="<%=System.currentTimeMillis()%>"></c:set>
                           <%-- <c:if test="${nowDate-item.deadline.time > 0}">
                                <div class="yijieshu">已结束</div>
                            </c:if>
                            <c:if test="${nowDate-item.deadline.time < 0}">
                                <div class="jinxingzhong">进行中</div>
                            </c:if>--%>
                        <div class="jinxingzhong">${item.rqrmntState}</div>
                        </div>
                    </c:forEach>
                </c:if>
                <div class="chakan0" id="chakanId">
                    <span class="chakan"></span>
                    &nbsp&nbsp <a class="chakanfont" onclick="lookMore1()">查看更多</a> &nbsp&nbsp
                    <span class="chakan"></span>
                </div>
            </div>
        </div>

    </div>
    </div>
</div>

</body>
<jsp:include page="../common/body_footer.jsp"></jsp:include>
<script type="text/javascript">
    function publish() {
        window.location.href="<%=basePath%>/open/apiDemand/add.htm" ;
    }

    //排序
    $(function() {
        var spans = $('#sortDivId').children();
        console.info(spans);
        for (var i = 0; i < spans.length; i++) {
            (function(j) {
                spans[j].onclick = function () {
                    window.location.href ="<%=basePath%>/open/apiDemand/list.htm?flag="+j;
                };
            })(i)
        }
    });

    //查看更多
    var flagMore=false;
    var count=1;
    function lookMore1(){
        count++;
        if(flagMore){
            return;
        }
        $.post("<%=basePath%>/open/apiDemand/getMore.action",{pageNo:count,rqrmntName:null},function(data){
            if($(data).html() ==null){
                flagMore=true;
                $('.chakanfont').text('已经到底了');
            }else {
                var connectPoint = $('#chakanId').parent().children('div:last').prev();
                connectPoint.after(data);
            }
        })
    }
</script>
</html>