Merge branch 'feature/wsl5.3' into release/2.0
Showing
1 changed file
with
21 additions
and
15 deletions
@@ -32,15 +32,7 @@ var recommmendProduct = { | @@ -32,15 +32,7 @@ var recommmendProduct = { | ||
32 | params: params | 32 | params: params |
33 | }); | 33 | }); |
34 | 34 | ||
35 | - // 最近预览 | ||
36 | - _this.getProducts({ | ||
37 | - url: '/product/recentPreview', | ||
38 | - index: 1, | ||
39 | - params: { | ||
40 | - limit: 20 | ||
41 | - } | ||
42 | - }); | ||
43 | - | 35 | + // tab切换 |
44 | $dom.find('.head-tab').on('click', function() { | 36 | $dom.find('.head-tab').on('click', function() { |
45 | var index = $(this).index(), | 37 | var index = $(this).index(), |
46 | $tabCont = $('.tab-cont-' + index); | 38 | $tabCont = $('.tab-cont-' + index); |
@@ -48,6 +40,9 @@ var recommmendProduct = { | @@ -48,6 +40,9 @@ var recommmendProduct = { | ||
48 | $('.head-tab').removeClass('active'); | 40 | $('.head-tab').removeClass('active'); |
49 | $(this).addClass('active'); | 41 | $(this).addClass('active'); |
50 | $tabCont.removeClass('hide').siblings().addClass('hide'); | 42 | $tabCont.removeClass('hide').siblings().addClass('hide'); |
43 | + | ||
44 | + _this.lazyImage(); | ||
45 | + _this.isShowChangeBtn($tabCont.find('.goods-group').length); | ||
51 | }); | 46 | }); |
52 | 47 | ||
53 | _this.$changeBtn.on('click', function() { | 48 | _this.$changeBtn.on('click', function() { |
@@ -84,9 +79,10 @@ var recommmendProduct = { | @@ -84,9 +79,10 @@ var recommmendProduct = { | ||
84 | }, | 79 | }, |
85 | getProducts: function(obj) { | 80 | getProducts: function(obj) { |
86 | var _this = this; | 81 | var _this = this; |
82 | + var $headTab = $('.head-tab'); | ||
87 | 83 | ||
88 | $.get(obj.url, obj.params, function(result) { | 84 | $.get(obj.url, obj.params, function(result) { |
89 | - var curTab = $('.head-tab').eq(obj.index); | 85 | + var curTab = $headTab.eq(obj.index); |
90 | 86 | ||
91 | if (result.length) { | 87 | if (result.length) { |
92 | if (_this.$recommendHeader.hasClass('hide')) { | 88 | if (_this.$recommendHeader.hasClass('hide')) { |
@@ -99,20 +95,30 @@ var recommmendProduct = { | @@ -99,20 +95,30 @@ var recommmendProduct = { | ||
99 | 95 | ||
100 | _this.$dom.find('.tab-cont-' + obj.index).html(recProduct({result: result})); | 96 | _this.$dom.find('.tab-cont-' + obj.index).html(recProduct({result: result})); |
101 | _this.lazyImage(); | 97 | _this.lazyImage(); |
98 | + _this.isShowChangeBtn.bind(result.length); | ||
102 | 99 | ||
103 | - _this.isShowChangeBtn(result.length); | ||
104 | - | ||
105 | - if (obj.index === 1) { | 100 | + if (obj.index === 1 && $headTab.eq(0).hasClass('hide')) { |
106 | curTab.click(); | 101 | curTab.click(); |
107 | } | 102 | } |
108 | } | 103 | } |
104 | + | ||
105 | + if (obj.index === 0) { | ||
106 | + // 最近预览 | ||
107 | + _this.getProducts({ | ||
108 | + url: '/product/recentPreview', | ||
109 | + index: 1, | ||
110 | + params: { | ||
111 | + limit: 20 | ||
112 | + } | ||
113 | + }); | ||
114 | + } | ||
109 | }); | 115 | }); |
110 | }, | 116 | }, |
111 | isShowChangeBtn: function(currGoodsLen) { | 117 | isShowChangeBtn: function(currGoodsLen) { |
112 | if (currGoodsLen <= 1) { | 118 | if (currGoodsLen <= 1) { |
113 | - this.$changeBtn.hide(); | 119 | + recommmendProduct.$changeBtn.hide(); |
114 | } else { | 120 | } else { |
115 | - this.$changeBtn.show(); | 121 | + recommmendProduct.$changeBtn.show(); |
116 | } | 122 | } |
117 | }, | 123 | }, |
118 | lazyImage: function() { | 124 | lazyImage: function() { |
-
Please register or login to post a comment