You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

636 lines
31 KiB
HTML

5 years ago
<extend name="Public/manage" />
<block name="head">
<!-- <script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script> -->
<script type="text/javascript" src="__STATIC__/webuploader/webuploader.js"></script>
<link rel="stylesheet" type="text/css" href="__STATIC__/webuploader/webuploader.css" media="all">
<script src="__STATIC__/md5.js" type="text/javascript" charset="utf-8"></script>
</block>
<block name="body" >
<div class="matter_right_content">
<form id="addServer" action="" method="post" onsubmit="return false;" class="form-horizontal" enctype="multipart/form-data" novalidate="novalidate">
<div class="title create_title create_server_title">
<h3>游戏原包 </h3>
</div>
<div class="form-group clearfix">
<label class="mrc_left mrc control-label"><span class="must_red">*</span> 游戏包名</label>
<div class="mrc_right3 mrc input-format">
<input type="text" class="form-control" name="pack_name" placeholder="请输入游戏包名长度50个字以内" value="{$data.pack_name}" id="pack_name">
</div>
<div class="mrc_right3 mrc">
<label class="control-label matter_notice matter_warn" style="font-weight: normal;">(您上传的安装包名称必须与此包名一致)</label>
</div>
<div class="clearfix"></div>
<div class="mrc_colum_ml mrc_colum4_1_6 mrc input-status"></div>
</div>
<div class="form-group clearfix">
<label class="mrc_left mrc control-label"><span class="must_red">*</span> 游戏版本</label>
<div class="mrc_right3 mrc input-format">
<input type="text" class="form-control" name="version" id="version" placeholder="请输入游戏版本" value="{$data.version}" >
</div>
<div class="clearfix"></div>
<div class="mrc_colum_ml mrc_colum4_1_6 mrc input-status"></div>
</div>
<div class="form-group clearfix">
<label class="mrc_left mrc control-label"> SDK版本</label>
<div class="mrc_right3 mrc input-format">
<input type="text" class="form-control" name="sdk_version" id="sdk_version" placeholder="请输入SDK版本" value="{$data.sdk_version}" >
</div>
<div class="clearfix"></div>
<div class="mrc_colum_ml mrc_colum4_1_6 mrc input-status"></div>
</div>
<div class="form-group clearfix">
<label class="mrc_left mrc control-label"><span class="must_red">*</span> 游戏支付通知地址</label>
<div class="mrc_right3 mrc input-format">
<input type="text" class="form-control" name="pay_notify_url" id="pay_notify_url" placeholder="请输入游戏支付通知地址" value="{$data.pay_notify_url}" >
</div>
<div class="mrc_right3 mrc">
<label class="control-label matter_notice" style="font-weight: normal;">(支付回调地址)</label>
</div>
<div class="clearfix"></div>
<div class="mrc_colum_ml mrc_colum4_1_6 mrc input-status"></div>
</div>
<div class="form-group clearfix">
<label class="mrc_left mrc control-label"><font color="red">*</font> 上传原包</label>
<div class="mrc_colum2_5 mrc input-format">
<div id="source" style="line-height: 35px;">上传原包</div>
<!--用来存放文件信息-->
<div id="thelist" class="uploader-list">
<!-- <notempty name="data.file_url">
<div id="" class="item jsitem">
<h4 class="info">
<table><tbody><tr><td>
<a href="http://{$_SERVER['HTTP_HOST']}{:substr($data['file_url'],1)}">{$data.file_name}</a>
</td><td>
<a href="javascript:;" onclick="delFile2(this);">
<img src="__IMG__/remove.gif">
</a>
</td></tr></tbody></table>
</h4>
<p class="state"></p>
</div>
</notempty> -->
</div>
<input type="hidden" id="file_name" name="file_name" value="{$data.file_name}"/>
<input type="hidden" id="file_url" name="file_url" value="{:str_replace('/'.$data['file_name'],'',$data['file_url'])}"/>
<input type="hidden" id="file_size" name="file_size" value="{$data.file_size}"/>
</div>
<div class="clearfix"></div>
<div class="mrc_colum_ml mrc_colum4_1_6 mrc input-status"></div>
</div>
<eq name="game.sdk_version" value="2">
<div class="form-group clearfix">
<label class="mrc_left mrc control-label"><font color="red">*</font> 上传描述文件</label>
<div class="mrc_colum2_5 mrc input-format">
<div id="description" style="line-height: 35px;">上传描述文件</div>
<!--用来存放文件信息-->
<div id="description_thelist" class="uploader-list">
<!-- <notempty name="data.description_file_url">
<div id="" class="item jsitem">
<h4 class="info">
<table><tbody><tr><td>
<a href="http://{$_SERVER['HTTP_HOST']}{:substr($data['description_file_url'],1)}">{$data.description_file_name}</a>
</td><td>
<a href="javascript:;" onclick="delFile2(this);">
<img src="__IMG__/remove.gif">
</a>
</td></tr></tbody></table>
</h4>
<p class="state"></p>
</div>
</notempty> -->
</div>
<input type="hidden" id="description_file_name" name="description_file_name" value="{$data.description_file_name}"/>
<input type="hidden" id="description_file_url" name="description_file_url" value="{$data.description_file_url}"/>
</div>
<div class="clearfix"></div>
<div class="mrc_colum_ml mrc_colum4_1_6 mrc input-status"></div>
</div>
</eq>
<div class="form-group clearfix">
<label class="mrc_left mrc control-label"><font color="red">*</font> 更新说明</label>
<div class="mrc_right4_3_3 mrc3 mrc input-format">
<textarea name="remark" class="form-control" rows="4" placeholder="更新说明">{$data.remark}</textarea>
</div>
<div class="clearfix"></div>
<div class="mrc_colum_ml mrc_colum4_1_6 mrc input-status"></div>
</div>
<div class="form-group clearfix">
<label class="mrc_left mrc control-label"></label>
<div class="mrc_colum4_1_6 mrc">
<input name="file_type" type="hidden" value="{$game['sdk_version']}">
<input type="submit" class="btn btn_primary user_btn" id="editServer" value="提交审核">&nbsp;&nbsp;&nbsp;<a href="javascript:history.go(-1);" class="btn btn_default user_btn_default">取消</a>
</div>
</div>
</form>
</div>
<script>
Think.setValue("pack_name", "{$Think.get.pack_name|default = ''}");
Think.setValue("version", "{$Think.get.version|default = ''}");
Think.setValue("sdk_version", "{$Think.get.sdk_version|default = ''}");
Think.setValue("pay_notify_url", "{$Think.get.pay_notify_url|default = ''}");
function delFile(){
layer.confirm('您确定要删除原包吗?', {
btn: ['确定','取消'] //按钮
}, function(){
var url=window.location.href+"/pack_name/"+$('#pack_name').val()+"/version/"+$('#version').val()+"/sdk_version/"+$('#sdk_version').val()+"/pay_notify_url/"+$('#pay_notify_url').val();
location.href=url;
}, function(){
});
}
function delFile2(that) {
layer.confirm('您确定要删除吗?',{btn: ['确定','取消']},function() {
$(that).closest('.uploader-list').siblings('input').val('');
$(that).closest('.item').remove();
layer.msg('',{time:1});
setTimeout(function(){
var url=window.location.href+"/pack_name/"+$('#pack_name').val()+"/version/"+$('#version').val()+"/sdk_version/"+$('#sdk_version').val()+"/pay_notify_url/"+$('#pay_notify_url').val();
location.href=url;
},1000);
});
}
$(function() {
$.validator.addMethod("checkFileSize", function(value, element,params){
var size = element.files[0].size;
if (size<params) {
return true;
}
return false;
}, "上传文件大小超出限制");
$.validator.addMethod("checkFileType", function(value, element,params){
return value.indexOf(params[0])>-1?true:false;
}, "上传文件类型错误");
});
</script>
<eq name="game.sdk_version" value="2">
<script>
$(function(){
$("#addServer").validate({
ignore:"",
rules:{
pack_name: {
required: true,
rangelength: [1,50],
},
version: {
required: true,
},
pay_notify_url: {
required: true,
},
file_name: {
required: true,
checkFileType: ['ipa'],
},
description_file_name: {
required: true,
}
},
messages:{
pack_name: {
required: "请输入游戏包名",
rangelength: $.validator.format("包名在{1}个字符以内"),
},
version: {
required: "请输入游戏版本",
},
pay_notify_url: {
required: "请输入游戏支付通知地址",
},
file_name: {
required: "请上传游戏原包",
checkFileType: "上传文件类型必须是.ipa",
},
description_file_name: {
required: "请上传描述文件",
}
},
submitHandler: function (form) {
$.post("{:U('Game/source',['game_id'=>$game['id']])}", $("#addServer").serializeArray(), function (result) {
if (result.status == 1) {
location.href = "{:U('Game/index')}";
} else {
layer.msg(result.info);
}
})
}
});
});
</script>
<else />
<script>
$(function(){
$("#addServer").validate({
ignore:"",
rules:{
pack_name: {
required: true,
rangelength: [1,50],
},
version: {
required: true,
},
pay_notify_url: {
required: true,
},
file_name: {
required: true,
checkFileType: ['apk'],
}
},
messages:{
pack_name: {
required: "请输入游戏包名",
rangelength: $.validator.format("包名在{1}个字符以内"),
},
version: {
required: "请输入游戏版本",
},
pay_notify_url: {
required: "请输入游戏支付通知地址",
},
file_name: {
required: "请上传游戏原包",
checkFileType: "上传文件类型必须是.apk",
}
},
submitHandler: function (form) {
$.post("{:U('Game/source',['game_id'=>$game['id']])}", $("#addServer").serializeArray(), function (result) {
if (result.status == 1) {
location.href = "{:U('Game/index')}";
} else {
layer.msg(result.info);
}
})
}
});
});
</script>
</eq>
<script>
$(function(){
//上传
var file_type = "{$game['sdk_version'] == 1 ? 'apk':'ipa'}";
var userInfo = {userId:"kazaff", md5:""}; //用户会话信息
var chunkSize = 5000 * 1024; //分块大小
var uniqueFileName = null; //文件唯一标识符
var md5Mark = null;var all_state = 0;
var backEndUrl = "{:U('File/shard_upload',array('session_id'=>session_id()))}";
WebUploader.Uploader.register({
"before-send-file" : "beforeSendFile",
"before-send" : "beforeSend",
"after-send-file" : "afterSendFile"
}, {
beforeSendFile: function(file){
//秒传验证
var task = new $.Deferred();
var start = new Date().getTime();
(new WebUploader.Uploader()).md5File(file, 0, 10*1024*1024).progress(function(percentage){
//console.log(percentage);
}).then(function(val){
//console.log("总耗时: "+((new Date().getTime()) - start)/1000);
md5Mark = val;
userInfo.md5 = val;
$.ajax({
type: "POST"
, url: backEndUrl
, data: {status: "md5Check", md5: val}
, cache: false
, timeout: 1000 //todo 超时的话,只能认为该文件不曾上传过
, dataType: "json"
}).then(function(data, textStatus, jqXHR){
alert(data.chunk);
//console.log(data);
if(data.ifExist){ //若存在这返回失败给WebUploader表明该文件不需要上传
task.reject();
uploader.skipFile(file);
file.path = data.path;
}else{
task.resolve();
//拿到上传文件的唯一名称,用于断点续传
uniqueFileName = md5(''+userInfo.userId+file.name+file.type+file.lastModifiedDate+file.size);
}
}, function(jqXHR, textStatus, errorThrown){ //任何形式的验证失败,都触发重新上传
task.resolve();
//拿到上传文件的唯一名称,用于断点续传
uniqueFileName = md5(''+userInfo.userId+file.name+file.type+file.lastModifiedDate+file.size);
});
});
return $.when(task);
}
, beforeSend: function(block){
//分片验证是否已传过,用于断点续传
var task = new $.Deferred();
$.ajax({
type: "POST"
, url: backEndUrl
, data: {
status: "chunkCheck"
, name: uniqueFileName
, chunkIndex: block.chunk
, size: block.end - block.start
}
, cache: false
, timeout: 1000 //todo 超时的话,只能认为该分片未上传过
, dataType: "json"
}).then(function(data, textStatus, jqXHR){
if(data.ifExist){ //若存在返回失败给WebUploader表明该分块不需要上传
task.reject();
}else{
task.resolve();
}
}, function(jqXHR, textStatus, errorThrown){ //任何形式的验证失败,都触发重新上传
task.resolve();
});
return $.when(task);
}
, afterSendFile: function(file){
var chunksTotal = 0;
if((chunksTotal = Math.ceil(file.size/chunkSize)) > 1){
//合并请求
var task = new $.Deferred();
$.ajax({
type: "POST"
, url: backEndUrl
, data: {
status: "chunksMerge"
, name: uniqueFileName
, chunks: chunksTotal
, ext: file.ext
, md5: md5Mark
}
, cache: false
, dataType: "json"
}).then(function(data, textStatus, jqXHR){
//todo 检查响应是否正常
task.resolve();
file.path = data.path;
$("#file_name").val(data.name);
$("#file_url").val(data.path);
var size = file.size;
size = size/1024/1024;
size = size.toFixed(2)+"MB";
$("#file_size").val(size);
}, function(jqXHR, textStatus, errorThrown){
task.reject();
});
return $.when(task);
}else{
//UploadComlate(file);
}
}
});
var uploader = WebUploader.create({
// 选完文件后,是否自动上传。
auto: true,
// swf文件路径
swf: '__STATIC__/webuploader/Uploader.swf',
// 文件接收服务端。
server: "{:U('File/shard_upload',array('session_id'=>session_id()))}",
// 选择文件的按钮。可选。
// 内部根据当前运行是创建可能是input元素也可能是flash.
pick: {id:'#source'},
//dnd: "#theList",
paste: document.body,
// 不压缩image, 默认如果是jpeg文件上传前会压缩一把再上传
resize: false,
accept:{extensions: file_type,mimeTypes:'.'+file_type},
disableGlobalDnd: true,
fileNumLimit:1,
threads:3,
compress: false,
prepareNextFile: true,
formData: function(){return $.extend(true, {}, userInfo);},
duplicate:true,
chunked:true,
chunkSize: 5*1000*1024,
duplicate: true
});
uploader.on('beforeFileQueued', function(file) {
if(all_state==2) {layer.msg('描述文件正在上传');return false;}
if($('#thelist').find('.item.jsupitem').length>0) {
layer.msg('原包已存在,请删除后重新上传');return false;
}
all_state=1;
});
// 当有文件被添加进队列的时候
uploader.on( 'fileQueued', function( file ) {
$("#thelist").append( '<div id="' + file.id + '" class="item jsupitem">' +
'<h4 class="info">' + file.name + '</h4>' +
'<p class="state">等待上传...</p>' +
'</div>' );
});
// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadProgress', function( file, percentage ) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress .progress-bar');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('<div class="progress progress-striped active">' +
'<div class="progress-bar" role="progressbar" style="width: 0%">' +
'</div>' +
'</div>').appendTo( $li ).find('.progress-bar');
}
$li.find('p.state').text('上传中');
$percent.css( 'width', percentage * 100 + '%' );
$percent.text( (percentage * 100).toFixed(0) + '%' );
});
uploader.on( 'uploadSuccess', function( file , response) {
var $li = $( '#'+file.id ),
$percent = $li.find('.progress .progress-bar');
$li.siblings().remove();
var url=window.location.host+response.path+"/"+response.name;
$li.find('h4.info').html("<table><tr><td><a class='showfile' href='https://"+url+"'>"+response.name+"</a></td>"+"<td><a href='javascript:;' id='source_del'><img src='__IMG__/remove.gif'></a></td></tr></table>");
$li.find('p.state').text('');
$li.find('#source_del').on('click',function() {
layer.confirm('您确定要删除原包吗?', {
btn: ['确定','取消']
}, function(index){
$li.closest('.uploader-list').siblings('input').val('');
$li.remove();
layer.msg('',{time:1});
uploader.removeFile(file);
layer.close(index);
});
return false;
});
if(!response.chunk){
$("#file_name").val(response.name);
$("#file_url").val(response.path);
$("#file_size").val(response.size);
}
});
uploader.on( 'uploadError', function(file,reason) {
var fileid = $( '#'+file.id );
fileid.find('p.state').text('上传出错');
$("#file_name").val('');
$("#file_url").val('');
fileid.find('h4.info').append("<a href='javascript:;' id='delFile'><img src='__IMG__/remove.gif'></a>");
fileid.find('h4.info #delFile').click(function() {
fileid.remove();
uploader.removeFile(file.id);uploader.reset();
});
});
uploader.on( 'uploadComplete', function(file) {
$( '#'+file.id ).find('.progress').fadeOut();
$('#file_name').valid();
var file_name = $.trim($('#file_name').val());
var file_url = $.trim($('#file_url').val());
if(file_name && file_url) {
var url='http://'+window.location.host+file_url.replace('./','/')+"/"+file_name;
$( '#'+file.id ).find('.showfile').attr('href',url).text(file.name);
}
});
uploader.on( 'uploadFinished', function() {
all_state=0;
});
//Plist 上传
var uploader2 = WebUploader.create({
// 选完文件后,是否自动上传。
auto: true,
// swf文件路径
swf: '__STATIC__/webuploader/Uploader.swf',
// 文件接收服务端。
server: "{:U('File/shard_upload2',array('session_id'=>session_id(),'typee'=>1))}",
// 选择文件的按钮。可选。
// 内部根据当前运行是创建可能是input元素也可能是flash.
pick: {id:'#description'},
//dnd: "#theList",
paste: document.body,
// 不压缩image, 默认如果是jpeg文件上传前会压缩一把再上传
resize: false,
accept:{extensions:"mobileprovision",mimeTypes:'.mobileprovision'},
disableGlobalDnd: true,
fileNumLimit:1,
threads:3,
compress: false,
prepareNextFile: true,
formData: function(){return $.extend(true, {}, userInfo);},
duplicate:true,
chunked:true,
chunkSize: 5*1000*1024,
duplicate: true
});
uploader2.on('beforeFileQueued', function(file) {
if(all_state==1) {layer.msg('原包正在上传');return false;}
if($('#description_thelist').find('.item.jsupitem').length>0) {
layer.msg('描述文件已存在,请删除后重新上传');
}
all_state=2;
});
// 当有文件被添加进队列的时候
uploader2.on( 'fileQueued', function( file2 ) {
$("#description_thelist").append( '<div id="' + file2.id + '" class="item jsupitem">' +
'<h4 class="info" id="upfilename">' + file2.name + '</h4>' +
'<p class="state">等待上传...</p>' +
'</div>' );
});
// 文件上传过程中创建进度条实时显示。
uploader2.on( 'uploadProgress', function( file2, percentage2 ) {
var $li = $( '#'+file2.id ),
$percent = $li.find('.progress .progress-bar');
// 避免重复创建
if ( !$percent.length ) {
$percent = $('<div class="progress progress-striped active">' +
'<div class="progress-bar" role="progressbar" style="width: 0%">' +
'</div>' +
'</div>').appendTo( $li ).find('.progress-bar');
}
$percent.css( 'width', percentage2 * 100 + '%' );
$percent.text( (percentage2 * 100).toFixed(0) + '%' );
});
uploader2.on( 'uploadSuccess', function( file2 , response2) {
//$( '#'+file2.id ).find('p.state').text('已上传');
// alert(JSON.stringify(response2));
//if(!response2.chunk){
// $("#description_file_name").val(response2.name);
// $("#description_file_url").val(response2.path);
//}
var $li = $( '#'+file2.id ),
$percent = $li.find('.progress .progress-bar');
$li.siblings().remove();
var url=window.location.host+response2.path+"/"+response2.name;
$li.find('h4.info').html("<table><tr><td><a class='showfile' href='http://"+url+"'>"+response2.name+"</a></td>"+"<td><a href='javascript:;' id='description_del'><img src='__IMG__/remove.gif'></a></td></tr></table>");
$li.find('p.state').text('');
$li.find('#description_del').on('click',function() {
layer.confirm('您确定要删除描述文件吗?', {
btn: ['确定','取消']
}, function(index){
$li.closest('.uploader-list').siblings('input').val('');
$li.remove();
layer.msg('',{time:1});
uploader2.removeFile(file2);
layer.close(index);
});
return false;
});
if(!response2.chunk){
$("#description_file_name").val(response2.name);
$("#description_file_url").val(response2.path);
}
});
uploader2.on( 'uploadError', function( file2 ) {
//$( '#'+file2.id ).find('p.state').text('上传出错');
var fileid2 = $( '#'+file2.id );
fileid2.find('p.state').text('上传出错');
fileid2.find('h4.info').append("<a href='javascript:;' id='delFile2'><img src='__IMG__/remove.gif'></a>");
fileid2.find('h4.info #delFile2').click(function() {
fileid2.remove();
uploader.removeFile(file2.id);uploader.reset();
});
});
uploader2.on( 'uploadComplete', function(file2) {
$( '#'+file2.id ).find('.progress').fadeOut();
$('#description_file_name').valid();
//var file_name = $.trim($('#description_file_name').val());
//var file_url = $.trim($('#description_file_url').val());
//if(file_name && file_url) {
//var url=window.location.host+file_url.replace('./','/')+"/"+file_name;
//$( '#'+file2.id ).find('.showfile').attr('href',url).text(file_name);
//}
});
uploader2.on( 'uploadFinished', function() {
all_state=0;
});
});
$.VMenu.show('#menu');
$.VMenu.open('m2.1');
</script>
</block>