function _debounce(func, wait, immediate) { var timeout; return function () { clearTimeout(timeout); timeout = setTimeout(func, wait) } } var IqwXiongJs = { PartnerLogoBox: [], RandomImgFunction: null, RandomImgTime: 0, RandomSpeed: 8000, RandomAnimate: 6600, IndexPageTab:null, Init: function () { var that = this; that.HtmlInit(); }, IndexPageSwiper: function () { var that = this; var TouchMove = false; if (that.Width < 1200) { TouchMove = true; } if ($('.index_page_swiper').length > 0) { that.IndexPageTab = new Swiper(".index_page_swiper", { speed: 1000, loop: false, initialSlide: 0, direction: 'vertical', allowTouchMove: TouchMove, // resizeObserver: true, slidesPerView: 'auto', //禁止滑动时swiper移动 followFinger: false, // 鼠标控制 keyboard:{ enabled: true, onlyInViewport: true, }, mousewheel: true, pagination: { // el: ".swiper_scoll", // type: "progressbar" el: '.swiper_scoll' }, on: { init: function () { $('.index_page_content0').addClass('index_page_current'); that.headerHover(this.realIndex) }, slideChangeTransitionStart: function () { $(".swiperPageBox").removeClass("bluePage") $(".body_home").addClass("showdiv") $('.index_partner_item_box,.index_partner_item_box2').removeAttr('style'); $(".body_home").removeClass("whitePage") clearInterval(that.RandomImgFunction); if (this.realIndex == 0) { } if (this.realIndex == 1) { $(".swiperPageBox").addClass("bluePage") $(".body_home").removeClass("showdiv") $(".body_home").addClass("whitePage") } if (this.realIndex == 2) { } if (this.realIndex == 3) { $(".swiperPageBox").addClass("bluePage") $(".body_home").removeClass("showdiv") $(".body_home").addClass("whitePage") } if (this.realIndex == 4) { that.indexAboutUsNum() } if (this.realIndex == 5) { $(".swiperPageBox").addClass("bluePage") $(".body_home").removeClass("showdiv") $(".body_home").addClass("whitePage") } if (this.realIndex == 6) { } if (this.realIndex == 7) { $(".swiperPageBox").addClass("bluePage") $(".body_home").removeClass("showdiv") $(".body_home").addClass("whitePage") } if (this.realIndex == 8) { $(".body_home").removeClass("showdiv") } }, slideChangeTransitionEnd: function () { if (this.realIndex == $('.index_page_slide').length - 1) { console.log('已到底部'); } else { console.log('当前第' + this.realIndex + '页'); $('.index_page_content').removeClass('index_page_current'); } $('.index_partner_content').removeClass('index_partner_logo_current'); $('.index_page_swiper .swiper-slide-active .index_page_content').addClass('index_page_current'); if (this.realIndex == 0) { } if (this.realIndex == 1) { } if (this.realIndex == 2) { } if (this.realIndex == 3) { } if (this.realIndex == 4) { } if (this.realIndex == 5) { } if (this.realIndex == 6) { } if (this.realIndex == 7) { for (var i = 0; i < $('.index_partner_item_box').length; i++) { $('.index_partner_item_box').eq(i).css({ transitionDelay: 100 + (i * 85) + 'ms' }); } for (var i = 0; i < $('.index_partner_item_box2').length; i++) { $('.index_partner_item_box2').eq(i).css({ transitionDelay: 100 + (i * 85) + 'ms' }); } that.RandomImg(); } if (this.realIndex == 8) { } } } }); window.addEventListener('resize', _debounce(that.windowResize, 100)) } }, indexAboutUsNum:function(){ $("*[count-up-to-p]").each(function () { $(this).html($(this).attr("count-up-to-p")); try { if ($(this).data("countup")) { $(this).data("countup").pauseResume(); } window.counterUp["default"](this, { duration: 1500, delay: 50 }); } catch (error) { console.log(error) } }); }, headerHover:function(num){ $(".body_home .indexTopHeader").hover(function(){ var $W = $(window).width(); console.log("2222",$W,"========",num) if($W>=1024){ setTimeout(function(){ $(".body_home").removeClass("showdiv"); },2) } },function(){ var $W2 = $(window).width(); if($W2>1024){ if(!$(".body_home").hasClass("whitePage")){ setTimeout(function(){ $(".body_home").addClass("showdiv"); },2) } } }) }, RandomImg: function () { var that = this; $('.index_partner_content').addClass('index_partner_logo_current'); that.PartnerLogoBox.sort(() => Math.random() - 0.5); // console.log(that.PartnerLogoBox); for (var i = 0; i < $('.index_partner_item_box').length; i++) { $('.index_partner_item_box').eq(i).find('img').attr('src', that.PartnerLogoBox[i]); } for (var i = 0; i < $('.index_partner_item_box2').length; i++) { $('.index_partner_item_box2').eq(i).find('img').attr('src', that.PartnerLogoBox[i]); } // that.RandomImgFunction = setInterval(function () { // that.RandomImgTime += 10; // if (that.RandomImgTime >= that.RandomAnimate) { // $('.index_partner_content').removeClass('index_partner_logo_current'); // } // if (that.RandomImgTime >= that.RandomSpeed) { // $('.index_partner_content').addClass('index_partner_logo_current'); // that.RandomImgTime = 0; // that.PartnerLogoBox.sort(() => Math.random() - 0.5); // console.log(that.PartnerLogoBox); // for (var i = 0; i < $('.index_partner_item_box').length; i++) { // $('.index_partner_item_box').eq(i).find('img').attr('src', that.PartnerLogoBox[i]); // } // } // }, 10); }, indexApp:function(){ $(".indexItem2 .bg_list .list").eq(0).addClass("active"); $(".indexYwly ul li").hover(function(){ var _index = $(this).index(); $(".indexItem2 .bg_list .list").removeClass("active").eq(_index).addClass("active"); }) }, indexProduct:function(){ var that = this; var $w = $(window).width(); if($w>1024){ $(".indexProductList_out").each(function(){ if($(this).find(".indexProductList").attr("data-num")>9){ $(this).find(".moreBtn").show() } }) }else{ $(".indexProductList_out").each(function(){ if($(this).find(".indexProductList").attr("data-num")>5){ $(this).find(".moreBtn").show() } }) } }, windowResize: function () { // location.reload(); // var that = this; // var $w = $(window).width(); // var $h = $(window).height(); // console.log("resize", $w, $h,IqwXiongJs.IndexPageTab) // IqwXiongJs.indexProduct(); // if($w<980){ // IqwXiongJs.IndexPageTab.destroy(true, true) // }else{ // that.IndexPageSwiper() // } }, HtmlInit: function () { var that = this; that.IndexPageSwiper() that.indexProduct() }, Loading: function () { var $w = $(window).width(); console.log('加载完成',$(window).width(),$(window).height()); var that = this; that.Init(); that.indexApp(); that.indexBannerGifFn(); if($w<=1024){ IqwXiongJs.IndexPageTab.destroy(true, true) $(".index_page_content").addClass("index_page_current") $(".index_page_content7").addClass("index_partner_logo_current") } }, isDivInViewport:function (element) { var rect = element[0].getBoundingClientRect(); return ( rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth) ); }, indexBannerGifFn:function(){ var $w = $(window).width(); $(".indexBannerBox .swiper-slide").each(function(){ var bannerBg = $(this).attr("data-cover2") || $(this).attr("data-cover1"); var bannerBg2 = $(this).attr("data-cover1"); var bannerBg3 = $(this).find(".indexBg").attr("data-cover2") || $(this).find(".indexBg").attr("data-cover1"); var bannerBg4 = $(this).find(".indexBg").attr("data-cover1"); // console.log("wwww",$w,bannerBg,bannerBg2,bannerBg3,bannerBg4) if($w<=750){ $(this).css("background-image","url("+bannerBg+")") $(this).find(".indexBg").css("background-image","url("+bannerBg3+")") }else{ $(this).css("background-image","url("+bannerBg2+")") $(this).find(".indexBg").css("background-image","url("+bannerBg4+")") } }) } } $(function () { $(".index_page_slide:last-child").css("height",$("footer").height()) IqwXiongJs.Loading(); var $div = $('.mPartnerBox'); if (IqwXiongJs.isDivInViewport($div)) { $div.addClass("activeView") } else { $div.removeClass("activeView") } window.addEventListener('resize', _debounce(function() { IqwXiongJs.indexBannerGifFn() }, 250)); window.addEventListener('scroll', _debounce(function() { if (IqwXiongJs.isDivInViewport($div)) { $div.addClass("activeView") } else { // $div.removeClass("activeView") } }, 250)); });