$(function(){ zz(); link(); menu(); // tips(); returnTop(); }); $(window).resize(function(){ zz(); link(); menu_big(); // tips(); }) // 鏇存敼閬僵灞傞珮搴 function zz(){ let width=window.innerWidth;//鍖呭惈婊氬姩鏉$殑瀹藉害 let height=$(window).height(); let header_height=$('header').height(); let zz_height=height-header_height; if (width<1200){ $('.zz').height(zz_height); }else{ $('.zz').height(50); }; } // 鏈変簩绾ф爮鐩紝涓€绾ф爮鐩氨绂佹璺宠浆 function link(){ $('.nav>li>a').on('click',function(){ if($(this).siblings('i').length>0){ let width=window.innerWidth;//鍖呭惈婊氬姩鏉$殑瀹藉害 if (width<=1200){ event.preventDefault(); } } }) } // 鑿滃崟澶勭悊 function menu(){ $('.nav>li>a').on('click',function(){ // i鏍囩鍙樺寲 if($(this).siblings('i').hasClass('active')){ $(this).siblings('i').text('+').removeClass('active'); }else{ $('i').text('+').removeClass('active'); $(this).siblings('i').text('-').addClass('active'); } // 鎶樺彔 if($(this).siblings('i').hasClass('active')){ $('.nav_ul').stop(false).slideUp(); $(this).siblings('.nav_ul').stop(false).slideDown(); }else{ $(this).siblings('.nav_ul').stop(false).slideUp(); } }) } // 鎶樺彔bug澶勭悊 function menu_big(){ let width=window.innerWidth;//鍖呭惈婊氬姩鏉$殑瀹藉害 if (width>1200){ $('.nav_ul').css({'display':'none'}); }else{ $('.nav_ul').each(function(){ if($(this).siblings('i').hasClass('active')){ $(this).siblings('i').text('+').removeClass('active'); } }) } }; // 鍙充笂瑙掕彍鍗曟寜閽 $('.but_box').on('click',function(){ $('.but').toggleClass('open'); $('.zz').toggleClass('open'); }) // 閫氱煡 function tips(){ let width=window.innerWidth;//鍖呭惈婊氬姩鏉$殑瀹藉害 if(width<768){ var mySwiper = new Swiper('.tips .swiper',{ loop: true, autoplay:true, }) }else{ var mySwiper = new Swiper('.tips .swiper',{ loop: true, autoplay:true, slidesPerView:2, slidesPerGroup : 2, }) } } function returnTop(){ $('#backTop').hide(); $(window).scroll(function(){ if($(this).scrollTop() > 200){ $('#backTop').fadeIn(); }else{ $('#backTop').fadeOut(); } }); $('#backTop').click(function(){ $('html ,body').animate({scrollTop: 0}, 300); return false; }); }