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>=4){
$('.header-box').addClass('scoll');
}else{
$('.header-box').removeClass('scoll');
}
$(window).scroll(function(){
ST = $(window).scrollTop();
if(ST>=4){
$('.header-box').addClass('scoll');
}else{
$('.header-box').removeClass('scoll');
}
});
}
if(!isMobile){
var prohei=(w_height+($(".recommend-box").outerHeight()/3));
var brandh=(w_height+($(".productcon").outerHeight())+$(".productcon").outerHeight()/3);
var fhe=(w_height+$(".recommend-box").outerHeight()+$(".product-box").outerHeight()+$(".brand-center").outerHeight()/4);
ST = $(window).scrollTop();
if(ST>=w_height/2){
$('.flexbo').addClass('on');
$('.title-list .commoned:nth-child(1)').addClass('on').siblings().removeClass('on');
if(ST>=prohei){
$('.title-list .commoned:nth-child(2)').addClass('on').siblings().removeClass('on');
}
if(ST>=brandh){
$('.title-list .commoned:nth-child(3)').addClass('on').siblings().removeClass('on');
}
if(ST>=fhe){
$('.title-list .commoned').removeClass('on');
}
}else{
$('.flexbo').removeClass('on');
$('.title-list .commoned').removeClass('on');
}
$(window).scroll(function(){
ST = $(window).scrollTop();
if(ST>=w_height/2){
$('.title-list .commoned:nth-child(1)').addClass('on').siblings().removeClass('on');
$('.flexbo').addClass('on');
if(ST>=prohei){
$('.title-list .commoned:nth-child(2)').addClass('on').siblings().removeClass('on');
}
if(ST>=brandh){
$('.title-list .commoned:nth-child(3)').addClass('on').siblings().removeClass('on');
}
if(ST>=fhe){
$('.title-list .commoned').removeClass('on');
}
}else{
$('.flexbo').removeClass('on');
$('.title-list .commoned').removeClass('on');
}
});
}
$('.hbanner,#slider .slides,#slider .slides li').css('height',w_height);
setImgMax($('.hbanner figure img,#slider .slides li img'), 1920, 949, w_width, w_height);
if(!isMobile){
}else{
$(".commoned,.recommend-list,.brandimg,.startimg,.startfix,.bicon,.woodbg,.ptext,.product-list,.resource").removeClass('article-block');
}
}
pageBox();
jQuery(window).resize(function () {
pageBox();
});
$(".banner .bannerdown").click(function(){
jQuery("html,body").animate({ scrollTop: w_height}, 650, 'easeInOutExpo');
});
$( '#menu_toggle' ).on('click', function(e) {
$('.menufix').addClass('on');
});
$( '#menu_toggle1' ).on('click', function(e) {
$(this).toggleClass('active');
$('.menubox').fadeToggle(500);
});
$(".menus-list li").each(function( index ) {
$( this ).css({'animation-delay': (index/2)+'s'});
});
$('.mclose').click(function(){
$('.menufix').removeClass('on');
});
jQuery(document).on('click',".menufix",function(e){
if ($(e.target).hasClass('menufix')) {
$(".menufix").removeClass('on');
}
});
$('.backtop').click(function(){
jQuery("html,body").animate({ scrollTop: 0}, 1200, 'easeInOutExpo');
})
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)");
};
});
$(".menu-list li").each(function( index ) {
$( this ).css({'animation-delay': (index/8)+'s'});
});
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 });
};
};
setImgMax($('.pagebg img'), 1920, 897, w_width, w_height);
var heinow=$('.footer').outerHeight()+4*w_height;
var $wrap = $('.wrapper'), pages = $('.page').length, scrolling = false, currentPage = 1, $navPanel = $('.nav-panel'), $scrollBtn = $('.scroll-btn'), $navBtn = $('.nav-btn');
function manageClasses() {
$wrap.removeClass(function (index, css) {
return (css.match(/(^|\s)active-page\S+/g) || []).join(' ');
});
$wrap.addClass('active-page' + currentPage);
$navBtn.removeClass('active');
$('.nav-btn.nav-page' + currentPage).addClass('active');
$navPanel.addClass('invisible');
scrolling = true;
setTimeout(function () {
$navPanel.removeClass('invisible');
scrolling = false;
}, 1000);
}
function navigateUp() {
if (currentPage > 1) {
currentPage--;
manageClasses();
$wrap.animate({ 'top': -(currentPage-1)*w_height }, 1000);
$('.side_btn_ul').addClass('in');
}
if (currentPage == 1){
$('.side_btn_ul').removeClass('in');
}
}
jQuery(window).resize(function () {
if(!isMobile){
$('.page,.wrapper,.pagebg img').css('height',w_height);
}
if (currentPage == 1){
$('.side_btn_ul').removeClass('in');
}else{
$('.side_btn_ul').addClass('in');
}
$wrap.animate({ 'top': -(currentPage-1)*w_height }, 1000);
});
if(!isMobile){
$('.page,.wrapper,.pagebg img').css('height',w_height);
}
function navigateDown() {
if (currentPage < pages) {
currentPage++;
manageClasses();
if(currentPage==6){
var hnum=jQuery(".footer-box").innerHeight();
$wrap.animate({ 'top': (-4*w_height)-hnum }, 500);
$('.side_btn_ul').removeClass('in');
}else{
$wrap.animate({ 'top': -(currentPage-1)*w_height }, 1000);
$('.side_btn_ul').addClass('in');
}
}
}
$(document).on('mousewheel DOMMouseScroll', function (e) {
if (!scrolling&&!isMobile) {
if (e.originalEvent.wheelDelta > 0 || e.originalEvent.detail < 0) {
navigateUp();
} else {
navigateDown();
}
}
});
$(document).on('click', '.scroll-btn', function () {
if ($(this).hasClass('up')) {
navigateUp();
} else {
navigateDown();
}
});
$(document).on('click', '.nav-btn:not(.active)', function () {
if (!scrolling&&!isMobile) {
$(this).addClass('active').siblings().removeClass('active');
var target = $(this).attr('data-target');
currentPage=target;
$wrap.removeClass(function (index, css) {
return (css.match(/(^|\s)active-page\S+/g) || []).join(' ');
});
$wrap.addClass('active-page' + currentPage);
$wrap.animate({ 'top': '-' + (target - 1) * 100 + '%' }, 1000);
}
});
$(".page1 .bannerdown").click(function(){
navigateDown();
});
var Video = {
load: function (objs) {
var objplay = jwplayer('vbBox').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;
}
}
jQuery("#vbBox").click(function(){
$(this).parents('.video').addClass('zindex');
var onj = jQuery("#h_video").val();
if (onj != '') {
Video.load({ vcontainer: 'vbBox', vfiles: '' + onj + '', isautoplay: 'true' });
};
});
getHash();
var hash="";
jQuery(".naved a").click(function(e){
hash=jQuery(this).attr("href").split("#")[1];
if(hash && jQuery("#"+hash).length==1&&isNaN(hash)){
setScroll("#"+hash);
}
if(hash && !isNaN(hash)){
setScroll1("#"+hash);
}
$(".menufix").removeClass("on");
});
function getHash(){
hash = location.href.split("#")[1];
if(hash&&isNaN(hash)){
setScroll("#"+hash);
}
if(!isNaN(hash)){
setScroll1("#"+hash);
}
};
var scnum=0;
function setScroll(anchorCur){
if(!isMobile){
scnum=0;
}else{
scnum=$('.header-box').outerHeight();
}
jQuery("html,body").animate({ scrollTop: jQuery(anchorCur).offset().top-scnum},1000,'easeInOutExpo');
};
function setScroll1(anchorCur){
var $wrap = $('.wrapper');
if(!isMobile){
currentPage=hash;
$wrap.addClass('active-page' + currentPage);
$wrap.animate({ 'top': -(currentPage-1)*w_height }, 1000);
$('.side_btn_ul').addClass('in');
$('.side_btn_ul li').eq(currentPage-1).addClass('active').siblings().removeClass('active');
}
};