var istouch = modernizr.touch, ismobile = false,//区分移动端与pc端 mobile = false,//区分手机端与平板 w_width = 0, w_height = 0, navitem = 0, h_height = 0, roll = 0, stop = 150, produs = 0, st = 0; var _mousemove; var _click; var _mousedown; var _mouseup; //移动端事件和pc事件的切换 if (modernizr.touch) { _mousemove = "touchmove"; _click = "touchend"; _mousedown = "touchstart"; _mouseup = "touchend"; } else { _mousemove = "mousemove"; _click = "click"; _mousedown = "mousedown"; _mouseup = "mouseup"; }; function pagebox() { w_width = jquery(window).width(); w_height = jquery(window).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 >= 1280) { var st = $(window).scrolltop(); var pbanh = $('.pbanner').height(); var headh = $('.header-box.scoll').height(); if (st >= (pbanh - headh)) { $('.common-menu').addclass('scoll1'); } else { $('.common-menu').removeclass('scoll1'); } if (st < 1) { $('.header-box').removeclass('scoll'); } else { $('.header-box').addclass('scoll'); } $(window).scroll(function () { var st = $(window).scrolltop(); var pbanh = $('.pbanner').height(); var headh = $('.header-box.scoll').height(); if (st >= (pbanh - headh)) { $('.common-menu').addclass('scoll1'); } else { $('.common-menu').removeclass('scoll1'); } if (st < 1) { $('.header-box').removeclass('scoll'); } else { $('.header-box').addclass('scoll'); } }); } } pagebox(); jquery(window).resize(function () { pagebox(); }); $(window).load(function () { $('.menubox').bind('click', function () { $('.iphone-mark').addclass('on'); $('.iphone-menu').addclass('on'); }); $('.closem,.iphone-mark').bind('click', function () { $('.iphone-mark').removeclass('on'); $('.iphone-menu').removeclass('on'); }); }); if ($(".nav >li").hasclass("current")) { var _index = $(".nav >li.current").index(); } $(".nav >li").mouseenter(function () { $(this).addclass("current").siblings().removeclass("current"); if ($(this).find('.menu-dwons li').length > 1) { $(this).find('.menu-dwons').stop(true, true).slidedown(); } else { $(this).find('.menu-dwons').stop(true, true).slideup() } }).mouseleave(function () { $(this).removeclass("current");; $(".nav >li").eq(_index).addclass("current"); $(this).find(".menu-dwons").stop(true, true).slideup(); }) var spam = ""; var text = ""; $('.menusd span').click(function (e) { e.stoppropagation(); $(this).parents('.menusd').toggleclass('on'); $(this).parents('.menusd').find('.menus-down').stop(true, true).slidetoggle(); }); $('.menusd .menus-down a').click(function () { $(this).parents('.menusd').removeclass('on'); $(this).parents('.menusd').find('.menus-down').stop(true, true).slidetoggle(); }); $(document).on('click', function (e) { e.stoppropagation(); $(".menus-down").slideup(); }); var style = ''; $(".menus-down a").each(function (index) { style += '.menus-down a:nth-child(' + (index + 1) + '):after {animation-delay:' + ((index + 1) / 10) + 's} '; }); gethash(); jquery(".menu-inner li a").click(function (e) { var hash = jquery(this).attr("href").split("#")[1]; if (hash && jquery("#" + hash).length == 1) { e.preventdefault(); setscroll("#" + hash); } }); function gethash() { var hash = location.href.split("#")[1]; if (hash) { setscroll("#" + hash); } }; var scnum = 0; function setscroll(anchorcur) { if (!ismobile) { scnum = $('.header-box').outerheight(); } else { scnum = $('.header-box').outerheight(); } if (jquery(anchorcur).length) jquery("html,body").animate({ scrolltop: jquery(anchorcur).offset().top - scnum },20); }; jquery(window).scroll(function () { var windowtop = jquery(window).scrolltop(); if (windowtop < w_height && !ismobile) { jquery('.pbanner img').css('transform', "translate(0px," + (windowtop) / 1.5 + "px)"); }; }); 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 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 }); }; };