tk.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. var thisPageIndex = 1;
  2. var thisTotalPage = $("#totalpage").val();
  3. var thisRow = 30;
  4. var thisType = $(".tuku-category.tuku-active").data("type");
  5. var thisQs = $("#currentqs").data("qs");
  6. $(function () {
  7. setTimeout(function () { initWrapperTop(true) },150);
  8. setTimeout(wrapperScroll, 1000);
  9. $('.tuku-category').click(function () {
  10. var index = $(".tuku-category").index(this);
  11. $(".tuku-category").removeClass('tuku-active').eq(index).addClass('tuku-active');
  12. thisType = $(".tuku-category").eq(index).data('type');
  13. thisPageIndex = 0;
  14. thisq = $("#currentqs").data("qs");
  15. if (thisType == 1) {
  16. $('#qishu').show();
  17. getAll(1, "A", thisq, 1);
  18. }
  19. if (thisType == 2) {
  20. $('#qishu').show();
  21. getHot(1, "彩吧图谜", thisq, 1);
  22. }
  23. if (thisType == 3) {
  24. $('#qishu').hide();
  25. getNewest(1);
  26. }
  27. if (thisType == 4) {
  28. $('#qishu').hide();
  29. getHistory();
  30. }
  31. })
  32. $("body").delegate(".tuku-area-item", "click", function () {
  33. var index = $(".tuku-area-item").index(this);
  34. $(".tuku-area-item").removeClass('area-selected').eq(index).addClass('area-selected');
  35. thisPageIndex = 0;
  36. var text = $(this).find("span:eq(0)").text();
  37. text = text.replace(/^\s+|\s+$/g, "");
  38. var qs = $("#currentqs").data("qs");
  39. if (thisType == 1) {
  40. getAll(2, text, qs ,3);
  41. }
  42. if (thisType == 2) {
  43. getHot(2, text, qs, 3);
  44. }
  45. $(".tuku-list-wrapper")[0].scrollTop = 0;
  46. })
  47. })
  48. function getAll(t, a, q, add) {
  49. initWrapperTop(true);
  50. //$(".tuku-wrapper").css("top", "140px");
  51. if (t == 1) {
  52. el = $(".tuku-wrapper");
  53. }
  54. if (t == 2) {
  55. el = $(".tuku-list-wrapper");
  56. }
  57. var load = layer.load(2, {
  58. shade: [0.1, '#000']
  59. });
  60. $.ajax({
  61. url: "/TK/GetTKQB",
  62. type: "post",
  63. async:false,
  64. data: {
  65. t: t,
  66. p: thisPageIndex + 1,
  67. r: thisRow,
  68. a: a,
  69. q: q
  70. },
  71. success: function (res) {
  72. if (res != "") {
  73. thisPageIndex = thisPageIndex + 1;
  74. if (add == 1) {
  75. el.eq(0).html(res);
  76. thisTotalPage = $("#totalpage").val();
  77. setTimeout(wrapperScroll, 1000);
  78. }
  79. if (add==2) {
  80. el.eq(0).append(res);
  81. }
  82. if (add == 3) {
  83. el.eq(0).html(res);
  84. thisTotalPage = $("#totalpage").val();
  85. setTimeout(wrapperScroll, 1000);
  86. if (thisTotalPage == 0) {
  87. el.eq(0).html("<li style='line-height:300px;text-align:center;'>暂无图片信息!</li>");
  88. }
  89. }
  90. }
  91. else {
  92. layer.msg("没有更多数据了!")
  93. }
  94. layer.close(load);
  95. }
  96. })
  97. }
  98. function getHot(t, n, q, add) {
  99. initWrapperTop(true);
  100. var load = layer.load(2, {
  101. shade: [0.1, '#000']
  102. });
  103. //$(".tuku-wrapper").css("top", "140px");
  104. if (t == 1) {
  105. el = $(".tuku-wrapper");
  106. }
  107. if (t == 2) {
  108. el = $(".tuku-list-wrapper");
  109. }
  110. $.ajax({
  111. url: "/TK/GetTKRM",
  112. type: "post",
  113. async: false,
  114. data: {
  115. t: t,
  116. p: thisPageIndex+1,
  117. r: thisRow,
  118. n: n,
  119. q: q
  120. },
  121. success: function (res) {
  122. if (res != "") {
  123. thisPageIndex = thisPageIndex + 1;
  124. if (add == 1) {
  125. el.eq(0).html(res);
  126. thisTotalPage = $("#totalpage").val();
  127. setTimeout(wrapperScroll, 1000);
  128. }
  129. if (add == 2) {
  130. el.eq(0).append(res);
  131. }
  132. if (add == 3) {
  133. el.eq(0).html(res);
  134. thisTotalPage = $("#totalpage").val();
  135. setTimeout(wrapperScroll, 1000);
  136. if (thisTotalPage == 0) {
  137. el.eq(0).html("<li style='line-height:300px;text-align:center;padding-left: 98px;'>暂无图片信息!</li>");
  138. }
  139. }
  140. }
  141. else {
  142. layer.msg("没有更多数据了!")
  143. }
  144. layer.close(load);
  145. }
  146. })
  147. }
  148. function getNewest(t) {
  149. initWrapperTop();
  150. var load = layer.load(2, {
  151. shade: [0.1, '#000']
  152. });
  153. //$(".tuku-wrapper").css("top", "100px");
  154. $.ajax({
  155. url: "/TK/GetTKZX",
  156. type: "post",
  157. async: false,
  158. data: {
  159. t:t,
  160. p: thisPageIndex+1,
  161. r: thisRow,
  162. q: thisQs
  163. },
  164. success: function (res) {
  165. if (res != "") {
  166. thisPageIndex = thisPageIndex + 1;
  167. if (t == 1) {
  168. $(".tuku-wrapper").html(res);
  169. thisTotalPage = $("#totalpage").val();
  170. setTimeout(wrapperScroll, 1000);
  171. }
  172. else if (t == 2) {
  173. $(".tuku-list-wrapper").append(res);
  174. }
  175. }
  176. else {
  177. layer.msg("没有更多数据了!")
  178. }
  179. thisTotalPage = $("#totalpage").val();
  180. layer.close(load);
  181. }
  182. })
  183. }
  184. function getHistory() {
  185. initWrapperTop();
  186. var load = layer.load(2, {
  187. shade: [0.1, '#000']
  188. });
  189. $.ajax({
  190. url: "/TK/GetTKLS",
  191. type: "post",
  192. success: function (res) {
  193. $(".tuku-wrapper").html(res).css("top", "100px");
  194. layer.close(load);
  195. }
  196. })
  197. }
  198. function getPeriods(el, t) {
  199. if ($(el).hasClass("notActive")) {
  200. layer.msg("当前已经是最近一期!");
  201. return;
  202. }
  203. thisPageIndex = 0;
  204. var curentQs = $("#currentqs").data("qs");
  205. var a = $(".tuku-area-item.area-selected").find("span:eq(0)").text().replace(/^\s+|\s+$/g, "");
  206. if (t == 1) {
  207. var qs = String(curentQs - 1);
  208. var year = Number(qs.substr(0, 4))-1;
  209. var num = qs.substr(4);
  210. if (num == '000') {
  211. $.ajax({
  212. url: "/TK/Getqs",
  213. type: "post",
  214. async: false,
  215. data: { y: year },
  216. success: function (data) {
  217. qs = data;
  218. $(".tuku-qishu-left").attr("data-"+year,data);
  219. }
  220. })
  221. }
  222. }
  223. else if (t == 2) {
  224. var qs = String(curentQs);
  225. var year = Number(qs.substr(0, 4));
  226. if ($(".tuku-qishu-left").attr("data-" + year)) {
  227. var ynum = $(".tuku-qishu-left").attr("data-" + year);
  228. if (Number(qs) < Number(ynum)) {
  229. qs = Number(qs) + 1;
  230. }
  231. else {
  232. qs = (year + 1) + "001";
  233. }
  234. }
  235. else {
  236. qs = Number(qs) + 1;
  237. }
  238. }
  239. $("#currentqs").text("第" + qs + "期").data("qs", qs);
  240. if (thisType == 1) {
  241. getAll(2, a, qs, 3);
  242. }
  243. if (thisType == 2) {
  244. getHot(2, a, qs, 3);
  245. }
  246. if (thisQs != qs) {
  247. $(".tuku-qishu-right").removeClass("notActive");
  248. } else {
  249. $(".tuku-qishu-right").addClass("notActive");
  250. }
  251. $(".tuku-list-wrapper")[0].scrollTop = 0;
  252. }
  253. function wrapperScroll() {
  254. var wrapper = $(".tuku-list-wrapper")[0];
  255. wrapper.addEventListener("scroll", function () {
  256. var ch = wrapper.clientHeight;
  257. var st = wrapper.scrollTop;
  258. var sh = wrapper.scrollHeight;
  259. if (st + ch - sh >= -10) {
  260. if (thisPageIndex < thisTotalPage) {
  261. if (thisType == 1) {
  262. var a = $(".tuku-area-item.area-selected").find("span:eq(0)").text().replace(/^\s+|\s+$/g, "");
  263. var q = $("#currentqs").data("qs");
  264. getAll(2, a, q, 2);
  265. }
  266. if (thisType == 2) {
  267. var a = $(".tuku-area-item.area-selected").find("span:eq(0)").text().replace(/^\s+|\s+$/g, "");
  268. var q = $("#currentqs").data("qs");
  269. getHot(2, a, q, 2);
  270. }
  271. if (thisType == 3) {
  272. getNewest(2);
  273. }
  274. }
  275. }
  276. })
  277. }
  278. function toAll(el) {
  279. var q = $(el).find("span:eq(0)").text();
  280. $(".tuku-category").removeClass('tuku-active').eq(0).addClass('tuku-active');
  281. thisType = $(".tuku-category").eq(0).data('type');
  282. $("#currentqs").data("qs", q).text("第" + q + "期");
  283. thisPageIndex = 0;
  284. $('#qishu').show();
  285. getAll(1, "A", q, 1);
  286. }
  287. function initWrapperTop(qs) {
  288. $("#ads-wrapper").show();
  289. var h1 = $("#ads-wrapper").height();
  290. var h = h1 + 40;
  291. if (qs) {
  292. h = h + 40;
  293. }
  294. $("#wrapper1").css({ top: h + "px" })
  295. }