function stopBubble(e) { // 如果传入了事件对象,那么就是非ie浏览器 if (e && e.stopPropagation) { //因此它支持W3C的stopPropagation()方法 e.stopPropagation(); } else { //否则我们使用ie的方法来取消事件冒泡 window.event.cancelBubble = true; } } var tap = 'ontouchstart' in document ? 'touchstart' : 'click'; //实现滚动条无法滚动 var mo=function(e){e.preventDefault();}; /***禁止滑动***/ function scrollStop(){ var h = $(window).height(); document.body.style.overflow = 'hidden'; document.addEventListener("touchmove",mo,false);//禁止页面滑动 } /***取消滑动限制***/ function scrollMove(){ document.body.style.overflow = ''; //出现滚动条 document.removeEventListener("touchmove",mo,false); } // 弹框出现 function popoverFun(obj, fn){ var ww = $(window).width(); var $obj = $(obj), $zhe = $obj.find('.pop-zhe'), $inner = $obj.find('.pop-inner'), popFn = fn; $obj.fadeIn(200, function() { $zhe.show(); if($inner.length > 0){ $inner.fadeIn(200, function() { $obj.addClass('has-open'); if (popFn != null) popFn(); }); }else{ $obj.addClass('has-open'); if (popFn != null) popFn(); } $(".main-box").addClass("main-index"); }) } // 弹框隐藏 $('.pop-close, .pop-zhe').on(tap, function(){ var $obj = $(this).parents('.pop-box'); $obj.removeClass('has-open').fadeOut(300); $(".main-box").removeClass("main-index"); }); /// 锚点跳转 function anchorMove(id, fn) { var $obj = $(id), moveFun = fn; var oh = $obj.offset().top - parseInt($('.header').outerHeight()) - 40; $('html,body').animate({ scrollTop: oh }, 300, function(){ if(moveFun) moveFun(); }); }; // 滚动条引用 $(window).on('load', function() { /// 竖向滚动条 if ($('.scrollbox').length > 0) { $('.scrollbox').mCustomScrollbar({ advanced:{ updateOnContentResize: true } }); } /// 横向滚动条 if ($('.scrollbox2').length > 0) { $('.scrollbox2').mCustomScrollbar({ axis:"x", mouseWheel: false }); } }); // 页面滚动wow.js再ie9以上引用 $(window).load(function() { var wow = new WOW({ boxClass: 'wow', animateClass: 'animated', offset: 100, mobile: true, live: true }); if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))) { wow.init(); }; }); /// pc导航 $('.head-nav > li').hover(function() { $('.head-nav .subnav-list').stop(true, true).slideUp(350); $(this).addClass('active').siblings().removeClass('active'); $(this).find('.subnav-list').stop(true, true).slideDown(350); }, function() { $(this).removeClass('active'); $(this).find('.subnav-list').stop(true, true).slideUp(350); }); /// 头部搜索按钮 $('.btn-open-sch, .btn-open-sch2').on(tap, function(){ $('body').addClass('head-sch-open'); $('.head-nav-close').hide(); $('.head-nav-open').removeClass('active'); $('.ph-nav-box').stop(true, true).slideUp(350) .find('li').removeClass('active') .find('.subnav-list').hide(); }); $('.btn-close-sch').on(tap, function(){ $('body').removeClass('head-sch-open'); }); //移动端导航 $('.head-nav-open').on(tap, function(){ $(this).addClass('active'); $('.head-nav-close').show(); $('.ph-nav-box').stop(true, true).slideDown(350); $('body').removeClass('head-sch-open'); }); $('.head-nav-close').on(tap, function(){ $('.head-nav-close').hide(); $('.head-nav-open').removeClass('active'); $('.ph-nav-box').stop(true, true).slideUp(350) .find('li').removeClass('active') .find('.subnav-list').hide(); }); $('.ph-nav-box .arrow').on(tap, function(){ var $li = $(this).parents('li'); $li.toggleClass('active') .find('.subnav-list').stop(true, true).slideToggle(350) .end() .siblings('li').removeClass('active') .find('.subnav-list').stop(true, true).slideUp(350); }); $(window).on('resize', function(){ var ww = $(window).width(); if(ww > 991){ $('.ph-nav-box').hide() .find('li').removeClass('active') .find('.subnav-list').hide(); } }); // 公司介绍 if($('.about-slide-bd').length > 0){ var aboutSlide = new Swiper('.about-slide-bd', { slidesPerView: 4, spaceBetween: '5.7%', prevButton:'.about-slide-ctrl.prev', nextButton:'.about-slide-ctrl.next', observer:true, observeParents:true, breakpoints: { 1440: { spaceBetween: '3%' }, 991: { slidesPerView: 3 }, 767: { slidesPerView: 2 }, 630: { slidesPerView: 1 } } }); } //滚动透明导航条 var nav = $(".header"); //得到导航对象 var win = $(window); //得到窗口对象 var sc=$(document);//得到document文档对象。 win.scroll(function(){ if(sc.scrollTop()>=200){ nav.addClass("on"); }else{ nav.removeClass("on"); } })