function windowLoadingPage(){// 页面加载执行
	var winw = $(window).width();
	var winh = $(window).height();

	/*PC端打开效果*/
	if(winw>=980){
		new WOW().init({});
	}

	/*头部开始*/
	//$('#header-block').height($('#header').outerHeight());
	$('#header-nav').css({'top':$('#header').outerHeight()});
	$('#header-search').css({'top':$('#header').outerHeight()});
	
	/*二级导航的宽度*/
	window.headerNavTwoWidth = 300;
	if(winw<=1440){
		window.headerNavTwoWidth = 200;
	}
	
	/*底部开始*/
	$('#float-four-block').height($('#float .four').outerHeight());
	
	/*悬浮开始*/
	window.floatOneWidth = $('#float .one .main').outerWidth();
	setTimeout(function(){
		$('#float .one .main').css({'right':'-'+window.floatOneWidth+'px'});
		$('#float .one .title').css({'right':'0'});
	},1000);

	/*相关产品*/
	window.relatedProductsHeight = $('[data-float-related-products]').outerHeight();
	setTimeout(function(){
		$('[data-float-related-products]').css({'bottom':'-'+window.relatedProductsHeight+'px'});
	},1000);
	
	$('.text-line').each(function(){
		var lineHeight = parseFloat($(this).css('line-height'));
		if($(this).hasClass('line3')){
			$(this).css({'height':lineHeight*3+'px'});
		}else if($(this).hasClass('line4')){
			$(this).height(lineHeight*4);
		}else if($(this).hasClass('line5')){
			$(this).height(lineHeight*5);
		}else if($(this).hasClass('line6')){
			$(this).height(lineHeight*6);
		}else{
			$(this).height(lineHeight*2);
		}
	})

}

$(window).off('load,resize,scroll').on({
	load: function(){
		windowLoadingPage();
	},
	resize: function(){
		windowLoadingPage();
	},
	scroll: function(){
		
	}
});


/*锚点滚动条动态*/
$(function(){
	$('a[href*=#],area[href*=#]').click(function() {
		if(location.pathname.replace(/^\//,'')==this.pathname.replace(/^\//, '')&&location.hostname==this.hostname){
			var $target=$(this.hash);
			$target=$target.length && $target || $('[name=' + this.hash.slice(1) + ']');
			if($target.length){
				var targetOffset=$target.offset().top;
				$('html,body').animate({scrollTop: targetOffset},500);
				return false;
			}
		}
	});
});

$('[data-products-search]').submit(function(){// 产品-搜索
	var Keyword = $(this).find("input[name='Keyword']").val();
	var action = $(this).attr('action');
	if(Keyword){
		window.location.href = action+"k-"+Keyword+"/";
	}else{
		$.alert({str:'请输入关键词',time:1000});
	}
	return false;
})

$('[data-feedback]').form({// 留言提交
	url:'/api/web/feedback',
	check: function(c,f){
		this.load = $.alert('loading');
	},
	end: function(d,f){
		this.load.remove(function(){
			if(d.ret==1){
				$.alert({str:d.msg,btn:1,end:function(){
					f[0].reset();
				}});
			}else{
				$.alert({str:d.msg,btn:1});
			}
		});
	}
});

if($(window).width()>750){// pc
	
	$('[data-float-related-products]').hover(function(){// 相关产品-鼠标事件
		$('[data-float-related-products]').stop(true,true).css({'bottom':'0'});
	},function(){
		$('[data-float-related-products]').stop(true,true).css({'bottom':'-'+window.relatedProductsHeight+'px'});
	})
	
	$('#float .one').hover(function(){// 右侧悬浮-鼠标事件
		$('#float .one .main').css({'right':'0'});
		$('#float .one .title').css({'right':'-30px'});
	},function(){
		$('#float .one .main').css({'right':'-'+window.floatOneWidth+'px'});
		$('#float .one .title').css({'right':'0'});
	})
	
}else{// 手机
	
	$('[data-float-related-target]').click(function(){
		var obj = $('[data-float-related-products]');
		if(obj.hasClass('cur')){
			obj.removeClass('cur').stop(true,true).css({'bottom':'-'+window.relatedProductsHeight+'px'});
		}else{
			obj.addClass('cur').stop(true,true).css({'bottom':'0'});
		}
	})
	
	$('#float .one .title').click(function(){// 右侧悬浮-鼠标事件
		var obj = $('#float .one');
		if(obj.hasClass('cur')){
			obj.removeClass('cur');
			$('#float .one .main').css({'right':'0'});
			$('#float .one .title').css({'right':'-30px'});
		}else{
			obj.addClass('cur');
			$('#float .one .main').css({'right':'-'+window.floatOneWidth+'px'});
			$('#float .one .title').css({'right':'0'});
		}
	})
	
}

var relatedProducts = new Swiper('#related-products',{// 相关产品
	roundLengths:true,
	speed:800,
	slidesPerView:'auto',
	freeMode : true,
	scrollbar: {
		el: '#related-products .swiper-scrollbar',
	},
});

if($('[data-related-products-list]').length){// 相关产品

	$('[data-related-products-list]').each(function(index){
		new Swiper($(this),{
			roundLengths:true,
			speed:800,
			slidesPerView:'auto',
			freeMode : true,
			scrollbar: {
				el: $(this).find('.swiper-scrollbar'),
			},
		});
	})

}

$('[data-products-category-select]').change(function(){// 产品分类点击跳转链接
	var CateId = $(this).val();
	
	if(!CateId){return false;}
	window.location.href = '/products/i-'+CateId+'/';
})

/*头部开始*/

function headerSearch(){// 搜索框
	var obj = $('[data-target-search]');
	if(!obj.hasClass('cur')){
		obj.addClass('cur');
		$('#header-search').stop(true,true).slideDown().find('.input').focus();
	}else{
		obj.removeClass('cur');
		$('#header-search').stop(true,true).slideUp().find('.input');
	}
}

$('[data-target-nav]').click(function(){// 导航栏
	$('#header-nav').stop(true,true).slideToggle();
})

/*$('#header .two .item').hover(function(){// 展示二级导航
	$(this).find('.nav-two').stop(true,true).slideDown();
},function(){
	$(this).find('.nav-two').stop(true,true).slideUp();
})*/

/*function headerNavMove(){// 二级导航 freeMode
	$('[data-nav-two]').each(function(index){
		new Swiper($(this),{
			roundLengths:true,
			speed:800,
			freeMode : true,
			//autoHeight:true,
			slidesPerView:'auto',
			direction : 'vertical',
			mousewheel: true,
		});
	})
}
headerNavMove();*/

function headerNavHover(){// 二级导航效果
	$('[data-hover-products-category]').hover(function(){
		
		if($(this).hasClass('cur')){return false;}
		var obj = $(this).parents('.nav-two');
		var CateId = $(this).attr('CateId');
		var Dept = $(this).attr('Dept');
		
		$(this).addClass('cur').siblings('[data-hover-products-category]').removeClass('cur');
		
		$.post('/ajax/header-products-category',{CateId:CateId,Dept:Dept},function(data){
			if(Dept==1){
				obj.find('[data-header-products-category2]').html('').parent().css({'width':'0'});
				obj.css({'width':((window.headerNavTwoWidth+obj.find('.ites-one').outerWidth())+'px')});
				obj.find('[data-header-products-category1]').html(data).parent().css({'width':(window.headerNavTwoWidth+'px')});
			}else if(Dept==2){
				obj.css({'width':(((window.headerNavTwoWidth*2)+obj.find('.ites-one').outerWidth())+'px')});
				obj.find('[data-header-products-category2]').html(data).parent().css({'width':(window.headerNavTwoWidth+'px')});
			}
			//headerNavMove();
			headerNavHover();
		});
	})
}
headerNavHover();

/*头部结束*/

/*广告开始*/

if($('#banner').hasClass('swiper-container')){
	var BannerSwiper = new Swiper('#banner',{
	    autoplay: {
	    	autoplay:3000,
			disableOnInteraction: false,
		},
		roundLengths:true,
		simulateTouch:false,
		speed:800,
		loop : $("#banner").find('.swiper-slide').length>1?true:false,
		navigation: {
			prevEl: '#banner .swiper-prev',
			nextEl: '#banner .swiper-next',
		},
	});
	
	var BannerSwiper2 = new Swiper('#phone-banner',{
	    autoplay: {
	    	autoplay:3000,
			disableOnInteraction: false,
		},
		roundLengths:true,
		simulateTouch:false,
		speed:800,
		loop : $("#phone-banner").find('.swiper-slide').length>1?true:false,
		pagination: {
			el: '#phone-banner .swiper-switch',
			clickable :true
		},
	});
}

/*广告结束*/

/*首页开始*/

if($('#index').length){
	if($(window).width()>980){
		window.indexFourwidth = '1550';
	}else if($(window).width()>750){
		window.indexFourwidth = '1140';
	}else if($(window).width()>480){
		window.indexFourwidth = '800';
	}else if($(window).width()>300){
		window.indexFourwidth = '500';
	}
}

var indexFour = new Swiper('#index-four .swiper-container', {// 解决方案
	autoplay: {
		autoplay:3000,
		disableOnInteraction: false,
	},
	speed:800,
	watchSlidesProgress: true,
	slidesPerView: 'auto',
	centeredSlides: true,
	loop: true,
	roundLengths:true,
	simulateTouch:false,
	pagination: {
		el: '#index-four .swiper-switch',
		clickable :true
	},
	navigation: {
		prevEl: '#index-four .swiper-prev',
		nextEl: '#index-four .swiper-next',
	},
	on: {
		progress: function(progress) {
			for (i = 0; i < this.slides.length; i++) {
				var slide = this.slides.eq(i);
				var slideProgress = this.slides[i].progress;
				modify = 1;
				if (Math.abs(slideProgress) > 1) {
					modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
				}
				translate = slideProgress * modify * window.indexFourwidth + 'px';
				scale = 1 - Math.abs(slideProgress) / 3;
				zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
				slide.transform('translateX(' + translate + ') scale(' + scale + ')');
				slide.css('zIndex', zIndex);
				slide.css('opacity', 1);
				if (Math.abs(slideProgress) > 3) {
					slide.css('opacity', 0);
				}
			}
		},
		setTransition: function(transition) {
			for (var i = 0; i < this.slides.length; i++) {
				var slide = this.slides.eq(i)
				slide.transition(transition);
			}

		}
	}
})

$('[data-index-news]').each(function(){
	
	new Swiper($(this),{
		speed:800,
		autoplay: {
			autoplay:1000,
			disableOnInteraction: false,
		},
		loop : $(this).find('.swiper-slide').length>3?true:false,
		roundLengths:true,
		simulateTouch:false,
		autoHeight:true,
		slidesPerView:'auto',
		direction : 'vertical',
	});
	
})

/*首页结束*/

/*内页开始*/

if(!$('#current-two').hasClass('none')){// 内页导航
	
	var currentTwoIndex = '';
	$('#current-two .swiper-slide').each(function(){
		if($(this).hasClass('cur')){
			currentTwoIndex += $(this).index();
		}
	})

	var currentTwo = new Swiper('#current-two .swiper-container',{
		roundLengths:true,
		speed:800,
		slidesPerView:'auto',
		freeMode : true,
		initialSlide: currentTwoIndex,
	});
}

/*内页结束*/

/*产品中心开始*/

$('[data-products-category-total]').hover(function(){// 鼠标离开左侧分类栏目  恢复
},function(){
	$('[data-products-category-slide]').each(function(){
		if($(this).hasClass('on')){
			$(this).addClass('cur').siblings('[data-products-category-slide]').removeClass('cur');
		}
	})
})

$('[data-products-category-slide]').click(function(){// 左侧分类点击显示
	$(this).addClass('cur').siblings('[data-products-category-slide]').removeClass('cur');
})

var productsDetailImg = new Swiper('#products-detail-img .swiper-container',{
	roundLengths:true,
	simulateTouch:false,
	speed:800,
	autoHeight:true,
	direction : 'vertical',
	slidesPerView:'auto',
	navigation: {
		prevEl: '#products-detail-img .swiper-prev',
		nextEl: '#products-detail-img .swiper-next',
	},
});

$('[data-small-img]').click(function(){// 产品详细-小图点击切换效果
	$(this).addClass('cur').siblings('[data-small-img]').removeClass('cur');
	var big_src = $(this).find('img').attr('src');
	$('[data-big-img] img').attr('src',big_src);
})

$('[data-products-feedback-target]').click(function(){// 产品询盘
	var obj = $('#float .two');
	if(obj.hasClass('cur')){
		obj.removeClass('cur').stop(true,true).fadeToggle();
	}else{
		obj.addClass('cur').stop(true,true).fadeToggle();
	}
})

/*产品中心结束*/

/*合作企业开始*/

var cooperationImg = new Swiper('#cooperation-one .img',{
	roundLengths:true,
	simulateTouch:false,
	speed:800,
	slidesPerView:'auto',
	slidesPerGroup:1,
	pagination: {
		el: '#cooperation-one .swiper-switch',
		clickable :true
	},
	navigation: {
		prevEl: '#cooperation-one .swiper-prev',
		nextEl: '#cooperation-one .swiper-next',
	},
	breakpoints:{
		640:{
			slidesPerView:1,
			slidesPerGroup:1,
		}
	},
	on: {
		slideChangeTransitionStart: function(){
			if ($(window).width()<641) {
				cooperationContents.slideTo(this.activeIndex,800,false);
			}
		},
	},
});

var cooperationContents = new Swiper('#cooperation-one .contents',{
	roundLengths:true,
	simulateTouch:false,
	speed:800,
	slidesPerView:'auto',
	pagination: {
		el: '#cooperation-one .swiper-switch',
		clickable :true
	},
	navigation: {
		prevEl: '#cooperation-one .swiper-prev',
		nextEl: '#cooperation-one .swiper-next',
	},
	on: {
		slideChangeTransitionStart: function(){
			cooperationImg.slideTo(this.activeIndex,800,false);
		},
	},
	breakpoints:{
		640:{
			slidesPerView:1,
			slidesPerGroup:1,
		}
	}
});

/*合作企业结束*/

/*新闻资讯开始*/

function infoMore(CateId,Keyword,Time){
	var Page = $('[data-info-html]').find('.slide-two').length+2;

	$.post('/ajax/info',{CateId:CateId,Keyword:Keyword,Time:Time,Page:Page},function(data){
		if(data=='false'){
			$.alert({str:'已经到底了',time:1000});
			$('.inside-more').remove();
		}else{
			$('[data-info-html]').append(data);
		}
	});
}

/*新闻资讯结束*/

/*走进赢润开始*/

function aboutRush(CateId){
	
	if(CateId==4){return false;}
	
	if(CateId==1){
		var aboutSet = $('#about .one').offset().top;
	}else if(CateId==2){
		var aboutSet = $('#about .two').offset().top;
	}else if(CateId==3){
		var aboutSet = $('#about .thr').offset().top;
	}

	$('html,body').animate({scrollTop: aboutSet-$('#header').outerHeight()},500);

}

var aboutImg = new Swiper('#about-img',{// 企业简介-图片滚动
	roundLengths:true,
	simulateTouch:false,
	speed:800,
	slidesPerView:'auto',
	pagination: {
		el: '#about-img .swiper-switch',
		clickable :true
	},
});

var aboutQualification = new Swiper('#about-qualification .swiper-container',{// 荣誉资质
	roundLengths:true,
	simulateTouch:false,
	speed:800,
	slidesPerView:'auto',
	slidesPerGroup:4,
	navigation: {
		prevEl: '#about-qualification .swiper-prev',
		nextEl: '#about-qualification .swiper-next',
	},
	breakpoints: {
		640: {
			slidesPerGroup:3,
		},
		480: {
			slidesPerGroup:2,
		}
	}
});

/*走进赢润结束*/


$(function () {
    let href = $("a");
    for (let i = 0; i < href.length; i++) {
        if (href[i].href == "javascript://") {
             if (href[i].innerHTML == "在线咨询" || href[i].innerHTML == "马上咨询") {
                // href[i].href = "https://affim.baidu.com/unique_31144380/mobile/chat?siteId=15753370&userId=31144380&siteToken=e106658a4e9be6e0d81f644b057d811b";
                href[i].href = "https://affim.baidu.com/unique_31144380/chat?siteId=15753370&userId=31144380&siteToken=e106658a4e9be6e0d81f644b057d811b"
            }
        }
    }
})


