{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">
			<blockquote class="layui-elem-quote">
				<p style="color:red">移动云盘会转码视频，未转码的视频无法在线播放，视频文件选择“文件直链”，将无法在网页端播放</p>
				<p>若要在网页端播放，请选择“播放链接”，默认使用的网盘转码后的播放地址</p>
			</blockquote>		
            <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}}&type={$param.type}&newCloud={$param.newCloud}"  id="fileId-{{d.fileId}}" style="color:blue;">{{d.fileName}}</a>
			{{# } }}
            </script>
			<!--操作模板-->
            <script type="text/html" id="opeBar">
			{{# if(d.fileType !== '文件夹'){ }}
				{{# if(d.fileType.match(/(mp4|mkv|flv)$/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="page-pagebar">
			  <div class="layui-btn-container" style="display:none;">
				<button class="layui-btn layui-btn-sm" lay-event="nextPageBtn">下一页</button>
			  </div>
			</script>
			<!--批量操作模板-->
			<script type="text/html" id="toolBar">
				<a class="layui-btn layui-btn-xs " lay-event="copyAll"><i class="layui-icon layui-icon-link"></i>批量复制</a>
				<a class="layui-btn layui-btn-normal layui-btn-xs " 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>
	var newCloud = '{$param.newCloud}';
    layui.use(['index','element','table','form'], function () {
        var $ = layui.$
            , form = layui.form
			, element = layui.element
            , table = layui.table;
		var load = layer.load();	
        table.render({
            elem: '#LAY-table-manage'
			, toolbar: '#toolBar'
			, defaultToolbar: ''
            , url: '?id=' + maopan.account_id + '&fileId=' + maopan.fileId + '&type=' + maopan.dataType
            , page: true
			, pagebar: '#page-pagebar' // 分页栏模板
            , even: false
            , autoSort: false
            , cellMinWidth: 150
            , limits: [100]
            , limit: "100"
            , loading: true
            , id: 'LAY-table'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'fileName', minWidth: 300, title: '文件名', 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: 'update_time', width: 180, title: '更新时间', align: 'center'}				
                , {fixed: 'right', width: 150, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
				layer.close(load);
				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 + '&type=' + maopan.dataType + '&newCloud='+newCloud+'">'+res.path[i].name+'</a>';
						maopan.filePath += res.path[i].name +'/';
					}
					maopan.filePath = maopan.filePath.replace('/全部文件/','/');
				}
				if(newCloud==1 && res.nextPage){
					$(".layui-table-pageview").hide();
					$(".layui-btn-container").show();
					$(".layui-table-pagebar").css("float","left");
					$(".layui-btn-container .layui-btn").attr("lay-event",res.nextPage);
				}
				$('.layui-breadcrumb').html(html);
				element.render('breadcrumb');
            }
        });
		// 底部分页栏事件
		table.on('pagebar(LAY-table-manage)', function(obj){
			var sort = obj.config.initSort;
			var whereData = {"nextPage":obj.event};
			if(typeof sort !== "undefined"){
				whereData["field"] = sort.field;
				whereData["order"] = sort.type;
			}
			table.reload('LAY-table', {
                where: whereData
            });
		});
    });


</script>
</body>
</html>