<?php
error_reporting(0); 
include("../../config/ht.php");
session_start();
if(!isset($_SESSION['adminname'])){echo "<script>alert('请重新登录!')</script><script>top.location.href='/$htlj/'</script>";exit;}
$adminname=$_SESSION['adminname'];
$type="where name='$adminname'";
$adminpd=queryall(admin,$type);
if(!$adminpd){echo "<script>alert('请重新登录!')</script><script>top.location.href='/$htlj/'</script>";exit;}
if($adminpd[qx]=='超级管理员'  or $adminpd[qx]=='资源管理员'){}else{echo "<script>alert('无权限')</script><script>top.location.href='/$htlj/'</script>";exit;}
$sjm=random(300);
$zykey=md5($sjm.$shijian);
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="gb2312">
<title>上传视频</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="/2019newui/houtai/css/font-awesome.min.css" media="all" />
<link rel="stylesheet" href="/2019newui/houtai/css/admin.css" media="all">
<link rel="stylesheet" href="/2019newui/houtai/css/peizhi.css" media="all">
<script src='/2019newui/js/jquery.min.js' type="text/javascript"></script>
<script src="/layui/layui.js"></script>
<link rel="stylesheet" type="text/css" href="/2019newui/houtai/css/api.css" />
<link rel="stylesheet" type="text/css" href="/2019newui/houtai/css/style.css" />
</head>
<body style="padding:10px;">
<div class="tplay-body-div">
<fieldset class="layui-elem-field layui-field-title" style="margin-top:20px;"><legend>上传视频</legend></fieldset>
<div class="layui-tab layui-tab-brief">
<div class="layui-tab-content">
<div id="uploader" class="wu-example" style="text-align: center;margin-top: 20px;">
<div id="thelist" class="uploader-list"></div>
<div class="btns">
<div id="picker">点击这里<br />选择您要上传的视频</div>
</div>
</div>
<div class="max-text">最大可以上传<span style="color:#f00;">200M</span>的视频文件</div>
<div class="mark_body">
<div class="mark">
<div style="margin: 15px 0;">视频名称 :
<input type="text" id="name"  value="" style=" width: 150px;">
</div>
<div style="margin: 15px 0;">视频分类 :
<select name="fl"   style=" width: 150px;"  id="fl" >
<option value='请选择'>请选择分类</option>
<?php 
$result = mysql_query("SELECT * FROM fenlei");
$count = mysql_num_rows($result);
?>
<?php if($count == 0){?><option value='0'>暂无分类</option><?php }?>
<?php
$query = mysql_query("SELECT * FROM fenlei");
while($a = mysql_fetch_array($query)) {
?>  
<option value='<?php echo $a[id]?>'><?php echo $a[name]?></option>
<?php }?>
</select>
</div>
<div style="margin: 5px 0;">打赏 :
<span id="dao"><input type="text" id="mininputNumber" onblur="onblurNum(this,1)" value="2" onkeyup="inputNumberF(this,1)" />元 到</span>
<input type="text" id="inputNumber" onblur="onblurNum(this,2)" value="5" onkeyup="inputNumberF(this,2)" />元
</div>
<div>(只能输入<span id="mylimit">1</span>到<span id="mymaxAmountLimit">99</span>之间)</div>
<span id='suijiSelect' class="suijiSelect bg_dui"></span>
<span>随机<span id="randomNum">(<label style="color: #098707;" id="minlableNumber">2</label>到<label id="lableNumber" style="color: #098707;">5</label>元)</span>
</span>
</div>
</div>
<br><br>
<div class="layui-btn" id="ctlBtn" style="text-align: center;width:99%;font-family: "Microsoft YaHei","Helvetica Neue";">上传</div>
<script src="/2019newui/js/myc.js" type="text/javascript" charset="utf-8"></script>
<script src="/2019newui/js/webuploader.js" type="text/javascript" charset="utf-8"></script>	
<script type="text/javascript">
var p =1;
var mylimit = '1';
var mymaxAmountLimit = '99.00';
//随机
$('#suijiSelect').click(function () {
if ($(this).hasClass('bg_dui')) {
$(this).removeClass('bg_dui');
$('#randomNum').css('display', 'none');
$('#dao').css('display', 'none');
} else {
$(this).addClass('bg_dui');
$('#randomNum').css('display', 'inline-block');
$('#dao').css('display', 'inline-block');
}
var mininputNumber = $('#mininputNumber').val().replace(/\.$/g, "");
var inputNumber = $('#inputNumber').val().replace(/\.$/g, "");
if (parseFloat(mininputNumber) > parseFloat(inputNumber)) {
$('#inputNumber').val(mininputNumber);
$('#lableNumber').html(mininputNumber);
}
});
function onblurNum(dom, style) {
var mininputNumber = $('#mininputNumber').val().replace(/\.$/g, "");
var inputNumber = $('#inputNumber').val().replace(/\.$/g, "");
$('#lableNumber').html(inputNumber);
$('#minlableNumber').html(mininputNumber);
if (!mininputNumber) {
$('#mininputNumber').val(1);
$('#minlableNumber').html(1);
}
if (!inputNumber) {
$('#inputNumber').val(1);
$('#lableNumber').html(1);
}
if (!$('#suijiSelect').hasClass('bg_dui')) {
return false;
}
if (style == 1) {
if (parseFloat(mininputNumber) > parseFloat(inputNumber)) {
$('#inputNumber').val(mininputNumber);
$('#lableNumber').html(mininputNumber);
}
} else {
if (parseFloat(inputNumber) < parseFloat(mininputNumber)) {
$('#inputNumber').val(mininputNumber);
$('#lableNumber').html(mininputNumber);
}
}
}
function inputNumberF(dom, style) {
if (style == 1) {
dom.value = dom.value.replace(/[^\d.]/g, "").replace(/^\./g, "").replace(/\.{2,}/g, ".").replace(".", "$#$").replace(/\./g, "").replace("$#$", ".").replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
if (dom.value) {
if (dom.value > 99) {
dom.value = mymaxAmountLimit;
$('#minlableNumber').html(mymaxAmountLimit);
} else if (dom.value < mylimit) {
dom.value = mylimit;
$('#minlableNumber').html(mylimit);
} else {
$('#minlableNumber').html(dom.value);
}
} else {
$('#minlableNumber').html(0);
}
} else {
dom.value = dom.value.replace(/[^\d.]/g, "").replace(/^\./g, "").replace(/\.{2,}/g, ".").replace(".", "$#$").replace(/\./g, "").replace("$#$", ".").replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
if (dom.value) {
if (dom.value > 99) {
dom.value = mymaxAmountLimit;
$('#lableNumber').html(mymaxAmountLimit);
} else {
$('#lableNumber').html(dom.value);
}
} else {
$('#lableNumber').html(0);
}
}
}
var uploader = WebUploader.create({
auto: false,
swf: '/2019newui/js/uploader.swf',
server: '/spupload<?php echo $dshz?>',
pick: '#picker',
disableGlobalDnd: true,
fileNumLimit: 300,
fileSizeLimit: 2000 * 1024 * 1024,    // 200 M
fileSingleSizeLimit: 5000 * 1024 * 1024,
chunkRetry: false,
chunked: true, 
chunkSize:2*1024*1024,
threads: 1,
method:'POST',
accept: {
title: '上传视频',
extensions: 'mp4',
mimeTypes: 'video/*'
}
});
//开始上传
$('#ctlBtn').click(function () {
if (!$('.state').html()) {
layer.msg('请选择您要上传的视频');
return false;
}
var shipinname = document.getElementById("name").value;
if (!shipinname) {
layer.msg('视频名称不能为空');
return false;
}
var fl = document.getElementById("fl").value;
if (fl=='请选择') {
layer.msg('分类未选择');
return false;
}
var random = 0;
if ($('#suijiSelect').hasClass('bg_dui')) {
var random = 1;
}
var amount = parseFloat($('#inputNumber').val()).toFixed(0);
var amount_min = parseFloat($('#mininputNumber').val()).toFixed(0);
if (random == 0) {
amount_min = amount;
}
if (amount_min < mylimit) {
layer.msg('必须要大于' + mylimit + '元');
return false;
}
if (amount < mylimit) {
layer.msg('必须要大于' + mylimit + '元');
return false;
}
if (amount > mymaxAmountLimit) {
layer.msg('必须要小于' + mymaxAmountLimit + '元');
return false;
}
if (amount <= 0) {
layer.msg('请输入金额');
return false;
}
if (!amount) {
layer.msg('您输入的不是数字哦');
return false;
}
if (!amount_min) {
layer.msg('您输入的不是数字哦');
return false;
}
uploader.options.formData.zykey =  '<?php echo $zykey?>';
uploader.options.formData.price = amount;
uploader.options.formData.priceMin = amount_min;
uploader.options.formData.shipinname = shipinname;
uploader.options.formData.fl = fl;
uploader.retry();
});
function sizeBig(num) {
if (num < 1024) {
return num + 'B';
} else if (num < 1024 * 1024) {
return (num / 1024).toFixed(2) + 'KB';
} else if (num < 1024 * 1024 * 1024) {
return ((num / 1024) / 1024).toFixed(2) + 'M';
}
}
uploader.on('fileQueued', function (file) {
$('.btns').css('display', 'none');
$list = $('#thelist');
var $li = $(
'<div id="' + file.id + '" class="file-item thumbnail" style="margin:20px 0" > ' +
'<img>' +
'<div class="info">' + file.name + '</div>' +
'<div class="state" style="color:red;">' + sizeBig(file.size) + '</div>' +
'<p class="state" style="color:red;">等待上传</p>' +
'</div>'
),
$img = $li.find('img');
$list.append($li);
var m=file.name;
var t = m.split('.')[0];
$('#name').val(t);
uploader.makeThumb(file, function (error, src) {
if (error) {
$img.replaceWith('<span>视频文件</span>');
return;
}
$img.attr('src', src);
}, 100, 100);
});
uploader.on('uploadProgress', function (file, percentage) {
var $li = $('#' + file.id),
$percent = $li.find('.barContainer .bar');
if (!$percent.length) {
$percent = $('<div class="barContainer"><div class="bar" style="width: 100%"></div></div>').appendTo($li).find('.bar');
}
$li.find('p.state').text('上传中');
$percent.html((percentage * 100).toFixed(2) + '%');
myc.showProgress({
title: '上传中',
text: (percentage * 100).toFixed(2) + '%'
});
if (percentage * 100 == 100) {
myc.showProgress({
title:'等待服务器处理'
});
}
});
uploader.on('uploadSuccess', function (file) {
myc.hideProgress();
$('#' + file.id).find('p.state').text('已上传');
layer.msg('上传成功,请上传封面');
$('.bgPop,.pop').show();
});
uploader.on('uploadError', function (file) {
$('#' + file.id).find('p.state').text('上传出错,请重新上传');
layer.msg('上传出错,请重新上传');
});
uploader.on('uploadComplete', function (file) {
$( '#'+file.id ).find('.progress').fadeOut();
});
</script>
</div>
</div>
<!--遮罩层-->
<div class="bgPop"></div>
<div class="pop">
<div class="pop-top">
<h2>上传封面</h2>
</div>
<div class="pop-content">
<div class="pop-content-right"><button type="button" class="layui-btn layui-btn-danger" id="userAvatar"><i class="layui-icon">&#xE64A;</i>上传封面</button>
</div>
</div>
</div>
<script>
layui.use(['form', 'layedit', 'laydate', 'element', 'jquery', 'upload', 'layer'], function(){
var form = layui.form
,layer   = layui.layer
,layedit = layui.layedit
,element = layui.element
,upload  = layui.upload
,$       = layui.jquery
,laydate = layui.laydate;
upload.render({
elem: '#userAvatar'
,url: '/htpic<?php echo $zykey?><?php echo $dshz?>'
,size: 500
,done: function(res){
if(res.status=='true'){
layer.msg('上传成功');
location.reload();
}else{
layer.msg(res.msg);
}
}
});
});
</script>
</body>
</html>