define(["/Assets/enp/v2/js/vendor/swiper-5.3.6.min.js"], function (s, pub) {
// PPT 弹窗形式。添加事件
$('.ppt-pop-up-box-btn').each(function () {
$(this).off('click').on('click', function () {
_this = $(this)
var winw = $(window).width();
var toggleWidth = 1200;
// 存储图片的高度
var getHeight = [];
// 存储图片的top值
var getTop = []
// 去掉body滚动条
$('body').css('overflow', 'hidden')
// 如果之前有了结构,删除掉
$('.ppt-pop-up-box').length > 0 ? ($('.ppt-pop-up-box').remove()) : '';
// 重新生成dom结构
var moreW = _this.attr('data-fullscreen');
var moreW = _this.attr('data-morew');
var pptPopDom = '
'
// var pptPopDom = '';
$("body").append(pptPopDom);
// 处理弹框
var $target = $(".ppt-pop-up-box");
if ($target.css('display') == 'block') return
$target.fadeIn();
// 获取标题并赋值
var h4Text = _this.parents('.box').find('h3 span').text();
$target.find('h4').text(h4Text)
// 获取图片并赋值
var imgList = eval(_this.data('img'));
var imgStr = "";
var imgSwiperStr = "";
for (var index = 0; index < imgList.length; index++) {
var element = imgList[index];
imgStr += "
";
if (winw < toggleWidth) {
imgSwiperStr += ""
}
}
$target.find('.pic').html(imgStr)
// $target.find('.swiper-wrapper').html(imgStr)
// 获取详情页链接并赋值
$target.find('.ebg-btn-box a').attr('href', _this.data('url'));
// 获取图片数量并赋值
$target.find('.page span').text(imgList.length)
// 计算pic元素的高,并赋值
if (winw > toggleWidth) {
$('.ppt-pop-up-box .con .cistern .box .pic').height(($(window).height() - 300) > 420 ? 420 : ($(window).height() - 300))
} else {
$('.ppt-pop-up-box .con .cistern .box .pic').height('auto')
}
// PPT 弹窗形式。滚动页面分页的数字变化
var pptPicObj = $('.ppt-pop-up-box .con .box .pic');
// 初始化图片
getImgHeight(pptPicObj)
pptPicObj.off('scroll').on('scroll', function () {
var scrollTop = $(this).scrollTop()
// 获取图片高度
getImgHeight($(this))
// 设置page页数
for (var i = 0; i < getHeight.length; i++) {
if (getHeight[i] > scrollTop) {
$('.ppt-pop-up-box .page input').val(i + 1)
return false
}
}
})
// 输入页数,自定跳转到当前位置
$('.ppt-pop-up-box .page input').off('blur').on('blur', function () {
// 重新获取图片高度
getImgHeight($('.ppt-pop-up-box .con .cistern .box .pic'));
// 获取input的值
var value = $(this).val();
if (value && value != 0 && value <= getHeight.length) {
var top = 0;
if (value == 1) {
top = 0
} else {
top = getHeight[value - 2]
}
$('.ppt-pop-up-box .con .box .pic').scrollTop(top);
}
})
// 移动端点击图片,展示轮播器
$('.ppt-pop-up-box .pic img').off('click').on('click', function () {
var index = $(this).index();
$('.ppt-pop-up-box .fullscreen').trigger('click', index);
})
// 点击放大按钮,图片放大
$('.ppt-pop-up-box .fullscreen').off('click').on('click', function (event, index) {
var _index = $('.ppt-pop-up-box .page input').val();
if (winw > toggleWidth) {
var $module = $(this).parents('.ppt-pop-up-box');
if ($module.hasClass("full")) {
$module.removeClass("full")
} else {
$module.addClass("full")
}
// PPT 弹窗形式。滚动页面分页的数字变化
var pptPicObj = $('.ppt-pop-up-box .con .box .pic');
// 初始化图片高度和top位置
getImgHeight(pptPicObj)
// 设置top位置
$('.ppt-pop-up-box .con .box .pic').scrollTop(getTop[_index-1]);
} else {
var pptSwiperBox = '';
$("body").append(pptSwiperBox);
// 初始化轮播器
var $pptTarget = $('.ppt-swiper-box')
pptInitSwiper($pptTarget, index);
// 移动端图片放大后,点击任何位置收起
$('.ppt-swiper-box').off('click').on('click', function () {
$(this).remove();
})
}
})
// 获取图片函数
function getImgHeight(_this) {
// 赋值前,清空数值
getHeight = []
getTop = []
_this.find('img').each(function (index, elm) {
if (index == 0) {
getHeight.push($(this).outerHeight(true))
getTop.push(0)
} else {
getHeight.push(getHeight[index - 1] + $(this).outerHeight(true))
getTop.push(getHeight[index - 1]+5)
}
})
}
})
})
// PPT 弹窗形式。关闭弹框
$('body').on('click', '.ppt-pop-up-box, .ppt-pop-up-box .icon-close', function () {
$('body').css('overflow', 'auto')
$(".ppt-pop-up-box").remove();
})
// PPT 弹窗形式。阻止事件冒泡
$('body').on('click', '.ppt-pop-up-box .cistern', function (e) {
e.stopPropagation();
})
// PPT 弹窗形式。初始化轮播器
function pptInitSwiper($target, index) {
var mySwiper = '';
mySwiper = new Swiper($target.find(".swiper-container"), {
centeredSlides: true,
initialSlide: index,
zoom: {
containerClass: 'swiper-slide',
}, //开启缩放功能
on:{
init: function(swiper){
setTimeout(function () {
this.slideTo(index, 0, false);
}, 50)
}
}
});
}
// iframe 弹窗形式。添加事件
$('.iframe-pop-up-box-btn').on('click', function () {
// 生成dom结构
if ($('.iframe-pop-up-box').length == 0) {
var moreW = $('.ebg-module-solution-list-two .iframe-pop-up-box-btn').attr('data-morew');
var iframePopDom = '';
$("body").append(iframePopDom);
}
var $target = $(".iframe-pop-up-box");
if ($target.css('display') == 'block') return
$target.fadeIn();
// 获取链接并赋值
$target.find('.iframe').attr('src', $(this).data('url'));
$target.find('.ebg-btn-box a').attr('href', $(this).data('url'));
})
// PPT 弹窗形式。关闭弹框
$('body').on('click', '.iframe-pop-up-box, .iframe-pop-up-box .icon-close', function () {
$(".iframe-pop-up-box").fadeOut();
})
// PPT 弹窗形式。阻止事件冒泡
$('body').on('click', '.iframe-pop-up-box .cistern', function (e) {
e.stopPropagation();
})
//模块数据
var moduleData = {
init: function () {}
}
return moduleData;
});