//_load var scrollHeight01 = document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop; var width1=$(window).width(); if(width>1024){ if (scrollHeight01>0){ $('header').addClass("notop"); } else { $('header').removeClass("notop"); } } var width=$(window).width(); if(width>790){ var scrollFunc = function (e) { e = e || window.event; if (e.wheelDelta) { //鍒ゆ柇娴忚鍣↖E锛岃胺姝屾粦杞簨浠 if (e.wheelDelta > 0) { //褰撴粦杞悜涓婃粴鍔ㄦ椂 //浜嬩欢 // console.log(111) } if (e.wheelDelta < 0) { //褰撴粦杞悜涓嬫粴鍔ㄦ椂 (function($,w){ var winHei=$(w).height(); var loadFn=function(){ var $conLis=$('[_load]'); $conLis.each(function(i,v){ var scrollTop=$(w).scrollTop(); var $v=$(v); if($conLis.filter('_load')==0) $(w).off('scroll.z'); if( winHei+scrollTop > $v.offset().top){ $v.addClass('active'); $(this).removeAttr('_load'); } }) }; $(w).on('scroll.z load',loadFn); })(jQuery, window); } } else if (e.detail) { //Firefox婊戣疆浜嬩欢 if (e.detail> 0) { //褰撴粦杞悜涓婃粴鍔ㄦ椂 (function($,w){ var winHei=$(w).height(); var loadFn=function(){ var $conLis=$('[_load]'); $conLis.each(function(i,v){ var scrollTop=$(w).scrollTop(); var $v=$(v); if($conLis.filter('_load')==0) $(w).off('scroll.z'); if( winHei+scrollTop > $v.offset().top){ $v.addClass('active'); $(this).removeAttr('_load'); } }) }; $(w).on('scroll.z load',loadFn); })(jQuery, window); } if (e.detail< 0) { //褰撴粦杞悜涓嬫粴鍔ㄦ椂 } } } }else{ var windowTop=0;//鍒濆璇濆彲瑙嗗尯鍩熻窛绂婚〉闈㈤《绔殑璺濈 $(window).scroll(function() { var scrolls = $(this).scrollTop();//鑾峰彇褰撳墠鍙鍖哄煙璺濈椤甸潰椤剁鐨勮窛绂 if(scrolls>=windowTop){//褰揃>A鏃讹紝琛ㄧず椤甸潰鍦ㄥ悜涓嬫粦鍔 (function($,w){ var winHei=$(w).height(); var loadFn=function(){ var $conLis=$('[_load]'); $conLis.each(function(i,v){ var scrollTop=$(w).scrollTop(); var $v=$(v); if($conLis.filter('_load')==0) $(w).off('scroll.z'); if( winHei+scrollTop > $v.offset().top){ $v.addClass('active'); $(this).removeAttr('_load'); } }) }; $(w).on('scroll.z load',loadFn); })(jQuery, window); }else{ } }); } //缁欓〉闈㈢粦瀹氭粦杞粴鍔ㄤ簨浠 if (document.addEventListener) {//firefox document.addEventListener('DOMMouseScroll', scrollFunc, false); } //婊氬姩婊戣疆瑙﹀彂scrollFunc鏂规硶 //ie 璋锋瓕 window.onmousewheel = document.onmousewheel = scrollFunc; $(function () { //fixed nav bind on jquery $.fn.navFixed = function(){ var $_this = $(this), $_this_prev_marginBottom = parseInt($_this.prev().css("margin-bottom").substring(0, $_this.prev().css("margin-bottom").length-2)), $_this_next_marginTop = parseInt($_this.next().css("margin-top").substring(0, $_this.next().css("margin-top").length-2)), _topPosition = $(document).scrollTop(), _navPosition = $_this.prev().find('img').height(); _if(); $(document).scroll( function() { _topPosition = $(document).scrollTop(); _if(); }); $(window).resize(function(){ _navPosition = $_this.prev().find('img').height(); _if(); }); function _if(){ var width=$(window).width(); // console.log(_topPosition,_navPosition) if (_navPosition>21 && _topPosition >= _navPosition){ $_this.css("position", "fixed"); if(width<=1024){ $_this.css("top", "5.5rem"); }else{ $_this.css("top", "100px"); } $_this.next().css("margin-top", $_this_prev_marginBottom + $_this.outerHeight() + $_this_next_marginTop + "px"); }else{ $_this.css("position", "relative"); if(width<=1024){ $_this.css("top", "0"); }else{ $_this.css("top", "0"); } $_this.next().css("margin-top", $_this_next_marginTop + "px"); } } } $.fn.navFixed01 = function(){ var $_this = $(this), $_this_prev_marginBottom = parseInt($_this.prev().css("margin-bottom").substring(0, $_this.prev().css("margin-bottom").length-2)), $_this_next_marginTop = parseInt($_this.next().css("margin-top").substring(0, $_this.next().css("margin-top").length-2)), _topPosition = $(document).scrollTop(), _navPosition = $_this.prev().find('img').height(); _if(); var banner_height = $('.banner').height(); var productsub_height = $('.product-sub').height(); var introduce_height = $('#introduce').height(); var this_height = $('header').height(); var all_height = banner_height+productsub_height+introduce_height-this_height; $(document).scroll( function() { _topPosition = $(document).scrollTop(); _if(); }); $(window).resize(function(){ _navPosition = $_this.prev().find('img').height(); _if(); }); function _if(){ var width=$(window).width(); // console.log(_topPosition,_navPosition) if (_topPosition >= all_height){ $_this.css("position", "fixed"); if(width<=1024){ $_this.css("top", "5.5rem"); }else{ $_this.css("top", "100px"); } $_this.next().css("margin-top", $_this_prev_marginBottom + $_this.outerHeight() + $_this_next_marginTop + "px"); }else{ $_this.css("position", "relative"); if(width<=1024){ $_this.css("top", "0"); }else{ $_this.css("top", "0"); } $_this.next().css("margin-top", $_this_next_marginTop + "px"); } } } }); $(function () { var mySwiper = new Swiper('.footer-slider.swiper-container',{ direction : 'horizontal', spaceBetween: 40, slidesPerView: 6, autoplay: true, breakpoints: { 1024: { slidesPerView: 3, spaceBetween: 20 }, 768: { slidesPerView: 3, spaceBetween: 20 }, } //绐楀彛缂╂斁鏃 }); //back to top if($(window).width()>1024){ $('#backTop').on('click',function () { $("html,body").animate({scrollTop:0}, 1000); }); addEvent('scroll',function () { var scrollHeight = document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop; if (scrollHeight>0){ $('header').addClass("notop"); } else { $('header').removeClass("notop"); } if (scrollHeight>400){ $('.sidebar').fadeIn(); } else { $('.sidebar').fadeOut(); } }); }else{ $('.return_top').on('click',function () { $("html,body").animate({scrollTop:0}, 1000); }); addEvent('scroll',function () { var scrollHeight = document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop; if (scrollHeight>100){ $('.return_top').fadeIn(); } else { $('.return_top').fadeOut(); } }); } // login // 鎶ュ悕琛ㄥ崟 $('.login').on('click',function(){ $('.sign-up-header').show(); $('header nav').removeClass('active'); $('header .nav-button').removeClass('active'); $('header .nav-container .nav-r').removeClass('active'); $('header .nav-container .nav').removeClass('active'); $('.search-list').removeClass('mobile-search'); $('header .header_in >.right .search').removeClass('active'); $('.header-mobile-mask').hide(); }); $(document).on('click','.sign-up-header .close',function(){ $('.sign-up-header').hide(); $('.member-login').show(); $('.forget-password').hide(); $('.table').removeClass('active'); $('.wrap span').eq(0).addClass('active').siblings().removeClass('active'); $('.mode li').eq(0).show().siblings().hide(); // $('form')[0].reset(); }); $(document).on('click','.register-header .close',function(){ $('.register-header').hide(); $('.member-login').show(); $('.forget-password').hide(); $('.table').removeClass('active'); $('.wrap span').eq(0).addClass('active').siblings().removeClass('active'); $('.mode li').eq(0).show().siblings().hide(); // $('form')[0].reset(); }); $('.wrap span').click(function () { var index=$(this).index(); $(this).addClass('active').siblings().removeClass('active'); $('.mode li').eq(index).show().siblings().hide(); }); $('.for-word').click(function () { $('.member-login').hide(); $('.forget-password').show(); $('.table').addClass('active'); }); $('.login-register').click(function () { $('.sign-up-header').hide(); $('.register-header').show(); }); $('.login-account').click(function () { $('.sign-up-header').show(); $('.register-header').hide(); }); // 瀵艰埅鐎戝竷娴 // 鐎戝竷娴 function waterFall_nav() { // 1- 纭畾鍥剧墖鐨勫搴 - 婊氬姩鏉″搴 // var pageWidth = getClient().width; var pageWidth=$('.masonry-nav.active').width(); //3鍒 var columns=4; var itemWidth = parseInt(pageWidth/columns); //寰楀埌item鐨勫搴 $('.masonry-nav.active .item').width(itemWidth); //璁剧疆鍒癷tem鐨勫搴 // $(".masonry-nav .item").css('padding','10px'); var arr = []; var arr_height=[]; $(".masonry-nav.active .item").each(function(i){ var height = $(this).height(); var width = $(this).width(); var bi = itemWidth/width; //鑾峰彇缂╁皬鐨勬瘮鍊 var boxheight = parseInt(height*bi); //鍥剧墖鐨勯珮搴?姣斿€ = item鐨勯珮搴 if (i < columns) { // 2- 纭畾绗竴琛 $(this).css({ top:0, left:(itemWidth) * i }); arr.push(boxheight); arr_height.push(boxheight); } else { // 鍏朵粬琛 // 3- 鎵惧埌鏁扮粍涓渶灏忛珮搴 鍜 瀹冪殑绱㈠紩 var minHeight = arr[0]; var index = 0; for (var j = 0; j < arr.length; j++) { if (minHeight > arr[j]) { minHeight = arr[j]; index = j; } } // 4- 璁剧疆涓嬩竴琛岀殑绗竴涓洅瀛愪綅缃 // top鍊煎氨鏄渶灏忓垪鐨勯珮搴 $(this).css({ top:arr[index], left:$(".masonry-nav.active .item").eq(index).css("left") }); // 5- 淇敼鏈€灏忓垪鐨勯珮搴 // 鏈€灏忓垪鐨勯珮搴 = 褰撳墠鑷繁鐨勯珮搴 + 鎷兼帴杩囨潵鐨勯珮搴 arr[index] = arr[index] + boxheight; arr_height.push(arr[index]); } }); var max=Math.max.apply(null,arr_height); $('.masonry-nav.active').css('height',max); //$('.drop-down-product').css('height',"calc( "+max+"px + 5.5rem )"); if(max<220){ $('.drop-down-product .left').css('height',220); //$('.drop-down-product').css('height',"calc( 220px + 5.5rem )"); $('.drop-down-product .masonry-nav').css('height',220); }else{ $('.drop-down-product .left').css('height',max); } $('.drop-down-product .left').css('padding-bottom',"5.5rem"); $('.drop-down-product .masonry-nav').css('padding-bottom',"5.5rem"); $('.drop-down-product .left').css('box-sizing',"content-box"); $('.drop-down-product .masonry-nav').css('box-sizing',"content-box"); } // 椤甸潰灏哄鏀瑰彉鏃跺疄鏃惰Е鍙 window.onresize = function() { //閲嶆柊瀹氫箟鐎戝竷娴 if(width>990){ waterFall_nav(); } }; // nav鎵嬫満绔弽搴 // if($(window).width()<=1024){ // var obj=$('header nav>ul'); // var list=obj.children("li"); // for(var i = list.length-1; i > -1; i--){ // obj.append(list[i]); // } // }; var width=$(window).width(); // waterFall_nav(); //鍒濆鍖 if(width>1024){ // 瀵艰埅pc鎼滅储 $('.search').hover(function () { $('header .header_in > .right').addClass('search-click'); },function(){ $('header .header_in > .right').removeClass('search-click'); }); $('.search-close').click(function () { $('header .header_in > .right').removeClass('search-click'); }); // 瀵艰埅pc鎼滅储 // $('.search-open').click(function () { // $('header .header_in > .right').addClass('search-click'); // }); // $('.search-close').click(function () { // $('header .header_in > .right').removeClass('search-click'); // }); $('.drop-down>.left li').hover(function () { var index=$(this).index(); $(this).addClass('active').siblings().removeClass('active'); $('.drop-down>.right .masonry-nav').removeClass('active').eq(index).addClass('active'); waterFall_nav(); }); var t=null; $("nav>ul>li").each(function() { $(this).mouseenter(function(){ var int=$(this).index(); t=setTimeout(function () { $('nav>ul>li').eq(int).siblings().find('.drop-down').hide(); $('nav>ul>li').eq(int).find('.drop-down').slideDown(100); waterFall_nav(); },100) }).mouseleave(function(){ clearTimeout(t); }) }); $('header').mouseleave(function () { $('nav>ul>li .drop-down').slideUp(); }); $('nav>ul>li .drop-down').mouseleave(function () { $('nav>ul>li .drop-down').slideUp(); }); $('header .header_in >.right').hover(function () { $('nav>ul>li .drop-down').slideUp(); }); }else{ $('footer').addClass('slider'); // 鎵嬫満鐗堝鑸 $('header nav>ul>li').click(function (event) { event.stopPropagation(); if ($(this).hasClass('mobile_active')){ $(this).removeClass('mobile_active'); }else{ $(this).addClass('mobile_active').siblings().removeClass('mobile_active'); } $('.nav-bottom').removeClass('mobile_active'); $('.product-mobile>li').removeClass('mobile_two'); }); // 浜у搧浜岀骇瀵艰埅 $('.product-mobile>li').click(function (event) { event.stopPropagation(); if ($(this).hasClass('mobile_two')){ $(this).removeClass('mobile_two'); }else{ $(this).addClass('mobile_two').siblings().removeClass('mobile_two'); } $('.product-three>li').removeClass('mobile_three'); }); // 浜у搧涓夌骇瀵艰埅 $('.product-three>li').click(function (event) { event.stopPropagation(); if ($(this).hasClass('mobile_three')){ $(this).removeClass('mobile_three'); }else{ $(this).addClass('mobile_three').siblings().removeClass('mobile_three'); } }); $('.nav-bottom').click(function () { $(this).toggleClass('mobile_active'); $('header nav>ul>li').removeClass('mobile_active'); }); $('header .nav-button').click(function () { $('.search-list').removeClass('mobile-search'); $('header .header_in >.right .search').removeClass('active'); if ($(this).hasClass('active')){ $(this).removeClass('active'); $('header .nav-container .nav-r').removeClass('active'); $('header .nav-container .nav').removeClass('active'); $('header nav').removeClass('active'); $('header nav>ul>li').removeClass('mobile_active'); $('.nav-bottom').removeClass('mobile_active'); $('.header-mobile-mask').hide(); }else{ $(this).addClass('active'); $('header .nav-container .nav').addClass('active'); $('header .nav-container .nav-r').addClass('active'); $('header nav').addClass('active'); $('.header-mobile-mask').show(); } }); $('.header-mobile-mask').click(function(){ $('header .nav-button').removeClass('active'); $('header nav').removeClass('active'); $('header .nav-container .nav-r').removeClass('active'); $('header .nav-container .nav').removeClass('active'); $('.header-mobile-mask').hide(); $('header nav > ul > li').removeClass('mobile_active'); $('.nav-bottom').removeClass('mobile_active'); $('.product-mobile>li').removeClass('mobile_two'); }); // 鎼滅储 $('header .header_in >.right .search').click(function () { $(this).toggleClass('active'); $('.search-list').toggleClass('mobile-search'); $('header .nav-button').removeClass('active'); $('header nav').removeClass('active'); $('header .nav-container .nav-r').removeClass('active'); $('header .nav-container .nav').removeClass('active'); $('.header-mobile-mask').hide(); }); // 搴曢儴瀵艰埅 $('footer .con .bottom>ul>li').click(function () { if ($(this).hasClass('mobile_active')){ $(this).removeClass('mobile_active'); }else{ $(this).addClass('mobile_active').siblings().removeClass('mobile_active'); } }); } });