//公众号: 声色视觉
//webSite: www.softboyo.cn
//date:2022-08-08
$("#file").change(function(b){if(this.files.length){b=this.files[0];var a=new FileReader;a.onload=function(){$("#img").attr("src",this.result)};a.readAsDataURL(b)}});$("#Commit").click(function(b){b=$("#file").get(0).files;if(0!=b.length)if(0==contentcheck()){var a=new FormData,c=b[0].name.split(".").pop().toLowerCase();-1<$.inArray(c,["bmp","jpg","jpeg","png","gif"])?(a.append("files",b[0]),a.append("product",$("#pname").val()),a.append("model",$("#pmodel").val()),a.append("price",$("#pprice").val()),a.append("token",localStorage.getItem("caketoken")),PostServiceFiles("../cakeapi.dll/upload",a,function(a){"not login"!=a?"Commit success"==a?(msgbox("\u4e0a\u67b6\u6210\u529f"),$("#img").attr("src","assets/img/show.png"),$("#file").val("")):(msgbox("\u4e0a\u67b6\u5931\u8d25"),console.log(a)):self.location="login.html"})):msgbox("\u53ea\u5141\u8bb8\u4e0a\u4f20\u56fe\u7247,\u8bf7\u91cd\u65b0\u9009\u62e9\u3002")}else msgbox("\u8bf7\u5b8c\u6574\u586b\u5199\u5546\u54c1\u57fa\u672c\u4fe1\u606f");else msgbox("\u9700\u8981\u4e00\u5f20\u5546\u54c1\u5c55\u793a\u56fe\u7247")});function contentcheck(){return""!=$("#pname").val()&&""!=$("#pmodel").val()&&""!=$("#pprice").val()?0:1}$("#quit").click(function(b){localStorage.removeItem("caketoken")});