function upload_ar_a_icon(){var upfile=$("#upload_ar_a_icon")[0].files[0];if(in_login<1){$("#tips_ar_a_icon").text("请先登录");return false;}
if(upfile.size>1048576){$("#tips_ar_a_icon").text("图标不能大于1M");return false;}
var fd=new FormData();fd.append("android",upfile);fd.append("ext",oauth["ext"]);var a_icon_xhr=new XMLHttpRequest();a_icon_xhr.open("post",in_path+"source/pack/webview/ajax_android.php");a_icon_xhr.onload=complete_ar_a_icon;a_icon_xhr.onerror=failed_ar_a_icon;a_icon_xhr.upload.onprogress=progress_ar_a_icon;a_icon_xhr.send(fd);}
function progress_ar_a_icon(evt){var per=Math.round(evt.loaded/evt.total*100);$("#tips_ar_a_icon").text(per+"%");if(per>99){$("#tips_ar_a_icon").text("请稍等...");}}
function complete_ar_a_icon(evt){var response=evt.target.responseText;if(response=="return_0"){$("#tips_ar_a_icon").text("文件不规范");}else if(response==-1){$("#tips_ar_a_icon").text("Access denied");}else{$("#preview_ar_a_icon").html('<img width="100" height="100" src="'+in_path+"data/tmp/"+oauth["ext"]+'.png">');}}
function failed_ar_a_icon(){$("#tips_ar_a_icon").text("上传异常");}
function and_roid(){var xhr=new XMLHttpRequest();if(in_login<1){layer.msg("请先登录后再操作！");return;}
if($("#ar_title").val()==""){$("#ar_title").focus();return;}
if($("#ar_url").val()==""){$("#ar_url").focus();return;}
if($("#preview_ar_a_icon img").length<1){layer.msg("请上传应用图标！");return;}
$(".ar-btn").attr("disabled","disabled").text("生成中...");xhr.open("GET",in_path+"source/pack/webview/ajax_android.php?ac=android&title="+escape($("#ar_title").val())+"&url="+$("#ar_url").val()+"&aicon="+$("#preview_ar_a_icon img")[0].src,true);xhr.onreadystatechange=function(){if(xhr.readyState==4){if(xhr.status==200){if(xhr.responseText=="return_0"){$(".ar-btn").text("请先登录");}else if(xhr.responseText=="return_1"){$(".ar-btn").text("点数不足");}else{$(".ar-btn").text("上传中...");ReturnArValue(xhr.responseText);}}else{$(".ar-btn").text("通讯异常");}}};xhr.send(null);}
function ReturnArValue(response){var xhr=new XMLHttpRequest();xhr.onreadystatechange=function(){processAJAX();};xhr.open("GET",in_path+"source/pack/webview/apk.php?time="+response,true);xhr.send(null);function processAJAX(){if(xhr.readyState==4){if(xhr.status==200){if(xhr.responseText==-1){$(".ar-btn").text("请先登录后再操作！");}else if(xhr.responseText==-2){$(".ar-btn").text("Access denied");}else if(xhr.responseText==-3){$(".ar-btn").text("未进行实名认证或认证审核中！");}else if(xhr.responseText==-4){$(".ar-btn").text("应用容量不足！");}else if(xhr.responseText==1){$(".ar-btn").text("跳转中...");location.href=in_path+"index.php/home";}else{$(".ar-btn").text("内部出现错误，请稍后再试！");}}}}}