//公众号: 声色视觉
//webSite: www.softboyo.cn
//date:2022-08-05
$(function(){GetServiceData("statistics/"+localStorage.getItem("caketoken"),function(a){a=a.result[0];if(null!=a){var b=a["items[0]"][0],c=$("#sales").html(),b=String.format(c,b.msale,b.nsale,b.newuser,b.users);$("#sales").html(b);var c=a["items[1]"],b=[],d=[],e=[];for(key in c)b.push(c[key].month+"\u6708"),d.push(c[key].amount.toFixed(2)),e.push("rgba(64, 185, 204, 0.3)");new Chart($("#pcard"),{type:"line",data:{labels:b,datasets:[{label:"\u6708\u9500\u552e",data:d,backgroundColor:e}]},options:{scales:{yAxes:[{ticks:{min:0}}]}}});c=$("#salesort").html();$("#salesort").html("");d=a["items[2]"];e=0;for(key in d)e+=parseInt(d[key].quantit);for(key in d)b=String.format(c,d[key].product,d[key].quantit,d[key].quantit/e*100),$("#salesort").append(b);d=a["items[3]"];c=$("#income").html();$("#income").html("");for(key in d)b=String.format(c,d[key].product,d[key].revenue),$("#income").append(b);b=a["items[4]"][0];c=$("#stati").html();$("#stati").html(String.format(c,b.wait,b.wamount,b.fpay,b.famount,b.fquantit,b.nop));c=a["items[5]"][0];$("#madd").val(c.address);$("#mname").val(c.merchant);$("#mtel").val(c.phone);a=a["items[6]"];c=$("#msg");b=c.html();c.html("");$(".count").text(a.length);for(key in a)c.append(String.format(b,a[key].msg,a[key].name+"\uff1a"+a[key].phone+"\x3cbr\x3e"+$.formatDT(a[key].postdate),a[key].lid))}else self.location="login.html"})});$("#quit").click(function(a){localStorage.removeItem("caketoken")});$("#modify").click(function(a){""==$("#madd").val()?msgbox("\u5730\u5740\u4e0d\u80fd\u4e3a\u7a7a"):""==$("#mname").val()?msgbox("\u5546\u6237\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a"):""==$("#mtel").val()?msgbox("\u8054\u7cfb\u65b9\u5f0f\u4e0d\u80fd\u4e3a\u7a7a"):(a={},a.merchant=$("#mname").val(),a.phone=$("#mtel").val(),a.address=$("#madd").val(),PostServiceData("editorMerchant",JSON.stringify(a),function(a){0<a.result[0]?msgbox("\u4fee\u6539\u5546\u6237\u4fe1\u606f\u6210\u529f"):msgbox("\u4fee\u6539\u5546\u6237\u4fe1\u606f\u5931\u8d25")}))});