window.onload = function() {
bindEvent();
};
function bindEvent() {
//控制显示文本省略号
$('.news_box li h3').dotdotdot();
$('.news_box li p').dotdotdot();
// 判断IE并执行不同事件
var IEVersion = getIEVersion();
if(IEVersion && IEVersion <= 9) {
lteIE9SwiperEvt();
if(IEVersion <= 8) {
lteIE8Evt();
}
} else {
swiperEvent();
}
// 判断是否火狐并执行事件
if (navigator.userAgent.indexOf('Firefox') >= 0) {
$('.video_placeholder').click(function() {
alert('火狐不支持该视频播放类型,请用其他浏览器观看');
});
} else {
// 显示视频事件
setTimeout(function() {
$('.video_placeholder').fadeOut();
}, 1000);
}
//荣誉资质预览效果
$('.honor_slide img').click(function() {
var imgUrl = $(this).attr('src');
previewHonorImg(imgUrl);
});
}
// 预览轮播图片事件
function previewHonorImg(imgUrl) {
if($('.honor_modal_box')) {
$('.honor_modal_box').remove();
}
console.log(2);
var honorStr = '
';
$('body').append(honorStr);
setTimeout(function() {
$('.honor_modal_box').addClass('show');
}, 200);
$('.honor_modal_box').click(function() {
$('.honor_modal_box').removeClass('show');
})
}
// 轮播事件
function swiperEvent() {
// 轮播事件
var mySwiper1 = new Swiper('.main_swiper_container', {
pagination: '.swiper-pagination',
paginationClickable: true,
loop: true,
autoplay: 5000,
speed: 750,
autoplayDisableOnInteraction: false,
simulateTouch : false,
prevButton:'.swiper-button-prev',
nextButton:'.swiper-button-next'
});
$('.main_swiper_container').mouseenter(function() { mySwiper1.stopAutoplay() });
$('.main_swiper_container').mouseleave(function() { mySwiper1.startAutoplay() });
var mySwiper2 = new Swiper('.honor_swiper_container', {
loop: true,
autoplay: false,
speed: 550,
autoplayDisableOnInteraction: false,
prevButton:'.btn_prev',
nextButton:'.btn_next',
// slidesPerView : 5,
slidesPerView :'auto',
simulateTouch : false,
slidesPerGroup : 1,
// spaceBetween : 43,
});
var coopSwiper = new Swiper('.coop_swiper', {
loop: true,
autoplay: 2500,
speed: 550,
autoplayDisableOnInteraction: false,
slidesPerView : 5,
slidesPerGroup : 1,
simulateTouch : false,
spaceBetween : 43,
});
}
// 低版本IE轮播事件
function lteIE9SwiperEvt() {
// 轮播事件
var mySwiper1 = new Swiper('.main_swiper_container', {
pagination: '.swiper-pagination',
loop: true,
autoplay: 3000,
speed: 750,
autoplayDisableOnInteraction: false,
simulateTouch : false,
// prevButton:'.swiper-button-prev',
// nextButton:'.swiper-button-next'
});
$('.swiper-button-prev').click(function(){
mySwiper1.swipePrev();
});
$('.swiper-button-next').click(function(){
mySwiper1.swipeNext();
});
var mySwiper2 = new Swiper('.honor_swiper_container', {
// loop: true,
autoplay: false,
autoplayDisableOnInteraction: false,
// slidesPerView : 5,
slidesPerView :'auto',
simulateTouch : false,
// slidesPerGroup : 1,
// spaceBetween : 43,
});
$('.btn_prev').click(function(){
mySwiper2.swipePrev();
});
$('.btn_next').click(function(){
mySwiper2.swipeNext();
});
var coopSwiper = new Swiper('.coop_swiper', {
loop: true,
autoplay: 2500,
speed: 500,
autoplayDisableOnInteraction: false,
slidesPerView : 5,
slidesPerGroup : 1,
simulateTouch : false,
// spaceBetween : 43,
});
// $('.expert_swiper_container').mouseover(function(){
// mySwiper2.stopAutoplay();
// });
// $('.expert_swiper_container').mouseout(function(){
// mySwiper2.startAutoplay();
// });
}
// IE8或更低版本处理
function lteIE8Evt() {
// 首页banner轮播修改
// $('.swiper-button-prev, .swiper-button-next').css({'display': 'none'});
// $('.main_swiper_container .swiper-slide').css({'background-size': 'auto 720px'});
// 荣誉资质修改
// $('.horder_box').css({'height': 'auto'});
// $('.honor_slide').css({'margin-right': '115px', 'margin-bottom': '25px'});
// $('.honor_slide:nth-child(4n)').css({'margin-right': '0'});
// $('.btn_prev, .btn_next').css({'display': 'none'});
//战略合作修改
$('.coop_show:nth-child(5n)').css({'margin-right': '0'});
}
// 获取IE版本
function getIEVersion() {
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE浏览器
if (isIE) {
var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
reIE.test(userAgent);
var fIEVersion = parseFloat(RegExp["$1"]);
if (fIEVersion == 7) { return 7; }
else if (fIEVersion == 8) { return 8; }
else if (fIEVersion == 9) { return 9; }
else if (fIEVersion == 10) { return 10; }
else if (fIEVersion == 11) { return 11; }
else { return 0 }//IE版本过低
}
}