product.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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="/taiwan/goods.html?pid=' + data[i].ProductId + '">查看H5页面</>' +
  69. '<a class="btn btn-primary radius td-button" onclick="product_add(' + title + ',' + href + ')">查看产品信息</a>' +
  70. '</td></tr>');
  71. warp.append(tr);
  72. }
  73. $("#loading").css({"display": "none"});
  74. $("#warp").css({"display": "table-row-group"});
  75. }
  76. keySearchProductInfo = function () {
  77. if (event.keyCode == 13) {
  78. searchProductInfo();
  79. }
  80. }
  81. searchProductInfo = function () {
  82. var _val = $("#SearchPlaceBtn").val().trim();
  83. if (_val == "") {
  84. layer.msg('请输入订单号、人名、地址、手机号其中一个', {icon: 1});
  85. }
  86. else {
  87. getProductInfo(_val, 1, 10);
  88. }
  89. }
  90. product_add = function (title, url) {
  91. var index = layer.open({
  92. type: 2,
  93. title: title,
  94. content: url
  95. });
  96. layer.full(index);
  97. }
  98. urlEncode = function (arr) {
  99. var i; //循环初始化
  100. for (i = 0; i < arr.length; i++) {
  101. arr[i] = encodeURIComponent(encodeURIComponent(arr[i]));
  102. }
  103. return arr.join();
  104. }
  105. toogle = function (cs) {
  106. var child = $(cs);
  107. for (var i = 0; i < child.length; i++) {
  108. if (child[i].style.display == "none") {
  109. child[i].style.display = "block";
  110. } else {
  111. child[i].style.display = "none";
  112. }
  113. }
  114. }