$(document).ready(function () { // 获取浏览器的宽度 let viewWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; // 获取顶部/导航/导航菜单的高度 let welcomeHeight = $(".welcome").outerHeight(true); let headerHeight = $(".logo").outerHeight(true); // pc端导航定位 $(window).scroll(function () { if ($(this).scrollTop() > welcomeHeight) { $(".header").addClass("header-active"); $(".welcome").css("margin-bottom", headerHeight); } else { $(".header").removeClass("header-active"); $(".welcome").css("margin-bottom", "0"); } }) // 搜索 $(".search-btn").click(function () { $(".search-form").slideToggle(); }) // banner大图 let bannerSwiper = new Swiper('.banner-swiper', { slidesPerView: 1, loop: true, autoHeight: true, autoplay: { delay: 5000, disableOnInteraction: false, }, pagination: { el: '.banner-swiper .swiper-pagination', clickable: true, }, navigation: { nextEl: '.banner-next', prevEl: '.banner-prev', } }); // 产品左侧 $('.menu-active').children("ul").stop().slideDown(); $('.menu-list>li').click(function () { $(".menu-child-list").slideUp(); $(".menu-list>li").removeClass("menu-active"); $(this).children("ul").stop().slideToggle(); $(this).toggleClass("menu-active"); }) // 成功案例 $('.case-left li').hover(function () { $(this).addClass('case-active').siblings('li').removeClass('case-active'); var index = $(this).index(); $('.case-right>img').eq(index).show().siblings('.news-right>img').hide(); }) // 资质证书 var honorSwiper = new Swiper('.honor .swiper', { observer: true, //开启动态检查器,监测swiper和slide observeParents: true, //监测Swiper 的祖/父元素 autoplay: { delay: 5000, disableOnInteraction: false, }, //自动滚动 loop: false, //循环滚动 slidesPerView: 2, //个数 spaceBetween: 5, //间距 breakpoints: { 767: { slidesPerView: 1, } } }); // var mySwiper = new Swiper('.-content .swiper', { // observer: true, //开启动态检查器,监测swiper和slide // observeParents: true, //监测Swiper 的祖/父元素 // autoplay: { // delay: 5000, // disableOnInteraction: false, // }, //自动滚动 // loop: false, //循环滚动 // slidesPerView: 3, //个数 // spaceBetween: 5, //间距 // grid: { // fill: 'row', // rows: 2, // }, // pagination: { //圆点 // el: '.swiper-pagination', // clickable: true, // }, // navigation: { //箭头 // nextEl: '.next-button', // prevEl: '.prev-button', // }, // breakpoints: { // 1200: { // slidesPerView: 6, // spaceBetween: 12, // }, // 1024: { // slidesPerView: 5, // }, // 767: { // slidesPerView: 4, // } // } // }); // 浏览器窗口宽度大于991 if (viewWidth > 991) { // pc端导航多层下拉 $(".nav li").hover(function () { $(this).children("ul").stop().slideDown(300); }, function () { $(this).children("ul").stop().slideUp(300); }); } else { // 浏览器窗口宽度小于991 // 手机端导航按钮 $(".menu-button").click(function () { if ($(this).hasClass("menu-button-active")) { $(this).removeClass("menu-button-active"); $("nav").removeClass("nav-active"); } else { $(this).addClass("menu-button-active"); $("nav").addClass("nav-active"); } }); // 手机端导航多层下拉 $(".drop-down").click(function () { $(".nav-child").stop().slideUp(300); $(this).prev("ul").stop().slideToggle(300); }); // 手机端左侧下拉 $(".menu-title").click(function () { $(".menu-list").slideToggle("slow"); }); } //手机端底部按钮 $(".root>li").eq(0).click(function () { $(".phone").fadeIn(); $(".phone").children("div").slideDown(); }) $(".root>li").eq(1).click(function () { $(".wecht").fadeIn(); $(".wecht").children("div").slideDown(); }) $(".root-off").click(function () { $(this).parents(".root-hover").fadeOut(); $(this).parents(".root-box").slideUp(); }) $(".root-hover").bind("click", function (e) { var target = $(e.target); if (target.closest(".root-box").length == 0) { $(".root-hover").fadeOut(); $(".root-box").slideUp(); } }) }); // 返回顶部 // $(".footer-btn a").click(function() { // $('body,html').animate({ // scrollTop: 0 // },1000); // return false; // }); // 锚链接 // $('.nav>li>a').click(function(){ // $(document).animate({scrollTop: ($($(this).attr('href')).offset().top - 0 )},1000); // }); // 视频点击播放 // $(".video-btn").click(function () { // $("video").trigger('pause'); // $(".video-btn").show(); // $(this).hide().next("video").trigger('play'); // }) // $('.work-content>dl>dd').eq(0).addClass("work-active"); // $('.work-content>dl>dd').eq(0).children("div").stop().slideDown(); // $('.work-content>dl>dd>ul').click(function () { // if ($(this).parents("dd").hasClass("work-active")) { // $(".work-box").slideUp(); // $(".work-content>dl>dd").removeClass("work-active"); // } else { // $(".work-box").slideUp(); // $(".work-content>dl>dd").removeClass("work-active"); // $(this).parents("dd").children("div").stop().slideDown(); // $(this).parents("dd").addClass("work-active"); // } // })