1
|
// const tip = require('../plugin/tip');
|
1
|
// const tip = require('../plugin/tip');
|
2
|
const filter = require('../plugin/filter');
|
2
|
const filter = require('../plugin/filter');
|
|
|
3
|
+const lazyLoad = require('yoho-jquery-lazyload');
|
3
|
|
4
|
|
4
|
// const loading = require('../plugin/loading');
|
5
|
// const loading = require('../plugin/loading');
|
5
|
|
6
|
|
|
@@ -10,7 +11,6 @@ require('plugin/sticky'); |
|
@@ -10,7 +11,6 @@ require('plugin/sticky'); |
10
|
require('./shop/coupon');
|
11
|
require('./shop/coupon');
|
11
|
|
12
|
|
12
|
let Tab = require('plugin/tab');
|
13
|
let Tab = require('plugin/tab');
|
13
|
-let defaultOpt = require('../common/query-param');
|
|
|
14
|
|
14
|
|
15
|
let $goodsContainer = $('#goods-container');
|
15
|
let $goodsContainer = $('#goods-container');
|
16
|
let $fsgc = $goodsContainer.children('.firstscreen-goods');
|
16
|
let $fsgc = $goodsContainer.children('.firstscreen-goods');
|
|
@@ -24,7 +24,6 @@ let $pre = $listNav.find('.active'); // 记录进入筛选前的active项,初 |
|
@@ -24,7 +24,6 @@ let $pre = $listNav.find('.active'); // 记录进入筛选前的active项,初 |
24
|
let $filterBody = $('.filter-body');
|
24
|
let $filterBody = $('.filter-body');
|
25
|
|
25
|
|
26
|
let allGoodsTabClickTimes = 0;
|
26
|
let allGoodsTabClickTimes = 0;
|
27
|
-
|
|
|
28
|
let navInfo = {
|
27
|
let navInfo = {
|
29
|
price: {
|
28
|
price: {
|
30
|
order: 1,
|
29
|
order: 1,
|
|
@@ -57,6 +56,8 @@ let navInfo = { |
|
@@ -57,6 +56,8 @@ let navInfo = { |
57
|
end: false
|
56
|
end: false
|
58
|
}
|
57
|
}
|
59
|
};
|
58
|
};
|
|
|
59
|
+let navType = 'default'; // 目前激活的导航页面
|
|
|
60
|
+let defaultOpt = navInfo.default; // 默认参数
|
60
|
|
61
|
|
61
|
/**
|
62
|
/**
|
62
|
* 处理筛选参数
|
63
|
* 处理筛选参数
|
|
@@ -75,7 +76,40 @@ function handleChoseFilter() { |
|
@@ -75,7 +76,40 @@ function handleChoseFilter() { |
75
|
*/
|
76
|
*/
|
76
|
function getGoodsList() {
|
77
|
function getGoodsList() {
|
77
|
handleChoseFilter();
|
78
|
handleChoseFilter();
|
78
|
- console.log('ok');
|
79
|
+ $.ajax({
|
|
|
80
|
+ type: 'GET',
|
|
|
81
|
+ url: location.protocol + '//m.yohobuy.com/product/search/search',
|
|
|
82
|
+ data: defaultOpt,
|
|
|
83
|
+ xhrFields: {
|
|
|
84
|
+ withCredentials: true
|
|
|
85
|
+ },
|
|
|
86
|
+ success: function(result) {
|
|
|
87
|
+ let $container = $defaultgc;
|
|
|
88
|
+
|
|
|
89
|
+ switch (navType) {
|
|
|
90
|
+ case 'new':
|
|
|
91
|
+ $container = $ngc;
|
|
|
92
|
+ break;
|
|
|
93
|
+ case 'price':
|
|
|
94
|
+ $container = $pgc;
|
|
|
95
|
+ break;
|
|
|
96
|
+ case 'discount':
|
|
|
97
|
+ $container = $dgc;
|
|
|
98
|
+ break;
|
|
|
99
|
+ case 'default':
|
|
|
100
|
+ $container = $defaultgc;
|
|
|
101
|
+ break;
|
|
|
102
|
+ case 'sale':
|
|
|
103
|
+ $container = $sgc;
|
|
|
104
|
+ break;
|
|
|
105
|
+ default:
|
|
|
106
|
+ break;
|
|
|
107
|
+ }
|
|
|
108
|
+
|
|
|
109
|
+ $container.html(result);
|
|
|
110
|
+ lazyLoad($container.find('.lazy'));
|
|
|
111
|
+ }
|
|
|
112
|
+ });
|
79
|
}
|
113
|
}
|
80
|
|
114
|
|
81
|
/**
|
115
|
/**
|
|
@@ -121,11 +155,10 @@ $listNav.bind('contextmenu', function() { |
|
@@ -121,11 +155,10 @@ $listNav.bind('contextmenu', function() { |
121
|
});
|
155
|
});
|
122
|
|
156
|
|
123
|
$listNav.on('touchend touchcancel', function(e) {
|
157
|
$listNav.on('touchend touchcancel', function(e) {
|
124
|
- var $this = $(e.target).closest('li'),
|
|
|
125
|
- nav,
|
|
|
126
|
- navType,
|
|
|
127
|
- $active;
|
|
|
128
|
- var bpIdData = $(this).find('.buriedpoint').attr('data-bp-id') || '';
|
158
|
+ let $this = $(e.target).closest('li'); // 被点击的 Tab
|
|
|
159
|
+ let $active;
|
|
|
160
|
+ let nav;
|
|
|
161
|
+ let bpIdData = $(this).find('.buriedpoint').attr('data-bp-id') || '';
|
129
|
|
162
|
|
130
|
if ($this.hasClass('filter')) {
|
163
|
if ($this.hasClass('filter')) {
|
131
|
|
164
|
|
|
@@ -160,6 +193,10 @@ $listNav.on('touchend touchcancel', function(e) { |
|
@@ -160,6 +193,10 @@ $listNav.on('touchend touchcancel', function(e) { |
160
|
|
193
|
|
161
|
nav = navInfo[navType];
|
194
|
nav = navInfo[navType];
|
162
|
|
195
|
|
|
|
196
|
+ /* 排序条件更新 */
|
|
|
197
|
+ defaultOpt.type = navType;
|
|
|
198
|
+ Object.assign(defaultOpt, nav);
|
|
|
199
|
+
|
163
|
if ($this.hasClass('active')) {
|
200
|
if ($this.hasClass('active')) {
|
164
|
|
201
|
|
165
|
// 默认、最新无排序切换
|
202
|
// 默认、最新无排序切换
|
|
@@ -218,6 +255,7 @@ $listNav.on('touchend touchcancel', function(e) { |
|
@@ -218,6 +255,7 @@ $listNav.on('touchend touchcancel', function(e) { |
218
|
$active.removeClass('active');
|
255
|
$active.removeClass('active');
|
219
|
$this.addClass('active');
|
256
|
$this.addClass('active');
|
220
|
}
|
257
|
}
|
|
|
258
|
+
|
221
|
if (nav.reload) {
|
259
|
if (nav.reload) {
|
222
|
$(document).trigger('shouldSendBpData', [bpIdData]);
|
260
|
$(document).trigger('shouldSendBpData', [bpIdData]);
|
223
|
getGoodsList({filtering: true});
|
261
|
getGoodsList({filtering: true});
|