var myslide = { //浏览器窗口宽度 winInfo: function() { var width = $(window).width(); var height = $(window).height(); return { _winW: width, _winH: height }; }, //ie9浏览器 isLetIe9: function() { return navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion.split(";")[1].replace( /[ ]/g, "").replace("MSIE", "")) <= 9; }, //ie8浏览器 isLetIe8: function() { return navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion.split(";")[1].replace( /[ ]/g, "").replace("MSIE", "")) <= 8; }, //ie8浏览器调用的js setIe8: function() { $('.lh-banner').height(this.winInfo()._winH); }, /* *banner,兼容ie8+ *@param *boxCell //外层盒子class *pagination //分页器{},el:分页器的class;type分页器的样式类型;bulletElement:分页器的html标签;dynamicBullets(false):动态分页器;dynamicMainBullets(1):动态分页器的主指示点的数量;clickable:分页器可点击;renderBullet:fun渲染分页器小点;bulletActiveClass(on):被选中class *stopOnLastSlide(true):如果设置为true,当切换到最后一个slide时停止自动切换。(loop模式下无效)。 *slidesPerView(1):设置slider容器能够同时显示的slides数量 *spaceBetween(0):在slide之间设置距离(单位px)。 *speed(1000):切换速度 *loop(false):循环切换 *direction(horizontal):滚动方向 *initialSlide(0):设定初始化时slide的索引。 *effect(slide):切换效果;slide的切换效果,默认为"slide"(位移切换),可设置为'slide'(普通切换、默认),"fade"(淡入)"cube"(方块)"coverflow"(3d流)"flip"(3d翻转)。 *mousewheel(false):开启鼠标滚轮控制Swiper切换。可设置鼠标选项,或true使用默认值。 *nextEl:上一页按钮 *prevEl:下一页按钮 *noSwipingClass:不可拖动块的类名 *on:回调函数 *observer(true):当改变swiper的样式(例如隐藏/显示)或者修改swiper的子元素时,自动初始化swiper *observeParents(true):将observe应用于Swiper的父元素。当Swiper的父元素变化时 *parallax(true):启动视觉差 */ setBanner: function(a) { var a = a || {}; var opt = $.extend({ boxCell: '.z_banner', paginationEl: '.hd', paginationType: 'bullets', paginationBulletElement: 'li', paginationDynamicBullets: false, paginationDynamicMainBullets: 1, paginationClickable: true, paginationRenderBullet: null, paginationBulletActiveClass: 'on', stopOnLastSlide: true, slidesPerView: 1, spaceBetween: 0, speed: 1000, loop: false, direction: 'horizontal', initialSlide: 0, effect: 'fade', mousewheel: false, nextEl: '.next', prevEl: '.prev', noSwipingClass: 'stop-swiping', on: null, observer: true, observeParents: true, parallax: true, disableOnInteraction: false, mainCell: '.swiper-wrapper', autoPage: true, autoplay: false, delay: 3500, stopOnLastSlide: false, disableOnInteraction: true, }, a); if (!this.isLetIe9()) { //正常浏览器,调用swiper if ($(opt.boxCell).find('.next').length > 0) { var nextEl = $(opt.boxCell).find('.next'), prevEl = $(opt.boxCell).find('.prev'); } else { var nextEl = $(opt.boxCell).parents(".swiper_btn_warp").find('.next'), prevEl = $(opt.boxCell).parents(".swiper_btn_warp").find('.prev') } if (opt.autoplay) { var autoplay = { delay: opt.delay, stopOnLastSlide: opt.stopOnLastSlide, disableOnInteraction: opt.disableOnInteraction } } else { var autoplay = false; } // if(this.winInfo()._winW <= 980) { // // opt.effect = 'slide'; // opt.slidesPerView = 1 // } var userAgent = navigator.userAgent; if (userAgent.indexOf('Chrome') <= -1 && opt.effect != 'fade') { opt.effect = 'slide'; } if ($(opt.boxCell).length > 1) { // 如果有多个相同的轮播 $(opt.boxCell).each(function() { var mySwiper = new Swiper($(this), { parallax: opt.parallax, slidesPerView: opt.slidesPerView, initialSlide: opt.initialSlide, pagination: { el: opt.paginationEl, type: opt.paginationType, bulletElement: opt.paginationBulletElement, dynamicBullets: opt.paginationDynamicBullets, dynamicMainBullets: opt.paginationDynamicMainBullets, clickable: opt.paginationClickable, renderBullet: opt.paginationRenderBullet, bulletActiveClass: opt.paginationBulletActiveClass }, speed: opt.speed, loop: opt.loop, effect: opt.effect, spaceBetween: opt.spaceBetween, navigation: { nextEl: $(this).find(".next"), prevEl: $(this).find(".prev"), }, direction: opt.direction, mousewheel: opt.mousewheel, noSwipingClass: opt.noSwipingClass, on: opt.on, observeParents: opt.observeParents, observer: opt.observer, autoplay: autoplay, stopOnLastSlide: opt.stopOnLastSlide, disableOnInteraction: opt.disableOnInteraction }); }) } else { var mySwiper = new Swiper(opt.boxCell, { parallax: opt.parallax, slidesPerView: opt.slidesPerView, initialSlide: opt.initialSlide, pagination: { el: opt.paginationEl, type: opt.paginationType, bulletElement: opt.paginationBulletElement, dynamicBullets: opt.paginationDynamicBullets, dynamicMainBullets: opt.paginationDynamicMainBullets, clickable: opt.paginationClickable, renderBullet: opt.paginationRenderBullet, bulletActiveClass: opt.paginationBulletActiveClass }, speed: opt.speed, loop: opt.loop, effect: opt.effect, spaceBetween: opt.spaceBetween, navigation: { nextEl: nextEl, prevEl: prevEl, }, direction: opt.direction, mousewheel: opt.mousewheel, noSwipingClass: opt.noSwipingClass, on: opt.on, observeParents: opt.observeParents, observer: opt.observer, autoplay: autoplay, stopOnLastSlide: opt.stopOnLastSlide, disableOnInteraction: opt.disableOnInteraction }); } // if(autoplay) { // $(opt.boxCell).mouseenter(function() { // mySwiper.autoplay.stop(); // }) // $(opt.boxCell).mouseleave(function() { // mySwiper.autoplay.start(); // }) // } } else { //ie9 let,调用SuperSlide if (opt.effect == 'slide') { opt.effect = 'left'; } else { opt.effect = 'fade'; } if (opt.on) { startFun = opt.on.startFun; endFun = opt.on.endFun; } else { startFun = null, endFun = null; } jQuery(opt.boxCell).slide({ titCell: opt.paginationEl, mainCell: opt.mainCell, vis: opt.slidesPerView, autoPage: opt.autoPage, autoPlay: opt.autoplay, prevCell: opt.prevEl, nextCell: opt.nextEl, pnLoop: opt.loop, delayTime: opt.speed, effect: opt.effect, interTime: opt.delay, startFun: startFun, endFun: endFun }); } }, //图片滚动效果 imgScroll: function(a) { var a = a || {}, opt = $.extend({ boxCell: '.imgScroll' }, a); $(window).scroll(function() { var s = $(this).scrollTop() / 3; $(opt.boxCell).find('.img').css({ 'background-position': 'center ' + s + 'px' }); }); }, //init Init: function() { smoothScroll.init({ offset: 80, speed: 1000, }); //数字滚动 if ($('.about_num').length > 0) { $(window).scroll(function() { var a = Math.round($('.about_num').offset().top + 100); var b = Math.round($(window).scrollTop() + $(window).height()); if (a < b && !$('.timer').hasClass('aa')) { $('.timer').addClass('aa'); setTimeout(function() { $('.timer').removeClass('aa'); }, 3000); $('.timer').countTo(); return false; } }); } $('.timer').countTo(); $(".z_page_nav li").click(function() { $(this).addClass("cur").siblings().removeClass("cur") }) if ($(".z_banner_swiper").length > 0) { var pf = 100 / $(".z_banner .bd li").length myslide.setBanner({ boxCell: ".z_banner_swiper", effect: "slide", autoplay: true, }) $(".z_jd_bar .index").css("width", pf + "%") myslide.setBanner({ boxCell: ".z_banner", effect: "fade", autoplay: true, on: { slideChangeTransitionStart: function() { $(".z_banner_num").text("0" + (this.activeIndex + 1)) var num = (this.activeIndex) + 1 $(".z_jd_bar .index").css("width", pf * num + "%") }, }, }) } if ($(window).width() > 980) { new WOW().init(); if ($('.z_page_nav').length >= 1) { var oftop = $('.z_page_nav').offset().top; $(window).scroll(function() { var s = $(this).scrollTop(); if (s >= oftop) { $('.z_page_nav').addClass('navFixed'); $('body').addClass('fixed'); } else { $('.z_page_nav').removeClass('navFixed'); $('body').removeClass('fixed'); } }); } var p = 0; t = 0; _h = $(window).height() - 200 $(window).scroll(function() { if ($(window).scrollTop() >= 200) { p = $(this).scrollTop(); if (t <= p) { $('body').addClass('fixed'); } else { $('body').removeClass('fixed'); } t = p; } }); if ($(".z_index_case_swiper").length > 0) { myslide.setBanner({ boxCell: ".z_index_case_swiper", slidesPerView: 4, spaceBetween: 25, effect: "slide", }) } if ($(".z_slide_swiper").length > 0) { myslide.setBanner({ boxCell: ".z_slide_swiper", slidesPerView: 9, spaceBetween: 0, direction: "vertical", effect: "slide", }) } if ($(".z_team_small").length > 0) { myslide.setBanner({ boxCell: ".z_team_small", slidesPerView: 3, spaceBetween: 0, effect: "slide" }) } } else { //手机二级栏目滑动 $(".z_menu_btn ").click(function() { $(this).toggleClass("on ") $(".z_header ").toggleClass("on ") $(".z_header_nav ").toggleClass("on ") }) if ($(".z_index_case_swiper").length > 0) { myslide.setBanner({ boxCell: ".z_index_case_swiper", slidesPerView: 2, spaceBetween: 10, effect: "slide", autoplay: true }) } if ($(".z_slide_swiper").length > 0) { myslide.setBanner({ boxCell: ".z_slide_swiper", slidesPerView: 3, spaceBetween: 0, direction: "horizontal", effect: "slide", }) } if ($(".z_team_small").length > 0) { myslide.setBanner({ boxCell: ".z_team_small", slidesPerView: 1, spaceBetween: 0, effect: "slide", autoplay: true }) } $('.wrapper').navbarscroll({ defaultSelect: $(".page_nav li.cur").index() }); } $(".z_play").click(function() { var videoscr = $(this).attr("data-video") $(".video_pop video").attr("src", videoscr) $(".video_pop").show() vdo.play() }) //视频播放 var vdo = document.getElementById("video") $(".close_btn").click(function() { $(".video_pop").fadeOut(300) vdo.pause() }) }, } myslide.Init();