...
|
...
|
@@ -23,7 +23,7 @@ var $head = $('.head-wrapper'), |
|
|
$miniCart = $head.find('.mini-cart-wrapper'),
|
|
|
$dropDown = $tool.find('.nav-drop-down-container');
|
|
|
|
|
|
var $subNav = $('.sub-nav-list.cure .contain-third');
|
|
|
var subNavFn;
|
|
|
|
|
|
var fetchUserInfoEvent = $.Callbacks('once'); // eslint-disable-line
|
|
|
|
...
|
...
|
@@ -100,6 +100,7 @@ $('.we-chat').mouseenter(function() { |
|
|
centerFn = handlebars.compile($('#simple-account-info-tpl').html() || '');
|
|
|
loginFn = handlebars.compile($('#header-login-info-tpl').html() || '');
|
|
|
cartFn = require('hbs/header/mini-cart-tpl.hbs'); // handlebars.compile($('#mini-cart-tpl').html() || '');
|
|
|
subNavFn = require('mix/common/header-nav.hbs');
|
|
|
|
|
|
// handlebars helper
|
|
|
handlebars.registerHelper('notzero', function(v1, options) {
|
...
|
...
|
@@ -284,32 +285,6 @@ function getBannerAndNotice() { |
|
|
});
|
|
|
}
|
|
|
|
|
|
// 格式化三级菜单
|
|
|
function formatThirdMenu() {
|
|
|
$subNav.each(function() {
|
|
|
var $thirdList = $(this).find('.hide-list'),
|
|
|
list = [],
|
|
|
i = 0;
|
|
|
|
|
|
if ($thirdList.length) {
|
|
|
$thirdList.children().each(function() {
|
|
|
if (i % thirdLineNum === 0) {
|
|
|
list.push('');
|
|
|
}
|
|
|
list[list.length - 1] += this.outerHTML + '';
|
|
|
i++;
|
|
|
});
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
if (!list[i]) {
|
|
|
return;
|
|
|
}
|
|
|
$thirdList.before('<dl class="category-list">' + list[i] + '</dl>');
|
|
|
}
|
|
|
$thirdList.remove();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 更新头部登陆信息
|
|
|
function updateLoginInfo(data) {
|
|
|
if (data.curLevel * 1 === 3) {
|
...
|
...
|
@@ -590,8 +565,28 @@ function isSupportCss3Animation() { |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 处理pageCache频道显示异常问题
|
|
|
function syncPageChannel() {
|
|
|
if (isSupportCss3Animation()) {
|
|
|
requestFrame = requestFrameAct();
|
|
|
window.setTimeout(tsAnimate, 3000);
|
|
|
} else {
|
|
|
window.setTimeout(fadeAnimate, 3000);
|
|
|
}
|
|
|
|
|
|
// 菜单设置
|
|
|
(function() {
|
|
|
var headerNav = {
|
|
|
init() {
|
|
|
var that = this;
|
|
|
|
|
|
this.syncPageChannel();
|
|
|
|
|
|
this.$base = $('.sub-nav-list.cure');
|
|
|
|
|
|
$('.contain-third', this.$base).mouseenter(function() {
|
|
|
that.getThirdNavs();
|
|
|
});
|
|
|
},
|
|
|
syncPageChannel() {
|
|
|
var $header = $('#yoho-header'),
|
|
|
$navs;
|
|
|
var channel = window.homePage || window.cookie('_Channel') || 'boys',
|
...
|
...
|
@@ -613,20 +608,96 @@ function syncPageChannel() { |
|
|
|
|
|
// 更新频道颜色
|
|
|
$header.addClass(channel).find('.func-area').removeClass('hide');
|
|
|
}
|
|
|
|
|
|
// 更新三级菜单jq对象
|
|
|
$subNav = $('.sub-nav-list.cure .contain-third');
|
|
|
this.channel = channel;
|
|
|
},
|
|
|
getThirdNavs() {
|
|
|
var that = this;
|
|
|
|
|
|
if (this.loaded || this.loading) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (isSupportCss3Animation()) {
|
|
|
requestFrame = requestFrameAct();
|
|
|
window.setTimeout(tsAnimate, 3000);
|
|
|
} else {
|
|
|
window.setTimeout(fadeAnimate, 3000);
|
|
|
}
|
|
|
syncPageChannel();
|
|
|
formatThirdMenu(); // 格式化三级菜单
|
|
|
this.loading = true;
|
|
|
|
|
|
$.ajax({
|
|
|
url: '/common/header/nav',
|
|
|
type: 'GET',
|
|
|
data: {channel: this.channel},
|
|
|
}).done(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
that.loaded = true;
|
|
|
that.$base.html(subNavFn(res.data));
|
|
|
that.reseatThirdMenu();
|
|
|
}
|
|
|
}).always(function() {
|
|
|
that.loading = false;
|
|
|
});
|
|
|
},
|
|
|
reseatThirdMenu() {
|
|
|
$('.contain-third', this.$base).each(function() {
|
|
|
var $thirdList = $(this).find('.hide-list'),
|
|
|
list = [],
|
|
|
i = 0;
|
|
|
|
|
|
if ($thirdList.length) {
|
|
|
$thirdList.children().each(function() {
|
|
|
if (i % thirdLineNum === 0) {
|
|
|
list.push('');
|
|
|
}
|
|
|
list[list.length - 1] += this.outerHTML + '';
|
|
|
i++;
|
|
|
});
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
if (!list[i]) {
|
|
|
return;
|
|
|
}
|
|
|
$thirdList.before('<dl class="category-list">' + list[i] + '</dl>');
|
|
|
}
|
|
|
$thirdList.remove();
|
|
|
}
|
|
|
}).on({
|
|
|
mouseenter: function() {
|
|
|
var $thirdNav = $(this).children('.third-nav-wrapper'),
|
|
|
$show = $thirdNav.find('.show-detail'),
|
|
|
param = {};
|
|
|
|
|
|
delayer = setTimeout(function() {
|
|
|
$thirdNav.show();
|
|
|
}, 200);
|
|
|
|
|
|
if (!$show.length || $show.hasClass('show')) {
|
|
|
return;
|
|
|
}
|
|
|
param.content_code = $show.data().code;
|
|
|
param.client_type = 'web';
|
|
|
param.width = 337;
|
|
|
param.height = 250;
|
|
|
param._ = new Date();
|
|
|
$.getJSON('//new.yohobuy.com/common/getbanner?callback=?', param, function(JsonData) {
|
|
|
if (JsonData.code === 200) {
|
|
|
$show.addClass('show');
|
|
|
$show.find('img').attr('src', JsonData.data.src);
|
|
|
$show.find('a').attr('href', JsonData.data.url);
|
|
|
$show.find('.title').text(JsonData.data.title);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
mouseleave: function() {
|
|
|
var $thirdNav = $(this).children('.third-nav-wrapper');
|
|
|
|
|
|
if (delayer) {
|
|
|
clearTimeout(delayer);
|
|
|
}
|
|
|
$thirdNav.hide();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
headerNav.init();
|
|
|
}());
|
|
|
|
|
|
(function() {
|
|
|
if (document.all && !document.querySelector) {
|
...
|
...
|
@@ -809,43 +880,6 @@ if ($miniCart && $miniCart.length) { |
|
|
});
|
|
|
}
|
|
|
|
|
|
$subNav.on({
|
|
|
mouseenter: function() {
|
|
|
var $thirdNav = $(this).children('.third-nav-wrapper'),
|
|
|
$show = $thirdNav.find('.show-detail'),
|
|
|
param = {};
|
|
|
|
|
|
delayer = setTimeout(function() {
|
|
|
$thirdNav.show();
|
|
|
}, 200);
|
|
|
|
|
|
if (!$show.length || $show.hasClass('show')) {
|
|
|
return;
|
|
|
}
|
|
|
param.content_code = $show.data().code;
|
|
|
param.client_type = 'web';
|
|
|
param.width = 337;
|
|
|
param.height = 250;
|
|
|
param._ = new Date();
|
|
|
$.getJSON('//new.yohobuy.com/common/getbanner?callback=?', param, function(JsonData) {
|
|
|
if (JsonData.code === 200) {
|
|
|
$show.addClass('show');
|
|
|
$show.find('img').attr('src', JsonData.data.src);
|
|
|
$show.find('a').attr('href', JsonData.data.url);
|
|
|
$show.find('.title').text(JsonData.data.title);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
mouseleave: function() {
|
|
|
var $thirdNav = $(this).children('.third-nav-wrapper');
|
|
|
|
|
|
if (delayer) {
|
|
|
clearTimeout(delayer);
|
|
|
}
|
|
|
$thirdNav.hide();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 首次进入有弹窗
|
|
|
* @return {[type]} [description]
|
...
|
...
|
|