<?php
error_reporting(0); 
include("../../config/wap.php");
session_start();
if(!isset($_SESSION['username'])){echo "<script>alert('请重新登录!')</script><script>top.location.href='/m$dshz'</script>";exit;}
$username=$_SESSION['username'];
$type="where name='$username'";
$user=queryall(user,$type);
$userid=$user['userid'];
if(!$user){echo "<script>alert('请重新登录!')</script><script>top.location.href='/m$dshz'</script>";exit;}
$sjm=random(200);
$zykey=md5($userid.$sjm.$shijian);
if ($shipin=='0'){echo '已关闭功能';exit;}
?>
<!DOCTYPE html>
<head>
<meta charset="gb2312" />
<title>上传视频</title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" type="text/css" href="/2019newui/m/css/api.css" />
<link rel="stylesheet" type="text/css" href="/2019newui/m/css/up.css" />
<link href="/2019newui/m/css/common.css" rel="stylesheet" type="text/css"/>
<link href="/layui/css/m.css" rel="stylesheet"/>
<script src="/2019newui/js/jquery.min.js"></script>
<script src="/2019newui/js/myc.js"></script>
<script src="/2019newui/js/webuploader.js" type="text/javascript" charset="utf-8"></script>
</head>
<body ontouchstart="" onmouseover="">
<header class="aui-navBar aui-navBar-fixed">
<a href="javascript:;"  onclick="window.history.back(-1);" class="aui-navBar-item"><i class="icon layui-icon" style="font-size: 20px;">&#xF060;</i></a>
<div class="aui-center"><span class="aui-center-title">上传视频</span></div>
</header>
<div class="divHeight"></div>
<div id="uploader" class="wu-example" style="text-align: center;margin-top: 10px;">
<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  id="tuijian"   style=" width: 100px; background-color: #e6e6e6;  margin: 0 7px 0 7px;  border-radius: 5px;color: #098707; height: 25px;" >
<option value="1">打赏观看</option>
<option value="2">免费观看</option>
</select>
</div>
<div style="margin: 15px 0;">视频分类 :
<select name="fl"   style=" width: 100px; background-color: #e6e6e6;  margin: 0 7px 0 7px;  border-radius: 5px;color: #098707; height: 25px;"   id="fl" >
<option value='请选择'>请选择</option>
<?php 
$result = mysql_query("SELECT * FROM  dlfl where userid='$userid'");
$count = mysql_num_rows($result);
?>
<?php if($count == 0){?><option value='0'>暂无分类</option><?php }?>
<?php
$query = mysql_query("SELECT * FROM  dlfl where userid='$userid'");
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"><?php echo $zxm?></span>到<span id="mymaxAmountLimit"><?php echo $zdm?></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>
<div class="divHeight"></div>
<div class="againUrl" id="ctlBtn">上传视频</div>
<script type="text/javascript">
var p =1;
var mylimit = '<?php echo $zxm?>';
var mymaxAmountLimit = '<?php echo $zdm?>';
$('#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 > <?php echo $zdm?>) {
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 > <?php echo $zdm?>) {
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: '/upload<?php echo $dshz?>',
pick: '#picker',
disableGlobalDnd: true,
fileNumLimit: 300,
fileSizeLimit: 2000 * 1024 * 1024,
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()) {
myc.toast({
msg: '请选择您要上传的视频'
});
return false;
}
var shipinname = document.getElementById("name").value;
if (!shipinname) {
myc.toast({
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) {
myc.toast({
msg: '必须要大于' + mylimit + '元'
});
return false;
}
if (amount < mylimit) {
myc.toast({
msg: '必须要大于' + mylimit + '元'
});
return false;
}
if (amount > mymaxAmountLimit) {
myc.toast({
msg: '必须要小于' + mymaxAmountLimit + '元'
});
return false;
}
if (amount <= 0) {
myc.toast({
msg: '请输入金额'
});
return false;
}
if (!amount) {
myc.toast({
msg: '您输入的不是数字哦'
});
return false;
}
if (!amount_min) {
myc.toast({
msg: '您输入的不是数字哦'
});
return false;
}
var tuijian = document.getElementById("tuijian").value;
uploader.options.formData.userid = '<?php echo $userid?>';
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.tuijian = tuijian;
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('已上传');
myc.toast({
msg: '上传成功,请上传封面'
});
$('.bgPop,.pop').show();
});
uploader.on('uploadError', function (file) {
$('#' + file.id).find('p.state').text('上传出错,请重新上传');
myc.toast({
msg: '上传出错,请重新上传'
});
});
uploader.on('uploadComplete', function (file) {
$( '#'+file.id ).find('.progress').fadeOut();
});
</script>
<!--遮罩层-->
<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">&#xF01B;</i>上传封面</button>
</div>
</div>
</div>
<script src="/layui/layui.js"></script>
<script>
layui.use(['form', 'layedit', 'laydate', 'element', 'jquery', 'upload'], 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: '/mpic<?php echo $zykey?><?php echo $dshz?>'
,size: 500
,done: function(res){
if(res.status=='true'){
myc.toast({
msg : '上传成功'
})
location.reload();
}else{
layer.msg(res.msg);
}
}
});
});
</script>
<footer class="aui-footer aui-footer-fixed">
<a href="/mmain<?php echo $dshz?>" class="aui-tabBar-item"><i class="icon layui-icon" style="font-size: 30px;">&#xF015;</i><span class="aui-tabBar-item-text">首页</span></a>
<a href="/mdingdan<?php echo $dshz?>" class="aui-tabBar-item"><i class="icon layui-icon" style="font-size: 30px;">&#xF123;</i><span class="aui-tabBar-item-text">订单</span></a>
<a href="/muser<?php echo $dshz?>" class="aui-tabBar-item"><i class="icon layui-icon" style="font-size: 30px;">&#xF007;</i><span class="aui-tabBar-item-text">我的</span></a>
</footer>
</body>
</html>