columns.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // $(".popular").hide();
  2. $(document).on("click", ".likeSee__state__filter--item", function (event) {
  3. // $(".News").toggle();
  4. // $(".popular").toggle();
  5. $(".likeSee__state__filter--item").removeClass('active');
  6. $(this).addClass("active");
  7. });
  8. const urlParams = new URLSearchParams(window.location.search);
  9. let id = urlParams.get('cid');
  10. console.log(id);
  11. function get_data() {
  12. $.ajax({
  13. method: "GET",
  14. url: `json/Columns-${id}.json`,
  15. // url:`json/Columns.json`,
  16. dataType: "json",
  17. })
  18. .done(function (msg) {
  19. console.log(msg);
  20. let ColumnsContent="";
  21. let ColumnsTag="";
  22. let breadcrumbTitle="";
  23. let article_info="";
  24. let OtherColumns="";
  25. let PopularColumns="";
  26. breadcrumbTitle=`<a href="#">${msg[0].Columnstitle}</a>`
  27. article_info=`
  28. <h1 class="article__title mt-4">${msg[0].Columnstitle}</h1>
  29. <div class="small">${msg[0].ColumnsDate}| 人氣:${msg[0].ColumnsViews}</div>
  30. `;
  31. ColumnsContent=`${msg[0].ColumnsContent}`;
  32. for (let j = 0; j < msg[0].ColumnsTag.length; j++) {
  33. ColumnsTag += ' \
  34. <a target="_blank" href="https://hhh.com.tw/cases/lists/' + msg[0].ColumnsTag[j].Tag + '-keyword/" \
  35. class="btn btn-outline-custom rounded-0">'
  36. + msg[0].ColumnsTag[j].Tag + '</a>';
  37. }
  38. for(let i=0; i<msg[0].OtherColumns.length; i++){
  39. OtherColumns+=
  40. '<div class="col-12 col-md-4 ps-0"><div class="cardList__items">\
  41. <a target="_blank" href="https://hhh.com.tw/columns/detail/'+msg[0].OtherColumns[i].Columnsid+'/"> <img src="'+msg[0].OtherColumns[i].ColumnsCoverImg+'" alt="">\
  42. <div class="cardList__items__content">\
  43. <a href="https://hhh.com.tw/columns/detail/'+msg[0].OtherColumns[i].Columnsid+'/"" target="_blank">\
  44. <div class="cardList__items--title cardList__items--ellipse">\
  45. '+msg[0].OtherColumns[i].Columnstitle+'\
  46. </div>\
  47. </a>'
  48. OtherColumns+='<p>'
  49. for(k=0; k<msg[0].OtherColumns[i].ColumnsTag.length; k++){
  50. OtherColumns+='\
  51. <a class="likeSee__tag--item" href="https://hhh.com.tw/columns/lists/'+msg[0].OtherColumns[i].ColumnsTag[k].tag+'-keyword/all-columntypea/" arget="_blank">'+msg[0].OtherColumns[i].ColumnsTag[k].Tag+'</a>'
  52. }
  53. OtherColumns+='</p>'
  54. OtherColumns+='</div></div></div>'
  55. }
  56. // for(let i=0; i<msg[0].PopularColumns.length; i++){
  57. // PopularColumns+=
  58. // '<div class="col-12 col-md-4 ps-0"><div class="cardList__items">\
  59. // <a target="_blank" href="https://hhh.com.tw/columns/detail/'+msg[0].PopularColumns[i].Columnsid+'/"> <img src="'+msg[0].PopularColumns[i].ColumnsCoverImg+'" alt="">\
  60. // <div class="cardList__items__content">\
  61. // <a href="https://hhh.com.tw/columns/detail/'+msg[0].PopularColumns[i].Columnsid+'/"" target="_blank">\
  62. // <div class="cardList__items--title cardList__items--ellipse">\
  63. // '+msg[0].PopularColumns[i].Columnstitle+'\
  64. // </div>\
  65. // </a>'
  66. // PopularColumns+='<p>'
  67. // for(k=0; k<msg[0].PopularColumns[i].ColumnsTag.length; k++){
  68. // PopularColumns+='\
  69. // <a class="likeSee__tag--item" href="https://hhh.com.tw/columns/lists/'+msg[0].PopularColumns[i].ColumnsTag[k].tag+'-keyword/all-columntypea/" arget="_blank">'+msg[0].PopularColumns[i].ColumnsTag[k].Tag+'</a>'
  70. // }
  71. // PopularColumns+='</p>'
  72. // PopularColumns+='</div></div></div>'
  73. // }
  74. $('.article_info').html(article_info);
  75. $('.breadcrumb-title').html(breadcrumbTitle);
  76. $('.ColumnsContent').html(ColumnsContent);
  77. $('.ColumnsTag').html(ColumnsTag);
  78. $('.OtherColumns').html(OtherColumns);
  79. // $('.PopularColumns').html(PopularColumns);
  80. });
  81. }
  82. function renderSec07() {
  83. $.ajax({
  84. method: "GET",
  85. // url: `json/bannerAds-${id}.json`,
  86. url:`json/bannerAds.json`,
  87. dataType: "json",
  88. })
  89. .done(function(msg){
  90. console.log(msg);
  91. let str = '';
  92. for(let i = 0; i < msg[0].data.length; i++){
  93. console.log(msg[i])
  94. str+= `<div class="sec-07__slider-${i+1} slide-item" onclick="window.open('${msg[0].data[i].link}');" data-bg="${msg[0].data[i].imgUrl}"><img class="img-fluid" src="${msg[0].data[i].imgUrl}"></div>`
  95. }
  96. $(`.sec-07__slider`).html(str);
  97. $(".sec-07__slider").slick({
  98. dots: false,
  99. autoplay: true,
  100. arrows: true,
  101. slidesToShow: 1,
  102. slidesToScroll: 1,
  103. autoplaySpeed: 7000,
  104. initialSlide: 0,
  105. infinite: true,
  106. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  107. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>'
  108. });
  109. });
  110. }
  111. get_data();
  112. renderSec07();
  113. $( ".views" ).click(function() {
  114. get_views_data();
  115. });
  116. $( ".recently" ).click(function() {
  117. get_data();
  118. });
  119. function get_views_data() {
  120. $.ajax({
  121. method: "GET",
  122. url: `json/Columns-${id}.json`,
  123. // url:`json/cases.json`,
  124. dataType: "json",
  125. })
  126. .done(function (msg) {
  127. console.log(msg);
  128. let OtherColumns = "";
  129. msg[0].OtherColumns.sort(function (a,b){
  130. return a['Views'] > b['Views']? -1:1;
  131. });
  132. console.log(msg[0].OtherColumns);
  133. for(let i=0; i<msg[0].OtherColumns.length; i++){
  134. OtherColumns+=
  135. '<div class="col-12 col-md-4 ps-0"><div class="cardList__items">\
  136. <a target="_blank" href="https://hhh.com.tw/columns/detail/'+msg[0].OtherColumns[i].Columnsid+'/"> <img src="'+msg[0].OtherColumns[i].ColumnsCoverImg+'" alt="">\
  137. <div class="cardList__items__content">\
  138. <a href="https://hhh.com.tw/columns/detail/'+msg[0].OtherColumns[i].Columnsid+'/"" target="_blank">\
  139. <div class="cardList__items--title cardList__items--ellipse">\
  140. '+msg[0].OtherColumns[i].Columnstitle+'\
  141. </div>\
  142. </a>'
  143. OtherColumns+='<p>'
  144. for(k=0; k<msg[0].OtherColumns[i].ColumnsTag.length; k++){
  145. OtherColumns+='\
  146. <a class="likeSee__tag--item" href="https://hhh.com.tw/columns/lists/'+msg[0].OtherColumns[i].ColumnsTag[k].tag+'-keyword/all-columntypea/" arget="_blank">'+msg[0].OtherColumns[i].ColumnsTag[k].Tag+'</a>'
  147. }
  148. OtherColumns+='</p>'
  149. OtherColumns+='</div></div></div>'
  150. }
  151. $('.OtherColumns').html(OtherColumns);
  152. });
  153. };