var ismobile = false, w_width = 0, w_height = 0, $mtoph = 0, st = 0, navitem = 0, $menubtn=$('.menu-handler'), $menubox=$(".menubox"); //移动端事件和pc事件的切换 var _mousemove; var _click; var _mousedown; var _mouseup; if (modernizr.touch) { _mousemove = "touchmove"; _click = "touchend"; _mousedown = "touchstart"; _mouseup = "touchend"; _mouseenter = "touchend"; } else { _mousemove = "mousemove"; _click = "click"; _mousedown = "mousedown"; _mouseup = "mouseup"; _mouseenter = "mouseenter"; }; 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(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 () { changetop(); function changetop(){ var st = $(window).scrolltop(); if(st<1){ $('#top').addclass('act'); }else{ $('#top').removeclass('act'); } }; $('#top').bind(_click, function() { $('html,body').stop().animate({scrolltop: 0}, 800); }); var isopen = 0; $('.flinkmore .t').bind(_click, function(){ if(isopen==0){ isopen = 1; $(this).addclass('act'); $('.flinkmore ul').stop().slidedown(300); }else{ isopen = 0; $(this).removeclass('act'); $('.flinkmore ul').stop().slideup(300); } }); $('.flinkmore').mouseleave(function(){ isopen = 0; $('.flinkmore .t').removeclass('act'); $('.flinkmore ul').stop().slideup(300); }); $(window).scroll(function () { var windowtop = $(window).scrolltop(); if (windowtop < w_height && !ismobile) { $('.pbanner .pic2').css('transform', "translate(0px," + (windowtop) / 1.5 + "px)"); }; // changeheader(); // changepnav(); changetop(); }); if($('.pro-nav').size()!=0){ $('.pro-nav li').each(function(i) { $(this).css({ 'transition-delay': i*100 + 'ms', '-webkit-transition-delay': i*100 + 'ms' }); }); }; var _probanner = ($('.pro-banner').size() !== 0); if (_probanner) { $('.pro-banner').slick({ speed: 1000, arrows: false, dots: true, autoplay: true, autoplayspeed: 5000, fade: true, pauseonhover: false }) }; var _pbannerslick = ($('.pbanner-slick').size() !== 0); if (_pbannerslick) { $('.pbanner-slick').on('init', function(event, slick, currentslide, nextslide) { $('.pbanner-slick .item').first().addclass('active'); }); $('.pbanner-slick').slick({ speed: 1000, arrows: false, dots: true, autoplay: true, autoplayspeed: 5000, fade: true, pauseonhover: false }).on('beforechange', function(event, slick, currentslide, nextslide){ $('.pbanner-slick .item').removeclass('active'); $('.pbanner-slick .item').eq(nextslide).addclass('active'); }); } // function changeheader(){ // var st = $(window).scrolltop(); // if(!ismobile){ // if( st > 1 ){ // $('.header').addclass('sheader'); // }else{ // $('.header').removeclass('sheader'); // } // } // }; // changeheader(); // function changepnav(){ // var st = $(window).scrolltop(); // if(!ismobile&&$('.pvpos').size()!=0){ // if( st > $('.pvpos').offset().top - $('.pnav').height() ){ // $('.pnav').addclass('spnav'); // }else{ // $('.pnav').removeclass('spnav'); // } // } // }; // changepnav(); $('.navmobile dd p a').bind(_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); } } }); $menubtn.bind(_click, function () { var w = $menubox.width(); if (navitem == 0) { $('.menublack').stop().fadein(600); $(this).addclass('active'); $menubox.show().stop(false,false).animate({right:0}); navitem = 1; } else { $('.menublack').stop().fadeout(600); $(this).removeclass('active'); $menubox.stop(false,false).animate({right:-w+"px"},function(){ $(this).hide(); }); navitem = 0; }; }); $('.menublack').bind(_click, function () { var w = $menubox.width(); $menubtn.removeclass('active'); $('.menublack').stop().fadeout(600); $menubox.stop(false,false).animate({right:-w+"px"},function(){ $(this).hide(); }); navitem = 0; }); //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 setscroll(anchorcur){ if(jquery(anchorcur).length>=1){ jquery("html,body").animate({ scrolltop: jquery(anchorcur).offset().top-$mtoph}, 0); } }; window.onload = function () { var hash = location.href.split("#")[1]; if (hash) { setscroll("#" + hash); } }; $('.pnav .cur').bind(_click, function(e) { var hash = $(this).attr('href').split("#")[1]; if (hash) { e.preventdefault(); jquery("html,body").animate({ scrolltop: jquery("#"+hash).offset().top-$mtoph},800); } }); $('.vwrap .close,.vwrap .videobtg').bind(_click,function(){ objplay.stop(); $('.vwrap').hide(); $('#videobox').html(''); }); $('.video-btn').bind(_click, function() { var $img = $(this).data('img'); var $video = $(this).data('video'); video.load({ vcontainer: 'videobox', vfimg: $img, vfiles: $video, isautoplay: 'true' }); $('.vwrap').fadein(); }); $(document).on(_click,'.ly-box',function(e){ if ($(e.target).hasclass('ly-box')) { $('.ly-box').remove(); $('html').removeclass('open'); } }); $(document).on(_click,'.ly-close',function(){ $('.ly-box').remove(); $('html').removeclass('open'); }); $(document).on(_click,'.pt-back .back',function(){ $('.ly-box').remove(); $('html').removeclass('open'); }); $('.ly-btn').click(function(e){ e.preventdefault(); var $this = $(this); getlayerajax($this, $this.attr('href')); }); $(document).on(_click,'.pt-back .arrow',function(e){ e.preventdefault(); var $this = $(this), url = $this.attr('href'); if(url!=""){ getlayerajax($this, url); }else{ alert("没有了...o(╥﹏╥)o") } }); }); $(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,width: w_width }); $('.imgshowdemo .item').css({ height: w_height }); jquery(window).resize(function(){ $(".imgshowbox").css({ height: w_height }); $('.imgshowdemo').css({ height: w_height,width: w_width }); $('.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 showmap(zuobiao, showmapinfo, zoom) { var arrzuobiao = zuobiao.split(','); var map = new bmap.map("map"); var point = new bmap.point(arrzuobiao[0], arrzuobiao[1]); var marker = new bmap.marker(point, { icon: new bmap.icon("images/mapi.png", new bmap.size(48, 64)) }) map.addoverlay(marker); map.addcontrol(new bmap.navigationcontrol()); marker.setanimation(bmap_animation_bounce); map.centerandzoom(point, zoom); map.disablescrollwheelzoom(); var opts = { width: 240 } var infowindow = new bmap.infowindow(showmapinfo, opts); marker.addeventlistener("click", function () { map.openinfowindow(infowindow,point); }); // map.setmapstyle({style:'grayscale'}); }; var objplay; var video = { 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 }); return objplay; } }; 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 getlayerheight(item) { var h = item.height(); if(h