ip.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. var test = true;
  2. window.onload = function (ev) {
  3. init();
  4. }
  5. init = function () {
  6. getOrderInfo(1, 10);
  7. }
  8. getOrderInfo = function (pageindex, pagesize) {
  9. var parameter = urlEncode(["SelectIpAddress", 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. $("#loading").css({"display": "none"});
  18. $("#warp").css({"display": "table-row-group"});
  19. var th = '<th colspan="10" scope="col" class="text-c f-20" style="padding: 50px 0;">暂无数据</th>';
  20. $("#warp").html(th);
  21. $("#Page").html("");
  22. // $("#warp").append(th);
  23. return;
  24. }
  25. printOrderInfo(data);
  26. if (test) {
  27. test = false;
  28. var totalSize = data[0].allcount,
  29. totalPage = Math.ceil(totalSize / pagesize);
  30. // $("#Page").whjPaging("setPage", {currPage: pageindex, totalPage: totalPage, totalSize: totalSize});
  31. $("#Page").whjPaging({
  32. currPage: pageindex,
  33. totalSize: totalSize,//可选,总条数
  34. totalPage: totalPage,//可选,总页数
  35. isShowRefresh: false,//可选,是否展示刷新,默认true
  36. isShowPageSizeOpt: false,//可选,是否展示每页条数下拉框,默认true,如果设置显示,总条数必须设置
  37. // isResetPage:true,
  38. callBack: function (currPage) {
  39. $("#loading").css({display: "block"});
  40. $("#warp").css({display: "none"});
  41. getOrderInfo(currPage, pagesize);
  42. // console.log('currPage:' + currPage + ' pageSize:' + pageSize);
  43. }
  44. });
  45. }
  46. }
  47. });
  48. }
  49. printOrderInfo = function (data) {
  50. var warp = $("#warp"),
  51. tr;
  52. warp.html("");
  53. for (var i = 0; i < data.length; i++) {
  54. href = "'product-add.html?pid=" + data[i].ProductId + "'";
  55. tr = '<tr class="text-c">' +
  56. '<td>' + data[i].OrderNum + '</td>' +
  57. '<td>' + data[i].IPAddress + '</td>' +
  58. '<td>' + data[i].Country + '</td>' +
  59. '<td>' + data[i].City + '</td>' +
  60. '<td>' + data[i].AddTime + '</td>' +
  61. '</tr>';
  62. warp.append(tr);
  63. }
  64. $("#loading").css({"display": "none"});
  65. $("#warp").css({"display": "table-row-group"});
  66. }
  67. urlEncode = function (arr) {
  68. var i; //循环初始化
  69. for (i = 0; i < arr.length; i++) {
  70. arr[i] = encodeURIComponent(encodeURIComponent(arr[i]));
  71. }
  72. return arr.join();
  73. }