var windowWidth,windowHeight;
var isFirst = true;
var _slidelength;
(function (doc, win) {
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function () {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
if (clientWidth >= 750) {
docEl.style.fontSize = '100px';
} else {
docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
}
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
$(function(){
$(".browser-tips .close").click(function(){
$(".browser-tips").fadeOut(300);
})
getWindowSize();
$(window).on('resize', function() {
getWindowSize();
});
var _headerHeight = $(".header").height();
if ($(window).scrollTop() > _headerHeight) {
$(".header").addClass('header-active');
} else {
$(".header").removeClass('header-active');
}
$(window).bind('scroll', function () {
var _headerHeight = $(".header").height();
if ($(window).scrollTop() > _headerHeight) {
$(".header").addClass('header-active');
} else {
$(".header").removeClass('header-active');
}
})
$(".header-top .icon-menu").click(function(){
if($(this).hasClass("active")){
$(this).removeClass("active");
$("body").removeClass("body-hidden");
$(".header-top").removeClass("active");
$(".menu-layer").fadeOut(300);
}else{
$(this).addClass("active");
$("body").addClass("body-hidden");
$(".header-top").addClass("active");
$(".menu-layer").fadeIn(300);
}
})
$(".menu-layer .menu-nav li.hover").click(function(){
$(this).siblings("li").removeClass("active");
$(this).addClass("active");
var _hoverMenu = $(this).attr("data-menu");
//console.log(_hoverMenu)
$(".menu-nav-side").each(function(){
var _this = $(this);
console.log(_hoverMenu)
if(_this.attr("data-menu") == _hoverMenu){
_this.siblings(".menu-nav-side").hide();
_this.show();
_this.siblings(".menu-nav-side").find(".side-item .side-title.title-hover").removeClass("active");
_this.siblings(".menu-nav-side").find(".side-item .side-cont").hide();
}
})
})
$(".menu-nav-side .side-item .side-title.title-hover").click(function(){
if($(this).hasClass("active")){
$(this).removeClass("active");
$(this).parents(".side-item").find(".side-cont").hide();
}else{
$(this).parents(".side-item").siblings().find(".title-hover").removeClass("active");
$(this).addClass("active");
$(this).parents(".side-item").siblings().find(".side-cont").hide();
$(this).parents(".side-item").find(".side-cont").show();
}
$(".menu-layer .menu-subnav-right").animate({scrollTop:0},100);
})
$(".header-top .nav li.hover").mouseenter(function(){
var _hoverMenu = $(this).attr("data-menu");
$(".header-nav-hidden-box").show();
$(".one-nav-side").each(function(){
var _this = $(this);
console.log(_hoverMenu)
if(_this.attr("data-menu") == _hoverMenu){
_this.siblings(".one-nav-side").hide();
_this.show();
_this.find(".subnav-left-box li").removeClass("active");
_this.find(".subnav-right-box .two-nav-side").hide();
_this.find(".subnav-left-box li").eq(0).addClass("active");
_this.find(".subnav-right-box .two-nav-side").eq(0).show();
}
})
})
$(".header-nav-hidden-box").hover(function(){
$(this).show();
},function(){
$(this).hide();
})
$(".header-top .nav li.hover").mouseleave(function(){
$(".header-nav-hidden-box").hide();
})
$(".header-nav-hidden-box .subnav-left-box li").mouseenter(function(){
var _index = $(this).index();
$(this).addClass("active").siblings().removeClass("active");
$(this).parents(".one-nav-side").find(".subnav-right-box .two-nav-side").eq(_index).show().siblings().hide();
})
$(".header-nav-hidden-box .one-nav-side").mouseenter(function(){
var _hoverMenu = $(this).attr("data-menu");
$(".header-top .nav li").each(function(){
var _this = $(this);
console.log(_hoverMenu)
if(_this.attr("data-menu") == _hoverMenu){
_this.addClass("active")
}
})
})
$(".header-nav-hidden-box .one-nav-side").mouseleave(function(){
var _hoverMenu = $(this).attr("data-menu");
$(".header-top .nav li").each(function(){
var _this = $(this);
console.log(_hoverMenu)
if(_this.attr("data-menu") == _hoverMenu){
_this.removeClass("active")
}
})
})
//监测 进入效果
$(".js-m").bind("inview", function (event, visible, topOrBottomOrBoth) {
if (visible == true) { // 元素在窗口中可见
$(this).addClass("animate");
if($(this).find(".timer").length > 0){
console.log(1)
if(isFirst){
$('.timer').each(count);
isFirst = false;
}
}
}
});
//视频弹框
Videoplay();
//返回顶部
var _windowHeight=$(window).height()/2;
//console.log($(window).height())
$(window).scroll(function(){
//console.log($(window).scrollTop())
if ($(window).scrollTop()>_windowHeight){
$(".return-top").fadeIn(500);
}else{
$(".return-top").fadeOut(500);
}
});
$(".return-top").click(function(){
$('body,html').animate({scrollTop:0},100);
return false;
});
//首页 banner
if($(".home-banner .swiper-slide").length > 1){
var homeBannerSwiper = new Swiper('.home-banner .swiper-container',{
autoplay: {
delay: 5000,
//disableOnInteraction: false,
},
speed: 1000,
loop: true,
pagination: {
el: '.home-banner .swiper-pagination',
clickable :true,
bulletClass : 'dot',
bulletActiveClass: 'current',
renderBullet: function (index, className) {
return '';
},
},
on:{
init: function(){
swiperAnimateCache(this); //隐藏动画元素
swiperAnimate(this); //初始化完成开始动画
},
slideChangeTransitionEnd: function(){
swiperAnimate(this); //每个slide切换结束时也运行当前slide动画
}
}
});
}
//首页 产品与服务1
if($(".home-cloud-focus .swiper-slide").length > 1){
var homeCloudFocusSwiper = new Swiper('.home-cloud-focus .swiper-container',{
autoplay: {
delay: 5000,
//disableOnInteraction: false,
},
speed: 1000,
loop: true,
pagination: {
el: '.home-cloud-focus .swiper-pagination',
clickable :true,
},
on: {
init: function(){
swiperAnimateCache(this); //隐藏动画元素
swiperAnimate(this); //初始化完成开始动画
},
slideChangeTransitionEnd: function(){
swiperAnimate(this); //每个slide切换结束时也运行当前slide动画
},
slideChangeTransitionStart: function(){
//console.log(this.realIndex);
var _listBtnHref = $(".home-cloud-focus .swiper-slide-active .txt-left-box .base-title-box .title-box a").attr("href");
var _detailsBtnHref = $(".home-cloud-focus .swiper-slide-active .txt-left-box .cont-box .more-btn a").attr("href");
//console.log(_listBtnHref,_detailsBtnHref)
$(".home-cloud-focus .details-block-btn a").attr("href",_detailsBtnHref);
$(".home-cloud-focus .list-block-btn a").attr("href",_listBtnHref);
},
}
});
$(".home-cloud-focus .swiper-slide .txt-left-box").hover(function(){
homeCloudFocusSwiper.autoplay.stop();
},function(){
homeCloudFocusSwiper.autoplay.start();
})
}
$(".home-leftsidebar li").click(function(){
var _section2 = $(".home-information").offset().top;
var _section3 = $(".home-cloud").offset().top;
var _section4 = $(".home-product").offset().top;
var _section5 = $(".home-case").offset().top;
var _section6 = $(".home-partner").offset().top;
var _index = $(this).index();
if(_index == 0){
$('body,html').animate({scrollTop:_section2},300);
}else if(_index == 1){
$('body,html').animate({scrollTop:_section3},300);
}else if(_index == 2){
$('body,html').animate({scrollTop:_section4},300);
}else if(_index == 3){
$('body,html').animate({scrollTop:_section5},300);
}else if(_index == 4){
$('body,html').animate({scrollTop:_section6},300);
}
})
var _hometype = location.search.split("hometype=")[1];
var _headerH = $(".header-top").height();
console.log(_headerH)
if(_hometype){
//console.log(_locate)
if(_hometype == 0){
var _homecloudOffsetTop = $(".home-cloud").offset().top - _headerH;
//console.log(_offsetTop)
$('body,html').animate({scrollTop:_homecloudOffsetTop},100);
}
if(_hometype == 1){
var _homeproductOffsetTop = $(".home-product").offset().top - _headerH;
//console.log(_offsetTop)
$('body,html').animate({scrollTop:_homeproductOffsetTop},100);
}
}
$(".technical-features-inner .tabs li").eq(0).addClass("active");
$(".technical-features-inner .tabs-content .box").eq(0).show();
$(".technical-features-inner .tabs li").click(function(){
$(this).addClass("active").siblings().removeClass("active");
$(".technical-features-inner .tabs-content .box").eq($(".technical-features-inner .tabs li").index(this)).show().siblings(".technical-features-inner .tabs-content .box").hide();
return false;
});
var newsListFocusSwiper = new Swiper(".news-list-focus .swiper-container", {
loop: true,
pagination: {
el: ".news-list-focus .swiper-pagination",
clickable: true,
},
navigation: {
nextEl: '.news-list-focus .swiper-arrow-next',
prevEl: '.news-list-focus .swiper-arrow-prev',
},
});
// 荣誉奖项
$(".about-ryjx-inner .tabs li").eq(0).addClass("active");
$(".about-ryjx-section .box").eq(0).show();
var _ryjxhtml = $(".about-ryjx-section .box").eq(0).find(".hidden-content").html();
$(".about-ryjx-section .box").eq(0).find(".ryjx-slide").html(_ryjxhtml);
_slidelength = $(".about-ryjx-section .box").eq(0).find(".hidden-content .swiper-slide").length;
//console.log(_slidelength)
ryjxSlide(_slidelength);
$(".about-ryjx-inner .tabs li").click(function(){
var _index = $(this).index();
$(".about-ryjx-inner .tabs li").removeClass("active");
$(".about-ryjx-inner .tabs-content .box").hide();
$(this).addClass("active");
$(".about-ryjx-inner .tabs-content .box").eq(_index).show();
$(".about-ryjx-inner .box .ryjx-slide").html("");
var _ryjxhtml = $(".about-ryjx-section .box").eq(_index).find(".hidden-content").html();
$(".about-ryjx-section .box").eq(_index).find(".ryjx-slide").html(_ryjxhtml);
_slidelength = $(".about-ryjx-section .box").eq(_index).find(".hidden-content .swiper-slide").length;
//console.log(_slidelength)
ryjxSlide();
});
$(".contactus-leftsidebar li .title").click(function(){
if($(this).parents("li").hasClass("active")){
$(this).parents("li").removeClass("active");
}else{
$(this).parents(".contactus-leftsidebar").find("li").removeClass("active");
$(this).parents("li").addClass("active");
}
})
$(".contactus-leftsidebar li dd").click(function(){
$(this).parents(".contactus-leftsidebar").find("dd").removeClass("active");
$(this).addClass("active");
var _city = $(this).attr("data-city");
$(".contactus-list-section li").each(function(){
var _this = $(this);
console.log(_city)
if(_this.attr("data-city") == _city){
_this.siblings("li").removeClass("active");
_this.addClass("active");
var _cityTop = _this.offset().top;
var _headerHeight = $(".header").height();
$('body,html').animate({scrollTop:_cityTop-_headerHeight},100);
}
})
})
$(".contactus-leftsidebar li:even").addClass("even");
$(".sub-leftsidebar.news .item-block").eq(0).addClass("active");
$(".sub-leftsidebar.news .item-block .title").click(function(){
if($(this).parents(".item-block").hasClass("active")){
$(this).parents(".item-block").removeClass("active");
}else{
$(this).parents(".item-block").addClass("active");
}
})
$(".anime-hover").one('mouseover', function(){
$(this).find(".anime-icon").addClass('mouse-out-class');
})
$("body").on("click",".fwzx-btn",function(){
$(".customer-service-layer").fadeIn(300);
if(windowWidth > 992){
textLayoutTabsSwiper();
}
$(".text-layout .textArea .autocomplete").html("");
$("#robotinput").val("");
$("#robotinput").focus();
})
$("body").on("click",".hzxq-btn",function(){
gethotanswer("1","表单");
$(".customer-service-layer").fadeIn(300);
if(windowWidth > 992){
textLayoutTabsSwiper();
}
$(".text-layout .textArea .autocomplete").html("");
$("#robotinput").val("");
$("#robotinput").focus();
$(".contact-from-layer").show(0,function(){
$(this).animate({"right":"0"},300);
})
})
/* $("body").on("click",".fwzx-btn,.hzxq-btn",function(){
$(".customer-service-local-layer").fadeIn(300);
}) */
//提示框
$(".error-layer .layer-close").click(function(){
$(".error-layer").fadeOut(300);
})
if(windowWidth < 992){
// 手机
// 二级导航 当前状态滚动定位
/* if($(".base-sub-nav").length>0){
var _subNavIndex = $('.base-sub-nav li a.active').parents("li").index();
//console.log(_subNavIndex)
if(_subNavIndex != 0){
var _positionLeft = $('.base-sub-nav li').eq(_subNavIndex).position().left;
$(".base-sub-nav .edit-container").animate({ scrollLeft: parseInt(_positionLeft)}, 500);
//console.log(parseInt(_positionLeft))
}
} */
var homeProductFocusSwiper = new Swiper('.home-product-focus .swiper-container',{
autoplay: {
delay: 5000,
//disableOnInteraction: false,
},
speed: 1000,
loop: true,
slidesPerView: 2,
//centeredSlides: true,
navigation: {
nextEl: ".home-product-focus .swiper-arrow-next",
prevEl: ".home-product-focus .swiper-arrow-prev",
},
});
var informationActivitiesFoucsSwiper = new Swiper(".information-activities-foucs .swiper-container", {
loop: true,
slidesPerView: 3,
//slidesPerGroup: 3,
pagination: {
el: ".information-activities-foucs .swiper-pagination",
clickable: true,
},
});
var qyzzFoucsSwiper = new Swiper(".qyzz-foucs .swiper-container", {
autoplay: {
delay: 5000,
//disableOnInteraction: true,
},
speed: 1000,
loop: true,
slidesPerView: 2,
pagination: {
el: ".qyzz-foucs .swiper-pagination",
clickable: true,
dynamicBullets: true,
},
});
if($(".ecological-partners-focus .swiper-slide").length > 12){
$(".ecological-partners-focus").addClass("foucs-animate");
var ecologicalpartnersFoucsSwiper = new Swiper(".ecological-partners-focus .swiper-container", {
//loop: true,
autoplay: {
delay: 5000,
//disableOnInteraction: true,
},
speed: 1000,
slidesPerView: 3,
slidesPerGroup: 3,
slidesPerColumn : 4,
slidesPerColumnFill : 'row',
pagination: {
el: ".ecological-partners-focus .swiper-pagination",
clickable: true,
dynamicBullets: true,
},
});
}
}else{
// PC
var homeProductFocusSwiper = new Swiper('.home-product-focus .swiper-container',{
autoplay: {
delay: 5000,
//disableOnInteraction: false,
},
speed: 1000,
loop: true,
slidesPerView: 3,
centeredSlides: true,
navigation: {
nextEl: ".home-product-focus .swiper-arrow-next",
prevEl: ".home-product-focus .swiper-arrow-prev",
},
});
if($(".information-activities-foucs .swiper-slide").length > 3){
var informationActivitiesFoucsSwiper = new Swiper(".information-activities-foucs .swiper-container", {
loop: true,
slidesPerView: 3,
slidesPerGroup: 3,
pagination: {
el: ".information-activities-foucs .swiper-pagination",
clickable: true,
},
});
}
var qyzzFoucsSwiper = new Swiper(".qyzz-foucs .swiper-container", {
//loop: true,
autoplay: {
delay: 5000,
//disableOnInteraction: true,
},
speed: 1000,
slidesPerView: 4,
slidesPerGroup: 4,
slidesPerColumn : 2,
slidesPerColumnFill : 'row',
pagination: {
el: ".qyzz-foucs .swiper-pagination",
clickable: true,
},
});
if($(".ecological-partners-focus .swiper-slide").length > 21){
$(".ecological-partners-focus").addClass("foucs-animate");
var ecologicalpartnersFoucsSwiper = new Swiper(".ecological-partners-focus .swiper-container", {
//loop: true,
autoplay: {
delay: 5000,
//disableOnInteraction: true,
},
speed: 1000,
slidesPerView: 7,
slidesPerGroup: 7,
slidesPerColumn : 3,
slidesPerColumnFill : 'row',
pagination: {
el: ".ecological-partners-focus .swiper-pagination",
clickable: true,
},
});
}
}
})
function getWindowSize(){
windowWidth = $(window).width();
windowHeight = $(window).height();
if( !('placeholder' in document.createElement('input')) ){
// 匹配 除type=password以外所有input、textarea
$('input[placeholder][type!=password],textarea[placeholder]').each(function(){
var self = $(this),
text= self.attr('placeholder');
// 如果内容为空,则写入
if(self.val()===""){
self.val(text).addClass('placeholder');
}
// 控件激活,清空placeholder
self.focus(function(){
self.val("");
if(self.val()===text){
self.val("").removeClass('placeholder');
}
// 控件失去焦点,清空placeholder
}).blur(function(){
if(self.val()===""){
self.val(text).addClass('placeholder');
}
});
});
}
if(windowWidth > 992){
//pc
$(".home-banner").height(windowHeight);
}
$(".section-404").height(windowHeight);
}
/*视频播放*/
function Videoplay(){
//视频弹框
$("body").on("click",".video-play",function(){
var _mp4 = $(this).attr("data-mp4");
$("body").append('
'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
');
$(".video-layer").fadeIn(300);
})
$("body").on("click",".video-layer .layer-close",function(){
$(".video-layer").fadeOut(300,function(){
$(".video-layer").remove();
});
})
}
function ryjxSlide(){
if(windowWidth < 992){
// 手机
var ryjxFocusSwiper = new Swiper('.ryjx-slide .swiper-container',{
autoplay: {
delay: 5000,
//disableOnInteraction: true,
},
speed: 1000,
loop: true,
slidesPerView: 3,
navigation: {
nextEl: ".ryjx-slide .swiper-arrow-next",
prevEl: ".ryjx-slide .swiper-arrow-prev",
},
});
}else{
// PC
if(_slidelength > 3){
//console.log(_slidelength)
$(".about-ryjx-inner .tabs-content .box .ryjx-slide").removeClass("active");
var ryjxFocusSwiper = new Swiper('.ryjx-slide .swiper-container',{
autoplay: {
delay: 5000,
//disableOnInteraction: true,
},
speed: 1000,
loop: true,
slidesPerView: 5,
centeredSlides: true,
navigation: {
nextEl: ".ryjx-slide .swiper-arrow-next",
prevEl: ".ryjx-slide .swiper-arrow-prev",
},
});
}else{
//console.log(_slidelength)
$(".about-ryjx-inner .tabs-content .box .ryjx-slide").addClass("active");
var ryjxFocusSwiper = new Swiper('.ryjx-slide .swiper-container',{
autoplay: {
delay: 5000,
//disableOnInteraction: true,
},
speed: 1000,
loop: true,
slidesPerView: 3,
centeredSlides: true,
navigation: {
nextEl: ".ryjx-slide .swiper-arrow-next",
prevEl: ".ryjx-slide .swiper-arrow-prev",
},
});
}
}
}
function homeScroll(){
var _section2 = $(".home-information").offset().top;
var _section3 = $(".home-cloud").offset().top;
var _section4 = $(".home-product").offset().top;
var _section5 = $(".home-case").offset().top;
var _section6 = $(".home-partner").offset().top;
var _windowScrollTop = $(window).scrollTop() + windowHeight/2;
//console.log(_section2+" , "+_section3+" , "+_section4+" , "+_section5+" , "+_windowScrollTop)
if(_windowScrollTop > _section2 && _windowScrollTop < _section3){
//console.log(1)
$(".home-leftsidebar").show();
$(".home-leftsidebar li").eq(0).addClass("active").siblings().removeClass("active");
}else if(_windowScrollTop > _section3 && _windowScrollTop < _section4){
//console.log(2)
$(".home-leftsidebar").show();
$(".home-leftsidebar li").removeClass("active");
$(".home-leftsidebar li").eq(1).addClass("active").siblings().removeClass("active");
}else if(_windowScrollTop > _section4 && _windowScrollTop < _section5){
//console.log(3)
$(".home-leftsidebar").show();
$(".home-leftsidebar li").removeClass("active");
$(".home-leftsidebar li").eq(2).addClass("active").siblings().removeClass("active");
}else if(_windowScrollTop > _section5 && _windowScrollTop < _section6){
//console.log(4)
$(".home-leftsidebar").show();
$(".home-leftsidebar li").removeClass("active");
$(".home-leftsidebar li").eq(3).addClass("active").siblings().removeClass("active");
}else if(_windowScrollTop > _section6){
//console.log(4)
$(".home-leftsidebar").show();
$(".home-leftsidebar li").removeClass("active");
$(".home-leftsidebar li").eq(4).addClass("active").siblings().removeClass("active");
}else{
//console.log(0)
$(".home-leftsidebar").hide();
}
var _homeIcon1 = $(".home-icon1").offset().top;
var _homeIcon2 = $(".home-icon2").offset().top;
var _homeIcon3 = $(".home-icon3").offset().top;
var _homeIcon4 = $(".home-icon4").offset().top;
var _homeIcon5 = $(".home-icon5").offset().top;
//console.log(_homeIcon1,_homeIcon2,_homeIcon3,_homeIcon4,_homeIcon5)
var _scrollTop = 0;
$(window).scroll(function(){
//console.log($(window).scrollTop(),_windowScrollTopiIcon)
$(".home-icon").each(function(i,el){
if($(window).scrollTop() > $(el).offset().top - windowHeight && $(window).scrollTop() < $(el).offset().top){
//console.log($(window).scrollTop() - $(el).offset().top)
}
if($(window).scrollTop() > $(el).offset().top - windowHeight && $(window).scrollTop() < $(el).offset().top){
var h = (windowHeight + $(window).scrollTop() - $(el).offset().top)/5;
$(el).css("transform","translateY(-" + Math.ceil(h) +"px)")
}
})
//console.log($(window).scrollTop(),_windowScrollTopiIcon)
})
}
$(function(){
//搜索
$('.header-search .search-btn').click(function(){
var form = document.getElementById('pcsearchfrom');
form.submit();
})
$('.menu-search .search-btn').click(function(){
var form = document.getElementById('mobilesearchfrom');
form.submit();
})
})
//写cookies,永久有效
function setCookieY(_cookie, _cookieValue) {
document.cookie = _cookie + "=" + escape(_cookieValue) + ";path=/";
}
//读取cookies
function getCookieY(_cookie) {
var arr, reg = new RegExp("(^| )" + _cookie + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg)){
return unescape(arr[2]);
}else{
return null;
}
}