<%@ page import="com.lightinit.hsdataportal.dictionary.DicDataRequirementState" %>
<%@ page import="com.lightinit.hsdataportal.dictionary.DicRequirmentAuditState" %>
<%@ 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="mid">
    <div class="mid0">
        <div class="mid001">
            <div class="mid01">
                <div class="mid01-left">
                    <div class="kuang">
                        <img src="${imageContextPath}${microapp.resourceImg}"  class="icon00">
                    </div>

                    <div class="left-bottom">
                        &nbsp;<span class="bottom0">
                                        <img src="<%=resourcePath%>/images/icon_chakan.png" class="bottomimg">&nbsp;
                        <c:if test="${not empty microapp.viewTimes}"> (${microapp.viewTimes})</c:if>
                        <c:if test="${empty microapp.viewTimes}"> (0)</c:if>
                                    </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <span class="bottom0">
                                        <img src="<%=resourcePath%>/images/icon_xiazai.png" class="bottomimg"> &nbsp;(0)
                                    </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <span class="bottom0">
                                        <img src="<%=resourcePath%>/images/icon_wenben.png" class="bottomimg"> &nbsp;(${microapp.coun})
                                    </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    </div>
                </div>
                <div class="mid01-right">
                    <div>
                        <span class="mingchen">${microapp.resourceName}</span>
                        <span class="biaoqian">${microapp.dataTag}</span>
                        <%--<span class="biaoqian">保险</span>--%>
                    </div>
                    <div class="clearfix"></div>
                    <div class="jianjie">${microapp.resourceSummary}</div>
                    <div class="jiage0">
                        <div>
                            <span class="jiage1">价格：</span>
                            <c:if test="${microapp.chargeMethod eq '免费'}">

                                <span class="jiage2"></span>
                                <span class="jiage3">免费</span>
                            </c:if>
                            <c:if test="${microapp.chargeMethod != '免费'}">
                                <span class="jiage2">￥</span>
                                <span class="jiage3">${microapp.packagePrice}</span>
                            </c:if>
                        </div>
                        <div class="clearfix"></div>

                        <div>
                            <span class="jiage1">${microapp.shareType}</span>
                            <%--<div class="guige2">--%>
                                <%--<span class="guige01">1500</span>--%>
                                <%--<span class="guige02">/1年</span>--%>
                            <%--</div>--%>
                            <%--<div class="guige3">--%>
                                <%--<span class="guige01">2000</span>--%>
                                <%--<span class="guige02">/2年</span>--%>
                            <%--</div>--%>
                        </div>
                    </div>
                    <%--<div class="pingfen">--%>
                        <%--<span class="pingfen1"></span>--%>
                        <%--&lt;%&ndash;<span>&ndash;%&gt;--%>
                                  <%--&lt;%&ndash;<img src="<%=resourcePath%>/images/icon_pingfen1.png" alt="" class="pingfen0">&ndash;%&gt;--%>
                                  <%--&lt;%&ndash;<img src="<%=resourcePath%>/images/icon_pingfen1.png" alt="" class="pingfen0">&ndash;%&gt;--%>
                                  <%--&lt;%&ndash;<img src="<%=resourcePath%>/images/icon_pingfen1.png" alt="" class="pingfen0">&ndash;%&gt;--%>
                                  <%--&lt;%&ndash;<img src="<%=resourcePath%>/images/icon_pingfen1.png" alt="" class="pingfen0">&ndash;%&gt;--%>
                                  <%--&lt;%&ndash;<img src="<%=resourcePath%>/images/icon_pingfen2.png" alt="" class="pingfen0">&ndash;%&gt;--%>
                              <%--&lt;%&ndash;</span>&ndash;%&gt;--%>
                        <%--<span class="pingfen2">4.0分</span>--%>
                    <%--</div>--%>
                    <div class="clearfix"></div>
                    <div class="xinxi04">
                        <div class="xinxi00">
                            <div>
                                <span class="xinxi1">面向对象：</span>
                                <span class="xinxi2">${microapp.customName}</span>
                            </div>
                            <div class="xinxi01">
                                <span class="xinxi1">发布机构：</span>
                                <span class="xinxi2">${microapp.provider}</span>
                            </div>
                        </div>
                        <div class="xinxi02">
                            <div>
                                <span class="xinxi1">分类：</span>
                                <span class="xinxi002">${microapp.themeName}</span>
                            </div>
                            <div class="xinxi01">
                                <span class="xinxi1">发布日期：</span>
                                <span class="xinxi2"><fmt:formatDate value="${microapp.createdAt}" pattern="yyyy-MM-dd"></fmt:formatDate> </span>
                            </div>

                        </div>
                    </div>
                    <div class="clearfix"></div>
                    <div class="button0">
                        <button class="button1"id="fnApplyInfoButton" onclick="fnApplyInfo()" >立即申请</button>

                        <%--<c:if test="${model.settingId ==null}">--%>
                        <%--<button class="button2" onclick="follow()">关注</button>--%>
                        <%--</c:if>--%>
                        <%--<c:if test="${model.settingId !=null}">--%>
                        <%--<input type="hidden" value="${model.followId}" name="followId"/>--%>
                        <%--<button class="button2" onclick="delfollow()">取消关注</button>--%>
                        <%--</c:if>--%>
                        ${microapp.settingId ==null ? '<button class="button2" onclick="fnFollow()" id="followId">关注</button>':'<button class="button2" onclick="fnDelFollow()" id="delfollowId" >取消关注</button>'}
                        <input type="hidden" value="${microapp.microappId}" name="microappId"/>
                        <button class="button3" onclick="openDemo()">查看演示</button>
                    </div>
                </div>
            </div>
            <div class="clearfix"></div>

            <div class="mid02">

                <img src="${imageContextPath}${microapp.screenshot}">

            </div>

        </div>

    </div>
</div>
<div class="clearfix"></div>
<!--------foot---------->

<%--////////////////////////////////////////申请信息   无条件共享///////////////////////////////////////////////////////--%>
<div id="divApply" class="fade" style="display: none;">
    <div style="width:1920px;height:1080px;background-color:rgba(17,23, 35, 0.34)"  >
        <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 id="applyaform">
                    <input type="hidden" name="publishSettingId" value="${microapp.publishSettingId}"/>
                    <input type="hidden" name="shareType" value="${microapp.shareType}"/>
                    <input type="hidden" name="publishInfoId" value="${microapp.publishInfoId}"/>

                    <div class="application-font0">
                        <span class="application-font1">共享类型：</span>
                        <span class="application-font2">${microapp.shareType}</span>
                    </div>
                    <div class="application-font">
                        <span class="application-font1">资源名称：</span>
                        <span class="application-font2">${microapp.resourceName}</span>
                    </div>

                    <div class="clearfix"></div>
                    <div>
                        <div class="xieyi0">
                            <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="apply()">立即申请</div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<%--================================================已申请开放=======================================================--%>
<div id="divApply1" class="fade" style="display: none;">
    <div style="width:1920px;height:1080px;background-color:rgba(17,23, 35, 0.34)"  >
        <div class="window">
            <div class="top00">
                <span class="p">申请信息</span>
                <img src="<%=resourcePath%>/images/icon_guanbi.png" alt="" class="guanbi" onclick="closeDivApply1()">
            </div>
            <div class="form6">
                <form id="applyaform1">
                    <input type="hidden" name="publishSettingId" value="${microapp.publishSettingId}"/>
                    <input type="hidden" name="shareType" value="${microapp.shareType}"/>
                    <input type="hidden" name="publishInfoId" value="${microapp.publishInfoId}"/>

                    <div class="application-font0">
                        <span class="application-font1">共享类型：</span>
                        <span class="application-font2">${microapp.shareType}</span>
                    </div>
                    <div class="application-font">
                        <span class="application-font1">资源名称：</span>
                        <span class="application-font2">${microapp.resourceName}</span>
                    </div>

                    <%--/////////////////////////////判断加入申请理由对话框//////////////////--%>
                    <div  class="application-font" style="display:${outputModel.openType=='无条件开放'?'none':''}">
                        <span class="application-font1">申请理由：</span>
                        <input type="text" name="applyReason" >
                    </div>
                    <%--/////////////////////////////////////////////////////////--%>
                    <div class="jiage-xinxi">
                        <%--已选择<span class="shuzi">1</span>个套餐，应付：¥<span class="shuzi">${outputModel.packagePrice}</span>元--%>
                    </div>
                    <div class="clearfix"></div>
                    <div>
                        <div class="xieyi0">
                            <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="shenqing" onclick="apply1()">授权申请</div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div id="divDemo" class="fade"  style="display: none;">
    <div class="window" style="width: 580px;left: 45%;">
        <div class="form6" style="width: 580px;">
            <form id="demo">
                <div class="application-font-0">

                    <%--<iframe style="margin-left: 20px"   height="580px" width="540px" src="" ></iframe>--%>
                <div class="application-font-0" id="resourceAuthId">
                    <c:if test="${list.size()>0}">
                        <iframe style="margin-left: 20px"   height="580px" width="540px" src="${microapp.url}" ></iframe>
                    </c:if>
                    <c:if test="${!(list.size()>0)}">
                        <iframe style="margin-left: 20px"   height="580px" width="540px" src="${microapp.demoUrl}" ></iframe>
                    </c:if>


                </div>
                <div class="queding0">
                    <span style="margin-left: 210px" class="quxiao" onclick="closeDemo()">取消</span>
                </div>
            </form>
        </div>
    </div>
</div>
<jsp:include page="../common/body_footer.jsp"></jsp:include>
</body>
<script>
    //关注
    function fnFollow () {
        if (!checkAuthentication()){
            return;
        }
        $.ajax({
            url:"<%=basePath%>/share/microapp/follow.action/${microapp.publishSettingId}",
            type:"post",
            success:function(msg){
                if(msg.stateCode==200){
                    $('#divApply').hide();
                    alert("关注成功");
                    window.location.href="<%=basePath%>/share/microapp/view.htm/${microapp.publishSettingId}";
                }



            }
        })
    }
    //取消关注
    function fnDelFollow() {
        if (!checkAuthentication()){
            return;
        }
        $.ajax({
            url:"<%=basePath%>/share/microapp/delfollow.action/${microapp.followId}",
            type:"post",
            success:function(msg){
                if(msg.stateCode==200){
                    $('#divApply').hide();
                    alert("取消关注成功");
                    window.location.href="<%=basePath%>/share/microapp/view.htm/${microapp.publishSettingId}";

                }



            }

        })
    }
    function demo() {
        if (!checkAuthentication()){
            return;
        }
        window.location.href="<%=basePath%>/share/microapp/demo.action/${microapp.publishSettingId}";
    }
    function offline() {
        window.location.href="<%=basePath%>/share/microapp/offline.htm/${microapp.publishSettingId}";
    }
    //打开申请页面
    function fnApplyInfo(){
        if (!checkAuthentication()){
            return;
        }

        if(${microapp.shareType.equals("无条件共享")}){
            $('#divApply').show();
        }else {
            $('#divApply1').show();
        }

    }
    //关闭申请页面
    function closeDivApply(){
        $('#divApply').hide();
    }
    function closeDivApply1(){
        $('#divApply1').hide();
    }
    function apply() {
        if($("input[type='checkbox']").is(':checked')) {
            $.ajax({
                url:"<%=basePath%>/share/microapp/apply.action",
                type:"post",
                data:$("#applyaform").serialize(),
                success:function(msg){
                    if(msg.stateCode==200) {

                        if((msg.msg)=="已经申请过了，请前往用户中心下载") {
                            alert(msg.msg);
                        }else {
                            alert("申请成功");
                        }
                        $('#divApply').hide();
                        $("#resourceAuthId").empty();
                        $("#resourceAuthId").append('<iframe style="margin-left: 20px"   height="580px" width="540px" src="${microapp.url}" ></iframe>');
                        location.href="<%=basePath%>/share/myMicroapp/shareList.action";
                    }

                }

            })
        }else {
            alert("请阅读接受平台服务协议");
        }

    }
    function apply1() {
        if($("input[type='checkbox']").is(':checked')) {
            $.ajax({
                url:"<%=basePath%>/share/microapp/apply.action",
                type:"post",
                data:$("#applyaform1").serialize(),
                success:function(msg){
                    if(msg.stateCode==200) {

                        if((msg.msg)=="已经申请过了，请前往用户中心下载") {
                            alert(msg.msg);
                        }else {
                            alert("申请成功");
                        }
                        $('#divApply1').hide();
                        $("#resourceAuthId").empty();
                        $("#resourceAuthId").append('<iframe style="margin-left: 20px"   height="580px" width="540px" src="${microapp.url}" ></iframe>');
                        location.href="<%=basePath%>/share/myMicroapp/shareList.action";
                    }

                }

            })
        }else{
            alert("请阅读接受平台服务协议");
        }

    }

    //================================================

    //弹出演示页面
    function openDemo(){
        if (!checkAuthentication()){
            return;
        }
        <%--$("iframe").attr("src", "${model.demoUrl}");--%>
        $("#divDemo").show();
    }
    //取消演示页面
    function closeDemo(){
        $("#divDemo").hide();
    }
    <%--function demo() {--%>
    <%--alert();--%>
    <%--$.ajax({--%>
    <%--url:"<%=basePath%>/open/microapp/offlineConference.action/${model.microappId}",--%>
    <%--type:"post"--%>
    <%--})--%>
    <%--}--%>


</script>
</html>