var test = true, webNotice = false, webNoticeId = "", oldOrderInfo = false, oldOrderInfo_malai = false; window.onload = function (ev) { init(); } init = function () { getProductInfo("", 1, 10); pagenotify(); } pagenotify = function () { notifyMe(); orderWheelSearch(); orderWheelSearchMaLai(); } notifyMe = function () { // 先检查浏览器是否支持 if (!("Notification" in window)) { // alert("本浏览器不支持网页通知提示,如需要网页提示,请使用chrome浏览器打开此网站。"); } else { Notification.requestPermission(function (permission) { if (permission === "granted") { webNotice = true; } else if (Notification.permission === "denied") { //alert("请打开网页通知权限,或者质询技术人员协助打开。"); } }); } } orderWheelSearch = function () { setInterval(function () { var parameter = urlEncode(["OrderWheelSearch"]); $.ajax({ type: "post", url: "/new/php/index.php", data: {mode: parameter}, dataType: "json", success: function (data) { if (oldOrderInfo == false) { oldOrderInfo = data[0]; } else { if (oldOrderInfo.OrderId == data[0].OrderId) { } else { oldOrderInfo = data[0]; orderNoticeBody(oldOrderInfo); $("#audio")[0].play(); } } console.log(oldOrderInfo); } }); }, 5000); } orderWheelSearchMaLai = function () { setInterval(function () { var parameter = urlEncode(["OrderWheelSearch"]); $.ajax({ type: "post", url: "/malai/php/index.php", data: {mode: parameter}, dataType: "json", success: function (data) { if (oldOrderInfo_malai == false) { oldOrderInfo_malai = data[0]; } else { if (oldOrderInfo_malai.OrderId == data[0].OrderId) { } else { oldOrderInfo_malai = data[0]; orderNoticeBodyMaLai(3, oldOrderInfo_malai); $("#audio")[0].play(); } } } }); }, 5000); } orderNoticeBody = function (type, data) { var title, obj; if (type == 1) { title = "泰国来订单啦"; } else if (type == 2) { title = "台湾来订单啦"; } else if (type == 3) { title = "马来西亚来订单啦"; } webNoticeId = data.OrderId + '<>' + data.ProductId; obj = { dir: "auto", body: "订单号:" + data.OrderNum + "\n" + "产品编号:" + data.ProductRemarks, // tag: webNoticeId, icon: JSON.parse(data.ProductInfoClassId)[1].img, renotify: false } var notification = new Notification(title, obj); notification.onclick = function (event, data) { event.preventDefault(); // prevent the browser from focusing the Notification's tab var oid = webNoticeId.split("<>")[0], pid = webNoticeId.split("<>")[1]; window.open('https://kjdspro.com/new/admin/orderinfo.html?oid=' + oid + '&pid=' + pid, '_blank'); } } orderNoticeBodyMaLai = function (type, data) { var title, obj; if (type == 1) { title = "泰国来订单啦"; } else if (type == 2) { title = "台湾来订单啦"; } else if (type == 3) { title = "马来西亚来订单啦"; } webNoticeId = data.OrderId + '<>' + data.ProductId; obj = { dir: "auto", body: "订单号:" + data.OrderNum + "\n" + "产品编号:" + data.ProductRemarks, // tag: webNoticeId, icon: JSON.parse(data.ProductInfoClassId)[1].img, renotify: false } var notification = new Notification(title, obj); notification.onclick = function (event, data) { event.preventDefault(); // prevent the browser from focusing the Notification's tab var oid = webNoticeId.split("<>")[0], pid = webNoticeId.split("<>")[1]; window.open('https://kjdspro.com/malai/admin/orderinfo.html?oid=' + oid + '&pid=' + pid, '_blank'); } } getProductInfo = function (judge, pageindex, pagesize) { var parameter = urlEncode(["SelectAllProduct", judge, pageindex, pagesize]); $.ajax({ type: "post", url: "/new/php/index.php", data: {mode: parameter}, dataType: "json", success: function (data) { if (data.length == 0 || data == -1) { var th = '