define("/Assets/enp/2022/js/module/e-module-202208091544.js", function (s, pub) { if ($('.e-module-202208091544').length > 0) { function module202208091544Fun($target) { var module202208091544Obj = { init: function () { // 获取属性 this.win = $(window); this.moduleObj = $target; this.moduleSlideObj = $target.find(".swiper-slide"); this.resizeInit(); // resize初始化 this.addClass(); // 根据slide个数,给模块添加calss this.judgmentSwiper(); // 判断需不需要执行swiper,如果只有一个就不需要执行。多个就需要执行 this.scrollEvent(); // 设置滚动事件,文字动画效果 this.resizeEvent(); // 设置自适应 this.lazyPicLink(); // 是否加载图片 }, resizeInit: function () { this.winw = this.win.width(); this.winh = this.win.height(); // 获取位置 this.scrollTop = this.win.scrollTop(); this.moduleTop = this.moduleObj.offset().top; }, judgmentSwiper: function () { if ((this.moduleSlideObj.length > 1 && this.winw > 1200) || (this.moduleSlideObj.length > 2 && this.winw > 750) || (this.moduleSlideObj.length > 1 && this.winw < 750)) { if (this.moduleObj.data("swiper-init")) { return; } this.moduleObj.data("swiper-init", true); this.initSwiper(); } else { this.setTextBgHeight(); } }, setTextBgHeight: function () { var swiperBgObj = this.moduleObj.find('.swiper-bg'); swiperBgObj.height("auto"); if (this.winw > 1200) { var H = 0; swiperBgObj.each(function () { var This = $(this); if (H < This.outerHeight(true)) { H = This.outerHeight(true) } }) var num = parseInt(swiperBgObj.css('padding-top')) + parseInt(swiperBgObj.css('padding-bottom')); var cH = this.moduleSlideObj.find('.e-lazy').eq(0).height() + 70; if (H > cH) { swiperBgObj.height(H - num) } else { swiperBgObj.height(cH - num) } } }, addClass: function () { if (this.moduleSlideObj.length == 1) { this.moduleObj.addClass("quantity1"); } else if (this.moduleSlideObj.length == 2) { this.moduleObj.addClass("quantity2"); } else { this.moduleObj.addClass("quantity3"); } }, lazyPicLink: function () { // 加载图片 if (this.scrollTop + this.winh * 1.5 > this.moduleTop) { // 当滚动条滚动到当前位置时,加载视频 this.moduleSlideObj = this.moduleObj.find(".swiper-slide"); this.moduleSlideObj.each(function () { var $this = $(this); var imgObj = $this.find('img'); var src = imgObj.attr("data-original"); if (imgObj.attr("src") != src) { imgObj.attr("src", src) } }) } }, initSwiper: function () { var _this = this; // 每次滚动的数量 var slidesPerGroup = 1; if (_this.winw < 1200 && _this.winw > 750) { slidesPerGroup = 2; } var slideLength = $target.find(".swiper-slide").length; var mySwiper = new Swiper($target.find(".swiper"), { spaceBetween: 20, // 板块与板块之间的间距 slidesPerView: 1, //每屏幕显示的个数 slidesPerGroup: slidesPerGroup, // 每次轮播的个数 // 如果需要前进后退按钮 navigation: { nextEl: $target.find('.swiper-button-next'), prevEl: $target.find('.swiper-button-prev'), }, pagination: { // 设置点点点 el: $target.find('.swiper-pagination'), clickable: true }, grabCursor: slideLength > 1 ? true : false, autoplay: ($target.data("auto-time") && _this.winw > 1200) ? { delay: $target.data("auto-time"), stopOnLastSlide: false, disableOnInteraction: true } : false, loop: (slideLength > 1 && _this.winw > 1200) ? true : false, // 设置自动轮播 noSwiping: slideLength > 1 ? false : true, runCallbacksOnInit: true, // 触发一次回调函数 breakpoints: { 1200: { slidesPerView: 1, spaceBetween: 40, }, 920: { slidesPerView: 2.5, spaceBetween: 20, }, 750: { slidesPerView: 2, spaceBetween: 20, } }, on: { init: function () { $target.find(".swiper-pagination").show(); // 每次滚动的数量 if (_this.winw < 1200 && _this.winw > 750) { this.params.slidesPerGroup = 2; } else { this.params.slidesPerGroup = 1; } // 处理数字显示问题 if (_this.winw > 1200) { $target.find(".pagination").show(); $target.find(".swiper-button").css({ "display": "flex" }); if (slideLength < 10) { $target.find('.allSlide').text('0' + slideLength) } else { $target.find('.allSlide').text(slideLength) } $target.find('.slideCur').text('0' + 1) } else { $target.find(".pagination").hide(); $target.find(".swiper-button").hide(); } // 设置pc端白色文字的背景图片高度 _this.setTextBgHeight(); }, slideChangeTransitionEnd: function () { // 设置数字的文字,给数字前面加个0 if (_this.winw > 1200) { var index = this.realIndex; index += 1; if (index < 10) { $target.find('.slideCur').text('0' + index); } else { $target.find('.slideCur').text(index); } } }, resize: function () { var _this = this; setTimeout(function () { _this.emit('init'); _this.emit('slideChangeTransitionEnd'); _this.update(); //窗口变化时,更新Swiper的一些属性,如宽高等 }, 150) }, } }); //鼠标覆盖停止自动切换 mySwiper.el.onmouseover = function () { mySwiper.autoplay.stop(); } //鼠标离开开始自动切换 mySwiper.el.onmouseout = function () { mySwiper.autoplay.start(); } }, scrollEvent: function () { var _this = this; _this.win.on('scroll.202208091544', function () { // 获取位置 _this.scrollTop = _this.win.scrollTop(); _this.moduleTop = $target.offset().top; _this.lazyPicLink(); // 视频是否图片 }); }, resizeEvent: function () { // 页面resize事件 var _this = this; var resizeWinw = 0; var resizeTimer = ''; this.win.on('resize.202208091544', function () { var winw = _this.win.width(); if (winw != resizeWinw) { currentWinw = winw; // 删除之前的定时器 if (resizeTimer) { clearTimeout(resizeTimer); } // 添加新的定时器 resizeTimer = setTimeout(function () { _this.resizeInit(); // resize初始化 _this.scrollEvent(); // 设置滚动事件,文字动画效果 _this.setTextBgHeight(); }, 100) } }) } }; module202208091544Obj.init(); } // 初始化 $('.e-module-202208091544').each(function () { // 防止js文件被执行2次。 var _this = $(this); if (_this.data('init')) { return; } _this.data('init', true); module202208091544Fun($(this)); }) } });