var isTouch = Modernizr.touch, isMobile = false,//区分移动端与PC端 mobile = false,//区分手机端与平板 w_width = 0, w_height = 0, $mtoph = 0, ST = 0, navItem = 1, $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'), 1920, 915, w_width, w_height); }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').removeClass('showNav'); navItem = 1; }else{ $(this).removeClass('active'); $('.htnavbox').addClass('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 }); }; };