ip.js 3.2 KB

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