$(document).ready(function () { var languageParameter = localStorage.getItem("language") || "CN"; var bannerArr = new Array(); var homePageText = ""; var endPageText = ""; var prevPageText = ""; var nextPageText = ""; if (languageParameter == "CN") { $(".quanWrap").text("加載中……"); homePageText = "首頁"; endPageText = "尾頁"; prevPageText = "上一頁"; nextPageText = "下一頁"; } else { $(".quanWrap").text("Loading……"); homePageText = "One"; endPageText = "Prev"; prevPageText = "Next"; nextPageText = "Last"; } $(".back").on("click", function () { history.back(); }); var dataArray = new Array(); var url = window.location.search; var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for (var i = 0; i < strs.length; i++) { theRequest[strs[i].split("=")[0]] = unescape( decodeURIComponent(strs[i].split("=")[1]) ); } } let typeName = theRequest.typename; $(".pageTitle").text(typeName); var currentPage = Number(theRequest.page) || 1; var allDataArray = new Array(); function getLabelData(pageNum) { clearScroll(); let languageParameter = localStorage.getItem('language') || 'CN'; $.ajax({ type: "post", url: "https://www.bibidd.com/bibidd/Mediasix/select_type_detail", dataType: "json", data: { LNG:languageParameter, type_name: typeName, type: "video", page: pageNum, }, success: function (res) { ispage = true; allDataArray = res.data; dataArray = []; if (allDataArray.length > 0) { let showDataNum = allDataArray.length % 12 === 0 ? 12 : allDataArray.length % 12; for (let i = 0; i < showDataNum; i++) { dataArray.push(allDataArray[i]); } } // 分页 let dataNum = res.all_num; $(function () { $("#pagination3").pagination({ currentPage: currentPage, totalPage: Math.ceil(dataNum / 60), isShow: true, count: 7, homePageText: homePageText, endPageText: endPageText, prevPageText: prevPageText, nextPageText: nextPageText, callback: function (current) { $(location).attr( "href", "labelVideoMore.html?typename=" + theRequest.typename + "&page=" + current ); }, }); Math.ceil(dataNum / 60) < 2 ? $(".firstPage").show() : $(".firstPage").hide(); }); $("html, body").animate( { scrollTop: 0, }, 50 ); createDomHtml(dataArray); } }); } getLabelData(1); function createDomHtml(dataArray) { let videoHtml = ""; $.each(dataArray, function (index, data) { if(data.jump_link) { let headBannerHtml = ` `; videoHtml += headBannerHtml; }else{ if(data.top_img != 'https://www.bibidd.com/bibidd_testtest/A.jpg') { videoHtml += `
${videoTime(data.time_chuo)}
${data.title}
`; } } }); $(".video").html(videoHtml); var loadingUrl = "/Public/bibidd/images/loading.png"; $(".lazy").lazyload({ effect: "show", placeholder: loadingUrl, failurelimit: 10, skip_invisible: false, }); $(".videoContent").on("click", function () { let thisId = $(this).attr('id'); let thisIdLength = $(this).attr('id').length; let thisIndex = Number(thisId.substring(12, thisIdLength)); $(location).attr( "href", "videodetails.html?videoid=" + allDataArray[thisIndex].id + "&fabulous=" + allDataArray[thisIndex].thumbs_up + "&favorite=" + allDataArray[thisIndex].favorite + "&videoname=" + allDataArray[thisIndex].title ); }); // 广告详情 $('.banner').on('click', function() { let bannerParent = $(this).parent().attr('class'); if(bannerParent == 'headBanner'){ window.location.href = bannerArr[0].jump_link; }else { window.location.href = allDataArray[$(this).index()].jump_link; } }) } function videoTime(time) { let timeStr = ""; let h = Math.floor(time / 60 / 60) < 10 ? "0" + Math.floor(time / 60 / 60) : Math.floor(time / 60 / 60); let m = Math.floor(Math.floor(time / 60) % 60) < 10 ? "0" + Math.floor(Math.floor(time / 60) % 60) : Math.floor(Math.floor(time / 60) % 60); let s = Math.floor(time % 60) < 10 ? "0" + Math.floor(time % 60) : Math.floor(time % 60); timeStr = h + ":" + m + ":" + s; return timeStr; } // 上拉加载更多 var showVideoNum = 12; var ispage = true; // 上拉加载更多 $(window).scroll(function () { var scrollT = $(document).scrollTop(); var offsetT = $(".main").offset().top; if (scrollT >= offsetT) { $(".backToTop").show(); } else { $(".backToTop").hide(); } let windowHeight = $(window).height(); let windowScrollTop = $(window).scrollTop(); let loadingHeight = $(".bottomLoadContent").height(); if ( windowHeight + windowScrollTop + loadingHeight + 220 >= $(document).height() ) { if (ispage && allDataArray.length > 0) { ispage = false; if (showVideoNum < allDataArray.length) { $(".bottomLoadContent").show(); $(".box").hide(); showVideoNum += 12; showVideoNum = showVideoNum > allDataArray.length ? allDataArray.length : showVideoNum; dataArray = []; let forNum = 0; if (showVideoNum % 12 != 0) { forNum = showVideoNum % 12; } else { forNum = 12; } for (let i = 0; i < 12; i++) { dataArray.push(allDataArray[showVideoNum - 12 + i]); } let videoHtml = ""; $.each(dataArray, function (index, data) { if(data.jump_link) { let headBannerHtml = ` `; videoHtml += headBannerHtml; }else{ if(data.top_img != 'https://www.bibidd.com/bibidd_testtest/A.jpg') { videoHtml += `
${videoTime(data.time_chuo)}
${data.title}
`; } } }); setTimeout(() => { $(".video").append(videoHtml); $(".bottomLoadContent").hide(); var loadingUrl = "/Public/bibidd/images/loading.png"; $(".lazy").lazyload({ effect: "show", placeholder: loadingUrl, failurelimit: 10, skip_invisible: false, }); $(".videoContent").on("click", function () { let thisId = $(this).attr('id'); let thisIdLength = $(this).attr('id').length; let thisIndex = Number(thisId.substring(12, thisIdLength)); $(location).attr( "href", "videodetails.html?videoid=" + allDataArray[thisIndex].id + "&fabulous=" + allDataArray[thisIndex].thumbs_up + "&favorite=" + allDataArray[thisIndex].favorite + "&videoname=" + allDataArray[thisIndex].title ); }); ispage = true; // 广告详情 $('.banner').on('click', function() { window.location.href = allDataArray[$(this).index()].jump_link; }) }, 500); } else { $(".bottomLoadContent").hide(); $(".box").show(); ispage = true; } } } }); function clearScroll() { showVideoNum = 12; ispage = false; scrollT = 0; offsetT = 0; $(".bottomLoadContent").show(); $(".box").hide(); } });