collection.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. $(document).ready(function () {
  2. $('.logo').on('click', function() {
  3. window.location.href = "https://www.bibidd.com";
  4. })
  5. $('.quanpinghei').hide();
  6. $(".back").on("click", function () {
  7. history.back(-1);
  8. });
  9. var uid = localStorage.getItem("uid");
  10. // 获取收藏数据
  11. function getData() {
  12. $.ajax({
  13. type: "post",
  14. url: "https://www.bibidd.com/bibidd/Media/shoucang_list_test",
  15. dataType: "json",
  16. data: {
  17. uid: uid,
  18. },
  19. success: function (res) {
  20. },
  21. complete: function (res) {
  22. let dataArray = res.responseJSON.data;
  23. if(dataArray.length==0) {
  24. $('.bottomLoadContent').hide();
  25. $("#tip").show();
  26. $(".tiptext").text('The data you need is not found.');
  27. }else{
  28. $("#tip").hide();
  29. }
  30. let videoHtml = "";
  31. $.each(dataArray, function (index, data) {
  32. videoHtml += '<div class="videoContent">';
  33. videoHtml += '<div class="lazy videoPhoto" data-original="' + data.top_img + '"></div>';
  34. videoHtml += ' <div class="videoTitle">' + data.title + "</div>";
  35. videoHtml += ' <div class="videoData">';
  36. videoHtml += ' <div class="videoColumn">';
  37. videoHtml += " <!-- 观看次数 -->";
  38. videoHtml += ' <div class="videoDataLeft">';
  39. videoHtml +=
  40. ' <img class="videoDataImgLook" src="/Public/bibidd/images/look.png" alt="" />';
  41. videoHtml +=
  42. ' <div id="looks" class="videoText">' + data.views + "</div>";
  43. videoHtml += " </div>";
  44. videoHtml += " <!-- 点赞次数 -->";
  45. videoHtml += ' <div class="videoDataRgiht">';
  46. videoHtml +=
  47. ' <img class="videoDataImgZan" src="/Public/bibidd/images/zan.png" alt="" />';
  48. videoHtml +=
  49. ' <div class="videoText">' + data.thumbs_up + "</div>";
  50. videoHtml += " </div>";
  51. videoHtml += " </div>";
  52. videoHtml += ' <div class="close">';
  53. videoHtml +=
  54. ' <img class="closeImg" src="/Public/bibidd/images/close.png" alt="">';
  55. videoHtml += " </div>";
  56. videoHtml += " </div>";
  57. videoHtml += "</div>";
  58. });
  59. $(".video").html(videoHtml);
  60. var loadingUrl = "/Public/bibidd/images/loading.png";
  61. $(".lazy").lazyload({
  62. effect: 'show',
  63. placeholder: loadingUrl,
  64. failurelimit: 10,
  65. skip_invisible: false,
  66. });
  67. // 取消收藏
  68. $(".close").on("click", function (event) {
  69. event.stopPropagation();
  70. // 取消收藏
  71. let closetype =
  72. dataArray[$(this).parent().parent().index()].type;
  73. const id = dataArray[$(this).parent().parent().index()].id;
  74. if (closetype === 'novel') {
  75. // 取消收藏小说
  76. $.ajax({
  77. type: 'post',
  78. url: 'https://www.bibidd.com/bibidd/Nnovel/close_novel_shoucang',
  79. dataType: "json",
  80. data: {
  81. n_id: id,
  82. uid: uid
  83. },
  84. success: function (res) {
  85. },
  86. complete: function (res) {
  87. getData();
  88. }
  89. })
  90. } else {
  91. // 取消收藏视频或图片
  92. closetype =
  93. dataArray[$(this).parent().parent().index()].type === "imgs" ? "img" : "video";
  94. $.ajax({
  95. type: "post",
  96. url: "https://www.bibidd.com/bibidd/Media/quxiao_shoucang",
  97. dataType: "json",
  98. data: {
  99. type: closetype,
  100. cid: id,
  101. uid: uid,
  102. },
  103. success: function (res) {
  104. },
  105. complete: function (res) {
  106. getData();
  107. },
  108. });
  109. }
  110. });
  111. // 查看收藏详情
  112. $(".videoContent").on("click", function () {
  113. let looks = $(this).find("#looks").eq(0).text();
  114. $(this).find("#looks").eq(0).text(Number(looks)+1);
  115. const type = dataArray[$(this).index()].type;
  116. let page = '';
  117. switch (type) {
  118. case "imgs":
  119. page = 'collectionphotodetails';
  120. break;
  121. case "video":
  122. page = 'videodetails';
  123. break;
  124. case "novel":
  125. page = 'bnoveldetalis';
  126. break;
  127. }
  128. $(location).attr("href", page + ".html?videoid=" +
  129. dataArray[$(this).index()].id +
  130. "&fabulous=" +
  131. dataArray[$(this).index()].thumbs_up +
  132. "&favorite=" +
  133. dataArray[$(this).index()].favorite)+
  134. '?status='+1;
  135. });
  136. },
  137. });
  138. }
  139. getData();
  140. // 判断屏幕滚动高度是否超过1屏
  141. $(window).scroll(function () {
  142. var scrollT = $(document).scrollTop();
  143. var offsetT = $(".videopage").offset().top;
  144. if (scrollT >= offsetT) {
  145. $(".backToTop").show();
  146. } else {
  147. $(".backToTop").hide();
  148. }
  149. });
  150. // 返回顶部
  151. $(".backToTop").on("click", function () {
  152. $("html, body").animate(
  153. {
  154. scrollTop: 0,
  155. },
  156. 500
  157. );
  158. });
  159. });