var istouch = modernizr.touchevents, ismobile = false, win_width = 0, win_height = 0, ath=0, scrollh=0, $menubtn=jquery('.menu-handler'), $menubox=jquery(".menubox"), $menumobile=jquery("#navmobile"), $menua=$menumobile.find("a"), $msubnav=$menumobile.find(".msubnav"), dannum=0, serachitem=0, scrollhpro=0, anavh=0; var pageinit = { init: function () { win_width = $(window).width(); win_height = $(window).height(); if (win_width <= 1024) { ismobile = true; $menubtn.removeclass("active"); $menubox.removeclass("openmneu"); navitem = 0; ath=70; jquery(".cpnav").bind("click",function(){ if(dannum==0){ jquery(this).next(".pnavbox").fadein(); dannum=1; }else{ jquery(this).next(".pnavbox").fadeout(); dannum=0; } }); } else if (win_width > 1024) { ismobile = false; ath=80; dannum=0; jquery(".cpnav").unbind("click"); jquery(".cpnav").next(".pnavbox").show(); }; }, setimgmax: function(img, imgw, imgh, tw, th) { var twidth = tw || win_width; var theight = th || win_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 }); }; } }, menu={ init:function(){ $menubtn.bind("click", function () { if (navitem == 0) { jquery(this).addclass("active"); $menubox.addclass("openmneu"); navitem = 1; }else{ jquery(this).removeclass("active"); $menubox.removeclass("openmneu"); navitem = 0; } }); } }, mobilenav={ init:function(){ jquery("#navmobile>dd>p>a").click(function (e) { var navcur = $(this); var navdd = $(this).parents("p").parents("dd"); if (navdd.find(".msubnav").size() > 0) { if (navcur.hasclass("cur")) { navdd.find(".msubnav").stop(false, false).slideup(); navcur.removeclass("cur"); } else { $menua.removeclass("cur"); $msubnav.stop(false, false).slideup(); navdd.find(".msubnav").stop(false, false).slidedown(); navcur.addclass("cur"); e.preventdefault(); } } }); } }, serachform = { trigger: ".serachbtn", init: function () { serachform.bind(); }, bind: function () { $(document).on("click", serachform.trigger, serachform.open); }, open: function () { if (serachitem==1) { $(".serachibox").removeclass("active"); serachitem=0; } else { $(".serachibox").addclass("active"); serachitem=1; } } }; jquery(window).resize(function () { pageinit.init(); }); function gethash(){ var hash = location.href.split("#")[1]; if(hash){ setscroll("#"+hash); } }; function setscroll(anchorcur) { jquery("html,body").delay(300).animate({ scrolltop: jquery(anchorcur).offset().top - ath -anavh}, 800, 'easeinoutexpo'); }; setpopup(jquery(".c"), "官方微信"); 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; }); }; function pagebanner() { if(!ismobile){ jquery('.pbanner2').css("height",jquery(".pbanner2 img").height()); }else{ jquery('.pbanner2').css("height","auto"); } if(jquery(".pagenav").length>=1){ scrollh=jquery(".pbanner2 img").height()-ath; } }; load(); function load() { var maxnum = $(".pbanner2 img").size(); var curnum = 0; jquery(".pbanner2 img").each(function () { $(this).attr("src", $(this).attr("_src")); jquery(this).load(function () { curnum++; if (curnum == maxnum) { pagebanner(); } }); }); }; jquery(function(){ pageinit.init(), menu.init(); mobilenav.init(); serachform.init(); jquery(".backtop").bind("click", function() {jquery('html, body').stop().animate({scrolltop: 0}, 800,'easeinoutexpo');}); if(jquery(window).scrolltop()>0){ jquery(".header").addclass("topfix"); } function pbannerw(){ if(!ismobile){ jquery(".pbanner").css({"height":win_height,"width":win_width}); pageinit.setimgmax(jquery(".pbanner img"),1920,900,win_width,win_height); }else{ jquery(".pbanner").css({"height":"auto","width":"100%"}); jquery(".pbanner img").attr("style","").css({"position":"relative"}); } }; pbannerw(); var $pbanner=jquery(".pbanner"); if($pbanner.length>=1){ var anavnum=jquery(".aboutnav a").index(jquery(".aboutnav .active")); jquery(".pbanner .img").eq(anavnum).addclass("active"); settimeout(function() { $pbanner.addclass('trans-1'); $pbanner.removeclass('picw'); }, 100); settimeout(function() { $pbanner.removeclass('trans-1'); }, 600); }; jquery(window).resize(function(){ pbannerw(); pagebanner(); }); jquery(".aboutnav a").mouseenter(function(e){ var $this = jquery(this); var num=jquery(".aboutnav a").index($this); var num2=jquery(".aboutnav a").index(jquery(".aboutnav a.active")); if(!ismobile && num!=num2){ jquery(".pbanner .img").eq(num).addclass("ashow").fadein(); } }).mouseleave(function(){ var $this = jquery(this); var num=jquery(".aboutnav a").index($this); var num2=jquery(".aboutnav a").index(jquery(".aboutnav a.active")); if(!ismobile && num!=num2){ jquery(".pbanner .img").eq(num).removeclass("ashow").fadeout(); } }); jquery(".pnavbox a").click(function(){ if(ismobile){ jquery(this).parent().fadeout(); } dannum=0; $('.cpnav .name').html($(this).text()); }); if(jquery(".pagenav").length>=1){ scrollh=jquery(".pagenav").offset().top-ath; } if(jquery(".productnav").length>=1){ scrollhpro=jquery(".productnav").offset().top-ath; } jquery(window).scroll(function () { var windowtop=jquery(window).scrolltop(); if(windowtop>0){ jquery(".header").addclass("topfix"); }else{ jquery(".header").removeclass("topfix"); }; if (windowtop < win_height && !ismobile) { jquery('.pbanner img').css('transform',"translate(0px,"+(windowtop) / 1.5+"px)"); jquery('.pbanner2 img').css('transform',"translate(0px,"+(windowtop) / 1.5+"px)"); } if(windowtop>scrollh){ jquery(".pagenav").addclass("fixed"); }else if(windowtopscrollhpro && !ismobile){ jquery(".productnav").addclass("fixed"); }else if(windowtop=1){ settimeout(function() { $pbanner2.addclass('trans-1'); $pbanner2.removeclass('picw'); }, 100); settimeout(function() { $pbanner2.removeclass('trans-1'); }, 600); }; window.onload = function () { gethash(); } }); function openshowimg(num) { $('html').addclass('openimg'); jquery("body").append('
/
'); for(var i = 0 ; i < imglist.length ; i++){ $('.imgshowdemo').append('
') var imgurl = imglist.eq(i).attr('data-img'); var imgtitle = imglist.eq(i).attr('data-title'); $('.imgshowdemo .item').eq(i).find(".img").attr("src",imgurl); $('.imgshowdemo .item').eq(i).find('.i').html(imgtitle); } $(".imgshowbox").css({ height: win_height }); $('.imgshowdemo').css({ height: win_height }); $('.imgshowdemo .item').css({ height: win_height }); jquery(window).resize(function(){ $(".imgshowbox").css({ height: win_height }); $('.imgshowdemo').css({ height: win_height }); $('.imgshowdemo .item').css({ height: win_height }); }); var imgowl=jquery(".imgshowdemo").owlcarousel({ items: 1, slidespeed : 600, autoplay: false, navigation: true, pagination: false, singleitem: true, rewindnav: false, aftermove: function () { $(".ovnum").html(this.owl.currentitem + 1); }, afteraction: function () { $(".ovnum").html(1); $(".maxnum").html(this.owl.owlitems.length); } }); imgowl.data('owlcarousel').jumpto(num); $('.imgshowbox').addclass('img-show'); } setpopup($('.weixin'), "官方微信"); setpopup($('.a3'), "官方微信"); 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; }); };