//公众号: 声色视觉
//webSite: www.softboyo.cn
//date:2022-08-14
$(function(){var a=ExtractURL("pid");GetServiceData("GetEditinfo/"+a,function(a){a=a.result[0];$("input[name\x3d'Product']").val(a.product);$("input[name\x3d'Model']").val(a.model);$("input[name\x3d'price']").val(a.price);$("#upload-label").text(a.picture);$(".mb-4").attr("src","../uploads/"+a.picture);1==a.issale[0]?$("#salestatu").attr("checked",!1):$("#salestatu").attr("checked",!0)})});function readURL(a){if(ispic()){if(a.files&&a.files[0]){var b=new FileReader;b.onload=function(b){$(".mb-4").attr("src",b.target.result);$("#upload-label").text(a.files[0].name)};b.readAsDataURL(a.files[0])}}else msgbox("\u53ea\u652f\u6301\u56fe\u7247\u6587\u4ef6\uff0c\u8bf7\u91cd\u9009\u3002")}function ispic(){var a=$("#upload").get(0).files[0].name.split(".").pop().toLowerCase();return-1<$.inArray(a,["bmp","jpg","jpeg","png","gif"])?!0:!1}$("#Commit").click(function(a){""==$("input[name\x3d'Product']").val()?msgbox("\u5546\u54c1\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a\uff0c\u8bf7\u91cd\u586b\u3002"):""==$("input[name\x3d'Model']").val()?msgbox("\u5546\u54c1\u4ef7\u683c\u4e0d\u80fd\u4e3a\u7a7a,\u8bf7\u91cd\u586b\u3002"):(a=1,a=$("#salestatu").is(":checked")?0:1,a={pname:$("input[name\x3d'Product']").val(),model:$("input[name\x3d'Model']").val(),price:$("input[name\x3d'price']").val(),sale:a,pid:ExtractURL("pid")},0<$("#upload").get(0).files.length&&(a.pic=btoa($(".mb-4").attr("src"))),a.token=localStorage.getItem("caketoken"),PostServiceData("editor",JSON.stringify(a),function(a){if(0<a.result[0])try{0<a.result[0]&&$("#salestatu").is(":checked")?msgbox($("input[name\x3d'Product']").val()+"\u5df2\u4e0b\u67b6\u3002"):msgbox($("input[name\x3d'Product']").val()+"\u66f4\u65b0\u4e0a\u67b6\u5b8c\u6210")}catch(c){msgbox($("input[name\x3d'Product']").val()+"\u66f4\u65b0\u5931\u8d25\uff0c\u8bf7\u7a0d\u5019\u540e\u91cd\u8bd5\u3002")}else self.location="login.html"}))});