<%@ 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-xuqiu">
                      <div class="line-xuqiu"></div>
                      <div class="xuqiu-0">
                          <div class="xuqiu-top">
                              <div>
                                    <div class="xuqiu-name">${demandOpenViewModel.rqrmntName}</div>
                                    <div class="jinxingzhong1">进行中</div> 
                              </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 demandOpenViewModel.viewTimes}">0</c:if>
                                         <c:if test="${not empty demandOpenViewModel.viewTimes}">${demandOpenViewModel.viewTimes}</c:if>
                                    </span>
                                    <span>
                                          <img src="<%=resourcePath%>/images/icon_shoucang.png" alt="">&nbsp;&nbsp;
                                          0
                                    </span>
                                </div>
                                <div class="xuqiu-1">
                                        <button class="jiedan" id="jiedan"  <c:if test="${isReceive > 0 }">hidden</c:if>  onclick="fnCloseReceive()">接单</button>


                                        <button class="jiedan" id="yijiedan"  <c:if test="${isReceive == 0}">hidden</c:if>>已接单</button>

                                    <button class="button2" <c:if test="${isFollow !=0}">hidden</c:if> onclick="follow()" id="followId">关注</button>
                                    <button class="button2" onclick="follow()" <c:if test="${isFollow ==0}">hidden</c:if> id="delfollowId" >取消关注</button>
                                </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 bgcolor="#dcdfe5" class="biaotou">
                                          <td>项目</td>
                                          <td>概述</td>
                                      </tr>
                                      <tr>
                                          <td>主联系人</td>
                                          <td>${demandOpenViewModel.contact1}</td>
                                      </tr>
                                      <tr>
                                          <td>主联系电话</td>
                                          <td>${demandOpenViewModel.phone1}</td>
                                      </tr>
                                      <tr>
                                          <td>备用联系人</td>
                                          <td>${demandOpenViewModel.contact2}</td>
                                      </tr>
                                      <tr>
                                          <td>备用联系人电话</td>
                                          <td>${demandOpenViewModel.phone2}</td>
                                      </tr>
                                      <tr>
                                          <td>是否需要平台撮合交易</td>
                                          <td>${demandOpenViewModel.needPlatformSupport}</td>
                                       </tr>
                                       <tr>
                                            <td>分类</td>
                                           <%-- TODO --%>
                                            <td>${demandOpenViewModel.categoryId}</td>
                                        </tr>
                                        <tr>
                                            <td>预期报价</td>
                                            <td>${demandOpenViewModel.expectedQuote}元</td>
                                        </tr>
                                        <tr>
                                            <td>接口个数</td>
                                            <td>${demandOpenViewModel.interfaceCount}</td>
                                        </tr>
                                        <tr>
                                            <td>发布日期</td>
                                            <td><fmt:formatDate value="${demandOpenViewModel.publishAt}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                                        </tr>
                                        <tr>
                                            <td>截止日期</td>
                                            <td><fmt:formatDate value="${demandOpenViewModel.deadline}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                                         </tr>                               
                                         <tr>
                                                <td>需求描述</td>
                                                <td>${demandOpenViewModel.rqrmntSummary}</td>
                                            </tr>
                                      <tr>
                                          <td>需求用户</td>
                                          <td>${demandOpenViewModel.rqrmntUser}</td>
                                      </tr>
                                            <tr>
                                                <td>附件</td>
                                                <td>${demandOpenViewModel.attachment}</td>
                                             </tr>
                                  </table>
                              </div>
                          </div>
                          <div>
                                <div class="xiangqing01">
                                    <img src="<%=resourcePath%>/images/icon_miaoshu.png" alt="" class="xiangqingimg">
                                    系统描述
                                </div>
                                <div>
                                    <table border="1" width="1080px" height="330px"  cellspacing="0" class="biaoge01">
                                        <tr bgcolor="#dcdfe5" class="biaotou">
                                            <td>项目</td>
                                            <td>概述</td>
                                        </tr>
                                        <tr>
                                            <td>系统描述</td>
                                            <td>${demandOpenViewModel.systemDesc}</td>
                                        </tr>
                                        <tr>
                                            <td>系统类型</td>
                                            <td>${demandOpenViewModel.systemType}</td>
                                        </tr>
                                        <tr>
                                            <td>开发语言</td>
                                            <td>${demandOpenViewModel.devLanguage}</td>
                                        </tr>
                                        <tr>
                                            <td>所属单位</td>
                                            <td>${demandOpenViewModel.belongTo}</td>
                                        </tr>
                                        <tr>
                                            <td>所有权</td>
                                            <c:if test="${demandOpenViewModel.hasOwnership==0}"><td>是</td></c:if>
                                            <c:if test="${demandOpenViewModel.hasOwnership!=0}"><td>否</td></c:if>
                                         </tr>
                                         <tr>
                                              <td>访问地址</td>
                                              <td>${demandOpenViewModel.url}</td>
                                          </tr>
                                          <tr>
                                              <td>网络类型</td>
                                              <td>${demandOpenViewModel.networkType}</td>
                                          </tr>
                                          <tr>
                                              <td>其他说明</td>
                                              <td>${demandOpenViewModel.description}</td>
                                          </tr>
                                          <input type="hidden" name="id" id="requirementId" value="${demandOpenViewModel.id}">
                                    </table>
                                </div>
                            </div>
                      </div>
                  </div>

    <div id="divReceive" class="fade" style="display: none;">
        <div class="window" >
            <div class="top00">
                <span class="p">接单</span>
                <img src="img/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 type="text/javascript">

        //弹出接单页面
        function fnCloseReceive(){
            if (!checkAuthentication()){
                return;
            }
            $("#divReceive").show();
        }
        //取消接单页面
        function offlineReceive(){
            $("#divReceive").hide();
        }
        function receive() {
            $.ajax({
                url:"<%=basePath%>/open/apiDemand/receive.action/${demandOpenViewModel.id}",
                type:"post",
                data:$("#receiveForm").serialize(),
                success:function(msg){
                    if(msg.stateCode==200) {
                        $("#divReceive").hide();
                        alert("接单成功");
                        $("#jiedan").hide() ;
                        $("#yijieda").show() ;
                    }
                }
            })

        }

        //关注
        function follow() {
            if (!checkAuthentication()){
                return;
            }
            var requirementId = $("#requirementId").val() ;
            $.post(
                '<%=basePath%>/open/apiDemand/follow.action',
                {id:requirementId},
                function(datas){
                    if(datas.stateCode==200){
                        if (datas.msg=='关注成功'){
                            alert('关注成功') ;
                            $('#followId').hide();
                            $('#delfollowId').show();
                        }else{
                            alert('已取消关注') ;
                            $('#followId').show();
                            $('#delfollowId').hide();
                        }
                    }else {
                        alert(datas.msg);
                    }
                },
                'json')
        }
    </script>
</html>