var ismobile = false, w_width = 0, w_height = 0, $mtoph = 0, st = 0, navitem = 0, $menubtn=$('.menu-handler'), $menubox=$(".menubox"), $top = 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(); $mtoph = $('.header').height(); if (w_width <= 1024) { ismobile = true; } else if (w_width > 1024) { ismobile = false; }; if (w_width <= 1200) { $top = $mtoph; } else if (w_width > 1200) { $top = 100; }; if(ismobile){ $('.header').removeclass('sheader'); $('.pnav').removeclass('spnav'); } if(ismobile){ var dannum=0; $('.pnav ul').css('display','none'); $('.pnav').bind('click',function(){ if(dannum==1){ $(this).removeclass('show'); $(this).find('ul').stop().fadeout(); dannum = 0; }else{ $(this).addclass('show'); $(this).find('ul').stop().fadein(); dannum = 1; } }); }else{ $('.pnav').removeclass('show'); $('.pnav ul').css('display','block'); $('.pnav').unbind('click'); } }; pagebox(); $(window).resize(function () { pagebox(); }); $(function () { $menubtn.bind(_click, function () { if (navitem == 0) { jquery(this).addclass("active"); $('.black').addclass('show'); $menubox.show().stop(false,false).animate({right:0}); navitem = 1; } else { $('.black').removeclass('show'); $(this).removeclass("active"); $menubox.stop(false,false).animate({right:-320+"px"},function(){ $(this).hide(); }); navitem = 0; }; }); $('.black').bind(_click, function () { $(this).removeclass('show'); $menubtn.removeclass("active"); $menubox.stop(false,false).animate({right:-320+"px"},function(){ $(this).hide(); }); navitem = 0; }); $('.navmobile dd p a').click(function(e){ if($(this).parent().next('.mtnav').size() >= 1){ if(!$(this).hasclass('act')){ e.preventdefault(); $('.navmobile dd p a').removeclass('act'); $('.mtnav').stop().slideup(300); $(this).addclass('act'); $(this).parent().next('.mtnav').stop().slidedown(300); }else{ $(this).removeclass('act'); $(this).parent().next('.mtnav').stop().slideup(300); } } }); /* var _str = $('.header .h-phone'), _str_word = _str.text().split(''); _str.text(''); for (var i in _str_word) { _str.append('' + _str_word[i] + ''); } */ /* $menubtn.bind(_click, function () { $('.content').addclass('active'); $menubox.addclass('menushow'); $('.menublack').addclass('show'); }); $('.menublack,.menuclose').click(function(){ $('.content').removeclass('active'); $menubox.removeclass('menushow'); $('.menublack').removeclass('show'); }); */ /* $('.navmobile dd p a').click(function(e){ if($(this).parent().next('.mtnav').size() >= 1){ if(!$(this).hasclass('act')){ e.preventdefault(); $('.navmobile dd p a').removeclass('act'); $('.mtnav').stop().slideup(300); $(this).addclass('act'); $(this).parent().next('.mtnav').stop().slidedown(300); }else{ $(this).removeclass('act'); $(this).parent().next('.mtnav').stop().slideup(300); } } }); */ /* function changeheader(){ var st = $(window).scrolltop(); if($('.mtop').size()==0){ if( st > w_height - $headerh ){ $('.header').addclass('sheader'); }else{ $('.header').removeclass('sheader'); } }else{ return; } }; if($('.mtop').size()!=0){ $('.header').addclass('sheader'); } */ settimeout(function(){ changepnav(); changeheader(); //changebacktoptwo(); }, 100); $(window).scroll(function () { changeheader(); changepnav(); var windowtop = $(window).scrolltop(); if (windowtop < w_height && !ismobile) { $('.pbanner .pic2').css('transform', "translate(0px," + (windowtop) / 1.5 + "px)"); }; }); /* var $pbanner=jquery(".pbanner"); if($pbanner.length>=1){ settimeout(function() { $pbanner.addclass('trans-1'); $pbanner.removeclass('picw'); }, 100); }; */ /* $(document).on('click','.depbox,.depclose',function(e){ if ($(e.target).hasclass('depbox')||$(e.target).hasclass('depclose')) { if(!$('.depbox').hasclass('hide')){ $('.depbox').addclass('hide'); }else{ $('.depbox').removeclass('show'); } $('html').removeclass('open'); settimeout(function(){ $('.depbox').remove(); },600); } }); */ /* function gotoabdetail(item,address){ $.ajax({ url: address, datatype: "html", success: function (data) { if (data == "" || data == null) { return; } else { if($('.depbox').size()!=0){ $('.depbox').remove(); $('.content').after(data); $('.depbox').removeclass('hide'); $('html').addclass('open'); }else{ $('.content').after(data); settimeout(function(){ $('html').addclass('open'); $('.depbox').addclass('show'); },100); } } }, error: function (xmlhttprequest, textstatus, errorthrown) { $('.depbox').remove(); } }); }; */ /* $(document).on('click','.adbtn',function(e){ e.preventdefault(); var $this = $(this); gotoabdetail($this, $this.attr("chref")); }); */ function setscroll(anchorcur){ if(jquery(anchorcur).length>=1){ jquery("html,body").animate({ scrolltop: jquery(anchorcur).offset().top-$top}, 0); } }; window.onload = function () { var hash = location.href.split("#")[1]; if (hash) { setscroll("#" + hash); } } jquery(".pnav a").click(function(){ var $this=jquery(this); var hash = $this.attr("href").split("#")[1]; if(hash && jquery("#"+hash).length>=1){ jquery("html,body").animate({ scrolltop: jquery("#"+hash).offset().top-$top},800,'easeinoutexpo'); } }); $('.mtnav a').click(function(){ var mhash = $(this).attr('href').split("#")[1]; if (mhash) { $('.black').removeclass('show'); $menubtn.removeclass("active"); $menubox.stop(false,false).animate({right:-320+"px"},function(){ $(this).hide(); }); navitem = 0; jquery("html,body").animate({ scrolltop: jquery("#"+mhash).offset().top-$top},800,'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; }); }; }); function changeheader(){ st = $(window).scrolltop(); if(w_width>1200){ if( st > 1 ){ $('.header').addclass('sheader'); }else{ $('.header').removeclass('sheader'); } } }; function changepnav(){ st = $(window).scrolltop(); if( w_width > 1200 && $('.pvpos').size() != 0 ){ if( st > $('.pvpos').offset().top - $('.pnav').height() ){ $('.pnav').addclass('spnav'); }else{ $('.pnav').removeclass('spnav'); } } }; $(document).on('click','.overlayclose',function(){ $('.imgshowbox').removeclass('img-show'); jquery('html').removeclass('openimg'); settimeout(function () { jquery('.imgshowbox').remove(); }, 800); }); function openshowimg(num,maxnum) { $('html').addclass('openimg'); jquery("body").append('
'); $(".imgstools .snumbox .actnum").html(num); $(".imgstools .snumbox .allnum").html(maxnum); for(var i = 1 ; i <= maxnum ; i++){ $('.imgshowdemo').append('
'); var imgurl = $("[data-big-num="+i+"]").attr('data-img'); var imgtitle = $("[data-big-num="+i+"]").attr('data-title'); $('.imgshowdemo .item').eq(i-1).find(".img").attr("src",imgurl); $('.imgshowdemo .item').eq(i-1).find('.i').html(imgtitle); } $(".imgshowbox").css({ height: w_height }); $('.imgshowdemo').css({ height: w_height }); $('.imgshowdemo .item').css({ height: w_height }); jquery(window).resize(function(){ $(".imgshowbox").css({ height: w_height }); $('.imgshowdemo').css({ height: w_height }); $('.imgshowdemo .item').css({ height: w_height }); }); var imgowl=$('.imgshowdemo').slick({fade:true,arrows:false}).on('beforechange', function(event, slick, currentslide, nextslide){ $(".imgstools .snumbox .actnum").html(nextslide+1); }); $('.imgstools .imgprev').click(function(e){ e.preventdefault(); imgowl.slick('slickprev'); }); $('.imgstools .imgnext').click(function(e){ e.preventdefault(); imgowl.slick('slicknext'); }); $('.imgshowdemo').slick('slickgoto',num-1); $('.imgshowbox').addclass('img-show'); }; 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 }); }; }; 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; }; var isnum = 1, count_num1,count_num2,count_num3,count_num4,a,b,c,d; function changenum(){ isnum = 0; var options = { useeasing : true, usegrouping : true, separator : '', decimal : '.', prefix : '', suffix : '' }; count_num1=$("#count_1").attr("data-num"); count_num2=$("#count_2").attr("data-num"); count_num3=$("#count_3").attr("data-num"); count_num4=$("#count_4").attr("data-num"); if(count_num1){a=new countup("count_1",0,count_num1,0,2.5,options);} if(count_num2){b=new countup("count_2",0,count_num2,0,2.5,options);} if(count_num3){c=new countup("count_3",0,count_num3,0,2.5,options);} if(count_num4){d=new countup("count_4",0,count_num4,0,2.5,options);} }; function numstart(){ st = $(window).scrolltop(); if(isnum==0) { if(count_num1){a.start();} if(count_num2){b.start();} if(count_num3){c.start();} if(count_num4){d.start();} isnum = 1; }else{ return true; } };