$(document).ready(function() {
var screen_w=window.innerwidth;
var screen_h=window.innerheight;
var center_dot={
x:screen_w/2,
y:screen_h/2
}
var mobilewidth=768;
var ismobile=false;
if(screen_w<=mobilewidth){
ismobile=true;
}else{
ismobile=false;
}
//桌面菜单交互
// $(".menu_list").hover(function(){
// if(!ismobile){ //如果是pc
// $(".wrap_head").addclass("submenu_show");
// }else{
// return false;
// }
// console.log("in");
// },function(){
// if(!ismobile){ //如果是pc
// $(".wrap_head").addclass("submenu_hide");
// var timer=settimeout(function(){
// $(".wrap_head").removeclass("submenu_show");
// $(".wrap_head").removeclass("submenu_hide");
// },150);
// }else{
// return false;
// }
// console.log("out");
// });
if(!ismobile) { // 桌面菜单交互
$(".menu_list").hover(function(){
if(window.innerwidth >768){
$(".wrap_head").addclass("submenu_show");
}
},function(){
if(window.innerwidth >768){
$(".wrap_head").addclass("submenu_hide");
var timer=settimeout(function(){
$(".wrap_head").removeclass("submenu_show");
$(".wrap_head").removeclass("submenu_hide");
},150);
}
});
}
$(".menu_list .menu_item").hover(function(){
if(!ismobile){ //如果是pc
if(!$(".wrap_head").hasclass("submenu_show")){
$(".wrap_head").addclass("submenu_show");
}
$(this).addclass("sublist_show");
$(this).children(".sub_list").show();
}else{
return false;
}
},function(){
if(!ismobile){ //如果是pc
$(this).addclass("sublist_hide");
var that=this;
var timer=settimeout(function(){
$(that).removeclass("sublist_show");
$(that).removeclass("sublist_hide");
$(that).children(".sub_list").hide();
},150);
}else{
return false;
}
});
function setmenuhook(){
if(!ismobile){ //如果是pc
$(".menu_item").append("");
var list=$(".menu_item .menu_hook");
for(var i=0;i768){
$(".menu_list").css({
"transform":"translate(0px,0)",
"opacity": 1
});
}else{
$(".menu_list").css({
"transform":"translate(-260px,0)",
"opacity": 0.8
});
}
});
//移动端菜单
$(".icon_menu .i_menu").click(function(){
$(".menu_list").css({
"transform":"translate(0,0)",
"opacity":1
});
$(this).show();
$(".icon_menu .i_close").show();
$(".icon_menu .i_menu").hide();
$(".wrap_head .bg_hover").show();
});
$(".icon_menu .i_close").click(function(){
menuhide();
});
$(".wrap_head .bg_hover").click(function(){
menuhide();
});
function menuhide(){
$(".menu_list").css({
"transform":"translate(-260px,0)",
"opacity":0.8
});
$(".icon_menu .i_close").hide();
$(".icon_menu .i_menu").show();
$(".wrap_head .bg_hover").hide();
$(".search_area").show();
}
//移动端搜索
$(".search_icon").click(function(){
$(".wrap_head").addclass("search_area_show");
$(".icon_menu").hide();
$(".search_area .ipt_search").show().focus();
});
$(".search_area .ipt_search").blur(function(){
$(".wrap_head").removeclass("search_area_show");
$(".icon_menu").show();
$(".search_area .ipt_search").hide();
});
// $(document).scroll(function() {
// console.log($(window).scrolltop());
// console.log($(".mod-tab").offset().top);
// if($(window).scrolltop() >= $('.mod-tab-content').offset().top - $(".mod-tab").height()){
// $(".mod-tab").addclass('mod-tab-fixed');
// //$('.mod-section-ad').css('margin-bottom',$(".mod-tab").height()+'px');
// }else{
// $(".mod-tab").removeclass('mod-tab-fixed');
// //$('.mod-section-ad').css('margin-bottom','0px');
// }
// })
/* 连接责任与信任banner */
var resp_area_banner_time;
var resp_area_index = 0;
var resp_area_width = $('.resp_area .slide_area').width();
var resp_area_len = $('.resp_area .slide_list li').length;
function resp_area_banner(l){
if(l){
resp_area_index--;
resp_area_index = resp_area_index < 0 ? resp_area_len-1 : resp_area_index;
}else{
resp_area_index++;
resp_area_index = resp_area_index < resp_area_len ? resp_area_index : 0;
}
$('.resp_area .slide_list li').removeclass('active');
$('.resp_area .slide_list li').eq(resp_area_index).addclass('active');
}
var resp_area_banner_time = setinterval(resp_area_banner,4000);
$('.resp_area .slide_area .icon_arrow').on('click',function(){
clearinterval(resp_area_banner_time);
if($(this).hasclass('icon_arrow_l')){
resp_area_banner(1);
}else{
resp_area_banner();
}
resp_area_banner_time = setinterval(resp_area_banner,4000);
})
/* 连接人才与发展banner */
var develop_area_banner_time;
var develop_area_index = 0;
var develop_area_width = $('.develop_area .slide_area').width();
var develop_area_len = $('.develop_area .slide_list li').length;
function develop_area_banner(l){
if(l!=undefined){
develop_area_index = l;
}else{
develop_area_index++;
}
develop_area_index = develop_area_index < develop_area_len ? develop_area_index : 0;
$('.develop_area .slide_list li').removeclass('active');
$('.develop_area .slide_list li').eq(develop_area_index).addclass('active');
$('.develop_area .slide-tab .li').removeclass('active');
$('.develop_area .slide-tab .li').eq(develop_area_index).addclass('active');
}
var develop_area_banner_time = setinterval(develop_area_banner,5000);
$('.develop_area .slide-tab .li').on('click',function(){
clearinterval(develop_area_banner_time);
develop_area_banner($(this).index());
develop_area_banner_time = setinterval(develop_area_banner,4000);
})
$('.back_to_top').on('click',function(){
$('html , body').animate({scrolltop: 0},'slow');
})
/* 二级页面导航栏 */
function pagetab(){
var devicewidth = $(window).width() // 设备屏幕宽度
if(devicewidth<=1226){
$('.mod-tab .mc-right').hide();
$('.mod-tab .mc-left').hide();
$('.mod-tab .clearfix ul').css({'left':'16px','right': 'auto'});
}else{
var modtabulw = $('.mod-tab .clearfix ul').width();
var modtabw = $('.mod-tab .clearfix').width();
if(modtabulw >modtabw){
$('.mod-tab .mc-right').show();
}
$('.mod-tab .mc-right').on('click',function(){
$('.mod-tab .clearfix ul').css({'right':'0px','left': 'auto'});
$('.mod-tab .mc-right').hide();
$('.mod-tab .mc-left').show();
})
$('.mod-tab .mc-left').on('click',function(){
$('.mod-tab .clearfix ul').css({'left':'16px','right': 'auto'});
$('.mod-tab .mc-right').show();
$('.mod-tab .mc-left').hide();
})
}
}
var brandtabofftop = [];
$(window).resize( function() { // 当pc端页面宽度缩小到移动端大小时
$('.mod-tab .clearfix ul').css({'left':'16px','right': 'auto'});
pagetab();
brandtabofftop = [];
var sanwidth = $('.artice-box .san').width() - 1;
$('.artice-box .san').css('right',-sanwidth+'px');
if($(window).width() <=1226){
$('.mobile-tab-brand').each(function(){
var that = $(this);
settimeout(function(){
brandtabofftop.push(that.offset().top);
},100)
})
}else{
$('.pc-tab-brand').each(function(){
brandtabofftop.push($(this).offset().top);
})
}
})
settimeout(function(){
pagetab();
brandtabofftop =[];
var modtab;
if($('.mod-tab').length>=1){
modtab = $('.mod-tab').offset().top;
}
var p=0,t=0;
// if($(document).scrolltop()>=$('.head_white').height()){
// $('.head_white').addclass('fixed');
// }
// if($(document).scrolltop()>=modtab){
// $('.mod-tab').addclass('fixed');
// }else{
// $('.mod-tab').removeclass('fixed');
// }
if($(window).width() <=1226){
$('.mobile-tab-brand').each(function(){
var that = $(this);
settimeout(function(){
brandtabofftop.push(that.offset().top);
},100)
})
}else{
$('.pc-tab-brand').each(function(){
brandtabofftop.push($(this).offset().top);
})
}
var showheadstate = true;
$(window).scroll(function(event){
p = $(this).scrolltop();
if(t<=p){
//向下滚
if($(document).scrolltop()>=$('.head_white').height()+30){
// if($('.head_white').hasclass('hestate')){
// $('.head_white').css({'position':'fixed','top':'-72px'});
// }else{
// $('.head_white').hide();
// $('.head_white').css({'position':'fixed','top':'-72px'});
// }
// $(".wrap_head").removeclass("submenu_show");
// $(".wrap_head").removeclass("submenu_hide");
$('.sub_list').hide();
}
$('.mod-tab').css('top','0px');
$('.left-nav').css('top','115px');
}else{
//向上滚
if(showheadstate == true){
//$('.head_white').removeclass('fixed');
// if($(document).scrolltop()<$('.head_white').height()){
// $('.head_white').css({'position':'fixed','top':'0px'});
// $('.head_white').removeclass('hestate')
// settimeout(function(){
// $('.head_white').css({'position':'absolute','top':'0px'});
// },50)
// }else{
// $('.head_white').show();
// settimeout(function(){
// $('.head_white').css({'position':'fixed','top':'0px'});
// $('.head_white').addclass('hestate')
// },20)
// }
}
}
settimeout(function(){t = p;},0);
if($(document).scrolltop()>=modtab){
// $('.mod-tab').addclass('fixedtop');
$('.left-nav').addclass('fixedtop');
$('.left-nav').addclass('fixed-left-nav');
}else{
// $('.mod-tab').css('top','0px');
// $('.mod-tab').removeclass('fixedtop');
$('.left-nav').removeclass('fixed-left-nav');
$('.left-nav').removeclass('fixedtop');
}
if($(window).width() <=1226){
if(showheadstate != false){
scrollnav($('.mobile-tab-brand'));
$('.left-nav').removeclass('fixedtop');
$('.left-nav').removeclass('fixed-left-nav');
$('.mod-tab').removeclass('fixedtop');
}
}else{
if(showheadstate != false){
scrollnav($('.pc-tab-brand'));
}
}
});
$('.mod-tab li').on('click',function(){
showheadstate = false;
$('.mod-tab li').removeclass('active-tab');
$(this).addclass('active-tab');
$('.mod-tab .line').stop().animate({'left':$(this).position().left+'px','width': $(this).width()},200);
var t = brandtabofftop[$(this).index()];
$("html,body").animate({scrolltop: t+"px"}, 200);
settimeout(function(){
showheadstate = true;
},300)
})
// 设置疫情页面斜边三角的初始高
var sanwidth = $('.artice-box .san').width() - 1;
$('.artice-box .san').css('right',-sanwidth+'px');
},50)
function scrollnav(dom){
var sections = dom;
sections.each(function(index,el){
var _this = $(this);
if( _this.offset().top <= $(document).scrolltop()){
$('.mod-tab .line').stop().animate({'left':$('.mod-tab li').eq(index).position().left+'px','width': $('.mod-tab li').eq(index).width()},200);
$('.mod-tab li').removeclass('active-tab');
$('.mod-tab li').eq(index).addclass('active-tab');
}
})
}
});