product.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. var test = true;
  2. window.onload = function (ev) {
  3. init();
  4. }
  5. init = function () {
  6. getProductInfo("", 1, 10);
  7. }
  8. getProductInfo = function (judge, pageindex, pagesize) {
  9. var parameter = urlEncode(["SelectAllProduct", judge, pageindex, pagesize]);
  10. $.ajax({
  11. type: "post",
  12. url: "/taiwan/php/index.php",
  13. data: {mode: parameter},
  14. dataType: "json",
  15. success: function (data) {
  16. if (data.length == 0 || data == -1) {
  17. var th = '<th colspan="8" scope="col" class="text-c f-20" style="padding: 50px 0;">暂无数据</th>';
  18. $("#warp").html(th);
  19. $("#Page").html("");
  20. // $("#warp").append(th);
  21. return;
  22. }
  23. if (test) {
  24. test = false;
  25. var totalSize = data[0].allcount,
  26. totalPage = Math.ceil(totalSize / pagesize);
  27. $("#Page").html("");
  28. // $("#Page").whjPaging("setPage", {currPage: pageindex, totalPage: totalPage, totalSize: totalSize});
  29. $("#Page").whjPaging({
  30. currPage: pageindex,
  31. totalSize: totalSize,//可选,总条数
  32. totalPage: totalPage,//可选,总页数
  33. isShowRefresh: false,//可选,是否展示刷新,默认true
  34. isShowPageSizeOpt: false,//可选,是否展示每页条数下拉框,默认true,如果设置显示,总条数必须设置
  35. // isResetPage:true,
  36. callBack: function (currPage) {
  37. $("#loading").css({display: "block"});
  38. $("#warp").css({display: "none"});
  39. getProductInfo(judge, currPage, pagesize);
  40. // test = true;
  41. // console.log('currPage:' + currPage + ' pageSize:' + pageSize);
  42. }
  43. });
  44. }
  45. printProductInfo(data);
  46. console.log(data);
  47. }
  48. });
  49. }
  50. printProductInfo = function (data) {
  51. var warp = $("#warp"),
  52. tr,
  53. href,
  54. title = "'查看商品信息'";
  55. warp.html("");
  56. for (var i = 0; i < data.length; i++) {
  57. href = "'product-add.html?pid=" + data[i].ProductId + "'";
  58. tr = $('<tr class="text-c">' +
  59. '<td>' + data[i].ProductId + '</td>' +
  60. '<td>' + data[i].ProductRemarks + '</td>' +
  61. '<td>' + data[i].ProductName + '</td>' +
  62. '<td>' + data[i].ProductPrimeCost + '</td>' +
  63. '<td>' + data[i].ProductPrice + '</td>' +
  64. // '<td>' + data[i].ProductIntroduce + '</td>' +
  65. '<td><a href="' + data[i].ProductIntroduce + '" target="_blank">' + data[i].ProductIntroduce + '</a></td>' +
  66. '<td>' + data[i].ProductAddTime + '</td>' +
  67. '<td>' +
  68. '<a class="btn btn-primary radius td-button" href="http://tw.kjdspro.com/' + data[i].shortnum + '" target="_blank">查看新H5页面</>' +
  69. '<a class="btn btn-primary radius td-button" href="/taiwan/goods.html?pid=' + data[i].ProductId + '">查看旧H5页面</>' +
  70. '<a class="btn btn-primary radius td-button" onclick="product_add(' + title + ',' + href + ')">查看产品信息</a>' +
  71. '</td></tr>');
  72. warp.append(tr);
  73. }
  74. $("#loading").css({"display": "none"});
  75. $("#warp").css({"display": "table-row-group"});
  76. }
  77. keySearchProductInfo = function () {
  78. if (event.keyCode == 13) {
  79. searchProductInfo();
  80. }
  81. }
  82. searchProductInfo = function () {
  83. var _val = $("#SearchPlaceBtn").val().trim();
  84. if (_val == "") {
  85. layer.msg('请输入订单号、人名、地址、手机号其中一个', {icon: 1});
  86. }
  87. else {
  88. getProductInfo(_val, 1, 10);
  89. }
  90. }
  91. product_add = function (title, url) {
  92. var index = layer.open({
  93. type: 2,
  94. title: title,
  95. content: url
  96. });
  97. layer.full(index);
  98. }
  99. urlEncode = function (arr) {
  100. var i; //循环初始化
  101. for (i = 0; i < arr.length; i++) {
  102. arr[i] = encodeURIComponent(encodeURIComponent(arr[i]));
  103. }
  104. return arr.join();
  105. }
  106. toogle = function (cs) {
  107. var child = $(cs);
  108. for (var i = 0; i < child.length; i++) {
  109. if (child[i].style.display == "none") {
  110. child[i].style.display = "block";
  111. } else {
  112. child[i].style.display = "none";
  113. }
  114. }
  115. }