define("/Assets/enp/2022/js/module/e-module-202209091356.js", function (require, factory) { if ($('.e-module-202209091356').length > 0) { function module202209091356Fun($target) { var module202209091356Obj = { init: function () { // 获取属性 this.win = $(window); this.moduleObj = $target; this.moduleSlideObj = this.moduleObj.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; }, 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"); } }, judgmentSwiper: function () { if (this.moduleSlideObj.length >= 3 || (this.moduleSlideObj.length == 2 && this.winw < 992)) { if (this.moduleObj.data("swiper-init")) { return; } this.moduleObj.data("swiper-init", true); this.initSwiper(); } }, 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 > 750) { slidesPerGroup = 2; } var mySwiper = new Swiper($target.find(".swiper"), { watchOverflow: true, // 一屏不显示左右箭头以及pagination 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, }, breakpoints: { // 最小屏幕 1200: { slidesPerView: 2.5, spaceBetween: 40, }, 750: { slidesPerView: 2, spaceBetween: 20, } }, on: { init: function () { $target.find(".pag").css({ "display": "flex" }) }, resize: function () { var This = this; setTimeout(function () { if (_this.winw > 750) { This.params.slidesPerGroup = 2; } else { This.params.slidesPerGroup = 1; } This.update(); //窗口变化时,更新Swiper的一些属性,如宽高等 }, 150) }, } }); }, scrollEvent: function () { var _this = this; _this.win.on('scroll.202209091356', function () { // 获取位置 _this.scrollTop = _this.win.scrollTop(); _this.moduleTop = _this.moduleObj.offset().top; _this.lazyPicLink(); // 视频是否图片 }); }, resizeEvent: function () { // 页面resize事件 var _this = this; var resizeWinw = 0; var resizeTimer = ''; this.win.on('resize.202209091356', function () { var winw = _this.win.width(); if (winw != resizeWinw) { currentWinw = winw; // 删除之前的定时器 if (resizeTimer) { clearTimeout(resizeTimer); } // 添加新的定时器 resizeTimer = setTimeout(function () { _this.resizeInit(); // resize初始化 _this.judgmentSwiper(); // 判断需不需要执行swiper _this.scrollEvent(); // 设置滚动事件,文字动画效果 _this.resizeEvent(); // 设置自适应 }, 100) } }) } }; module202209091356Obj.init(); } // 初始化 $('.e-module-202209091356').each(function () { // 防止js文件被执行2次。 var _this = $(this); if (_this.data('init')) { return; } _this.data('init', true); module202209091356Fun($(this)); }) } });