var public = { winwidth: $(window).width(), //初始化 init: function(){ /*$('body,html').animate({scrolltop:0});*/ smoothscroll.init({offset:95}); if($('.timer').length>0){ var a = math.round($('.lh-power').offset().top+100); var b = math.round($(window).scrolltop()+$(window).height()); if(a0){ $(window).scroll(function(){ var s= $(this).scrolltop()/3; $('.lh-banner .img').css({ 'background-position':'center '+s+'px' }); }); } if($('.lh-ban').length>0){ $(window).scroll(function(){ var s= $(this).scrolltop()/3; $('.lh-ban .img').css({ 'background-position':'center '+s+'px' }); }); } } //导航 this.nav(); }, //banner banner : function(a){ var a = a || {}; var opt = $.extend({ boxcell : '.lh-banner', stoponlastslide:true, slidesperview:1, spacebetween:0, parallax:true, pagination:'.hd', paginationtype:'bullets', speed:1000, loop:false, clickable:true, grabcursor:false, direction:'horizontal', initialslide:0, effect:'fade', mousewheel:false, scrollbar: { el: 'null', }, slidetoclickedslide:false, nextel:'.next', prevel:'.prev', noswipingclass:'stop-swiping', on:'', renderbullet:null, observeparents:true, observer:true },a); if($(opt.boxcell).find('.next').length>=1){ var nextel = $(opt.boxcell).find('.next'),prevel = $(opt.boxcell).find('.prev'); }else{ var nextel =opt.nextel,prevel =opt.prevel; } var myswiper = new swiper(opt.boxcell, { parallax : opt.parallax,//data-swiper-parallax slidesperview:opt.slidesperview, initialslide :opt.initialslide, slidetoclickedslide:opt.slidetoclickedslide, pagination : { el : opt.pagination, type:opt.paginationtype, clickable :opt.clickable, renderbullet:opt.renderbullet }, speed:opt.speed, loop:opt.loop, paginationclickable :opt.paginationclickable, effect : opt.effect, fadeeffect: { crossfade: true, }, spacebetween:opt.spacebetween, navigation: { nextel: nextel, prevel: prevel, }, grabcursor :opt.grabcursor, direction:opt.direction, mousewheel:opt.mousewheel, scrollbar:opt.scrollbar, noswipingclass:opt.noswipingclass, on:opt.on, observeparents:opt.observeparents, observer:opt.observer }); },//banner end //banner1 autoplay banner1 : function(a){ var a = a || {}; var opt = $.extend({ boxcell : '.lh-banner', stoponlastslide:true, parallax:true, pagination:'.hd', renderbullet:null, paginationtype:'bullets', speed:800, loop:true, clickable:true, grabcursor:false, direction:'horizontal', initialslide:0, effect:'fade', mousewheel:false, scrollbar: { el: 'null', }, slidesperview:1, spacebetween:0, on:'', delay:4500, },a); if($(opt.boxcell).find('.next').length>=1){ var nextel = $(opt.boxcell).find('.next'),prevel = $(opt.boxcell).find('.prev'); }else{ var nextel =opt.nextel,prevel =opt.prevel; } var myswiper1 = new swiper(opt.boxcell, { autoplay:{ delay: opt.delay, stoponlastslide: false, disableoninteraction: true, }, parallax : opt.parallax,//data-swiper-parallax pagination : { el : opt.pagination, type:opt.paginationtype, clickable :opt.clickable, renderbullet:opt.renderbullet }, spacebetween:opt.spacebetween, speed:opt.speed, loop:opt.loop, paginationclickable :opt.paginationclickable, effect : opt.effect, fadeeffect: { crossfade: true, }, navigation: { nextel: nextel, prevel: prevel, }, slidesperview:opt.slidesperview, grabcursor :opt.grabcursor, direction:opt.direction, mousewheel:opt.mousewheel, scrollbar:opt.scrollbar, on:opt.on }); $(opt.boxcell).mouseenter(function () { myswiper1.autoplay.stop(); }) $(opt.boxcell).mouseleave(function () { myswiper1.autoplay.start(); }) },//banner end //tab tab:function(a){ var a = a || {}; var opt = $.extend({ boxcell:'.lhtab', hdcell:'.lhtabhd', bdcell:'.lhtabbd', delay:0, trigger:'mouseover' },a) if(this.winwidth<=1024){ opt.trigger='click'; } init(); function init(){ $(opt.boxcell).each(function(){ var _this = $(this); _this.find(opt.hdcell).children('li').eq(0).addclass('on'); _this.find(opt.bdcell).children('ul').eq(0).show(opt.delay,function(){ _this.find(opt.bdcell).children('ul').eq(0).addclass('on'); }); }); tabshow(); } function tabshow(){ if(opt.trigger=='click'){ clickshow(); }else{ hovershow(); } } function hovershow(){ $(opt.hdcell).children('li').hover(function(){ var _this = $(this),_index=_this.index(); _this.addclass('on').siblings().removeclass('on'); _this.parents(opt.boxcell).find(opt.bdcell).children('ul').stop(true,true).hide().removeclass('on'); _this.parents(opt.boxcell).find(opt.bdcell).children('ul').eq(_index).stop(true,true).show(opt.delay,function(){ _this.parents(opt.boxcell).find(opt.bdcell).children('ul').eq(_index).addclass('on'); }); },function(){}); } function clickshow(){ $(opt.hdcell).children('li').click(function(){ var _this = $(this),_index=_this.index(); if(!_this.hasclass('on')){ _this.addclass('on').siblings().removeclass('on'); _this.parents(opt.boxcell).find(opt.bdcell).children('ul').stop(true,true).hide().removeclass('on'); _this.parents(opt.boxcell).find(opt.bdcell).children('ul').eq(_index).stop(true,true).show(opt.delay,function(){ _this.parents(opt.boxcell).find(opt.bdcell).children('ul').eq(_index).addclass('on'); }); } }); } }, //lhaccordion accordion:function(a){ var a = a || {}; var opt = $.extend({ boxcell:'.lhaccordion', hdcell:'.hd', bdcell:'.bd', delay:600, trigger:'mouseover' },a) if(this.winwidth<=1024){ opt.trigger='click'; } init(); function init(){ $(opt.boxcell).each(function(){ var _this = $(this); _this.children().eq(0).addclass('on').find(opt.bdcell).stop(true,true).slidedown(); }); accordionshow(); } function accordionshow(){ if(opt.trigger=='click'){ clickshow(); }else{ hovershow(); } } function hovershow(){ $(opt.boxcell).find(opt.hdcell).hover(function(){ var _this = $(this).parent(); if(!_this.hasclass('on')){ $(opt.boxcell).children().removeclass('on').find(opt.bdcell).stop(true,true).slideup(); _this.addclass('on').find(opt.bdcell).stop(true,true).slidedown(); } },function(){}); } function clickshow(){ $(opt.boxcell).find(opt.hdcell).click(function(){ var _this = $(this).parent(); if(_this.hasclass('on')){ _this.removeclass('on').find(opt.bdcell).stop(true,true).slideup(); }else{ $(opt.boxcell).children().removeclass('on').find(opt.bdcell).stop(true,true).slideup(); _this.addclass('on').find(opt.bdcell).stop(true,true).slidedown(); } }); } }, //导航 nav : function(){ this.returntop(); $('.lh-nav li').each(function(){ var _this = $(this); var length = _this.find('.lh-nav-toogle dl').length; if(length>6){ _this.find('.lh-nav-toogle .container').css({'max-width':'90%'}); } }); //视频弹窗 if($('.lh-video-layer').length>0){ $('.lh-video-btn').click(function(){ if($(this).attr('video')){ $('.lh-video-layer video').attr('src',$(this).attr('video')) } $('body').addclass('video'); $('.lh-video-layer video')[0].play(); }); $('.lh-layer-btn').click(function(){ $('body').removeclass('video'); $('.lh-video-layer video')[0].pause(); }); $('.lh-video-layer video')[0].onended=function(){ $('body').removeclass('video'); } } //团队风采 if($('.lh-demeanour-banner').length>0){ var slidesperview=4; if(this.winwidth<=980){ slidesperview=2; } this.banner({boxcell:'.lh-demeanour-banner',effect:'slide',slidesperview:slidesperview}) } //发展历程 if($('.lh-course-banner').length>0){ var slidesperview=5; if(this.winwidth<=980){ slidesperview=2; } this.banner({boxcell:'.lh-course-banner',effect:'slide',slidesperview:slidesperview}) } //加入我们 查看职位 if($('.lh-joina-banner').length>0){ this.banner({boxcell:'.lh-joina-banner',effect:'slide',paginationtype:'fraction',pagination:'.pa1',nextel:'.next1',prevel:'.prev1'}); } if($('.lh-joinar-banner').length>0){ this.banner({boxcell:'.lh-joinar-banner',effect:'slide',paginationtype:'fraction',pagination:'.pa2',nextel:'.next2',prevel:'.prev2'}); } //招聘头部 if($('.lh-recruitment-header').length>0){ $('.lh-recruitment-nav-btn').click(function(){ if($(this).hasclass('on')){ $(this).removeclass('on'); $('body').removeclass('recruitment'); }else{ $(this).addclass('on'); $('body').addclass('recruitment'); } }); } //tab切换 if($('.lhtab').length>0){ this.tab(); } //手风琴 if($('.lhaccordion').length>0){ this.accordion({boxcell:'.lhaccordion'}); } //推荐新闻 if($('.lh-recomnews-banner').length>0){ var slidesperview=3; if(this.winwidth<=980){ slidesperview=2; } this.banner({boxcell:'.lh-recomnews-banner',slidesperview:slidesperview,effect:'slide',speed:600}); } //成功案例 if($('.lh-casesuccessful-banner').length>0){ for(var i=1;i<=3;i++){ public.banner({boxcell:'.casesuccessful'+i,effect:'slide',pagination:'.casesuccessfulbtn'+i}); } $('.lh-casesuccessful-bd>div').eq(0).show().find('.lh-casesuccessful-banner').show(); $('.lh-casesuccessful-hd li').eq(0).addclass('on'); $('.lh-casesuccessful-hd li').click(function(){ var _this = $(this),_index = _this.index(); _this.addclass('on').siblings().removeclass('on'); $('.lh-casesuccessful-bd>div').hide(); $('.lh-casesuccessful-bd>div').eq(_index).show(); }); } //产品/系统解决方案 if($('.lh-solution-banner').length>0){ var slidesperview=4; if(this.winwidth<=980){ slidesperview=2; } this.banner({boxcell:'.lh-solution-banner',slidesperview:slidesperview,effect:'slide'}); } //行业解决方案展开收起 if($('.lh-toggle-btn').length>0){ if($('.lh-solutions-item li').length<7){ $('.lh-toggle-btn').css({display:'none'}); $('.lh-solutions-a').css({height:'auto',overflow:'initial'}) }else{ $('.lh-toggle-btn').click(function(){ var _this = $(this); var height = $('.lh-solutions-item li').outerheight(),length = math.ceil($('.lh-solutions-item li').length/3); var ulheight = height*length; if(_this.hasclass('on')){ _this.removeclass('on').children('h2').text('展开更多'); $('.lh-solutions-a').height(313); }else{ _this.addclass('on').children('h2').text('收起'); $('.lh-solutions-a').height(ulheight); } }); } } //二级栏目 if($('.lh-other-nav').length>0){ if($('.lh-other-nav li').length<=3){ $('.lh-other-nav').addclass('othernav3'); } if($('.lh-other-nav li').length==4){ $('.lh-other-nav').addclass('othernav4'); } } //三级栏目 if($('.lh-three-item').length>0){ if($('.lh-three-item li').length>=8){ $('.lh-cursom').css({display:'none'}); } } //二级展开 function totallj(){ var n=0; $('.lh-sidebar-item>li').each(function(){ if($(this).hasclass('on')){ return false; } $('.lh-sidebar-two').each(function(){ if($(this).hasclass('hover')){ return false; } n+=$(this).find('li').size(); }) }) return n; } if(this.winwidth>1024){//电脑版 //seacrh if($('.lh-search-layer').length>0){ $('.lh-search-btn').click(function(){ $('body').addclass('search'); }); $('.lh-search-close').click(function(){ $('body').removeclass('search'); }); } //nav $('.lh-nav li').hover(function(){ var _this = $(this); if(_this.find('.lh-nav-toogle').length>0){ _this.addclass('hover'); } },function(){ var _this = $(this); if(_this.find('.lh-nav-toogle').length>0){ _this.removeclass('hover'); } }); //左侧map var cc=true; $('.lh-header-l').hover(function(){ $('.lh-sidebar').addclass('hover'); },function(){ settimeout(function(){ if(cc){ $('.lh-sidebar').removeclass('hover'); } },100); }); //三级展示 $('.lh-sidebar-item>li').hover(function(){ var _this = $(this),_index = _this.index(); _this.addclass('on').siblings().removeclass('on'); $('.lh-sidebar-a>ul').removeclass('hover'); $('.lh-sidebar-b>ul').removeclass('hover'); if($('.lh-sidebar-a>ul').eq(_index).children().length>0){ $('.lh-sidebar-a>ul').eq(_index).addclass('hover'); } },function(){}); //产品展示 $('.lh-sidebar-two>li').hover(function(){ var _this = $(this),_index = _this.index(); $('.lh-sidebar-two>li').removeclass('on'); _this.addclass('on').siblings().removeclass('on'); _index+=totallj(); $('.lh-sidebar-b>ul').removeclass('hover'); if($('.lh-sidebar-b>ul').eq(_index).children().length>0){ $('.lh-sidebar-b>ul').eq(_index).addclass('hover'); } },function(){}); //移出 $('.lh-sidebar').hover(function(){ cc=false; },function(){ cc=true; $('.lh-sidebar-item>li').removeclass('on'); $('.lh-sidebar-two>li').removeclass('on'); $('.lh-sidebar-b>ul').removeclass('hover'); settimeout(aa,250); function aa(){ $('.lh-sidebar-a>ul').removeclass('hover'); } settimeout(bb,500); function bb(){ $('.lh-sidebar').removeclass('hover'); } }); }else{//手机版 $('.lh-header-l').click(function(){ if($(this).hasclass('on')){ $(this).removeclass('on'); $('body').removeclass('webon'); }else{ $(this).addclass('on'); $('body').addclass('webon'); } }); $('.lh-sidebar-item li').click(function(){ event.stoppropagation(); var _this=$(this),_index=_this.index(); _this.addclass('on').siblings().removeclass('on'); $('.lh-sidebar-a>ul').removeclass('on'); if($('.lh-sidebar-a>ul').eq(_index).children().length>0){ $('.lh-sidebar-a').addclass('on'); $('.lh-sidebar-a>ul').eq(_index).addclass('on'); } }); function totallj1(){ var n=0; $('.lh-sidebar-item>li').each(function(){ if($(this).hasclass('on')){ return false; } $('.lh-sidebar-two').each(function(){ if($(this).hasclass('on')){ return false; } n+=$(this).find('li').size(); }) }) return n; } $('.lh-sidebar-two li').click(function(){ event.stoppropagation(); var _this=$(this),_index=_this.index(); _index+=totallj1(); $('.lh-sidebar-b>ul').removeclass('on'); if($('.lh-sidebar-b>ul').eq(_index).children().length>0){ $('.lh-sidebar-b').addclass('on'); $('.lh-sidebar-b>ul').eq(_index).addclass('on'); } }); //返回 $('.lh-return').click(function(){ $(this).parent().removeclass('on'); $(this).parent().children('ul').removeclass('on'); }); } //banner if($(".lh-banner").length>0){ this.banner1({boxcell:'.lh-banner'}); this.mouse({boxcell:'.lh-banner',boxfun:function(_this,e){ tweenlite.to($('.lh-banner .bg'), 1.5,{x:-e}); }}) } //解决方案 /*if($('.lh-plan-item').length>0 && this.winwidth>1024){ plan(); $(window).resize(function(e) { plan(); }); function plan(){ var winwidth = $(window).width(),length =$('.lh-plan-item li').length; $('.lh-plan-item li').width(math.ceil(winwidth/length)); $('.lh-plan-item li').hover(function(){ $('.lh-plan-item li').width(math.ceil(winwidth/length)); $(this).width(370); }); } }*/ //解决方案 if($('.lh-plan-banner').length>0){ var slidesperview = 6; if($(window).width()<=980){ slidesperview=2; } this.banner1({boxcell:'.lh-plan-banner',slidesperview:slidesperview,effect:'slide',delay:2000}); } //研究 if($('.lh-research-banner').length>0){ this.banner({boxcell:'.lh-research-banner',effect:'slide',pagination:'.lh-research-hd',renderbullet: function (index, classname) { return '0' + (index + 1) + ''; },}); } }, //阻止默认行为 preventdefault:function(el){ el.addeventlistener('touchmove',function(e){ e.preventdefault(); }); }, //效果 mouse : function(a){ var a = a || {}; var opt = $.extend({ boxcell : '.lhmouse', boxfun : function(_this,e){ } },a); $(opt.boxcell).on('mousemove',function(e){ var pointx = e.pagex; var pointy = e.pagey; var w = $(window).width()/2; var h = $(window).height()/2; var pianyix = pointx - w ; var pianyiy = pointy - h- $(window).scrolltop(); var jiaodux = (15/w)*pianyix; var jiaoduy = (15/h)*pianyiy; var _this = $(this); opt.boxfun(_this,jiaodux); }) }, returntop : function(){ $('.lhtop').on('click',function(){ $('html,body').animate({scrolltop:'0px'}); }); }, fixednav:function(){ var p=0;t=0; $(window).scroll(function(){ p = $(this).scrolltop(); if(t<=p){ $('body').addclass('fixed'); }else{ $('body').removeclass('fixed'); } t=p; }); } } public.init();