{include file="public/header" /}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto" id="LAY-user">
            <div>
				<span class="layui-breadcrumb" lay-separator="/"></span>	
            </div>
        </div>

        <div class="layui-card-body">
            <table id="LAY-table-manage" lay-filter="LAY-table-manage"></table>
			<!--账号模板-->
            <script type="text/html" id="fileBar">
			{{# if(d.fileType !== '文件夹'){ }}
				{{d.fileName}}
			{{# }else{ }}
				<a href="{:url('panList')}?id={$param.id}&fileId={{d.fileId}}" id="fileId-{{d.md5}}" style="color:blue;">{{d.fileName}}</a>
			{{# } }}
            </script>
			<!--操作模板-->
            <script type="text/html" id="opeBar">
			{{# if(d.fileType !== '文件夹'){ }}
				{{# if(d.fileType.match(/(mp4|ts|mkv)$/i)){ }}
				<a class="layui-btn layui-btn-xs layui-btn-primary" title="播放预览" lay-event="look"><i class="layui-icon layui-icon-play"></i></a>
				{{# }else if(d.fileType.match(/(gif|jpg|jpeg|png)$/i)){ }}
				<a class="layui-btn layui-btn-xs layui-btn-primary" title="预览图片" lay-event="look"><i class="layui-icon layui-icon-picture"></i></a>
				{{# }else{ }}
				<a class="layui-btn layui-btn-xs layui-btn-primary" title="下载" lay-event="look"><i class="layui-icon layui-icon-download-circle"></i></a>
				{{# } }}
				<a class="layui-btn layui-btn-xs layui-btn-normal" title="复制链接" lay-event="copy"><i class="layui-icon layui-icon-link"></i></a>
				<a class="layui-btn layui-btn-xs " title="分享文件" lay-event="share"><i class="layui-icon layui-icon-share"></i></a>
			{{# }else{ }}
				<a class="layui-btn layui-btn-xs layui-btn-normal" title="打开文件夹" lay-event="openFolder">打开文件夹</a>
				<a class="layui-btn layui-btn-xs " title="分享文件夹" lay-event="share"><i class="layui-icon layui-icon-share"></i></a>
			{{# } }}
            </script>
			<!--批量操作模板-->
			<script type="text/html" id="toolBar">
				<a class="layui-btn layui-btn-xs " title="批量复制外链" lay-event="copyAll"><i class="layui-icon layui-icon-link"></i>批量复制</a>
				<a class="layui-btn layui-btn-xs layui-btn-normal" title="一键发布" lay-event="fabu"><i class="layui-icon layui-icon-release"></i>一键发布</a>
				<a class="layui-btn layui-btn-xs " lay-event="m3u8"><i class="layui-icon layui-icon-senior"></i>生成m3u8链接</a>
			</script>
        </div>
    </div>
</div>
<!--复制-->
<!--公共变量-->
{$pan_data}
{include file="public/footer" /}
{include file="public/copy" /}
<script>
    layui.use(['index','element','table','form'], function () {
        var $ = layui.$, form = layui.form, element = layui.element, table = layui.table;
		var load = layer.load();
        var panList = table.render({
            elem: '#LAY-table-manage'
			, toolbar: '#toolBar'
			, defaultToolbar: ''
            , url: '?id=' + maopan.account_id + '&fileId=' + maopan.fileId
            , page: true
            , even: false
            , limits: [200]
            , limit: "200"
            , loading: true
            , id: 'LAY-table'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'fileName', title: '文件名', minWidth: 200,sort:true, toolbar: '#fileBar'}
				, {field: 'fileId', minWidth: 200, title: '文件ID'}
                , {field: 'fileType', width: 100, title: '文件类型', align: 'center'}
				, {field: 'fileSize', width: 110, title: '文件大小', align: 'center',templet: function (d){
					return d.fileSize ? bytesToSize(d.fileSize) : (d.fabu ? '<font color="green" title="最后发布时间：'+layui.util.toDateString(d.fabu*1000)+'">已发布</font>' : '');
				}}
                , {field: 'create_time', width: 180, sort:true, title: '更新时间', align: 'center'}				
                , {fixed: 'right', width: 150, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
				layer.close(load);
				if(typeof res.page_token !== "undefined" && res.page_token!=''){
				    if($("#page_token").length > 0){
				        $(".layui-flow-more").remove();
				    }
				    $('.layui-table-page').after('<div class="layui-flow-more"><a href="javascript:;" id="page_token" data-page="' + res.page_token + '"><cite>加载更多</cite></a></div>');
					$('.layui-table-page').hide();
				}
				var device = layui.device();
				if(typeof res.capacity !== "undefined"){
				    res.capacity.total_size>0 ? device.mobile ? '' : $('.layui-table-tool-self').html('容量：' + bytesToSize(res.capacity.used_size) +' / ' + bytesToSize(res.capacity.total_size)) : '';
				}
				html = '';
				if(typeof res.path !== "undefined"){
					maopan.filePath = '/';
					for(var i=0;i<res.path.length;i++){
						html += '<a href="?id=' + maopan.account_id + '&fileId=' + res.path[i].parentId + '">'+res.path[i].name+'</a>';
						maopan.filePath += res.path[i].name +'/';
						maopan.filePath = maopan.filePath.replace('/全部文件/','/');
					}
				}
				$('.layui-breadcrumb').html(html);
				element.render('breadcrumb');
            }
        });
		$(document).on("click", "#page_token",function () {
			page_token = $("#page_token").attr("data-page");
			$("#page_token").remove();
			table.reload("LAY-table",{
				page: { curr: 1 },
				where: {page_token:page_token}
			});
			$('body,html').animate({scrollTop:0},1000); ;
			return false;
		});
    });
</script>
</body>
</html>