// javascript document $(document).ready(function() { new wow().init(); //导航 new nav('.nav','.nav-btn') layui.use('layer', function(){ var layer = layui.layer; //相册弹层 layer.photos({ photos: '#layer-photos' ,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数) ,shade: .85 }); var vid = 0; $('.video-btn').each(function(index,el){ $(this).attr('data-num',index); }) $('.video-btn').click(function(e){ vid = $(this).attr('data-num'); var flag = false; var type = ["mp4"]; var tit = $(this).attr('data-title')?$(this).attr('data-title'):''; var index = $(this).attr('data-video').lastindexof("."); var ext = $(this).attr('data-video').substr(index+1); //循环比较 for(var i=0;i当前浏览器不支持 video直接播放', }); var video = document.getelementbyid("video"); video.play(); }else{ layer.open({ type: 2, title: false, shade: 0.7, anim: 5, isoutanim:false, skin:'video-show', content: $(this).attr('data-video'), }); } //创建按钮名称 $('.video-show .layui-layer-content').append('
'+tit+'
'); vidbtn('.video-prev','.video-next',vid,0,$('.video-btn').length); }); //视频切换 $('body').on('click','.video-switch-btn',function(){ if($(this).hasclass('video-prev')){ vid--; }else if($(this).hasclass('video-next')){ vid++; } $(this).parent().find('video').attr('src',$("[data-num='"+vid+"']").attr('data-video')); $(this).parent().find('.video-tit span').html($("[data-num='"+vid+"']").attr('data-title')?$("[data-num='"+vid+"']").attr('data-title'):''); var video = document.getelementbyid("video"); video.play(); vidbtn('.video-prev','.video-next',vid,0,$('.video-btn').length); }) //鼠标经过动画 $('.e-anim').hover(function(){ $(this).addclass('anim-on').removeclass('anim-off'); },function(){ $(this).addclass('anim-off').removeclass('anim-on'); }); //鼠标经过显示隐藏动画 $('.e-anim-switch').hover(function(){ animon(this); },function(){ animoff(this); }); //语言 $('.lang dl').click(function(){ if(phoneis()){ $(this).toggleclass('on'); animswitch(this); } }); $('.lang dl').hover(function(){ if(!phoneis()){ $(this).addclass('on'); animon(this); } },function(){ if(!phoneis()){ $(this).removeclass('on'); animoff(this); } }); //实用简易切换普通 $('.tabs-box-ord').each(function(){ $(this).find('.hd-ord>*').eq(0).addclass('on'); $(this).find('.bd-ord>*').eq(0).show().siblings().hide(); $(this).find('.bdl-ord>*').eq(0).show().siblings().hide(); }) $('.tabs-box-ord .hd-ord>*').on('click',function(e){ $(this).addclass('on').siblings().removeclass('on'); $(this).parents('.tabs-box-ord').find('.bd-ord>*').eq($(this).index()).show().siblings().hide(); $(this).parents('.tabs-box-ord').find('.bdl-ord>*').eq($(this).index()).show().siblings().hide(); }) //返回顶部 $('.totop').click(function(){ $('html,body').animate({scrolltop:0}, document.body.scrollheight/10); }) }); //浏览器版本提示 mybrowser(); var tips ="
您当前的浏览器版本过低,网站部分功能将无法正常显示,请更新您的浏览器。
"; if (mybrowser() == "ff") { } if (mybrowser() == "opera") { } if (mybrowser() == "safari") { } if (mybrowser() == "ie55") { $("body").prepend(tips); } if (mybrowser() == "ie6") { $("body").prepend(tips); } if (mybrowser() == "ie7") { $("body").prepend(tips); } if (mybrowser() == "ie8") { $("body").prepend(tips); } }); $(window).scroll(function() { }); var sizetimer = null; $(window).resize(function() { cleartimeout(sizetimer); sizetimer = settimeout(function(){ },400); }); $(window).load(function() { }); //网站类型 function phoneis() { if($('.nav-box .container').outerwidth()<960){ return true }else{ return false; } } //浏览器版本判断 function mybrowser(){ var useragent = navigator.useragent; //取得浏览器的useragent字符串 var isopera = useragent.indexof("opera") > -1; //判断是否opera浏览器 var isie = useragent.indexof("compatible") > -1 && useragent.indexof("msie") > -1 && !isopera; //判断是否ie浏览器 var isff = useragent.indexof("firefox") > -1; //判断是否firefox浏览器 var issafari = useragent.indexof("safari") > -1; //判断是否safari浏览器 if (isie) { var ie5 = ie55 = ie6 = ie7 = ie8 = false; var reie = new regexp("msie (\\d+\\.\\d+);"); reie.test(useragent); var fieversion = parsefloat(regexp["$1"]); ie55 = fieversion == 5.5; ie6 = fieversion == 6.0; ie7 = fieversion == 7.0; ie8 = fieversion == 8.0; if (ie55) { return "ie55"; } if (ie6) { return "ie6"; } if (ie7) { return "ie7"; } if (ie8) { return "ie8"; } }//isie end if (isff) { return "ff"; } if (isopera) { return "opera"; } } //获取左偏移值 function navl(obj){ if(!phoneis()){ $(obj).find('.nav-list-sub').removeattr('style'); var pl = 0; parentleft(obj); var lmax = pl + $(obj).find('.nav-list-height').outerwidth()-$('.container-header').position().left; //判断左偏移加宽度是否超出 if(lmax > $('.nav-box .container').width()){ var l = $('.nav-box .container').width() - lmax; $(obj).find('.nav-list-sub').css('width',$(obj).find('.nav-list-height').outerwidth()+1); $(obj).find('.nav-list-sub').css('left',l); }else{ $(obj).find('.nav-list-sub').css('width',$(obj).find('.nav-list-height').outerwidth()+1); } }else{ $('.nav-list-sub').css('width',''); } //递归到body function parentleft(obj){ if(!$(obj).is('body')){ parentleft($(obj).parent()) } pl += $(obj).position().left; } } //swiper2.x,auto显示数量 function swipersl(cla,obj,ss,mm,ll){ swiperdx(cla,obj,ss,mm,ll); $(window).resize(function() { swiperdx(cla,obj,ss,mm,ll); }); } function swiperdx(c,o,s,m,l){ var w = $('.container').outerwidth(); var x = $(c).outerwidth(); if(w>=960){ $(c).find('.swiper-slide').css('width',x/l); }else if(w>=720){ $(c).find('.swiper-slide').css('width',x/m); }else{ $(c).find('.swiper-slide').css('width',x/s); } o.resizefix(); } //设备横竖屏判断 window.addeventlistener("onorientationchange" in window ? "orientationchange" : "resize", function() { //竖屏 if (window.orientation === 180 || window.orientation === 0) { $('html').removeclass('landscape'); } //横屏时提示 if (window.orientation === 90 || window.orientation === -90 ){ $('html').addclass('landscape'); } }, false); //进入全屏 function enterfullscreen() { var de = document.documentelement; if (de.requestfullscreen) { de.requestfullscreen(); } else if (de.mozrequestfullscreen) { de.mozrequestfullscreen(); } else if (de.webkitrequestfullscreen) { de.webkitrequestfullscreen(); } } //退出全屏 function exitfullscreen() { var de = document; if (de.exitfullscreen) { de.exitfullscreen(); } else if (de.mozcancelfullscreen) { de.mozcancelfullscreen(); } else if (de.webkitcancelfullscreen) { de.webkitcancelfullscreen(); } } //判断是否全屏 $(window).resize(function() { var fullscreenelement = document.fullscreenenabled || document.mozfullscreenelement || document.webkitfullscreenelement; var fullscreenenabled = document.fullscreenenabled || document.mozfullscreenenabled || document.webkitfullscreenenabled; if (fullscreenelement == null) { //非全屏 $('.icon-fullscreen').show(); $('.icon-fullexit').hide(); } else { //全屏 $('.icon-fullscreen').hide(); $('.icon-fullexit').show(); } }); //视频背景居中 function bgvideo(id,opt){ var bgvideo = document.getelementbyid(id); var vidh = opt.height?opt.height:document.body.offsetwidth; var videowh,videovw,videovh,videotime; //视频初始化 bgvideo.onresize = function(){ videosize(); } document.read = function(){ cleartimeout(videotime) videotime = settimeout(function(){videosize()},50); } addeventonload(function(){ cleartimeout(videotime) videotime = settimeout(function(){videosize()},50); }) addeventonresize(function(){ cleartimeout(videotime) videotime = settimeout(function(){videosize()},50); }) //视频背景缩放计算 function videosize(){ videovw = bgvideo.videowidth; videovh = bgvideo.videoheight; videowh =videovw/videovh; var windoww = document.documentelement.clientwidth; var windowh = vidh; //宽高比例比较 if( windoww / windowh > videowh ){ // bgvideo.classlist.add('video-bg-w'); // bgvideo.classlist.remove('video-bg-h'); bgvideo.style.width = windoww+'px'; bgvideo.style.height = windoww/videowh+'px'; }else{ // bgvideo.classlist.add('video-bg-h'); // bgvideo.classlist.remove('video-bg-w'); bgvideo.style.height = windowh+'px'; bgvideo.style.width = windowh*videowh+'px'; } } } //多个ready function addeventready(fn){ var originfn = document.ready document.ready =function () { originfn && originfn() fn() } } //多个onload function addeventonload(fn){ var originfn = window.onload window.onload =function () { originfn && originfn() fn() } } //多个onresize function addeventonresize(fn){ var originfn = window.onresize window.onresize =function () { originfn && originfn() fn() } } //当前日期 function presenttime(){ var show_day=new array('星期日','星期一','星期二','星期三','星期四','星期五','星期六'); var time=new date(); var year=time.getfullyear(); var month=time.getmonth(); var date=time.getdate(); var day=time.getday(); var hh=time.gethours(); var mm=time.getminutes(); var ss=time.getseconds(); month=month+1; month<10?month='0'+month:month; date<10?date='0'+date:date; hh<10?hh='0'+hh:hh; mm<10?mm='0'+mm:hh; ss<10?ss='0'+ss:hh; var now_time=''+year+'年'+month+'月'+date+'日'+' '+show_day[day]+''; $('#present-time').html(now_time); } setinterval(presenttime,100); //滑动监听 var th,tht; var isscroll = false; $(window).on('touchstart',function(e) { clearinterval(tht); th = 0; }); $(window).scroll(function(e) { if(isscroll){ clearinterval(tht); $('.pf-box').addclass('pf-nav-off'); th = 0; tht = setinterval(function(){ th++; if(th>5){ clearinterval(tht); $('.pf-box').removeclass('pf-nav-off'); clearinterval(tht); } }, 50); }else{ isscroll = true; } }); //tabs切换 function tabs(cla,opt){ var obj = this; var oh,nh;//切换前后的高度 //opt接受的参数 var clickevent = true;//是否接受点击事件 var mouseenterevent = true;//是否接受鼠标经过事件 var fun;//切换后的回调,function(index){},返回切换后的index值 //获取定义值 if(opt){ clickevent = opt.clickevent != null?opt.clickevent:clickevent; mouseenterevent = opt.mouseenterevent != null?opt.mouseenterevent:mouseenterevent; fun = opt.fun?opt.fun:''; } var event =''; clickevent?event +=' click':''; mouseenterevent?event +=' mouseenter':''; //鼠标触发切换事件 $(cla).find('.hd>*').on(event,function(e){ //手机版阻止切换按钮的链接跳转 if(phoneis()){ stopdefault(e); } if(!$(this).hasclass('on')){ //获取切换后的index var index = $(this).index(); obj.tabsswitch(index); } }) //tabs方法 //切换方法 obj.tabsswitch = function(i){ //获取切换前高度 oh = $(cla).find('.e-anim-on').outerheight(); $(cla).find('.bd').css({'height':oh}); $(cla).find('.hd>*').eq(i).addclass('on').siblings().removeclass('on'); $(cla).find('.bd>.e-anim-on').removeclass('e-anim-on').addclass('e-anim-off'); $(cla).find('.bd>*').eq(i).removeclass('e-anim-off').addclass('e-anim-on'); //获取切换后高度 nh = $(cla).find('.e-anim-on').outerheight(); $(cla).find('.bd').css({'height':nh}); $(cla).find('.bd>*').each(function(){ var el = this; animoff(el,{'fun':function(){ $(el).parents('.bd').css({'height':''}); }}) }); //切换后回调 fun?fun(i):''; } //初始化 $(cla).find('.bd>*').addclass('e-anim-hide'); obj.tabsswitch(0); } //导航 function nav(cla,btn,opt){ //opt接受的参数 //移动端导航事件 $(btn).click(function(event){ propagation(); //回到顶部 $('html,body').animate({scrolltop:0},100); $(btn).toggleclass('nav-btn-show'); if(!$(btn).hasclass('nav-btn-show')){ closenav() } animswitch(cla); }); //手机版带二级阻止跳转 $(cla).find('li>a').click(function(e){ if(phoneis() && $(this).next('.nav-list-sub').length>0){ stopdefault(e); } }) //手机点击导航 $('.nav li').click(function(){ if(phoneis()){ $('.nav-list-sub').css('height',0); $('.nav-list-sub .e-anim-on').each(function(){ animoff(this); }); $(this).toggleclass('nav-on').siblings().removeclass('nav-on'); if($(this).hasclass('nav-on')){ animon($(this).find('.e-anim-hide')); }else{ animoff($(this).find('.e-anim-hide')); } //获取高度 var navsubh = $(this).hasclass('nav-on') ? $(this).find('.nav-list-height').outerheight() : 0; $(this).find('.nav-list-sub').css('height',navsubh); } }); //导航拦截冒泡 $('.nav-box').click(function(){ propagation(); }); //防ie抖动 $('.nav-list li .on .nav-btn-bg').css({'width':$('.nav-list .on').parent().outerwidth()}) //pc导航鼠标经过 $(cla).find('li').mouseenter(function(){ if(!phoneis()){ $(cla).find('li').removeclass('nav-on'); $(this).addclass('nav-on').siblings().addclass('nav-off'); if($(this).find('.nav-list-sub').length>0){ animon($(this).find('.e-anim-hide')); } //导航滑块 if($('.nav-list li .on').length >= 1){ $('.nav-list li .on .nav-btn-bg').css({'left':$(this).offset().left-$('.nav-list .on').offset().left,'width':$(this).width()})//个别特殊网站可加入误差修正 }else{ $('.nav-btn-bg-02').addclass('nav-btn-bg-02-show').css({'left':$(this).offset().left-$('.nav-list').offset().left-1,'width':$(this).width()}) } if($(this).find('.nav-list-height').length>0){ //二级下拉背景色 $('.nav-list-sub-bg').addclass('e-animte-show nav-list-sub-bg-show'); } //下拉偏移 navl(this); //二级选中 if($(this).find('.nav-list-sub .on').length){ var subon = $(this).find('.nav-list-sub .on'); $(this).find('.nav-list-sub .btn-sub-bg').css({'left':subon.find('span').offset().left-subon.parent().offset().left,'width':subon.find('span').width(),'transition-duration':'0s'}) } } }); //pc导航鼠标离开 $(cla).find('li').mouseleave(function(){ if(!phoneis()){ $(this).removeclass('nav-on').siblings().removeclass('nav-off'); $('.nav-list li .on .nav-btn-bg').removeattr('style'); $('.nav-list li .on .nav-btn-bg').css({'width':$('.nav-list .on').parent().outerwidth()}) if($(this).find('.e-anim-hide').length){ var el = $(this).find('.e-anim-hide'); animoff(el,{fun:function(){ el.parent().css({'width':''}) }}); } //二级下拉背景色 $('.nav-list-sub-bg').removeclass('e-animte-show nav-list-sub-bg-show'); } $(this).find('.btn-sub-bg').css({'width':'','left':''}) }); //pc导航鼠标二级 $(cla).find('.nav-list-sub a').mouseenter(function(){ $(this).parent().find('.btn-sub-bg').css({'left':$(this).find('span').offset().left-$(this).parent().offset().left,'width':$(this).find('span').width(),'transition-duration':''}) }); $('.nav-list').mouseleave(function(){ $('.nav-btn-bg-02').removeclass('nav-btn-bg-02-show').removeattr('style'); }) } //收起导航 function closenav(){ $('.nav-list-sub').css('height',0); $('.nav-list li').removeclass('nav-on'); $('.nav .e-anim-on').each(function(){ animoff(this); }) } //切换动画 function animswitch(obj,onopt,offopt){ var el; if($(obj).hasclass('e-anim-hide')){ el = $(obj); }else{ el = $(obj).children('.e-anim-hide'); } if(!el.hasclass('e-anim-on')){ animon(obj,onopt) }else{ animoff(obj,offopt) } } //添加动画 function animon(obj,opt){ var fun; if(opt){ fun = opt.fun?opt.fun:''; } var el; if($(obj).hasclass('e-anim-hide')){ el = $(obj); }else{ el = $(obj).children('.e-anim-hide'); } el.addclass('e-anim-on').removeclass('e-anim-off'); el[0].addeventlistener('animationend', function () { //回调 fun?fun(obj):''; }); } //移除动画 function animoff(obj,opt){ var fun; var removeoff = true;//动画结束后是否移除 e-anim-off if(opt){ fun = opt.fun?opt.fun:''; opt.removeoff?removeoff = opt.removeoff:''; } var el; if($(obj).hasclass('e-anim-hide')){ el = $(obj); }else{ el = $(obj).children('.e-anim-hide'); } el.removeclass('e-anim-on').addclass('e-anim-off'); el[0].addeventlistener('animationend', function () { //回调 if(el.hasclass('e-anim-off')){ fun?fun(obj):''; } removeoff?el.removeclass('e-anim-off'):''; }); } //字符截取 function substr(str,length){ var a=str.match(/[^\x00-\xff]|\w{1,2}/g); return a.length$('.nav-box').outerheight()+$('.banner-min').outerheight()+$('.banner-box').outerheight()+$('.ind-box').outerheight()+$('.footer-bg').outerheight()){ $('.ind-box').css('min-height',$(window).height()-$('.nav-box').outerheight()-$('.banner-min').outerheight()-$('.banner-box').outerheight()-$('.footer-bg').outerheight()); } } //视频翻页 function vidbtn(prev,next,num,min,max){ $(prev).show(); $(next).show(); if(num == min){ $(prev).hide(); } if(num == max-1){ $(next).hide(); } } //阻止冒泡事件 function propagation(){ if (event.stoppropagation) { // this code is for mozilla and opera event.stoppropagation(); } else if (window.event) { // this code is for ie window.event.cancelbubble = true; } } //阻止跳转 function stopdefault(e) { if ( e && e.preventdefault ) e.preventdefault(); else window.event.returnvalue = false; return false; }