/**
* Created by Tong on 2018/6/22.
*/
var Common={
init:function () {
this.bind();
},
bind:function () {
var isClose=false;
//ie8
var DEFAULT_VERSION = 8.0;
var ua = navigator.userAgent.toLowerCase();
var isIE = ua.indexOf("msie")>-1;
var safariVersion;
if(isIE){
safariVersion = ua.match(/msie ([\d.]+)/)[1];
if(safariVersion <= DEFAULT_VERSION ){
$("body").prepend("
关闭你所用的浏览器版本过低,可能有安全风险,360、Sogou 等浏览器请切换到急速模式,或升级您的浏览器到
更高的版本!以获得更好的观看效果。
");
$('.header.pcArea').css('top', '70px').addClass('ie8');
$('.ie_low_version span').click(function () {
$('.ie_low_version').css('display','none');
$('.header.pcArea').css('top', '0').removeClass('ie8');
$('.ie_low_version+div').css('margin-top','0');
isClose=true;
});
}else {
//内容栏目banner分类
if($('#wrapper').is('.innerWrapper')){
var className=$('.innerMain .innerBanner .positionColumn').attr('class').split(' ')[1];
$('.innerMain .innerBanner').addClass(className);
}
}
}else{
if($('#wrapper').is('.innerWrapper')){
var className=$('.innerMain .innerBanner .positionColumn').attr('class').split(' ')[1];
$('.innerMain .innerBanner').addClass(className);
}
}
//手机菜单show and hide
var overlay = $('.overlay');
$('[data-toggle="offcanvas"]').click(function () {
Common.phoneMenu();
});
overlay.click(function () {
Common.phoneMenu();
});
$('#sidebar-wrapper .menu_close span').click(function () {
Common.phoneMenu();
});
$('.rightS_popup .popup_contain ul li .shop_mask').click(function () {
$(this).next('a').find('img').trigger('click');
});
//视频区域
var h=$(window).height();
$('.bg_video_contain').height(h);
$('.phone .index_img').height(h);
$('.home-container').height(h);
$('.video-section').height(h);
$('.videoMenu').height(h);
// $('.bg_video_contain .word').height(h);
$('.bg_video_contain .word').height(h);
$('.phone .bg_video_contain .word').height(h+80-47);
$('.main .bg_video_contain .word .more').show();
var videoW_h=(h-166-72-42)/2+24;
var videoW_h_phove=(h-47-166-60-20)/2;
if (videoW_h>0){
$('.bg_video_contain .word .videoWord').css('margin-top',videoW_h+'px');
}
if (videoW_h_phove>0){
$('.phone .bg_video_contain .word .videoWord').css('margin-top',videoW_h_phove+'px');
}
//内页subNav下li的宽度
var liNum=$('.innerMain .innerBanner > div .subMenu>ul>li').length;
var li_w=100/liNum;
$('.innerMain .innerBanner > div .subMenu>ul>li').css('width',li_w+'%');
//头部动画
var p=0,t=0;
$(window).scroll(function(e){
var scroll_H=document.body.scrollTop||document.documentElement.scrollTop;
p = $(this).scrollTop();
if (scroll_H>80){
if(t<=p){
$('.header').css('top','-80px');
// console.log('y');
$('.header .navContainer > ul > li > ul').stop().slideUp('500');
$('.pcArea.header .navContainer .submenuBg').stop().slideUp('500').css('border-bottom','none');
clearTimeout(timer);
} else{
if($('.header.pcArea').is('.ie8')){
if (isClose){
$('.header').css('top','0');
}else {
$('.header').css('top','70px');
}
}else {
$('.header').css('top','0');
}
}
setTimeout(function(){t = p;},10);
}else {
if($('.header.pcArea').is('.ie8')){
if (isClose){
$('.header').css('top','0');
}else {
$('.header').css('top','70px');
}
}else {
$('.header').css('top','0');
}
}
//内页向上动画
if($('#wrapper').is('.innerWrapper')){
Common.innerS();
}
});
//内页向上动画
if($('#wrapper').is('.innerWrapper')){
Common.innerS();
}
//
// 头部下拉菜单
// $('.pcArea.header .navContainer .submenu').mouseenter(function () {
// $('.pcArea.header .navContainer .submenu').height(190).css('border-bottom','1px solid #FF773D');
// });
// $('.pcArea.header .navContainer .submenu').mouseleave(function () {
// $('.pcArea.header .navContainer .submenu').css('height','0').css('border-bottom','0');
// });
var timer = null;
$('.header .navContainer > ul').hover(function () {
timer = setTimeout(function () {
// $('.pcArea.header .navContainer .submenu').animate({height:'190px'});
// $('.pcArea.header .navContainer .submenu').css('border-bottom','1px solid #FF773D');
// console.log('top',$('.header').css('top'));
$('.header .navContainer > ul > li > ul').stop().slideDown('500');
$('.pcArea.header .navContainer .submenuBg').stop().slideDown('500').css('border-bottom','1px solid #FF773D');
}, 200);
}, function () {
// $('.pcArea.header .navContainer .submenu').css('height','0').css('border-bottom','0');
$('.header .navContainer > ul > li > ul').stop().slideUp('500');
$('.pcArea.header .navContainer .submenuBg').stop().slideUp('500').css('border-bottom','none');
clearTimeout(timer);
});
// 手机头部
//手机二级菜单展开
//手机二级菜单展开
$('.leftS_popup .navContainer > ul > li').each(function () {
if($(this).children('ul').length==0) {
} else {
$(this).append('')
}
});
$('.leftS_popup .navContainer > ul > li .showMore').on('click',function () {
if($(this).is('.plus')){
$('.leftS_popup .navContainer > ul > li ul').slideUp();
$('.showMore').removeClass('minus').addClass('plus');
$('.leftS_popup .navContainer > ul > li').removeClass('active');
$(this).parent('li').addClass('active');
$(this).prev('ul').slideDown();
$(this).addClass('minus').removeClass('plus');
}else {
// $('.leftS_popup .navContainer > ul > li ul').slideUp();
$(this).parent('li').removeClass('active');
$('.showMore').removeClass('minus');
$(this).prev('ul').slideUp();
$(this).addClass('plus');
}
});
//pc版二级菜单
var subMenuHtml='';
$('.header .navContainer>ul>li').each(function(){
var li_w=$(this).width()+18;
subMenuHtml=subMenuHtml+''+$(this).children('ul').eq(0).html()+'
';
});
$('.header .navContainer .submenu div div').html(subMenuHtml);
var window_h=$(window).height();
//PC商城
$('.header .headerRight .onlineMall').click(function () {
$(' .rightS_popup').show();
$('.popup_bg').show();
$('.ie_low_version.banner').css('z-index','-1');
$('#wrapper').css('position','relative').css('z-index','99999');
$(".rightS_popup .popup_contain").animate({right:"0"},function () {
});
Common.canScroll(0,window_h);
});
//手机商城
$('.phoneArea .shoppingMall').click(function () {
$(' .rightS_popup').show();
$('.popup_bg').show();
$('.ie_low_version.banner').css('z-index','-1');
$('#wrapper').css('position','relative').css('z-index','99999');
$(".rightS_popup .popup_contain").animate({right:"0"},function () {
});
Common.canScroll(0,window_h);
});
$('.rightS_popup .popup_contain .popup_header .close').click(function () {
$('.ie_low_version.banner').css('z-index','9999');
$('#wrapper').css('position','relative').css('z-index','1');
$(".popup_contain").animate({right:"-375"},function () {
$('.rightS_popup').hide();
$('.popup_bg').hide();
});
Common.canScroll(1,window_h);
});
//手机菜单
$('.phoneArea .burgerMenu').click(function () {
$(' .leftS_popup').show();
$('.popup_bg').show();
$('.ie_low_version.banner').css('z-index','-1');
$('#wrapper').css('position','relative').css('z-index','99999');
$(".leftS_popup .navContainer").animate({left:"0"},function () {
});
Common.canScroll(0,window_h);
});
$(".leftS_popup .navContainer .closeDiv .closeBtn").click(function () {
$('.ie_low_version.banner').css('z-index','9999');
$('#wrapper').css('position','relative').css('z-index','1');
$(".leftS_popup .navContainer").animate({left:"-375"},function () {
$('.leftS_popup').hide();
$('.popup_bg').hide();
});
Common.canScroll(1,window_h);
});
//点击背景关闭
$('.popup_bg').click(function () {
$(".popup_contain").animate({right:"-375"},function () {
$('.rightS_popup').hide();
$('.popup_bg').hide();
});
$(".leftS_popup .navContainer").animate({left:"-375"},function () {
$('.leftS_popup').hide();
$('.popup_bg').hide();
});
Common.canScroll(1,window_h);
});
//搜索框
$(".leftS_popup .navContainer .search .searchValue").focus(function(){
$('.leftS_popup .navContainer .search .deleteBtn').show();
});
$('.leftS_popup .navContainer .search .deleteBtn').click(function () {
$(".leftS_popup .navContainer .search .searchValue").val('');
});
//设置手机版subMenu
Common.phoneSubMenu();
$(window).resize(function () {
Common.phoneSubMenu();
});
//导航的品牌中心下加分类
var brand_html='中华老字号'+
'中国驰名商标'+
'广东省老字号'+
'广州市老字号';
$('.navContainer li.Brand ul').html(brand_html);
},
//手机导航菜单设置
phoneMenu:function () {
$('#wrapper').toggleClass('toggled');
if (overlay.is('.is-open')){
$('#page-content-wrapper').css('width','100%');
overlay.removeClass('is-open');
$('#page-content-wrapper').css('height','auto').css('position','absolute');
}else{
overlay.addClass('is-open');
var window_h=$('#sidebar-wrapper').height()+100;
$('#page-content-wrapper').height(window_h).css('overflow','hidden').css('position','relative');
}
},
canScroll:function (param,window_h) {
if(param==1){
$('#page-content-wrapper').css('height','auto').css('position','static');
$('.rightS_popup .popup_contain ul li').css('opacity','0');
$('.leftS_popup .navContainer > ul > li').css('opacity','0');
}else {
$('#page-content-wrapper').height(window_h).css('overflow','hidden').css('position','relative');
setTimeout(function(){
if($('.rightS_popup .popup_contain ul').children('li').eq(0).css("animation").indexOf('showLi')<0 && $('.rightS_popup').css('display')=='block'){
$('.rightS_popup .popup_contain ul li').css('opacity','1');
}
if($('.leftS_popup .navContainer > ul ').children('li').eq(0).css("animation").indexOf('showLi')<0 && $('.leftS_popup').css('display')=='block'){
$('.leftS_popup .navContainer > ul > li').css('opacity','1');
}
}, 500);
}
},
phoneSubMenu:function () {
var pageUrl=window.location.href;
var path;
if(pageUrl.indexOf('/ywly/')>0){
path='dropdown';
}else {
path='dropup';
}
var window_w=$(window).width();
if (window_w>800){
$('.innerMain .innerBanner > div .subMenu').removeClass(path);
$('.innerMain .innerBanner > div .subMenu ul').removeClass('dropdown-menu');
}else {
var selectedValue=$('.innerMain .innerBanner > div .subMenu ul li.selected a').text()+'';
$('.innerMain .innerBanner > div .subMenu .dropdown-toggle').html(selectedValue);
$('.innerMain .innerBanner > div .subMenu').addClass(path);
$('.innerMain .innerBanner > div .subMenu ul').addClass('dropdown-menu');
}
},
innerS:function () {
var scroll_H=document.body.scrollTop||document.documentElement.scrollTop;
$('.transitionLable').each(function () {
if($(this).is('.currentColumn')){
var db=$(this).offset().top-$(window).height()-10;
}else {
var db=$(this).offset().top-$(window).height();
}
if(db