zxzlxq.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. var thisWrapper=null;
  2. var thisPageIndex = 1;
  3. var thisRow = 30;
  4. var thisItem = $(".zxzlxq-itemlist.active").data("item");
  5. var thisType = $(".zxzlxq-itemlist.active").data("type");
  6. var thisIcon = $("#micon").val();
  7. $(function () {
  8. init();
  9. // setTimeout(wrapperScroll, 1000);
  10. setTimeout(initScroll, 500);
  11. $(".back").click(function () {
  12. var origin = window.location.origin;
  13. //console.log(origin);
  14. window.location.href = origin + "/zx/index.html";
  15. })
  16. $(".news-item").click(function () {
  17. localStorage.href = window.location.href;
  18. })
  19. $(".zxzlxq-itemlist").click(function () {
  20. thisWrapper.destroy();
  21. var index = $(".zxzlxq-itemlist").index(this);
  22. $(".zxzlxq-itemlist").removeClass("active").eq(index).addClass("active");
  23. thisItem = $(".zxzlxq-itemlist.active").data("item");
  24. thisType = $(".zxzlxq-itemlist.active").data("type");
  25. changeItem();
  26. })
  27. })
  28. function init() {
  29. var search = window.location.pathname.split(".")[0].split("/")[3];
  30. if (search != undefined) {
  31. if (search.indexOf("cstzm") > -1) {
  32. $(".zxzlxq-itemlist").each(function (i, e) {
  33. if ($(e).data("type") == "彩神通字谜") {
  34. $(".zxzlxq-itemlist").removeClass("active").eq(i).addClass("active");
  35. thisItem = $(e).data("item");
  36. thisType = $(e).data("type");
  37. changeItem();
  38. }
  39. })
  40. }
  41. }
  42. }
  43. function changeItem() {
  44. var load = layer.load(2, {
  45. shade: [0.3, '#000']
  46. });
  47. $.ajax({
  48. url: "/ZX/ZXLXGD",
  49. type: "post",
  50. async: false,
  51. data: {
  52. c: thisType,
  53. m: thisIcon,
  54. i: thisItem
  55. },
  56. success: function (res) {
  57. layer.close(load);
  58. if (res != "") {
  59. thisPageIndex = 1;
  60. $(".zxzlxq-newslist-wrapper").html(res);
  61. setTimeout(initScroll,100);
  62. }
  63. else {
  64. layer.msg("没有更多数据了!")
  65. }
  66. },
  67. error: function (err) {
  68. console.log(err)
  69. layer.close(load);
  70. }
  71. })
  72. }
  73. function getMore() {
  74. var load = layer.load(2, {
  75. shade: [0.3, '#000']
  76. });
  77. $.ajax({
  78. url: "/ZX/ZXZLXQList",
  79. type: "post",
  80. async: false,
  81. data: {
  82. c: thisIcon,
  83. i: thisItem,
  84. p: thisPageIndex + 1,
  85. r: thisRow
  86. },
  87. success: function (res) {
  88. layer.close(load);
  89. if (res != "") {
  90. thisPageIndex++;
  91. $("#v-morezx-wrapper .content").append(res);
  92. thisWrapper.refresh();
  93. }
  94. else {
  95. layer.msg("没有更多数据了!")
  96. }
  97. }
  98. })
  99. }
  100. //function wrapperScroll() {
  101. // var wrapper = $("#v-morezx-wrapper")[0];
  102. // wrapper.addEventListener("scroll", function () {
  103. // var ch = wrapper.clientHeight;
  104. // var st = wrapper.scrollTop;
  105. // var sh = wrapper.scrollHeight;
  106. // if (st + ch - sh >= -20) {
  107. // getMore();
  108. // }
  109. // })
  110. //}
  111. function initScroll() {
  112. var wrapper = document.getElementById("v-morezx-wrapper");
  113. thisWrapper = new BScroll(wrapper, {
  114. probeType: 1,
  115. click:true
  116. });
  117. thisWrapper.on("scroll", function (pos) {
  118. var h = $("#v-morezx-wrapper .content")[0].clientHeight;
  119. var h2 = $("#v-morezx-wrapper")[0].clientHeight;
  120. if (h-120< Math.abs(pos.y) + h2) {
  121. getMore();
  122. }
  123. })
  124. }