$(function(){ document.documentElement.style.fontSize = window.innerWidth/7.5 + 'px'; (function() { var doc = document, win = window; var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', recalc = function() { var clientWidth = docEl.clientWidth; if(!clientWidth) return; //如果屏幕大于750(750是根据我效果图设置的,具体数值参考效果图),就设置clientWidth=750,防止font-size会超过100px if(clientWidth > 750) { clientWidth = 1920 } //设置根元素font-size大小 docEl.style.fontSize = 100 * (clientWidth / 1920) + 'px'; }; //屏幕大小改变,或者横竖屏切换时,触发函数 win.addEventListener(resizeEvt, recalc, false); //文档加载完成时,触发函数 doc.addEventListener('DOMContentLoaded', recalc, false); })(); $('.nav ul li').hover(function(){ $('.nav ul li h2 a').removeClass('on'); $(this).children('h2').children('a').addClass('on'); if($(this).children('dl').length > 0){ $(this).children('dl').toggle(); $('.hea_navbg').toggle(); } }) $('.ewx_btn').hover(function(){ $(".ewm_tc").addClass('on'); },function(){ $(".ewm_tc").removeClass('on'); }) $('.menu_btn').click(function(){ $('.mob_nav2').toggleClass('on') }) $('.mob_close').click(function(){ $('.mob_nav2').removeClass('on') }) $('.mob_nav2con ul li h2').click(function(){ $(this).parents('li').toggleClass('on').siblings().removeClass('on') $(this).siblings('.mob_lv2').slideToggle(300).parents('li').siblings().children('.mob_lv2').slideUp(300); }) if($(window).width() < 750 ){ //alert(1) $('.mlb_lbtjs').css('top','1.8rem'); $('.mlb_promore').css('bottom','0.8rem'); $('.mob_lbt .swiper-slide:nth-of-type(2)').css('background-position','center 30%'); $('.mob_lbt .swiper-slide:nth-of-type(5)').css('background-position','center 18%'); } /*var headerheight=$('.header').outerHeight(true); $('.home_lbt').css('margin-top', headerheight +'px');*/ var swiperL = new Swiper('.swiper-container-l', { direction: 'vertical', slidesPerView: 'auto', speed:1000, lazyLoading : true, lazyLoadingInPrevNext:true, lazyLoadingInPrevNextAmount : 2, spaceBetween: 0, mousewheelControl:true, pagination:'.swiper-pagination-l', paginationClickable: true, onSlideChangeEnd: function(swiper){ var index=swiper.activeIndex; //alert(index); if(index == 1){ $('.home_pc .page2 .home_projspc').addClass('on') } if(index == 2){ $('.home_pc .page3 .home_projspc').addClass('on') } if(index == 3){ $('.home_pc .page4 .home_projspc').addClass('on') } if(index == 4){ $('.home_pc .page5 .home_projspc').addClass('on') } } }); $('.homepc_gotop').click(function(){ swiperL.slideTo(0,2000,false) }) var swiperP= new Swiper('.swiper-container-p', { slidesPerView: 'auto', speed:1000, autoplay:5000, loop:true, lazyLoading : true, lazyLoadingInPrevNext:true, lazyLoadingInPrevNextAmount : 2, spaceBetween: 0, pagination:'.swiper-pagination-p', paginationClickable: true, }); var swiperK= new Swiper('.swiper-container-k', { slidesPerView: 'auto', speed:1000, autoplay:5000, lazyLoading : true, lazyLoadingInPrevNext:true, lazyLoadingInPrevNextAmount : 2, spaceBetween: 0, pagination:'.swiper-pagination-k', paginationClickable: true, onSlideChangeEnd: function(swiper){ var index=swiper.activeIndex; //alert(index); if(index == 1){ $('.pageT .home_projspc').addClass('on') } } }); $('.mlb_lbtwz').addClass('on'); var swiperJ = new Swiper('.swiper-container-j', { direction: 'vertical', slidesPerView: 'auto', speed:1000, lazyLoading : true, lazyLoadingInPrevNext:true, lazyLoadingInPrevNextAmount : 2, spaceBetween: 0, mousewheelControl: true, pagination: { el: '.swiper-pagination-j', clickable: true, }, onSlideChangeEnd: function(swiper){ var index=swiper.activeIndex; console.log(index) /*if(index > 0){ $('.mlb_lbtwz').addClass('on'); $('.mlbT_lbtjs').removeClass('on'); }else{ $('.mlb_lbtwz').removeClass('on'); $('.mlbT_lbtjs').addClass('on'); }*/ if(index > 0){ $('.homewap_gotop').addClass('active') $('.mlb_lbtwz').addClass('on'); $('.mlb_lbtwz ul li').eq(index).animate({ opacity: "1" },0).siblings().animate({ opacity: "0" },0); }else{ $('.homewap_gotop').removeClass('active') } if(index == 5){ $('.mlb_lbtwz').removeClass('on'); } /*if(index > 0){ $('.mlb_lbtwz').addClass('on'); $('.mlbT_lbtjs').removeClass('on'); }else{ $('.mlb_lbtwz').removeClass('on'); $('.mlbT_lbtjs').addClass('on'); } if(index == 5){ $('.mlb_lbtwz ul li').removeClass('active'); }else{ $('.mlb_lbtwz ul li').eq(this.activeIndex).addClass('active').siblings().removeClass('active'); $('.mlb_lbtwz ul li').eq(swiper.activeIndex-1).animate({ opacity: "1" },0).siblings().animate({ opacity: "0" },0); }*/ } }); $('.homewap_gotop').click(function(){ swiperJ.slideTo(0,2000,false) }) var swiper1 = new Swiper('.swiper-container-o', { slidesPerView: 1, speed:1000, lazyLoading : true, lazyLoadingInPrevNext:true, lazyLoadingInPrevNextAmount : 2, spaceBetween: 0, pagination: { el: '.swiper-pagination-o', clickable: true, }, onSlideChangeEnd: function(swiper){ var index=swiper.activeIndex; if(index == 1){ $('.mlbT_lbtjs').addClass('on'); }else{ $('.mlbT_lbtjs').removeClass('on'); } } }); var swiperM= new Swiper('.swiper-container-m', { slidesPerView: 'auto', speed:1000, lazyLoading : true, lazyLoadingInPrevNext:true, lazyLoadingInPrevNextAmount : 2, spaceBetween: 0, pagination:'.swiper-pagination-m', paginationClickable: true, /*onSlideChangeStart: function(swiper){ var index=swiper.activeIndex; //alert(index); if(index >= 1){ $('.mlb_lbtwz').removeClass('on') }else{ $('.mlb_lbtwz').addClass('on') } }*/ }); }) $(".top_seasub").click(function(){ var key = $("#topKey").val(); if(key){ location.href = "/search/?key=" + key; } }); $(".top_seasub_wap").click(function(){ var key = $("#topKeyWap").val(); if(key){ location.href = "/search/?key=" + key; } });