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;
});
};