123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- // $(".popular").hide();
- $(document).on("click", ".likeSee__state__filter--item", function (event) {
- // $(".News").toggle();
- // $(".popular").toggle();
- $(".likeSee__state__filter--item").removeClass('active');
- $(this).addClass("active");
- });
- const urlParams = new URLSearchParams(window.location.search);
- let id = urlParams.get('cid');
- console.log(id);
- function get_data() {
- $.ajax({
- method: "GET",
- // url: `json/Columns-${id}.json`,
- url: `https://m3.hhh.com.tw:18686/gencolumn?id=${id}&sort=new&page=1`,
- // url:`json/Columns.json`,
- dataType: "json",
- })
- .done(function (msg) {
- console.log(msg);
- let ColumnsContent = "";
- let ColumnsTag = "";
- let breadcrumbTitle = "";
- let article_info = "";
- let OtherColumns = "";
- let PopularColumns = "";
- let author_inf="";
- breadcrumbTitle = `<a href="#">${msg[0].Columnstitle}</a>`
- article_info = `
- <h1 class="article__title mt-4">${msg[0].Columnstitle}</h1>
- <div class="small">${msg[0].ColumnsDate}| 人氣:${msg[0].ColumnsViews}</div>
- `;
- ColumnsContent = `${msg[0].ColumnsContent}`;
- for (let j = 0; j < msg[0].ColumnsTag.length; j++) {
- ColumnsTag += ' \
- <a target="_blank" href="https://hhh.com.tw/cases/lists/' + msg[0].ColumnsTag[j].Tag + '-keyword/" \
- class="btn btn-outline-custom rounded-0">'
- + msg[0].ColumnsTag[j].Tag + '</a>';
- }
- for (let i = 0; i < 12; i++) {
- OtherColumns +=
- '<div class="col-12 col-md-4 ps-0"><div class="cardList__items">\
- <a target="_blank" href="https://hhh.com.tw/columns/detail/'+ msg[0].OtherColumns[i].Columnsid + '/"> <img src="' + msg[0].OtherColumns[i].ColumnsCoverImg + '" alt="">\
- <div class="cardList__items__content">\
- <a href="https://hhh.com.tw/columns/detail/'+ msg[0].OtherColumns[i].Columnsid + '/"" target="_blank">\
- <div class="cardList__items--title cardList__items--ellipse">\
- '+ msg[0].OtherColumns[i].Columnstitle + '\
- </div>\
- </a>'
- OtherColumns += '<p>'
- for (k = 0; k < msg[0].OtherColumns[i].ColumnsTag.length; k++) {
- OtherColumns += '\
- <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>'
- }
- OtherColumns += '</p>'
- OtherColumns += '</div></div></div>'
- }
- author_inf=`
- <div>
- ${msg[0].author_inf}
- </div>
- `;
- // for(let i=0; i<msg[0].PopularColumns.length; i++){
- // PopularColumns+=
- // '<div class="col-12 col-md-4 ps-0"><div class="cardList__items">\
- // <a target="_blank" href="https://hhh.com.tw/columns/detail/'+msg[0].PopularColumns[i].Columnsid+'/"> <img src="'+msg[0].PopularColumns[i].ColumnsCoverImg+'" alt="">\
- // <div class="cardList__items__content">\
- // <a href="https://hhh.com.tw/columns/detail/'+msg[0].PopularColumns[i].Columnsid+'/"" target="_blank">\
- // <div class="cardList__items--title cardList__items--ellipse">\
- // '+msg[0].PopularColumns[i].Columnstitle+'\
- // </div>\
- // </a>'
- // PopularColumns+='<p>'
- // for(k=0; k<msg[0].PopularColumns[i].ColumnsTag.length; k++){
- // PopularColumns+='\
- // <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>'
- // }
- // PopularColumns+='</p>'
- // PopularColumns+='</div></div></div>'
- // }
- $('.article_info').html(article_info);
- $('.breadcrumb-title').html(breadcrumbTitle);
- $('.ColumnsContent').html(ColumnsContent);
- $('.ColumnsTag').html(ColumnsTag);
- $('.OtherColumns').html(OtherColumns);
- $('.anchor_info').html(author_inf);
- // $('.PopularColumns').html(PopularColumns);
- });
- }
- function renderSec07() {
- $.ajax({
- method: "GET",
- // url: `json/bannerAds-${id}.json`,
- url: `https://m3.hhh.com.tw:18686/getColumnAds`,
- dataType: "json",
- })
- .done(function (msg) {
- console.log(msg);
- console.log(msg.length);
- let str = '';
- for (let i = 0; i < msg.length; i++) {
-
- str += `<div class="sec-07__slider-${i + 1} slide-item p-1" onclick="window.open('${msg[i].link}');" data-bg="${msg[i].imgUrl}"><img class="img-fluid" src="${msg[i].imgUrl}"></div>`
- }
- $(`.sec-07__slider`).html(str);
- $(".sec-07__slider").slick({
- dots: false,
- autoplay: true,
- arrows: true,
- slidesToShow: 4,
- slidesToScroll: 1,
- autoplaySpeed: 7000,
- initialSlide: 0,
- infinite: true,
- prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
- nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>'
- });
- });
- }
- get_data();
- renderSec07();
- let filter;
- $(".views").click(function () {
- console.log(1);
- filter = "hot";
- get_views_data();
- });
- $(".recently").click(function () {
- console.log(2);
- filter = "new";
- get_views_data();
- });
- function get_views_data() {
- $.ajax({
- method: "GET",
- url:`https://m3.hhh.com.tw:18686/gencolumn?id=${id}&sort=${filter}&page=1`,
- // url: `json/Columns-${id}.json`,
- // url:`json/cases.json`,
- dataType: "json",
- })
- .done(function (msg) {
- console.log(msg);
- // msg[0].OtherColumns.sort(function (a, b) {
- // return a['Views'] > b['Views'] ? -1 : 1;
- // });
- console.log(msg[0].OtherColumns);
- let OtherColumns = "";
- for (let i = 0; i < msg[0].OtherColumns.length; i++) {
- OtherColumns +=
- '<div class="col-12 col-md-4 ps-0"><div class="cardList__items">\
- <a target="_blank" href="https://hhh.com.tw/columns/detail/'+ msg[0].OtherColumns[i].Columnsid + '/"> <img src="' + msg[0].OtherColumns[i].ColumnsCoverImg + '" alt="">\
- <div class="cardList__items__content">\
- <a href="https://hhh.com.tw/columns/detail/'+ msg[0].OtherColumns[i].Columnsid + '/"" target="_blank">\
- <div class="cardList__items--title cardList__items--ellipse">\
- '+ msg[0].OtherColumns[i].Columnstitle + '\
- </div>\
- </a>'
- OtherColumns += '<p>'
- for (k = 0; k < msg[0].OtherColumns[i].ColumnsTag.length; k++) {
- OtherColumns += '\
- <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>'
- }
- OtherColumns += '</p>'
- OtherColumns += '</div></div></div>'
- }
- $('.OtherColumns').html(OtherColumns);
- });
- };
- if ($(".views").hasClass("active")) {
- filter = "hot";
- // alert('1');
- } else {
- filter = "new";
- // alert('2');
- }
- function scroll_bottom_load_data(page) {
- $.ajax({
- method: "GET",
- // url: `json/cases-${id}.json`,
- // url:`json/cases.json`,
- url: `https://m3.hhh.com.tw:18686/gencolumn?id=${id}&sort=${filter}&page=${page}`,
- dataType: "json",
- })
- .done(function (msg) {
- let OtherColumns = "";
- for (let i = 0; i < msg[0].OtherColumns.length; i++) {
- OtherColumns +=
- '<div class="col-12 col-md-4 ps-0"><div class="cardList__items">\
- <a target="_blank" href="https://hhh.com.tw/columns/detail/'+ msg[0].OtherColumns[i].Columnsid + '/"> <img src="' + msg[0].OtherColumns[i].ColumnsCoverImg + '" alt="">\
- <div class="cardList__items__content">\
- <a href="https://hhh.com.tw/columns/detail/'+ msg[0].OtherColumns[i].Columnsid + '/"" target="_blank">\
- <div class="cardList__items--title cardList__items--ellipse">\
- '+ msg[0].OtherColumns[i].Columnstitle + '\
- </div>\
- </a>'
- OtherColumns += '<p>'
- for (k = 0; k < msg[0].OtherColumns[i].ColumnsTag.length; k++) {
- OtherColumns += '\
- <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>'
- }
- OtherColumns += '</p>'
- OtherColumns += '</div></div></div>'
- }
- // $('.OtherColumns').html(OtherColumns);
- $('.OtherColumns').append(OtherColumns);
- });
- }
- $(window).scroll(function () {
- var scrollTop = $(this).scrollTop();
- var scrollHeight = $('body').prop("scrollHeight");
- var clientHeight = document.documentElement.clientHeight;
- if (jQuery(window).width() < 767) {
-
- //一樣 var scrollHeight2 = document.documentElement.scrollHeight;
-
- if (scrollTop + clientHeight >= scrollHeight - 5) {
- loadMore_m();
- console.log(page);
- }
- } else {
- if (scrollTop + clientHeight >= scrollHeight - 5) {
- loadMore();
- console.log(page);
- }
- }
- })
- var page = 1;
- function loadMore() {
- setTimeout(function () {
- page++;
- // console.log(page);
- scroll_bottom_load_data(page);
- return page
- }, 500);
- }
- function loadMore_m() {
- // console.log(page);
- setTimeout(function () {
- page++;
- // console.log(page);
- scroll_bottom_load_data(page);
- return page
- }, 500);
- }
- // function loadMore_m() {
- // // console.log(page);
- // setTimeout(function () {
- // page++;
- // // console.log(page);
- // scroll_bottom_load_data(page);
- // return page
- // }, 500);
- // }
|