231 lines
11 KiB
HTML
Executable File
231 lines
11 KiB
HTML
Executable File
<div class="upload-video-box">
|
||
<div id="upload_video_list{$append}" class="upload_video_list upload-items-list">
|
||
{if !empty($videos)}
|
||
{php}$videos = json_decode($videos, true);{/php}
|
||
{foreach $videos as $k => $video}
|
||
<dd class="item_video upload-items-one" id="video_{$k}">
|
||
<div class="videos">
|
||
<div class="operate">
|
||
<i onclick="UPLOAD_VIDEO_DEL(this)" class="close layui-icon"></i>
|
||
</div>
|
||
<div class="layer-videos">
|
||
<video src="{$video.src ?? ''}" style="width: 300px;" controls="controls">您的浏览器不支持video标签。</video>
|
||
</div>
|
||
</div>
|
||
<div class="info">
|
||
<textarea name="videos{$append}[{$k}][title]" class="layui-textarea" placeholder="标题">{$video.title ?? ''}</textarea>
|
||
<textarea name="videos{$append}[{$k}][desc]" class="layui-textarea" placeholder="描述">{$video.desc ?? ''}</textarea>
|
||
<input type="text" class="layui-input" name="videos{$append}[{$k}][alt]" value="{$video.alt ?? ''}" placeholder="ALT属性,选填" />
|
||
<input type="text" class="layui-input" name="videos{$append}[{$k}][link]" value="{$video.link ?? ''}" placeholder="链接,选填" />
|
||
<input type="hidden" name="videos{$append}[{$k}][src]" value="{$video.src ?? ''}" />
|
||
</div>
|
||
</dd>
|
||
{/foreach}
|
||
{/if}
|
||
</div>
|
||
<div class="upload_video_btn upload_file_btn" id="upload-videos{$append}">
|
||
<i></i><p>视频上传</p>
|
||
</div>
|
||
<div class="upload_img_btn" id="serverVideoList{$append}" style="margin-left: 15px;">
|
||
<i></i><p>服务器视频</p>
|
||
</div>
|
||
<div class="layui-clear"></div>
|
||
<div class="upload-image-points">
|
||
<div class="layui-form-mid layui-word-aux">服务器最大支持:{$post_max_size}以内的文件上传</div>
|
||
</div>
|
||
</div>
|
||
<style type="text/css">
|
||
#selectable .ui-selecting { background: #FECA40; }
|
||
#selectable .ui-selected { background: #F39814; color: white; }
|
||
#selectable { list-style-type: none; margin: 0; padding: 0;}
|
||
</style>
|
||
<script type="text/javascript">
|
||
var _token = $('#token').attr('content');
|
||
var page = 1;
|
||
|
||
$(document).ready(function() {
|
||
var numid = $('#upload_video_list{$append}>dd').length;
|
||
$(".upload_video_list").sortable({
|
||
cursor: "move",
|
||
items: "dd", //只是li可以拖动
|
||
opacity: 0.6, //拖动时,透明度为0.6
|
||
revert: true, //释放时,增加动画
|
||
update: function(event, ui) { //更新排序之后
|
||
//alert($(this).sortable("toArray"));
|
||
}
|
||
});
|
||
|
||
var uploadUrl = "{:url('manager.upload/video')}";
|
||
layui.use(['upload', 'element'], function() {
|
||
var upload = layui.upload;
|
||
var element = layui.element;
|
||
|
||
upload.render({
|
||
elem: '#upload-videos{$append}',
|
||
url: uploadUrl,
|
||
data: {_token:_token},
|
||
field: 'video',
|
||
multiple: false,
|
||
accept: 'video',
|
||
acceptMime: 'video/*',
|
||
exts: 'mp4',
|
||
before: function(obj) {
|
||
layer.msg('文件上传中...', {
|
||
icon: 16,
|
||
shade: 0.01,
|
||
time: 0
|
||
})
|
||
},
|
||
done: function(res) {
|
||
if(res.code == 0){
|
||
layer.close(layer.msg());
|
||
$('#upload_video_list{$append}').append('<dd class="item_video" id="video_' + numid +'">'+
|
||
'<div class="videos">' +
|
||
'<div class="operate"><i onclick="UPLOAD_VIDEO_DEL(this)" class="close layui-icon"></i></div>'+
|
||
'<div class="layer-videos"><video style="width: 300px;" src="' +res.data.src +'" controls="controls">您的浏览器不支持video标签。</video></div>' +
|
||
'</div>'+
|
||
'<div class="info">' +
|
||
'<textarea name="videos{$append}['+numid+'][title]" class="layui-textarea" placeholder="标题"></textarea>' +
|
||
'<textarea name="videos{$append}['+numid+'][desc]" class="layui-textarea" placeholder="描述"></textarea>' +
|
||
'<input type="text" class="layui-input" name="videos{$append}['+numid+'][alt]" value="" placeholder="ALT属性,选填" />'+
|
||
'<input type="text" class="layui-input" name="videos{$append}['+numid+'][link]" value="" placeholder="链接,选填" />'+
|
||
'<input type="hidden" name="videos{$append}['+numid+'][src]" value="' +res.data.src + '" />' +
|
||
'</div>' +
|
||
'</dd>');
|
||
numid++;
|
||
$(window).trigger("resize");
|
||
}else{
|
||
layer.msg(res.msg);
|
||
}
|
||
}
|
||
})
|
||
|
||
$('#serverVideoList{$append}').click(function(){
|
||
var html = '';
|
||
page = 1;
|
||
$.ajax('/manager/file/list',{
|
||
data:{
|
||
type:'video',
|
||
page:page,
|
||
size:30
|
||
},
|
||
headers: {
|
||
'X-CSRF-TOKEN': _token
|
||
},
|
||
dataType:'json',//服务器返回json格式数据
|
||
type:'post',//HTTP请求类型
|
||
timeout:10000,//超时时间设置为10秒;
|
||
success:function(data){
|
||
if(data.code == 0){
|
||
if(data.data.length > 0){
|
||
html += '<div class="layui-card-body"><div class="serverVideosList"><ul id="selectable">'
|
||
$.each(data.data,function(i,item){
|
||
html += '<li>' +
|
||
'<video controls="controls" src="'+item.src+'"></video>' +
|
||
'<p onclick="videoListUrl(this, ' + numid + ')" data-box="upload_video_list{$append}">'+item.name+'</p>'+
|
||
'</li>'
|
||
})
|
||
html += '</ul></div>';
|
||
if(data.data.length >= 30){
|
||
html += '<div class="serverMore"><a data-box="upload_video_list{$append}" onclick="videosList(this, ' + numid + ')">加载更多</a></div>'
|
||
page++
|
||
}
|
||
html += '<div class="layui-clear"></div></div>';
|
||
layer.open({
|
||
type: 1,
|
||
title: '服务器视频',
|
||
shadeClose: true,
|
||
area: ['800px',''], //宽高
|
||
move: false,
|
||
content: html,
|
||
success:function(layero, index) {
|
||
alertRender()
|
||
layero.find('.serverVideosList ul li p').attr('data-id',index)
|
||
layero.find('.serverMore a').attr('data-id',index)
|
||
}
|
||
});
|
||
numid++;
|
||
}else{
|
||
layer.msg('暂无数据')
|
||
}
|
||
}
|
||
},
|
||
error:function(xhr,type,errorThrown){
|
||
|
||
}
|
||
});
|
||
|
||
})
|
||
|
||
});
|
||
});
|
||
|
||
function videoListUrl(obj, numid){
|
||
var videoSrc = $(obj).parent().find('video').attr('src');
|
||
var imTpl = '<dd class="item_video upload-items-one" id="video_' + numid +'">'+
|
||
'<div class="videos">' +
|
||
'<div class="operate"><i onclick="UPLOAD_VIDEO_DEL(this)" class="close layui-icon"></i></div>'+
|
||
'<div class="layer-videos"><video src="'+ videoSrc +'" controls="controls">您的浏览器不支持video标签。</video></div>'+
|
||
'</div>'+
|
||
'<div class="info">' +
|
||
'<textarea name="videos{$append}['+numid+'][title]" class="layui-textarea" placeholder="标题"></textarea>' +
|
||
'<textarea name="videos{$append}['+numid+'][desc]" class="layui-textarea" placeholder="描述"></textarea>' +
|
||
'<input type="text" class="layui-input" name="videos{$append}['+numid+'][alt]" value="" placeholder="ALT属性,选填" />'+
|
||
'<input type="text" class="layui-input" name="videos{$append}['+numid+'][link]" value="" placeholder="链接,选填" />'+
|
||
'<input type="hidden" name="videos{$append}['+numid+'][src]" value="' + videoSrc + '" />' +
|
||
'</div>' +
|
||
'</dd>';
|
||
numid++;
|
||
$('#'+$(obj).attr('data-box')).append(imTpl);
|
||
parent.layer.close($(obj).attr('data-id'));
|
||
}
|
||
|
||
|
||
function videosList(obj, numid){
|
||
$.ajax('/manager/file/list',{
|
||
data:{
|
||
type:'video',
|
||
page:page,
|
||
size:30
|
||
},
|
||
headers: {
|
||
'X-CSRF-TOKEN': _token
|
||
},
|
||
dataType:'json',//服务器返回json格式数据
|
||
type:'post',//HTTP请求类型
|
||
timeout:10000,//超时时间设置为10秒;
|
||
success:function(data){
|
||
if(data.code == 0){
|
||
if(data.data.length > 0){
|
||
var html = ''
|
||
$.each(data.data,function(i,item){
|
||
html += '<li>' +
|
||
'<video controls="controls" src="'+item.src+'" data-id="'+$(obj).attr('data-id')+'" ></video>' +
|
||
'<p onclick="videoListUrl(this, ' + numid + ')" data-box="'+$(obj).attr('data-box')+'">'+item.name+'</p>'+
|
||
'</li>'
|
||
})
|
||
$(obj).parent().parent().find('.serverVideosList ul').append(html)
|
||
$(window).trigger("resize");
|
||
if(data.data.length < 30){
|
||
$(obj).parent().append('<p>没有了</p>')
|
||
$(obj).parent().find('a').remove();
|
||
}else{
|
||
page++;
|
||
}
|
||
}else{
|
||
layer.msg(data.msg)
|
||
}
|
||
}
|
||
},
|
||
error:function(xhr,type,errorThrown){
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
// 删除上传音频
|
||
function UPLOAD_VIDEO_DEL(divs) {
|
||
$(divs).closest('dd.item_video').remove();
|
||
}
|
||
</script>
|