/** * 通用模块 * */ var $win = $(window), $doc = $(document), $body = $('body', $doc), winW = $win.width(); $(window).resize(function() { winW = $win.width(); }) /** * 图片加载 */ $(function() { if(!$.fn.lazyload) return; $(".lazy", $body).lazyload({ effect: "fadeIn", threshold: 400, failure_limit: 0 }); }); // 出现 $(function() { if($win.width() > 992) { if(!(/msie [6|7|8|9]/i.test(navigator.userAgent))) { new WOW().init(); }; } }); // 数字滚动 $(function() { $('.counter').countUp(); }); // // 内部放大 // $(".piczoom").elevateZoom({ // zoomType: "inner", // cursor: "crosshair", // zoomWindowFadeIn: 300, // zoomWindowFadeOut: 300 // }); $(function() { $(window).on("scroll", function() { var t = document.documentElement.scrollTop || document.body.scrollTop; //获取滚动距离 if(screen.width > 0) { if(t >= 100) { //判断 $(".header").addClass("fixed-header"); } else { $(".header").removeClass("fixed-header"); } } }) }); // 视频 $(function() { var $box = $(".video", $body); if(!$box.length) return; $box.on('click', '.video-box .play', function(event) { event.preventDefault(); var me = $(this); var $iframe = me.next('.iframe'), url = $iframe.data('src'); if($win.width() > 1200) { $.fancybox.open({ src: url, type: 'iframe', padding: 10, }); } else { var height = me.find('.img-responsive').length ? me.height() : $box.height(); height = Math.max(height, 170); if(!$iframe.attr('src')) $iframe.attr('src', url); $iframe.height(height); $iframe.css('display', 'block'); me.hide(); } }); }); //头部导航 $(function() { //折叠导航 var oset; $(".nav-collapse").click(function(e) { if(e && e.stopPropagation) { e.stopPropagation(); } else { window.event.cancelBubble = true; } $(".nav-collapse").toggleClass("active"); $(".nav").stop().fadeToggle().toggleClass("fade-out"); $("body").toggleClass("fixed"); $(".video-box").toggle(); $(".nav").removeClass("left-100 left-200"); if(winW > 991 && winW < 1200) { $(".nav-list1 .more").eq(0).addClass("show").children(".nav-list2").show(); } if(!$(this).hasClass("active")) { $(".nav").hide(); $(".nav-list1").find("li").removeClass("act"); } else { if(winW > 991 && winW < 1200) { var listMore = $(".nav-list1 .more"); listMore.removeClass("show").children(".nav-list2").hide(); listMore.eq(0).addClass("show").children(".nav-list2").fadeIn(); } clearTimeout(oset); $(".nav-list1 >li").each(function(index, val) { var me = $(this); var num = $(this).index() oset = setTimeout(function() { me.addClass("act"); }, (index * 55)) }) } }); }); $(function() { var list1 = $(".nav-list1"), list2 = $(".nav-list2"), list3 = $(".nav-list3"); list1.on("click", ".more", function(event) { if(winW > 1199) return; event.stopPropagation(); event.preventDefault(); $(".nav").addClass("left-100"); var ostr = ""; ostr = $(this).children(".nav-list2").html(); ohref="$(uijt).dijmesfo(""a").clone(true); $(".nav-2 .content ul").html(ostr).children("li").has(".nav-list3").addClass("more"); $(".nav-2 .nav-title").html(ohref); }) $(".nav2-list2").on("click", "li", function(event) { if(winW > 1199) return; event.stopPropagation(); if($(this).hasClass("more")) { event.preventDefault(); $(".nav").addClass("left-200"); var ostr = ""; ostr = $(this).children(".nav-list3").html(); ohref="$(uijt).dijmesfo(""a").clone(true); console.log($(this).children("a")); $(".nav-3 .content ul").html(ostr); $(".nav-3 .nav-title").html(ohref); } }) list1.on("mouseenter", ".more", function(event) { if(winW < 1200) return; var me2 = $(this).children(".nav-list2"); me2 .stop().fadeIn(0); // .children("li").has(".nav-list3").addClass("more"); }).on("mouseleave", ".more", function(event) { if(winW < 1200) return; $(this).children(".nav-list2").hide(); }) list2.on("mouseenter", "li", function(event) { if(winW < 1200) return; // console.log($(this).children(".nav-list3")) // $(this).children(".nav-list3").stop().slideDown(0); }).on("mouseleave", "li", function(event) { if(winW < 1200) return; // $(this).children(".nav-list3").stop().slideUp(0); }) $(".back-btn2").click(function() { $(".nav").removeClass("left-100"); }) $(".back-btn3").click(function() { $(".nav").removeClass("left-200"); }) //查找按钮 $(".find").click(function(e) { if(e && e.stopPropagation) { //W3C取消冒泡事件 e.stopPropagation(); } else { //IE取消冒泡事件 window.event.cancelBubble = true; } $(".search-lg").stop().fadeIn(); $(".input-text").focus(); $("body").addClass('searchactive'); if(winW < 1200) { $("#btn").removeClass("active"); } }) // $(".search-icon").click(function() { // if (winW < 1200) { // $(".search-xs").addClass("show") // } // }) $(".nav").click(function(e) { if(!$(e.target).hasClass("input-text") && !$(e.target).hasClass("search-icon")) { console.log(e.target); $(".search-xs").removeClass("show") } }) $(".close-btn").click(function() { $(".search-lg").fadeOut("fast"); $("body").removeClass('searchactive'); }) }); // 导航下拉tab $(function() { $('.header .nav .nav-list1 .nav-list2>li').mouseover(function() { var liindex = $('.header .nav .nav-list1 .nav-list2>li').index(this); $(this).addClass('active').siblings().removeClass('active'); // $(this).children('.navpro_box').show().siblings().hide(); }); }); // 表格 $(function() { var oTable = $("table"); if(oTable.length !== 0) { var oTr = oTable.find('tr'), oTd = oTable.find('td'); oTable.wrap("
"); oTr.attr("style", ""); oTd.each(function(index) { if(typeof($(this).attr("style")) !== "undefined") { if($(this).attr("style").indexOf("text-align: center") >= 0) { $(this).attr("style", "text-align: center"); } else { $(this).attr("style", ""); } } }) } }); //首页 banner $(function() { var ban = $('.slickbanner') if(!$.fn.slick) return; $('.slickbanner').slick({ autoplay: true, autoplaySpeed: 4000, //以毫秒为单位的自动播放速度 centerMode: true, //居中视图 slidesToShow为双数的时候慎用 centerPadding: '0px', //左右两侧padding值 arrows: false, //上一下,下一页 fade: false, //启用淡入淡出 dots: true, //显示点指示符 speed: 500, //幻灯片/淡入淡出动画速度 cssEase: 'ease', //CSS3动画缓和 slidesToShow: 1, //显示的幻灯片数量 slidesToScroll: 1, //要滚动的幻灯片数量 focusOnSelect: true, //启用选定元素的焦点(单击) touchThreshold: 300, //滑动切换阈值,即滑动多少像素后切换 infinite: true, //无限循环 swipeToSlide: true, //允许用户将幻灯片直接拖动或滑动到幻灯片 lazyLoad: 'ondemand', //接受'ondemand'或'progressive' variableWidth: false, //幻灯片宽度自适应 adaptiveHeight: false, //自适应高度 rows: 1, //将其设置为1以上将初始化网格模式。使用slidesPerRow设置每行应放置多少个幻灯片 slidesPerRow: 1, //在通过行选项初始化网格模式时,这会设置每个网格行中的幻灯片数量 pauseOnHover: false, }); }); //首页证书 $(function() { if(!$.fn.slick) return; var slick_honor = $('.slick_honor'); slick_honor.slick({ autoplay: false, autoplaySpeed: 3000, //以毫秒为单位的自动播放速度 arrows: true, //上一下,下一页 fade: false, //启用淡入淡出 dots: false, //显示点指示符 speed: 1000, //幻灯片/淡入淡出动画速度 cssEase: 'ease', //CSS3动画缓和 slidesToShow: 5, //显示的幻灯片数量 slidesToScroll: 1, //要滚动的幻灯片数量 focusOnSelect: false, //启用选定元素的焦点(单击) touchThreshold: 300, //滑动切换阈值,即滑动多少像素后切换 infinite: true, //无限循环 lazyLoad: 'ondemand', //接受'ondemand'或'progressive' variableWidth: false, //幻灯片宽度自适应 adaptiveHeight: false, //自适应高度 swipeToSlide: false, rows: 1, //将其设置为1以上将初始化网格模式。使用slidesPerRow设置每行应放置多少个幻灯片 slidesPerRow: 1, //在通过行选项初始化网格模式时,这会设置每个网格行中的幻灯片数量 pauseOnHover: false, responsive: [{ breakpoint: 992, settings: { slidesToShow: 3, slidesToScroll: 3, } }, { breakpoint: 768, settings: { slidesToShow: 2, slidesToScroll: 2, } }, { breakpoint: 480, settings: { slidesToShow: 1, slidesToScroll: 1, } }], }); }); //产品详情 $(function() { if(!$.fn.slick) return; $('.product_box .slider-for').slick({ autoplay: false, slidesToShow: 1, slidesToScroll: 1, arrows: false, fade: false, infinite: true, centerMode: false, touchThreshold: 300, asNavFor: '.product_box .slider-nav' }); var sliderNav = $('.product_box .slider-nav'); sliderNav.slick({ autoplay: true, slidesToShow: 5, slidesToScroll: 1, infinite: true, centerMode: false, centerPadding: '0px', asNavFor: '.product_box .slider-for', dots: false, arrows: false, vertical: true, //竖直排列 verticalSwiping: true, //竖直滑动 touchThreshold: 300, focusOnSelect: true, responsive: [{ breakpoint: 1200, settings: { slidesToShow: 4, } }, { breakpoint: 992, settings: { slidesToShow: 3, vertical: false, verticalSwiping: false, } } ], }); if(sliderNav.slick('slickGetOption', 'slidesToShow') >= sliderNav.find(".slick-slide").length) { $('.slider-nav .slick-track').addClass('aa'); }; // if($.fn.imagezoom && winW > 991) { // $('.prod_main .slider-for img').imagezoom({ // offset: 10, // xzoom: 300, // yzoom: 300 // }); // } }); // 产品详情询价 $(".inquiry_btn").click(function() { $("html,body").animate({ scrollTop: $('.inquire_form').offset().top - 150 }, 400) }); // 在线客服 $(function() { var code = $(".code-pic"); $(".online .code").on("mouseenter", function() { if(winW > 991) { $(this).children(".mask").stop(true, true).fadeIn(); } else { $(this).children(".code-pic").stop(true, true).fadeIn(); } }).on("mouseleave", function() { if(winW > 991) { $(this).children(".mask").stop(true, true).fadeOut(); } else { $(this).children(".code-pic").stop(true, true).fadeOut(); } }); code.on("mouseenter", function(e) { $(this).stop(true, true).fadeIn(); }).on("mouseleave", function() { $(this).stop(true, true).fadeOut(); }); $(".online-wrap .btn").on("click", function() { $(this).toggleClass("active"); $(".online").toggleClass("active"); }); //返回顶部按钮 $("#gotop,.backtop").click(function() { $("html,body").animate({ scrollTop: 0 }, 500) }) }); $(function() { $('.icon-online').click(function() { $('.online').toggleClass('active'); $('.icon-online').toggleClass('icon'); }); }); // 放大 $(function() { $("a[rel=fancybox-product]").fancybox({ 'overlayShow': true, 'overlayColor': '#000', 'overlayOpacity': 0.9, 'opacity': 0.5, 'transitionIn': 'elastic', 'transitionOut': 'none', 'titlePosition': 'over', 'showCloseButton': false, 'titleFormat': function(title, currentArray, currentIndex, currentOpts) { return '' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? '   ' + title : '') + ' '; } }); }); // 手机底部 $(".footer .foot ul li .title-foot").click(function() { if($win.width() < 991) { var par = $(this).parent().parent(); if(par.attr("class") == "on") { $(".footer .foot ul li .title-foot").parent().parent().addClass("on").find('.info-down').slideUp(); par.find('.info-down').slideDown(); par.removeClass("on").addClass("current").siblings().removeClass('current'); } else { par.find('.info-down').slideUp(); par.addClass("on").removeClass("current"); } } }); $(function() { //获取所有div的高度,存入allDivHeight if($win.width() > 767) { var allDivHeight = []; $(".box-choose .choose .item").each(function(index, element) { allDivHeight.push($(this).height()); }); //循环分组和设置最大高度 for(var j = 0; j < Math.ceil(allDivHeight.length / 5); j++) { var group = allDivHeight.slice(j * 5, 5 * (j + 1)); //每5个为一组 var maxGroupHeight = Math.max.apply(null, group); //该组中最大的 //设置该组中所有div的高度为最大高度(这里比较烂,没想到好方法) $(".box-choose .choose .item").each(function(index, element) { if(j * 5 <= index && index <= 5 * (j + 1)) { $(this).height(maxGroupHeight); } // console.log(maxGroupHeight); }); } } }); $(function() { if(!placeholderSupport()) { // 判断浏览器是否支持 placeholder $('[placeholder]').focus(function() { var input = $(this); if(input.val() == input.attr('placeholder')) { input.val(''); input.removeClass('placeholder'); } }).blur(function() { var input = $(this); if(input.val() == '' || input.val() == input.attr('placeholder')) { input.addClass('placeholder'); input.val(input.attr('placeholder')); } }).blur(); }; }) function placeholderSupport() { return 'placeholder' in document.createElement('input'); } //等高 $.fn.extend({ 'sameH': function(autoEl, resize) { var lis = this.find(autoEl), num = 0, oset = null; setTimeout(autoH, 500); $(window).on("load resize", function() { clearTimeout(oset); oset = setTimeout(autoH, 50); }); function autoH() { if(winW > resize) { lis.css("height", "auto"); num = 0; lis.each(function() { num = Math.max(num, $(this).height()); }) lis.height(num); } else { lis.height("auto"); } }; } }); //首页优势 $(function() { $(".index_advantage .lists ul li").sameH(".item", 480); $(".contact .lists ul li").sameH(".item", 480); $(".contact .contact_main .left .list ul li").sameH(".item", 480); }); //左侧导航 $(function() { var menuSet = null; (function() { $(".menu1").find("li.active").children("ul").stop().slideDown(); $(".menu1 li").each(function() { var _this = $(this); // if(_this.children(".menu2").length && _this.children(".menu2").children("li").length) { // _this.addClass("more"); // } if(_this.children("ul").has("li").length) { _this.addClass("more"); } }) })(); $(".menu1").on("mouseenter", ">li.more", function() { var $this = $(this); menuSet = setTimeout(function() { $this.addClass("active").siblings().removeClass("active"); $this.children(".menu2").stop().slideDown(); $this.siblings().children(".menu2").stop().slideUp(); }, 150); }).on("mouseleave", ">li.more", function() { clearTimeout(menuSet); }); var m2set, m3set; $(".menu2").on("mouseenter", ">li.more", function() { var $this = $(this); m2set = setTimeout(function() { $this.addClass("active").siblings().removeClass("active"); $this.siblings().children(".menu3").stop().slideUp(100); $this.children(".menu3").stop().slideDown(100); }, 150); }).on("mouseleave", ">li.more", function() { clearTimeout(m2set); // var $this = $(this); // m3set = setTimeout(function() { // $this.children(".menu3").slideUp(200,"linear"); // }, 350); }); // $(".menu3").on("mouseenter", function() { // clearTimeout(m3set); // console.log(m3set) // }) });