<%@ 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>
</head>
<body>
<jsp:include page="../common/body_header.jsp"></jsp:include>

<div class="line0"></div>
<div class="mid-xuqiu01">
    <div class="line-xuqiu"></div>
    <div class="xuqiu-01">
        <div class="xuqiu-top">
            <div>
                <div class="xuqiu-name">市A级旅游景区名单</div>
                <%--<c:if test="${requirement.rqrmntState eq '进行中'}"> <div class="jinxingzhong"></div></c:if>--%>
                <%--<c:if test="${requirement.rqrmntState eq '已结束'}"> <div class="yijieshu">${requirement.rqrmntState}</div></c:if>--%>
                <c:set var="nowDate" value="<%=System.currentTimeMillis()%>"></c:set>
                <c:if test="${nowDate-item.deadline.time > 0}">
                    <div class="yijieshu1">已结束</div>
                </c:if>
                <c:if test="${nowDate-item.deadline.time < 0}">
                    <div class="jinxingzhong1">进行中</div>
                </c:if>
            </div>
            <div class="clearfix"></div>
            <div class="xuqiu-icon">
                                    <span class="imgsc">
                                        <img src="<%=resourcePath%>/images/icon_chakan.png" alt="">&nbsp;&nbsp;
                                       <c:if test="${empty requirement.viewTimes}">0</c:if>
                                         <c:if test="${not empty requirement.viewTimes}"> ${requirement.viewTimes}</c:if>
                                    </span>
                <span>
                                          <img src="<%=resourcePath%>/images/icon_shoucang.png" alt="">&nbsp;&nbsp;
                                          ${requirement.coun}
                                    </span>
            </div>
            <div class="xuqiu-1">
                <input type="hidden" name="rqrmntId" value="${requirement.rqrmntId}"/>
                <c:if test="${requirement.receiveId ==null}">
                    <button class="jiedan" onclick="fnCloseReceive()">接单</button>
                </c:if>
                <c:if test="${requirement.receiveId !=null}">
                    <button class="jiedan" >已接单</button>
                </c:if>
                <c:if test="${requirement.followId ==null}">
                    <button class="button2" onclick="follow()">关注</button>
                </c:if>
                <c:if test="${requirement.followId !=null}">
                    <button class="jiedan" >已关注</button>
                </c:if>


            </div>

        </div>
        <div>
            <div class="xiangqing01">
                <img src="<%=resourcePath%>/images/icon_xiangqing.png" alt="" class="xiangqingimg">
                详情
            </div>
            <div>
                <table border="1" width="1080px" height="480px"  cellspacing="0" class="biaoge01">

                    <tr>
                        <td>主联系人</td>
                        <td>${requirement.contact}</td>
                    </tr>
                    <tr>
                        <td>主联系电话</td>
                        <td>${requirement.phone}</td>
                    </tr>

                    <tr>
                        <td>分类</td>
                        <td>${requirement.themeName}</td>

                    </tr>

                    <tr>
                        <td>需求描述</td>
                        <td>${requirement.rqrmntSummary}</td>
                    </tr>
                    <tr>
                        <td>发布日期</td>
                        <td><fmt:formatDate value="${requirement.publishAt}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                    </tr>
                    <tr>
                        <td>截止日期</td>
                        <td><fmt:formatDate value="${requirement.deadline}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                    </tr>
                    <tr>
                        <td>邮箱</td>
                        <td>${requirement.email}</td>
                    </tr>

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

        <div id="divReceive" class="fade" style="display: none;">
            <div class="window" >
                <div class="top00">
                    <span class="p">接单</span>
                    <img src="<%=resourcePath%>/images/icon_guanbi.png" alt="" class="guanbi">
                </div>
                <div class="form" >
                    <form id="receiveForm">
                        <input type="hidden" name="rqrmntState" value="${requirement.rqrmntState}"/>
                        <div class="application-font-0">
                            <span class="application-font-2">联系人：</span>
                            <input type="text" class="area4" id="contact" name="contact" placeholder="请输入联系人">
                        </div>
                        <div class="application-font-0">
                            <span class="application-font-2">联系电话：</span>
                            <input type="text" class="area4"id="phone" name="phone" placeholder="请输入联系电话">
                        </div>

                        <div class="application-font-0">
                            <span class="application-font-2">方案概述：</span>
                            <textarea name="solution" id="usage" cols="46" rows="3" class="area2" placeholder="请输入您的使用意向"></textarea>
                        </div>

                        <div class="clearfix"></div>
                        <div class="queding0">
                            <span class="quxiao" onclick="receive()">确定</span>
                            <span class="queding" onclick="offlineReceive()">取消</span>
                        </div>
                    </form>
                </div>
            </div>
        </div>

    <jsp:include page="../common/body_footer.jsp"></jsp:include>
</body>
<script>

    //弹出接单页面
    function fnCloseReceive(){
        if (!checkAuthentication()){
            return;
        }
        $("#divReceive").show();
    }
    //取消接单页面
    function offlineReceive(){
        $("#divReceive").hide();
    }
    function receive() {
        $.ajax({
            url:"<%=basePath%>/open/requirementMicroapp/receive.action/${requirement.rqrmntId}",
            type:"post",
            data:$("#receiveForm").serialize(),
            success:function(msg){
                if(msg.stateCode==200) {
                    $("#divReceive").hide();
                    alert("接单成功");
                }
            }
        })
        
    }
    function follow() {
        if (!checkAuthentication()){
            return;
        }
        $.ajax({
            url:"<%=basePath%>/open/requirementMicroapp/follow.action/${requirement.rqrmntId}",
            type:"post",
            success:function(msg){
                if(msg.stateCode==200) {
                    window.location.href="<%=basePath%>/open/requirementMicroapp/view.htm/${requirement.rqrmntId}";
                    alert("关注成功");
                }
            }
        })
    }
    
</script>
</html>