var isTouch = Modernizr.touch, isMobile = false,//区分移动端与PC端 mobile = false,//区分手机端与平板 w_width = 0, w_height = 0, bannerImgh = 638, 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 (!isMobile) { ST = $(window).scrollTop(); if (ST < 1) { $('.header-box').removeClass('scollfox'); } else { console.log(22) $('.header-box').addClass('scollfox'); } $(window).scroll(function () { ST = $(window).scrollTop(); if (ST < 1) { $('.header-box').removeClass('scollfox'); } else { $('.header-box').addClass('scollfox'); } }); } else { $('.header-box').removeClass('scollfox'); $('.devote,.eventnew,.pbannerfix,.common-t,.intro-text,.video-info,.brand-top,.profile-text,.honor-list,.sundat,.farmtop,.story-tab,.farmborder').removeClass('article-block'); } var $padd = $('.innerbox'); paddw = parseInt($padd.css('paddingLeft')) + parseInt($padd.css('paddingRight')); var $pbanner = $('.pbanner'); var hheight = $('.header-box').innerHeight(); $('.pbanner').css('height', w_height - hheight); $('.pbanner figure').css('height', w_height - hheight); setImgMax($('.pbanner figure img'), 1800, 830, w_width - paddw, w_height - hheight); } pageBox(); jQuery(window).resize(function () { pageBox(); }); var Spam = ""; var text = ""; $('.friendlinks span').click(function (e) { e.stopPropagation(); $(this).toggleClass('on'); $(this).parents('.friendlinks').find('ul').slideToggle(); }); $(document).on('click', function (e) { e.stopPropagation(); $(".friend-down").slideUp(); }); jQuery(".menuBtn").click(function () { $(".menubox").toggleClass("on"); $(".home").toggleClass("on"); $(".header-box").toggleClass("on"); $(".innerbox").toggleClass("on"); }); $('.leval').removeClass('show'); if ($(".nav >li").hasClass("creent")) { var indexs = $('.nav li.creent').index(); } $('.nav >li').hover(function () { $('.leval').removeClass('show'); $(this).toggleClass('creent').siblings().removeClass('creent'); $(this).find('.leval').addClass('show').parents('li').siblings().find('.leval').removeClass('show'); }, function () { }); $('.nav').mouseleave(function () { $('.leval').removeClass('show'); $('.nav >li').removeClass('creent'); $('.nav >li').eq(indexs).addClass('creent'); }); jQuery(".menu-list > li > a").bind("click", function (e) { var $navMobile = jQuery(".menubox"), $navA = $navMobile.find(".menu-list > li > a"), $mSubnav = $navMobile.find(".leval-menu"); var hjcur = $(this); var hjDD = $(this).parents("li"); if (hjDD.find(".leval-menu").size() > 0) { if (hjcur.hasClass("on")) { $navMobile.slideUp(); hjDD.find(".leval-menu").stop(false, false).slideUp(); hjcur.removeClass("on"); $navMobile.slideUp(); } else { $navA.removeClass("on"); $mSubnav.stop(false, false).slideUp(); hjDD.find(".leval-menu").stop(false, false).slideDown(); hjcur.addClass("on"); e.preventDefault(); } } }); getHash(); jQuery(".leval-nav li a,.leval-menu li a,.eggs-info a,.farm-list li a").click(function (e) { var hash = jQuery(this).attr("href").split("#")[1]; if (hash && jQuery("#" + hash).length == 1) { setScroll("#" + hash); } $(".menubox").removeClass("on"); $(".home").removeClass("on"); $(".header-box").removeClass("on"); $(".innerbox").removeClass("on"); }); function getHash() { var hash = location.href.split("#")[1]; if (hash) { setScroll("#" + hash); } }; var scnum = 0; function setScroll(anchorCur) { if (!isMobile) { scnum = 74; } else { scnum = $('.header-box').outerHeight(); } jQuery("html,body").animate({ scrollTop: jQuery(anchorCur).offset().top - scnum }, 400); }; $('.pbanner .down').click(function () { if (!isMobile) { scnum = 74; } else { scnum = $('.header-box').outerHeight(); } jQuery("html,body").animate({ scrollTop: w_height - scnum }, 800); }); var inver=$(".investorb figure img").outerHeight(); $('.investorb .down').click(function () { if (!isMobile) { scnum = inver+28; } else { scnum =inver; } jQuery("html,body").animate({ scrollTop: scnum }, 800); }); jQuery(window).scroll(function () { var windowTop = jQuery(window).scrollTop(); if (windowTop < w_height && !isMobile) { jQuery('.pbanner figure img,.investorb img').css('transform', "translate(0px," + (windowTop) / 1.5 + "px)"); }; }); $('.iphone-fix span').click(function () { $('.iphone-down').slideToggle(); }); 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 }); }; };