product.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. var test = true,
  2. webNotice = false,
  3. webNoticeId = "",
  4. oldOrderInfo = false,
  5. oldOrderInfo_malai = false;
  6. window.onload = function (ev) {
  7. init();
  8. }
  9. init = function () {
  10. getProductInfo("", 1, 10);
  11. pagenotify();
  12. }
  13. pagenotify = function () {
  14. notifyMe();
  15. orderWheelSearch();
  16. orderWheelSearchMaLai();
  17. }
  18. notifyMe = function () {
  19. // 先检查浏览器是否支持
  20. if (!("Notification" in window)) {
  21. //alert("本浏览器不支持网页通知提示,如需要网页提示,请使用chrome浏览器打开此网站。");
  22. }
  23. else {
  24. Notification.requestPermission(function (permission) {
  25. if (permission === "granted") {
  26. webNotice = true;
  27. }
  28. else if (Notification.permission === "denied") {
  29. //alert("请打开网页通知权限,或者质询技术人员协助打开。");
  30. }
  31. });
  32. }
  33. }
  34. orderWheelSearch = function () {
  35. setInterval(function () {
  36. var parameter = urlEncode(["OrderWheelSearch"]);
  37. $.ajax({
  38. type: "post",
  39. url: "/new/php/index.php",
  40. data: {mode: parameter},
  41. dataType: "json",
  42. success: function (data) {
  43. if (oldOrderInfo == false) {
  44. oldOrderInfo = data[0];
  45. }
  46. else {
  47. if (oldOrderInfo.OrderId == data[0].OrderId) {
  48. }
  49. else {
  50. oldOrderInfo = data[0];
  51. orderNoticeBody(oldOrderInfo);
  52. $("#audio")[0].play();
  53. }
  54. }
  55. console.log(oldOrderInfo);
  56. }
  57. });
  58. }, 5000);
  59. }
  60. orderWheelSearchMaLai = function () {
  61. setInterval(function () {
  62. var parameter = urlEncode(["OrderWheelSearch"]);
  63. $.ajax({
  64. type: "post",
  65. url: "/malai/php/index.php",
  66. data: {mode: parameter},
  67. dataType: "json",
  68. success: function (data) {
  69. if (oldOrderInfo_malai == false) {
  70. oldOrderInfo_malai = data[0];
  71. }
  72. else {
  73. if (oldOrderInfo_malai.OrderId == data[0].OrderId) {
  74. }
  75. else {
  76. oldOrderInfo_malai = data[0];
  77. orderNoticeBodyMaLai(3, oldOrderInfo_malai);
  78. $("#audio")[0].play();
  79. }
  80. }
  81. }
  82. });
  83. }, 5000);
  84. }
  85. orderNoticeBody = function (type, data) {
  86. var title, obj;
  87. if (type == 1) {
  88. title = "泰国来订单啦";
  89. }
  90. else if (type == 2) {
  91. title = "台湾来订单啦";
  92. }
  93. else if (type == 3) {
  94. title = "马来西亚来订单啦";
  95. }
  96. webNoticeId = data.OrderId + '<>' + data.ProductId;
  97. obj = {
  98. dir: "auto",
  99. body: "订单号:" + data.OrderNum + "\n" +
  100. "产品编号:" + data.ProductRemarks,
  101. // tag: webNoticeId,
  102. icon: JSON.parse(data.ProductInfoClassId)[1].img,
  103. renotify: false
  104. }
  105. var notification = new Notification(title, obj);
  106. notification.onclick = function (event, data) {
  107. event.preventDefault(); // prevent the browser from focusing the Notification's tab
  108. var oid = webNoticeId.split("<>")[0],
  109. pid = webNoticeId.split("<>")[1];
  110. window.open('https://kjdspro.com/new/admin/orderinfo.html?oid=' + oid + '&pid=' + pid, '_blank');
  111. }
  112. }
  113. orderNoticeBodyMaLai = function (type, data) {
  114. var title, obj;
  115. if (type == 1) {
  116. title = "泰国来订单啦";
  117. }
  118. else if (type == 2) {
  119. title = "台湾来订单啦";
  120. }
  121. else if (type == 3) {
  122. title = "马来西亚来订单啦";
  123. }
  124. webNoticeId = data.OrderId + '<>' + data.ProductId;
  125. obj = {
  126. dir: "auto",
  127. body: "订单号:" + data.OrderNum + "\n" +
  128. "产品编号:" + data.ProductRemarks,
  129. // tag: webNoticeId,
  130. icon: JSON.parse(data.ProductInfoClassId)[1].img,
  131. renotify: false
  132. }
  133. var notification = new Notification(title, obj);
  134. notification.onclick = function (event, data) {
  135. event.preventDefault(); // prevent the browser from focusing the Notification's tab
  136. var oid = webNoticeId.split("<>")[0],
  137. pid = webNoticeId.split("<>")[1];
  138. window.open('https://kjdspro.com/malai/admin/orderinfo.html?oid=' + oid + '&pid=' + pid, '_blank');
  139. }
  140. }
  141. getProductInfo = function (judge, pageindex, pagesize) {
  142. var parameter = urlEncode(["SelectAllProduct", judge, pageindex, pagesize]);
  143. $.ajax({
  144. type: "post",
  145. url: "/malai/php/index.php",
  146. data: {mode: parameter},
  147. dataType: "json",
  148. success: function (data) {
  149. if (data.length == 0 || data == -1) {
  150. var th = '<th colspan="8" scope="col" class="text-c f-20" style="padding: 50px 0;">暂无数据</th>';
  151. $("#warp").html(th);
  152. $("#Page").html("");
  153. // $("#warp").append(th);
  154. return;
  155. }
  156. if (test) {
  157. test = false;
  158. var totalSize = data[0].allcount,
  159. totalPage = Math.ceil(totalSize / pagesize);
  160. $("#Page").html("");
  161. // $("#Page").whjPaging("setPage", {currPage: pageindex, totalPage: totalPage, totalSize: totalSize});
  162. $("#Page").whjPaging({
  163. currPage: pageindex,
  164. totalSize: totalSize,//可选,总条数
  165. totalPage: totalPage,//可选,总页数
  166. isShowRefresh: false,//可选,是否展示刷新,默认true
  167. isShowPageSizeOpt: false,//可选,是否展示每页条数下拉框,默认true,如果设置显示,总条数必须设置
  168. // isResetPage:true,
  169. callBack: function (currPage) {
  170. $("#loading").css({display: "block"});
  171. $("#warp").css({display: "none"});
  172. getProductInfo(judge, currPage, pagesize);
  173. // test = true;
  174. // console.log('currPage:' + currPage + ' pageSize:' + pageSize);
  175. }
  176. });
  177. }
  178. printProductInfo(data);
  179. console.log(data);
  180. }
  181. });
  182. }
  183. printProductInfo = function (data) {
  184. var warp = $("#warp"),
  185. tr,
  186. href,
  187. title = "'查看商品信息'";
  188. warp.html("");
  189. for (var i = 0; i < data.length; i++) {
  190. href = "'product-add.html?pid=" + data[i].ProductId + "'";
  191. tr = $('<tr class="text-c">' +
  192. '<td>' + data[i].ProductId + '</td>' +
  193. '<td>' + data[i].ProductRemarks + '</td>' +
  194. '<td>' + data[i].ProductName + '</td>' +
  195. '<td>' + data[i].ProductPrimeCost + '</td>' +
  196. '<td>' + data[i].ProductPrice + '</td>' +
  197. '<td><a href="' + data[i].ProductIntroduce + '" target="_blank">' + data[i].ProductIntroduce + '</a></td>' +
  198. '<td>' + data[i].ProductAddTime + '</td>' +
  199. '<td>' +
  200. '<a class="btn btn-primary radius td-button" href="/malai/goods.html?pid=' + data[i].ProductId + '">查看H5页面</>' +
  201. '<a class="btn btn-primary radius td-button" onclick="product_add(' + title + ',' + href + ')">查看产品信息</a>' +
  202. '</td></tr>');
  203. warp.append(tr);
  204. }
  205. $("#loading").css({"display": "none"});
  206. $("#warp").css({"display": "table-row-group"});
  207. }
  208. keySearchProductInfo = function () {
  209. if (event.keyCode == 13) {
  210. searchProductInfo();
  211. }
  212. }
  213. searchProductInfo = function () {
  214. var _val = $("#SearchPlaceBtn").val().trim();
  215. if (_val == "") {
  216. layer.msg('请输入订单号、人名、地址、手机号其中一个', {icon: 1});
  217. }
  218. else {
  219. getProductInfo(_val, 1, 10);
  220. }
  221. }
  222. product_add = function (title, url) {
  223. var index = layer.open({
  224. type: 2,
  225. title: title,
  226. content: url
  227. });
  228. layer.full(index);
  229. }
  230. urlEncode = function (arr) {
  231. var i; //循环初始化
  232. for (i = 0; i < arr.length; i++) {
  233. arr[i] = encodeURIComponent(encodeURIComponent(arr[i]));
  234. }
  235. return arr.join();
  236. }
  237. toogle = function (cs) {
  238. var child = $(cs);
  239. for (var i = 0; i < child.length; i++) {
  240. if (child[i].style.display == "none") {
  241. child[i].style.display = "block";
  242. } else {
  243. child[i].style.display = "none";
  244. }
  245. }
  246. }