var istouch = modernizr.touch, ismobile = false,//区分移动端与pc端 mobile = false,//区分手机端与平板 w_width = 0, w_height = 0, $mtoph = 0, st = 0, navitem = 0, $menubtn=$('.menu-handler'), $menubox=$(".menubox"), pbah = 0; //移动端事件和pc事件的切换 var _mousemove; var _click; var _mousedown; var _mouseup; if (modernizr.touch) { _mousemove = "touchmove"; _click = "touchend"; _mousedown = "touchstart"; _mouseup = "touchend"; } else { _mousemove = "mousemove"; _click = "click"; _mousedown = "mousedown"; _mouseup = "mouseup"; }; function pagebox() { w_width = $(window).width(); w_height = $(window).height(); $hdh = $('.header').innerheight(); $mtoph = $('.mtop').height(); if (w_width <= 1024) { ismobile = true; } else if (w_width > 1024) { ismobile = false; }; if (w_width <= 640) { mobile = true; } else if (w_width > 640) { mobile = false; }; if( w_width > 1152 ){ pbah = $hdh; }else{ pbah = $mtoph; } if( w_width > 861 ){ $('.pbanner').css({height:w_height - pbah}); setimgmax($('.pbanner .pic'), 1880, 834, w_width, w_height - pbah); }else{ $('.pbanner').css({height:"auto"}); $('.pbanner .pic').attr("style",""); } }; pagebox(); $(window).resize(function () { pagebox(); }); var menu = { trigger: ".menu-handler", init: function () { menu.bind(); }, bind: function () { $(document).on("click", menu.trigger, menu.open); $(document).on("click", ".navmobile dd p a", function (e) { var stcur = $(this); var stdd = $(this).parents("p").parents("dd"); if (stdd.find(".msubnav").size() > 0) { if (stcur.hasclass("cur")) { stdd.find(".msubnav").stop(false, false).slideup(); stcur.removeclass("cur"); } else { jquery(".navmobile dd p a").removeclass("cur"); jquery(".msubnav").stop(false, false).slideup(); stdd.find(".msubnav").stop(false, false).slidedown(); stcur.addclass("cur"); e.preventdefault(); } } }); $(document).on("click", "#bg-santai", menu.open) }, open: function () { if ($("body").is(".open")) { $("body").removeclass("open"); $(".menu-handler").removeclass("active"); $("#bg-santai").fadeto("fast", 0, function () { $("#bg-santai").hide(); }); } else { $("#bg-santai").fadeto("fast", 0.4); $("body").addclass("open"); $(".menu-handler").addclass("active"); } } }; $(function () { $(window).scroll(function () { st = $(window).scrolltop(); if (st < w_height&&$('.pbanner').size()!=0&&!ismobile) { $('.pbanner .pic').css('transform',"translate(0px,"+(st) / 1.5+"px)"); } changeheader(); }); //pc nav $('.nav li').mouseenter(function(){ if($(this).find('.tnavbox').size()!=0){ $(this).find('.tnavbox').addclass('show'); } }).mouseleave(function(){ if($(this).find('.tnavbox').size()!=0){ $(this).find('.tnavbox').removeclass('show'); } }); if($('.pbanner').length>=1){ settimeout(function() { $('.pbanner').addclass('trans-1'); $('.pbanner').removeclass('picw'); //$('.pbtxts .transx').addclass('transshow'); //$('.pbtxts .transx2').addclass('transshow'); }, 100); settimeout(function() { $('.pbanner').removeclass('trans-1'); }, 600); }; if(w_width>1153){ $('.menu-handler').bind(_click, function(){ if (navitem == 0) { $(this).addclass('active'); $('.htnavbox').addclass('shownav'); navitem = 1; }else{ $(this).removeclass('active'); $('.htnavbox').removeclass('shownav'); navitem = 0; }; }); }else{ menu.init(); } function changeheader(){ if($('.header2').size()!=0&&!ismobile){ st = $(window).scrolltop(); if(st > $hdh){ $('.header2').addclass('show'); }else{ $('.header2').removeclass('show'); } } }; changeheader(); $('.bamouse').click(function(){ $("html,body").animate({scrolltop:w_height},800,"easeinoutexpo"); }); //pc nav end //手机nav /* function gethash() { var hash = location.href.split("#")[1]; if (hash) { settimeout(function () { $("html,body").animate({ scrolltop: $("#" + hash).offset().top - $mtoph }, 800); }, 250); } }; gethash(); $('.abnav li').click(function(){ var phash = $(this).find('a').attr('href').split("#")[1]; if (phash) { settimeout(function () { $("html,body").animate({ scrolltop: $("#" + phash).offset().top - $mtoph - 36 }, 800,'easeinoutexpo'); }, 250); $(this).find('a').addclass('act').end().siblings().find('a').removeclass('act'); } }); */ //back top -- 回到顶部 /* $('#top').click(function(){ $('html,body').stop().animate({scrolltop:0},500,"easeinoutexpo"); }); */ //weixin setpopup($('.weixin'), "官方微信"); function setpopup(obj, title) { obj.click(function () { var str = '
'; $("body").append(str); jquery(".popupblack").fadein(); jquery(".popup").animate({margintop:"-127"},400); $(".popup .close").click(function () { $(".popupblack").remove(); }); jquery(".popupblack").click(function(){$(".popupblack").remove();}); return false; }); }; //输入框 /* $('.s-input').bind({ focus:function(){ if (this.value == this.defaultvalue){ this.value=""; } },blur:function(){ if (this.value == ""){ this.value = this.defaultvalue; } } }) */ //video -- 弹框视频 /* $(".vwrap .close,.vwrap .videobtg").click(function () { objplay.stop(); $(".vwrap").hide(); }); $('.ly-video').click(function(){ var videoimg = $(this).attr('data-img'); var videourl = $(this).attr('data-url'); var onj = videourl; if (onj != '') { $(".vwrap").fadein(); tonyvideo.load({ vcontainer: videobox, vfiles: videourl, vfimg: videoimg, isautoplay: 'true' }); isvideo = true; }; }) */ }); //video /* var objplay; var tonyvideo = { load: function (objs) { objplay = jwplayer(objs.vcontainer).setup({ flashplayer: 'js/video/flashplay.swf', html5player: 'js/video/html5player.js', file: objs.vfiles, image: objs.vfimg, width: '100%', height:'100%', aspectratio:'16:9', stretching:'fill', controls: 'true', autostart: objs.isautoplay, repeat: "always" }); return objplay; } } */ //传参 /*function geturlparam(url, name) { var pattern = new regexp("[?&]" + name + "\=([^&]+)", "g"); var matcher = pattern.exec(url); var items = null; if (null != matcher) { try { items = decodeuricomponent(decodeuricomponent(matcher[1])); } catch (e) { try { items = decodeuricomponent(matcher[1]); } catch (e) { items = matcher[1]; } } } return items; };*/ //img 尺寸 function setimgmax(img, imgw, imgh, tw, th) { var twidth = tw || w_width; var theight = th || w_height; var coe = imgh / imgw; var coe2 = theight / twidth; if (coe < coe2) { var imgwidth = theight / coe; img.css({ height: theight, width: imgwidth, left: -(imgwidth - twidth) / 2, top: 0 }); } else { var imgheight = twidth * coe; img.css({ height: imgheight, width: twidth, left: 0, top: -(imgheight - theight) / 2 }); }; };