@using GBLab.Common.Expand;
@{
    Layout = "~/Views/Shared/_Layout_Shop.cshtml";
    var config = ViewData["SystemConfig"] as GBLab.Entities.Config.SystemConfig;
    var listdata = ViewData["listdata"] as List<GBLab.Entities.T_ZYInfo>;
    string tree = ViewData["tree"].DefaultIsNullOrEmpty("");
    var model = ViewData["infomodel"] as GBLab.Entities.T_ZYInfo;
}
@*头部查询*@
@{Html.RenderPartial("~/Views/Shared/Shop/_Header_Search.cshtml");}
<div class="row container" style="margin: auto;">
    <div class="col-sm-9">
        <div class="ibox btc3">
            <div class="ibox-content">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="m-b-md">
                            <a href="https://wpa.qq.com/msgrd?v=3&uin=381418569&site=qq&menu=yes" class="btn btn-white btn-xs pull-right feedback" target="_blank">提交反馈</a>
                            <h2>@(model.F_Name)</h2>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <dl class="dl-horizontal infoheader">

                            <dt>资源分类：</dt>
                            <dd><a target="_blank" title="@(model.T_Type.F_Name)" href="/@(model.T_Type.F_EnName)/all/all/all/1.html">@(model.T_Type.F_Name)</a></dd>

                            <dt>资源类型：</dt>
                            <dd>程序源码</dd>

                            <dt>资源大小：</dt>
                            <dd>@((model.F_FilesSize / 1024).ToString("f2") + "KB")</dd>
                            <dt>上传时间：</dt>
                            <dd>
                                @(model.F_AddDate.ToString("yyyy-MM-dd"))
                            </dd>
                        </dl>
                    </div>
                    <div class="col-sm-6" id="cluster_info">
                        <dl class="dl-horizontal infoheader">
                            <dt>文件夹数量：</dt>
                            <dd>@(model.F_FolderAllCount)</dd>
                            <dt>文件数量：</dt>
                            <dd>@(model.F_FileAllCount)</dd>
                            <dt>浏览次数：</dt>
                            <dd>@(model.F_NumView)</dd>
                            <dt>下载次数：</dt>
                            <dd>@(model.F_NumDownload)</dd>
                        </dl>
                    </div>
                </div>
                <div class="col-sm-12">
                    <dl class="dl-horizontal infoheader">
                        <dt>安全检测：</dt>
                        <dd>
                            <small>通过杀毒软件检测</small>
                        </dd>
                    </dl>
                </div>
                <div class="col-sm-12">
                    <dl class="dl-horizontal infoheader">
                        <dt>资源下载：</dt>
                        <dd>
                            <button id="subdownloadnormal" name="subfav" type="button" class="btn btn-primary btn-sm infosub">积分下载</button>
                            <button id="subdownloadvip" name="subfav" type="button" class="btn btn-primary btn-sm infosub">VIP下载</button>
                            <button id="subfav" name="subfav" type="button" class="btn btn-primary btn-sm infosub">收藏资源</button>
                        </dd>
                    </dl>
                </div>
                <div class="row m-t-sm">
                    <div class="col-sm-12">
                        <div class="panel blank-panel">
                            <div class="panel-heading">
                                <div class="panel-options">
                                    <ul class="nav nav-tabs">
                                        <li>
                                            <a href="project_detail.html#tab-1" data-toggle="tab">资源说明</a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                            <div class="panel-body">
                                <div class="tab-content">
                                    <div class="tab-pane active" id="tab-1">
                                        @Html.Raw(model.F_Info.DefaultIsNullOrEmpty("") == "" ? "暂无" : model.F_Info.DefaultIsNullOrEmpty(""))
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="ibox float-e-margins">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>资源目录结构</h5>
                </div>
                <div class="ibox-content">

                    <div id="jstree1">
                        @Html.Raw(tree)
                    </div>

                </div>
            </div>
        </div>
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>相关资源列表</h5>
            </div>
            <div class="ibox-content">
                <div class="feed-activity-list">
                    @if (listdata.Count == 0) {
                        <div class="noinfo">
                            未找到相关资源。
                        </div>
                    } else {
                        foreach (var item in listdata) {
                            <div class="feed-element">
                                <div>
                                    <small class="pull-right text-navy">@("积分：" + item.F_Money.ToString())</small>
                                    <strong><a target="_blank" title="@(item.T_Type.F_Name)" href="/@(item.T_Type.F_EnName)/all/all/all/1.html">@(item.T_Type.F_Name)</a></strong>
                                    <div class="listdata"><a target="_blank" title="@(item.F_Name)" href="/detail/@(item.F_Id.ToString()).html">@(item.F_Name)</a></div>
                                    <small class="text-muted">@(item.F_AddDate.ToString("yyyy-MM-dd"))</small>
                                </div>
                            </div>
                        }
                    }
                </div>
            </div>
        </div>
    </div>
    @*@{Html.RenderPartial("~/Views/Shop/Block/_Left_Upload.cshtml");}*@
    @{Html.RenderPartial("~/Views/Shop/Block/_Left_Buy.cshtml");}
    @{Html.RenderPartial("~/Views/Shop/Block/_Left_Download.cshtml");}
    @*@{Html.RenderPartial("~/Views/Shop/Block/_Left_View.cshtml");}*@
    @{Html.RenderPartial("~/Views/Shop/Block/_Left_New.cshtml");}
    @{Html.RenderPartial("~/Views/Shop/Block/_Left_TagsList.cshtml");}
</div>
@section JavaScript{
    <script type="text/javascript">
        // 事件初始化
        $(function () {
            detailview();
            $("#subfav").click(function () {
                detailfav();
            });
            $("#subdownloadnormal").click(function () {
                subdownloadnormal();
            });
            $("#subdownloadvip").click(function () {
                subdownloadvip();
            });
        });

        // 信息浏览
        function detailview() {
            var infoId = '@(model.F_Id)';
            var infoUserGuid = $.cookie('@(GBLab.Common.Utils.ConfigHelper.ZYUserAuthName)');
            // 获取分类信息
            $.ajax({
                type: "POST",
                url: "/user/detailview",
                data: "infoId=" + infoId
                    + "&infoUserGuid=" + infoUserGuid,
                success: function (data) {
                    var result = $.parseJSON(data);
                    console.log(result);
                },
                error: function (data) {
                    alert('数据提交失败，请联系管理员。')
                }
            });
        }

        // 正常下载
        function subdownloadnormal(){            
            var infoUserGuid = $.cookie('@(GBLab.Common.Utils.ConfigHelper.ZYUserAuthName)');
            if (infoUserGuid == '' || infoUserGuid == undefined) {
                alert('用户未登录，请先登录。');
            } else {
                window.location.href = '/user/detaildownload?downloadtype=normal&infoId='+'@(model.F_Id)';
            }
        }

        // vip下载
        function subdownloadvip(){            
            var infoUserGuid = $.cookie('@(GBLab.Common.Utils.ConfigHelper.ZYUserAuthName)');
            if (infoUserGuid == '' || infoUserGuid == undefined) {
                alert('用户未登录，请先登录。');
            } else {
                window.location.href = '/user/detaildownload?downloadtype=vip&infoId='+'@(model.F_Id)';
            }
        }

        // 信息收藏
        function detailfav() {
            var infoId = '@(model.F_Id)';
            var infoUserGuid = $.cookie('@(GBLab.Common.Utils.ConfigHelper.ZYUserAuthName)');
            // 获取分类信息
            $.ajax({
                type: "POST",
                url: "/user/detailfav",
                data: "infoId=" + infoId
                    + "&infoUserGuid=" + infoUserGuid,
                success: function (data) {
                    var result = $.parseJSON(data);
                    console.log(result);
                    if (result.statusCode === 200) {
                        alert("[成功]收藏成功。" + result.message);
                    }
                    if (result.statusCode === 300) {
                        alert("[失败]收藏失败" + result.message)
                    }
                },
                error: function (data) {
                    alert('数据提交失败，请联系管理员。')
                }
            });
        }
    </script>
}