|
@@ -23,7 +23,7 @@ var $head = $('.head-wrapper'), |
|
@@ -23,7 +23,7 @@ var $head = $('.head-wrapper'), |
23
|
$miniCart = $head.find('.mini-cart-wrapper'),
|
23
|
$miniCart = $head.find('.mini-cart-wrapper'),
|
24
|
$dropDown = $tool.find('.nav-drop-down-container');
|
24
|
$dropDown = $tool.find('.nav-drop-down-container');
|
25
|
|
25
|
|
26
|
-var $subNav = $('.sub-nav-list.cure .contain-third');
|
26
|
+var subNavFn;
|
27
|
|
27
|
|
28
|
var fetchUserInfoEvent = $.Callbacks('once'); // eslint-disable-line
|
28
|
var fetchUserInfoEvent = $.Callbacks('once'); // eslint-disable-line
|
29
|
|
29
|
|
|
@@ -100,6 +100,7 @@ $('.we-chat').mouseenter(function() { |
|
@@ -100,6 +100,7 @@ $('.we-chat').mouseenter(function() { |
100
|
centerFn = handlebars.compile($('#simple-account-info-tpl').html() || '');
|
100
|
centerFn = handlebars.compile($('#simple-account-info-tpl').html() || '');
|
101
|
loginFn = handlebars.compile($('#header-login-info-tpl').html() || '');
|
101
|
loginFn = handlebars.compile($('#header-login-info-tpl').html() || '');
|
102
|
cartFn = require('hbs/header/mini-cart-tpl.hbs'); // handlebars.compile($('#mini-cart-tpl').html() || '');
|
102
|
cartFn = require('hbs/header/mini-cart-tpl.hbs'); // handlebars.compile($('#mini-cart-tpl').html() || '');
|
|
|
103
|
+subNavFn = require('mix/common/header-nav.hbs');
|
103
|
|
104
|
|
104
|
// handlebars helper
|
105
|
// handlebars helper
|
105
|
handlebars.registerHelper('notzero', function(v1, options) {
|
106
|
handlebars.registerHelper('notzero', function(v1, options) {
|
|
@@ -284,32 +285,6 @@ function getBannerAndNotice() { |
|
@@ -284,32 +285,6 @@ function getBannerAndNotice() { |
284
|
});
|
285
|
});
|
285
|
}
|
286
|
}
|
286
|
|
287
|
|
287
|
-// 格式化三级菜单
|
|
|
288
|
-function formatThirdMenu() {
|
|
|
289
|
- $subNav.each(function() {
|
|
|
290
|
- var $thirdList = $(this).find('.hide-list'),
|
|
|
291
|
- list = [],
|
|
|
292
|
- i = 0;
|
|
|
293
|
-
|
|
|
294
|
- if ($thirdList.length) {
|
|
|
295
|
- $thirdList.children().each(function() {
|
|
|
296
|
- if (i % thirdLineNum === 0) {
|
|
|
297
|
- list.push('');
|
|
|
298
|
- }
|
|
|
299
|
- list[list.length - 1] += this.outerHTML + '';
|
|
|
300
|
- i++;
|
|
|
301
|
- });
|
|
|
302
|
- for (i = 0; i < 3; i++) {
|
|
|
303
|
- if (!list[i]) {
|
|
|
304
|
- return;
|
|
|
305
|
- }
|
|
|
306
|
- $thirdList.before('<dl class="category-list">' + list[i] + '</dl>');
|
|
|
307
|
- }
|
|
|
308
|
- $thirdList.remove();
|
|
|
309
|
- }
|
|
|
310
|
- });
|
|
|
311
|
-}
|
|
|
312
|
-
|
|
|
313
|
// 更新头部登陆信息
|
288
|
// 更新头部登陆信息
|
314
|
function updateLoginInfo(data) {
|
289
|
function updateLoginInfo(data) {
|
315
|
if (data.curLevel * 1 === 3) {
|
290
|
if (data.curLevel * 1 === 3) {
|
|
@@ -590,8 +565,28 @@ function isSupportCss3Animation() { |
|
@@ -590,8 +565,28 @@ function isSupportCss3Animation() { |
590
|
}
|
565
|
}
|
591
|
}
|
566
|
}
|
592
|
|
567
|
|
593
|
-// 处理pageCache频道显示异常问题
|
|
|
594
|
-function syncPageChannel() {
|
568
|
+if (isSupportCss3Animation()) {
|
|
|
569
|
+ requestFrame = requestFrameAct();
|
|
|
570
|
+ window.setTimeout(tsAnimate, 3000);
|
|
|
571
|
+} else {
|
|
|
572
|
+ window.setTimeout(fadeAnimate, 3000);
|
|
|
573
|
+}
|
|
|
574
|
+
|
|
|
575
|
+// 菜单设置
|
|
|
576
|
+(function() {
|
|
|
577
|
+ var headerNav = {
|
|
|
578
|
+ init() {
|
|
|
579
|
+ var that = this;
|
|
|
580
|
+
|
|
|
581
|
+ this.syncPageChannel();
|
|
|
582
|
+
|
|
|
583
|
+ this.$base = $('.sub-nav-list.cure');
|
|
|
584
|
+
|
|
|
585
|
+ $('.contain-third', this.$base).mouseenter(function() {
|
|
|
586
|
+ that.getThirdNavs();
|
|
|
587
|
+ });
|
|
|
588
|
+ },
|
|
|
589
|
+ syncPageChannel() {
|
595
|
var $header = $('#yoho-header'),
|
590
|
var $header = $('#yoho-header'),
|
596
|
$navs;
|
591
|
$navs;
|
597
|
var channel = window.homePage || window.cookie('_Channel') || 'boys',
|
592
|
var channel = window.homePage || window.cookie('_Channel') || 'boys',
|
|
@@ -613,20 +608,96 @@ function syncPageChannel() { |
|
@@ -613,20 +608,96 @@ function syncPageChannel() { |
613
|
|
608
|
|
614
|
// 更新频道颜色
|
609
|
// 更新频道颜色
|
615
|
$header.addClass(channel).find('.func-area').removeClass('hide');
|
610
|
$header.addClass(channel).find('.func-area').removeClass('hide');
|
|
|
611
|
+ }
|
616
|
|
612
|
|
617
|
- // 更新三级菜单jq对象
|
|
|
618
|
- $subNav = $('.sub-nav-list.cure .contain-third');
|
613
|
+ this.channel = channel;
|
|
|
614
|
+ },
|
|
|
615
|
+ getThirdNavs() {
|
|
|
616
|
+ var that = this;
|
|
|
617
|
+
|
|
|
618
|
+ if (this.loaded || this.loading) {
|
|
|
619
|
+ return;
|
619
|
}
|
620
|
}
|
620
|
-}
|
|
|
621
|
|
621
|
|
622
|
-if (isSupportCss3Animation()) {
|
|
|
623
|
- requestFrame = requestFrameAct();
|
|
|
624
|
- window.setTimeout(tsAnimate, 3000);
|
|
|
625
|
-} else {
|
|
|
626
|
- window.setTimeout(fadeAnimate, 3000);
|
|
|
627
|
-}
|
|
|
628
|
-syncPageChannel();
|
|
|
629
|
-formatThirdMenu(); // 格式化三级菜单
|
622
|
+ this.loading = true;
|
|
|
623
|
+
|
|
|
624
|
+ $.ajax({
|
|
|
625
|
+ url: '/common/header/nav',
|
|
|
626
|
+ type: 'GET',
|
|
|
627
|
+ data: {channel: this.channel},
|
|
|
628
|
+ }).done(function(res) {
|
|
|
629
|
+ if (res.code === 200) {
|
|
|
630
|
+ that.loaded = true;
|
|
|
631
|
+ that.$base.html(subNavFn(res.data));
|
|
|
632
|
+ that.reseatThirdMenu();
|
|
|
633
|
+ }
|
|
|
634
|
+ }).always(function() {
|
|
|
635
|
+ that.loading = false;
|
|
|
636
|
+ });
|
|
|
637
|
+ },
|
|
|
638
|
+ reseatThirdMenu() {
|
|
|
639
|
+ $('.contain-third', this.$base).each(function() {
|
|
|
640
|
+ var $thirdList = $(this).find('.hide-list'),
|
|
|
641
|
+ list = [],
|
|
|
642
|
+ i = 0;
|
|
|
643
|
+
|
|
|
644
|
+ if ($thirdList.length) {
|
|
|
645
|
+ $thirdList.children().each(function() {
|
|
|
646
|
+ if (i % thirdLineNum === 0) {
|
|
|
647
|
+ list.push('');
|
|
|
648
|
+ }
|
|
|
649
|
+ list[list.length - 1] += this.outerHTML + '';
|
|
|
650
|
+ i++;
|
|
|
651
|
+ });
|
|
|
652
|
+ for (i = 0; i < 3; i++) {
|
|
|
653
|
+ if (!list[i]) {
|
|
|
654
|
+ return;
|
|
|
655
|
+ }
|
|
|
656
|
+ $thirdList.before('<dl class="category-list">' + list[i] + '</dl>');
|
|
|
657
|
+ }
|
|
|
658
|
+ $thirdList.remove();
|
|
|
659
|
+ }
|
|
|
660
|
+ }).on({
|
|
|
661
|
+ mouseenter: function() {
|
|
|
662
|
+ var $thirdNav = $(this).children('.third-nav-wrapper'),
|
|
|
663
|
+ $show = $thirdNav.find('.show-detail'),
|
|
|
664
|
+ param = {};
|
|
|
665
|
+
|
|
|
666
|
+ delayer = setTimeout(function() {
|
|
|
667
|
+ $thirdNav.show();
|
|
|
668
|
+ }, 200);
|
|
|
669
|
+
|
|
|
670
|
+ if (!$show.length || $show.hasClass('show')) {
|
|
|
671
|
+ return;
|
|
|
672
|
+ }
|
|
|
673
|
+ param.content_code = $show.data().code;
|
|
|
674
|
+ param.client_type = 'web';
|
|
|
675
|
+ param.width = 337;
|
|
|
676
|
+ param.height = 250;
|
|
|
677
|
+ param._ = new Date();
|
|
|
678
|
+ $.getJSON('//new.yohobuy.com/common/getbanner?callback=?', param, function(JsonData) {
|
|
|
679
|
+ if (JsonData.code === 200) {
|
|
|
680
|
+ $show.addClass('show');
|
|
|
681
|
+ $show.find('img').attr('src', JsonData.data.src);
|
|
|
682
|
+ $show.find('a').attr('href', JsonData.data.url);
|
|
|
683
|
+ $show.find('.title').text(JsonData.data.title);
|
|
|
684
|
+ }
|
|
|
685
|
+ });
|
|
|
686
|
+ },
|
|
|
687
|
+ mouseleave: function() {
|
|
|
688
|
+ var $thirdNav = $(this).children('.third-nav-wrapper');
|
|
|
689
|
+
|
|
|
690
|
+ if (delayer) {
|
|
|
691
|
+ clearTimeout(delayer);
|
|
|
692
|
+ }
|
|
|
693
|
+ $thirdNav.hide();
|
|
|
694
|
+ }
|
|
|
695
|
+ });
|
|
|
696
|
+ }
|
|
|
697
|
+ };
|
|
|
698
|
+
|
|
|
699
|
+ headerNav.init();
|
|
|
700
|
+}());
|
630
|
|
701
|
|
631
|
(function() {
|
702
|
(function() {
|
632
|
if (document.all && !document.querySelector) {
|
703
|
if (document.all && !document.querySelector) {
|
|
@@ -809,43 +880,6 @@ if ($miniCart && $miniCart.length) { |
|
@@ -809,43 +880,6 @@ if ($miniCart && $miniCart.length) { |
809
|
});
|
880
|
});
|
810
|
}
|
881
|
}
|
811
|
|
882
|
|
812
|
-$subNav.on({
|
|
|
813
|
- mouseenter: function() {
|
|
|
814
|
- var $thirdNav = $(this).children('.third-nav-wrapper'),
|
|
|
815
|
- $show = $thirdNav.find('.show-detail'),
|
|
|
816
|
- param = {};
|
|
|
817
|
-
|
|
|
818
|
- delayer = setTimeout(function() {
|
|
|
819
|
- $thirdNav.show();
|
|
|
820
|
- }, 200);
|
|
|
821
|
-
|
|
|
822
|
- if (!$show.length || $show.hasClass('show')) {
|
|
|
823
|
- return;
|
|
|
824
|
- }
|
|
|
825
|
- param.content_code = $show.data().code;
|
|
|
826
|
- param.client_type = 'web';
|
|
|
827
|
- param.width = 337;
|
|
|
828
|
- param.height = 250;
|
|
|
829
|
- param._ = new Date();
|
|
|
830
|
- $.getJSON('//new.yohobuy.com/common/getbanner?callback=?', param, function(JsonData) {
|
|
|
831
|
- if (JsonData.code === 200) {
|
|
|
832
|
- $show.addClass('show');
|
|
|
833
|
- $show.find('img').attr('src', JsonData.data.src);
|
|
|
834
|
- $show.find('a').attr('href', JsonData.data.url);
|
|
|
835
|
- $show.find('.title').text(JsonData.data.title);
|
|
|
836
|
- }
|
|
|
837
|
- });
|
|
|
838
|
- },
|
|
|
839
|
- mouseleave: function() {
|
|
|
840
|
- var $thirdNav = $(this).children('.third-nav-wrapper');
|
|
|
841
|
-
|
|
|
842
|
- if (delayer) {
|
|
|
843
|
- clearTimeout(delayer);
|
|
|
844
|
- }
|
|
|
845
|
- $thirdNav.hide();
|
|
|
846
|
- }
|
|
|
847
|
-});
|
|
|
848
|
-
|
|
|
849
|
/**
|
883
|
/**
|
850
|
* 首次进入有弹窗
|
884
|
* 首次进入有弹窗
|
851
|
* @return {[type]} [description]
|
885
|
* @return {[type]} [description]
|