Showing
4 changed files
with
117 additions
and
35 deletions
@@ -25,13 +25,20 @@ | @@ -25,13 +25,20 @@ | ||
25 | <div class="tab"> | 25 | <div class="tab"> |
26 | <ul class="shop-tabs tab-navs" data-sticky> | 26 | <ul class="shop-tabs tab-navs" data-sticky> |
27 | <li class="shop-tab-nav tab-nav active"> | 27 | <li class="shop-tab-nav tab-nav active"> |
28 | - <a href="#red-index" data-trigger="tab">红人首页</a> | 28 | + <a href="#red-index" data-trigger="tab" data-funFilterHide>红人首页</a> |
29 | </li> | 29 | </li> |
30 | <em>|</em> | 30 | <em>|</em> |
31 | <li class="shop-tab-nav tab-nav"> | 31 | <li class="shop-tab-nav tab-nav"> |
32 | - <a href="#all-goods" data-trigger="tab" data-funGetFilter data-funGetGoodsList>全部商品</a> | 32 | + <a href="#all-goods" data-trigger="tab" |
33 | + data-funFilterShow | ||
34 | + data-funGetGoodsList>全部商品</a> | ||
33 | </li> | 35 | </li> |
34 | </ul> | 36 | </ul> |
37 | + {{!--筛选tab--}} | ||
38 | + <div class="filter-box"> | ||
39 | + {{> product/filter-tab}} | ||
40 | + {{> common/filter}} | ||
41 | + </div> | ||
35 | <div class="tab-panels"> | 42 | <div class="tab-panels"> |
36 | {{!--shop-tab: 红人首页--}} | 43 | {{!--shop-tab: 红人首页--}} |
37 | <div id="red-index" class="tab-panel active"> | 44 | <div id="red-index" class="tab-panel active"> |
@@ -137,9 +144,6 @@ | @@ -137,9 +144,6 @@ | ||
137 | {{!--shop-tab: 全部商品--}} | 144 | {{!--shop-tab: 全部商品--}} |
138 | <div id="all-goods" class="tab-panel"> | 145 | <div id="all-goods" class="tab-panel"> |
139 | <div class="good-list-page yoho-page"> | 146 | <div class="good-list-page yoho-page"> |
140 | - {{!--筛选tab--}} | ||
141 | - {{> product/filter-tab}} | ||
142 | - | ||
143 | <div id="goods-container" class="goods-container"> | 147 | <div id="goods-container" class="goods-container"> |
144 | <div class="firstscreen-goods container clearfix"></div> | 148 | <div class="firstscreen-goods container clearfix"></div> |
145 | {{!--<div class="search-divide">正在加载...</div>--}} | 149 | {{!--<div class="search-divide">正在加载...</div>--}} |
@@ -148,7 +152,6 @@ | @@ -148,7 +152,6 @@ | ||
148 | <div class="sale-goods container clearfix"></div> | 152 | <div class="sale-goods container clearfix"></div> |
149 | <div class="price-goods container clearfix hide"></div> | 153 | <div class="price-goods container clearfix hide"></div> |
150 | <div class="discount-goods container clearfix hide"></div> | 154 | <div class="discount-goods container clearfix hide"></div> |
151 | - {{> common/filter}} | ||
152 | </div> | 155 | </div> |
153 | </div> | 156 | </div> |
154 | </div> | 157 | </div> |
@@ -21,9 +21,9 @@ let $pgc = $goodsContainer.children('.price-goods'); | @@ -21,9 +21,9 @@ let $pgc = $goodsContainer.children('.price-goods'); | ||
21 | let $dgc = $goodsContainer.children('.discount-goods'); | 21 | let $dgc = $goodsContainer.children('.discount-goods'); |
22 | let $listNav = $('#list-nav'); // 筛选项列表 | 22 | let $listNav = $('#list-nav'); // 筛选项列表 |
23 | let $pre = $listNav.find('.active'); // 记录进入筛选前的active项,初始为选中项 | 23 | let $pre = $listNav.find('.active'); // 记录进入筛选前的active项,初始为选中项 |
24 | +let $filterBox = $('.filter-box'); | ||
24 | let $filterBody = $('.filter-body'); | 25 | let $filterBody = $('.filter-body'); |
25 | 26 | ||
26 | -let allGoodsTabClickTimes = 0; | ||
27 | let navInfo = { | 27 | let navInfo = { |
28 | price: { | 28 | price: { |
29 | order: 1, | 29 | order: 1, |
@@ -116,39 +116,36 @@ function getGoodsList() { | @@ -116,39 +116,36 @@ function getGoodsList() { | ||
116 | * 加载筛选数据 | 116 | * 加载筛选数据 |
117 | */ | 117 | */ |
118 | function getFilter() { | 118 | function getFilter() { |
119 | - if (allGoodsTabClickTimes === 0) { | ||
120 | - // 第一次点进来调用 | ||
121 | - | ||
122 | - $.ajax({ | ||
123 | - type: 'GET', | ||
124 | - url: location.protocol + '//m.yohobuy.com/product/search/filter', | ||
125 | - data: defaultOpt, | ||
126 | - success: function(data) { | ||
127 | - if (data) { // 判断需要再严禁些,确定数据正常后再 ++ | ||
128 | - allGoodsTabClickTimes++; | ||
129 | - } | ||
130 | - $goodsContainer.append(data); | 119 | + $.ajax({ |
120 | + type: 'GET', | ||
121 | + url: location.protocol + '//m.yohobuy.com/product/search/filter', | ||
122 | + data: defaultOpt, | ||
123 | + success: function(data) { | ||
124 | + $goodsContainer.append(data); | ||
131 | 125 | ||
132 | - // 初始化filter&注册filter回调 | ||
133 | - filter.initFilter({ | ||
134 | - fCbFn: getGoodsList, | ||
135 | - hCbFn: function() { | 126 | + // 初始化filter&注册filter回调 |
127 | + filter.initFilter({ | ||
128 | + fCbFn: getGoodsList, | ||
129 | + hCbFn: function() { | ||
136 | 130 | ||
137 | - // 切换active状态到$pre上 | ||
138 | - $pre.addClass('active'); | ||
139 | - $pre.siblings('.filter').removeClass('active'); | ||
140 | - } | ||
141 | - }); | 131 | + // 切换active状态到$pre上 |
132 | + $pre.addClass('active'); | ||
133 | + $pre.siblings('.filter').removeClass('active'); | ||
134 | + } | ||
135 | + }); | ||
142 | 136 | ||
143 | - $filterBody = $('.filter-body'); | ||
144 | - } | ||
145 | - }); | ||
146 | - } | 137 | + $filterBody = $('.filter-body'); |
138 | + } | ||
139 | + }); | ||
147 | } | 140 | } |
148 | 141 | ||
149 | -// 绑定 getfilter 方法,在点击全部商品 Tab 时调用 | ||
150 | -Tab.prototype.getfilter = getFilter; | ||
151 | -Tab.prototype.getgoodslist = getGoodsList; | 142 | +Tab.prototype.getgoodslist = getGoodsList; // 获取商品列表 |
143 | +Tab.prototype.filterhide = function() { // 隐藏筛选 TAB | ||
144 | + $filterBox.css('display', 'none'); | ||
145 | +}; | ||
146 | +Tab.prototype.filtershow = function() { // 显示筛选 TAB | ||
147 | + $filterBox.css('display', 'block'); | ||
148 | +}; | ||
152 | 149 | ||
153 | $listNav.bind('contextmenu', function() { | 150 | $listNav.bind('contextmenu', function() { |
154 | return false; | 151 | return false; |
@@ -262,3 +259,4 @@ $listNav.on('touchend touchcancel', function(e) { | @@ -262,3 +259,4 @@ $listNav.on('touchend touchcancel', function(e) { | ||
262 | } | 259 | } |
263 | } | 260 | } |
264 | }); | 261 | }); |
262 | +getFilter(); |
public/scss/product/shop/reds-shop/_nav.css
0 → 100644
1 | +.filter-box { | ||
2 | + display: none; | ||
3 | + | ||
4 | + .list-nav { | ||
5 | + border-top: 2px solid #fff; | ||
6 | + border-bottom: 1px solid #e6e6e6; | ||
7 | + | ||
8 | + > li { | ||
9 | + float: left; | ||
10 | + width: 20%; | ||
11 | + height: 33PX; | ||
12 | + line-height: 33PX; | ||
13 | + text-align: center; | ||
14 | + font-size: 14PX; | ||
15 | + } | ||
16 | + | ||
17 | + .bytouch { | ||
18 | + background: #eee; | ||
19 | + } | ||
20 | + | ||
21 | + a { | ||
22 | + display: block; | ||
23 | + box-sizing: border-box; | ||
24 | + width: 100%; | ||
25 | + height: 100%; | ||
26 | + color: #999; | ||
27 | + } | ||
28 | + | ||
29 | + .nav-txt { | ||
30 | + display: inline-block; | ||
31 | + height: 100%; | ||
32 | + box-sizing: border-box; | ||
33 | + } | ||
34 | + | ||
35 | + .active > a { | ||
36 | + color: #000; | ||
37 | + | ||
38 | + .iconfont { | ||
39 | + color: #999; | ||
40 | + | ||
41 | + &.cur { | ||
42 | + color: #000; | ||
43 | + } | ||
44 | + } | ||
45 | + } | ||
46 | + | ||
47 | + .new .iconfont { | ||
48 | + transform: scale(0.8); | ||
49 | + font-weight: bold; | ||
50 | + font-size: 12PX; | ||
51 | + } | ||
52 | + | ||
53 | + .filter .iconfont { | ||
54 | + font-size: 12PX; | ||
55 | + transition: transform 0.1 ease-in; | ||
56 | + } | ||
57 | + | ||
58 | + .filter.active .iconfont { | ||
59 | + transform: rotate(-180deg); | ||
60 | + } | ||
61 | + | ||
62 | + .icon { | ||
63 | + position: relative; | ||
64 | + | ||
65 | + i { | ||
66 | + position: absolute; | ||
67 | + transform: scale(0.8); | ||
68 | + font-weight: bold; | ||
69 | + } | ||
70 | + | ||
71 | + .up { | ||
72 | + top: -11PX; | ||
73 | + } | ||
74 | + | ||
75 | + .down { | ||
76 | + top: -4PX; | ||
77 | + } | ||
78 | + } | ||
79 | + } | ||
80 | +} |
-
Please register or login to post a comment