<%@ page import="com.lightinit.hsdataportal.dictionary.DicResourceShareType" %>
<%@ 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>
<head>
    <jsp:include page="../common/head.jsp"></jsp:include>
</head>
<body>
<jsp:include page="../common/body_header.jsp"></jsp:include>

<div class="mid">
    <jsp:include page="../common/user_center_header.jsp"></jsp:include>
    <div class="user-mid2">
        <div class="xinxi0">
            <div class="user-mid0">
                <div class="if">
                    <span onclick="showAndHiddenApi1()" class="xx0 " id="tagShenqing"><a>我的API</a></span>
                    <span onclick="showAndHiddenApi2()" class="xx" id="tagGuanzhu"><a>关注的API</a></span>
                </div>
                <div class="clearfix"></div>
                <div id="shenqing" class="xx-main">

                    <table>
                        <tr bgcolor="#f2f2f2" class="biaotou1">
                            <td class="td7">API名称</td>
                            <td class="td7">API描述</td>
                            <td class="td7">申请时间</td>
                            <td class="td7">申请次数</td>
                            <td class="td3">共享类型</td>
                            <td class="td3">状态</td>
                            <td class="td3">操作</td>

                        </tr>
                        <c:if test="${applyList.size()>0}">
                            <c:forEach items="${applyList}" var="apply">
                                <tr>
                                    <td>
                                        <a class="qxbm"
                                           href="<%=basePath%>/share/api/view.htm?id=${apply.resourceId}&settingId=${apply.publishSettingId}">${apply.resourceName}</a>
                                    </td>
                                    <td>${apply.resourceSummary}</td>
                                    <td><fmt:formatDate value="${apply.applyTime}" pattern="yyyy-MM-dd"/></td>
                                        <%-- TODO 申请次数--%>
                                    <td></td>
                                    <td>${apply.shareType}</td>
                                    <c:set var="nowDate" value="<%=System.currentTimeMillis()%>"></c:set>
                                    <c:if test="${nowDate-apply.expiriedDate.time > 0}">
                                        <td>已过期</td>
                                    </c:if>
                                    <c:if test="${nowDate-apply.expiriedDate.time < 0}">
                                        <td>${apply.authState}</td>
                                    </c:if>
                                    <td>
                                        <c:if test="${nowDate-apply.expiriedDate.time > 0}">
                                            <a class="qxbm"
                                               href="<%=basePath%>/share/api/view.htm?id=${apply.resourceId}&settingId=${apply.publishSettingId}">再次申请</a>
                                        </c:if>
                                        <a class="qxbm" href="##" onclick="showApply(${apply.id})">查看反馈</a>
                                    </td>
                                </tr>
                            </c:forEach>
                        </c:if>
                    </table>


                    <input type="hidden" id="flag" value="${falg}">
                </div>

                <div id="guanzhu" class="xx-main">
                    <table>
                        <tr bgcolor="#f2f2f2" class="biaotou1">
                            <td class="td5">API名称</td>
                            <td>API描述</td>
                            <td class="td3">发布时间</td>
                            <td class="td3">关注时间</td>
                            <td class="td3">操作</td>
                        </tr>

                        <c:if test="${followList.size()>0}">
                            <c:forEach items="${followList}" var="follow">
                                <tr>
                                    <td>${follow.resourceName}</td>
                                    <td>${follow.resourceSummary}</td>
                                    <td><fmt:formatDate value="${follow.auditedAt}" pattern="yyyy-MM-dd"/></td>
                                    <td><fmt:formatDate value="${follow.createdAt}" pattern="yyyy-MM-dd"/></td>
                                    <td><a class="qxbm" onclick="onFollow(${follow.id})">取消关注</a></td>
                                </tr>
                            </c:forEach>
                        </c:if>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <%--////////////////////////////////////////反馈详情信息  ///////////////////////////////////////////////////////--%>
    <div id="divApply" style="display: none;" class="fade" >
        <div class="window">
            <div class="top00">
                <span class="p">查看反馈</span>
                <img src="<%=resourcePath%>/images/icon_guanbi.png" alt="" class="guanbi" onclick="closeDivApply()">
            </div>
            <div class="form6">
                <form>
                    <div class="application-font0">
                        <span class="application-font1">授权状态：</span>
                        <span class="application-font2" id="zhuangtai"></span>
                    </div>
                    <div class="application-font">
                        <span class="application-font1">授权反馈：</span>
                        <span class="application-font2" id="fankui"></span>
                    </div>
                    <div class="application-font">
                        <span class="application-font1">授权部门：</span>
                        <span class="application-font2" id="bumen"></span>
                    </div>
                    <div  class="application-font" style="visibility: hidden;">
                        <span class="application-font1">申请理由：</span>
                        <input type="text" class="application-font2" id="applyReason" name="applyReason" >
                    </div>
                    <div class="jiage-xinxi" style="visibility: hidden;">
                        已选择<span class="shuzi">1</span>个套餐，应付：¥<span class="shuzi">${outputModel.packagePrice}</span>元
                    </div>
                    <div class="clearfix"></div>
                    <div>
                        <div class="xieyi0" style="visibility: hidden;">
                            <span><input type="checkbox" class="box0" value="我已阅读并接受"></span>
                            <span class="fuwu00">阅读并接受<a class="xieyi" target="_blank" href="<%=basePath%>/share/static/agreement_service">《平台服务协议》</a></span>
                        </div>
                        <div class="jiarugwc" style="visibility: hidden;">加入购物车</div>
                        <div class="shenqing" onclick="closeDivApply()">取消</div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


<jsp:include page="../common/body_footer.jsp"></jsp:include>
<script type="text/javascript">
    if ($("#flag").val() == 0) {
        showAndHiddenApi1();
    } else {
        showAndHiddenApi2();
    }
    function showAndHiddenApi1() {
        $("#shenqing").show();
        $("#guanzhu").hide();
        $("#tagShenqing").addClass("xx01");
        $("#tagGuanzhu").removeClass("xx01");
    }

    function showAndHiddenApi2() {
        $("#shenqing").hide();
        $("#guanzhu").show();
        $("#tagGuanzhu").addClass("xx01");
        $("#tagShenqing").removeClass("xx01");
    }

    //打开反馈详情页面
    function fnApplyInfo(){
        $('#divApply').show();
    }
    //关闭反馈详情页面
    function closeDivApply(){
        $('#divApply').hide();
    }

    function showApply(id) {
        $.post("<%=basePath%>/share/myApi/feedback.htm/"+id,function (result) {
            fnApplyInfo()
            $("#zhuangtai").text(result.authState);
            $("#fankui").text(result.auditOpinion);
            $("#bumen").text(result.auditedByName);
        })
    }

    function onFollow(id) {
        window.location.href = "<%=basePath%>/share/myApi/noFollow.action/" + id;
    }
</script>
</body>
</html>