1
|
var $ = require('yoho-jquery'),
|
1
|
var $ = require('yoho-jquery'),
|
2
|
tip = require('../plugin/tip'),
|
2
|
tip = require('../plugin/tip'),
|
3
|
Swiper = require('yoho-swiper'),
|
3
|
Swiper = require('yoho-swiper'),
|
|
|
4
|
+ loading = require('../plugin/loading'),
|
4
|
debounce = require('lodash/debounce');
|
5
|
debounce = require('lodash/debounce');
|
5
|
|
6
|
|
6
|
var plusstar = {},
|
7
|
var plusstar = {},
|
7
|
$footer = $('#yoho-footer');
|
8
|
$footer = $('#yoho-footer');
|
8
|
|
9
|
|
|
|
10
|
+var windowHeight = $(window).height();
|
9
|
var scrollFn,
|
11
|
var scrollFn,
|
|
|
12
|
+ scrollTop,
|
10
|
RECPOSE,
|
13
|
RECPOSE,
|
11
|
isApp,
|
14
|
isApp,
|
|
|
15
|
+ searching = false,
|
12
|
speckParamApp = {
|
16
|
speckParamApp = {
|
13
|
udid: '',
|
17
|
udid: '',
|
14
|
apt: '',
|
18
|
apt: '',
|
|
@@ -21,6 +25,9 @@ require('../common'); |
|
@@ -21,6 +25,9 @@ require('../common'); |
21
|
plusstar = {
|
25
|
plusstar = {
|
22
|
common: {
|
26
|
common: {
|
23
|
codeDefault: '',
|
27
|
codeDefault: '',
|
|
|
28
|
+ page: 1,
|
|
|
29
|
+ pagesize: 20,
|
|
|
30
|
+ pageTotal: 1,
|
24
|
productSkns: []
|
31
|
productSkns: []
|
25
|
},
|
32
|
},
|
26
|
init: function() {
|
33
|
init: function() {
|
|
@@ -30,13 +37,6 @@ plusstar = { |
|
@@ -30,13 +37,6 @@ plusstar = { |
30
|
|
37
|
|
31
|
$tabUlDom = $('.plusstar-page .tab-nav ul');
|
38
|
$tabUlDom = $('.plusstar-page .tab-nav ul');
|
32
|
|
39
|
|
33
|
- // 重置tab code位置
|
|
|
34
|
- if (window.localStorage) {
|
|
|
35
|
- $tabUlDom.find('li').each(function() {
|
|
|
36
|
- localStorage.setItem($(this).data('code'), 0);
|
|
|
37
|
- });
|
|
|
38
|
- }
|
|
|
39
|
-
|
|
|
40
|
$tabUlDom.find('li').css({
|
40
|
$tabUlDom.find('li').css({
|
41
|
width: 100 / $tabUlDom.find('li').length + '%'
|
41
|
width: 100 / $tabUlDom.find('li').length + '%'
|
42
|
});
|
42
|
});
|
|
@@ -58,18 +58,16 @@ plusstar = { |
|
@@ -58,18 +58,16 @@ plusstar = { |
58
|
if (window._yas && window._yas.sendCustomInfo) {
|
58
|
if (window._yas && window._yas.sendCustomInfo) {
|
59
|
window._yas.sendCustomInfo({
|
59
|
window._yas.sendCustomInfo({
|
60
|
op: 'YB_FASHION_TAB_C',
|
60
|
op: 'YB_FASHION_TAB_C',
|
61
|
- param: JSON.stringify($.extend(speckParamApp, {
|
|
|
62
|
- TAB_ID: $liDom.index() + 1,
|
|
|
63
|
- PRD_ID: ''
|
|
|
64
|
- }))
|
61
|
+ param: JSON.stringify($.extend({
|
|
|
62
|
+ TAB_ID: $liDom.index() + 1
|
|
|
63
|
+ }, speckParamApp))
|
65
|
}, true);
|
64
|
}, true);
|
66
|
|
65
|
|
67
|
window._yas.sendCustomInfo({
|
66
|
window._yas.sendCustomInfo({
|
68
|
op: 'YB_FASHION_HOME_L',
|
67
|
op: 'YB_FASHION_HOME_L',
|
69
|
- param: JSON.stringify($.extend(speckParamApp, {
|
|
|
70
|
- TAB_ID: that.ParentLiDom.index() + 1,
|
|
|
71
|
- PRD_ID: ''
|
|
|
72
|
- }))
|
68
|
+ param: JSON.stringify($.extend({
|
|
|
69
|
+ TAB_ID: that.ParentLiDom.index() + 1
|
|
|
70
|
+ }, speckParamApp))
|
73
|
}, true);
|
71
|
}, true);
|
74
|
}
|
72
|
}
|
75
|
});
|
73
|
});
|
|
@@ -106,28 +104,28 @@ plusstar = { |
|
@@ -106,28 +104,28 @@ plusstar = { |
106
|
// 商品单击埋点
|
104
|
// 商品单击埋点
|
107
|
$dom = $(event.target).closest('.good-info');
|
105
|
$dom = $(event.target).closest('.good-info');
|
108
|
index = $dom.index() + 1;
|
106
|
index = $dom.index() + 1;
|
109
|
- window.givePoint($.extend(speckParamApp, {
|
107
|
+ window.givePoint($.extend({
|
110
|
REC_POSE: RECPOSE,
|
108
|
REC_POSE: RECPOSE,
|
111
|
PRD_ID: $dom.data('good-id'),
|
109
|
PRD_ID: $dom.data('good-id'),
|
112
|
ORDER_CODE: '',
|
110
|
ORDER_CODE: '',
|
113
|
- PRD_NUM: index,
|
|
|
114
|
- ACTION_ID: 1
|
|
|
115
|
- }));
|
111
|
+ PRD_NUM: index % that.common.pagesize === 0 ? that.common.pagesize : index % that.common.pagesize,
|
|
|
112
|
+ ACTION_ID: 1,
|
|
|
113
|
+ page_num: Math.ceil(index / that.common.pagesize)
|
|
|
114
|
+ }, speckParamApp));
|
116
|
} else if ($(event.target).closest('.banner-top').length > 0) {
|
115
|
} else if ($(event.target).closest('.banner-top').length > 0) {
|
117
|
// 头部banner楼层埋点
|
116
|
// 头部banner楼层埋点
|
118
|
$dom = $(event.target).closest('li');
|
117
|
$dom = $(event.target).closest('li');
|
119
|
index = $dom.index() + 1;
|
118
|
index = $dom.index() + 1;
|
120
|
window._yas.sendCustomInfo({
|
119
|
window._yas.sendCustomInfo({
|
121
|
op: 'YB_FASHION_FLR_C',
|
120
|
op: 'YB_FASHION_FLR_C',
|
122
|
- param: JSON.stringify($.extend(speckParamApp, {
|
121
|
+ param: JSON.stringify($.extend({
|
123
|
TAB_ID: that.ParentLiDom.index() + 1,
|
122
|
TAB_ID: that.ParentLiDom.index() + 1,
|
124
|
F_ID: $dom.closest('ul').data('id'),
|
123
|
F_ID: $dom.closest('ul').data('id'),
|
125
|
F_NAME: '焦点图',
|
124
|
F_NAME: '焦点图',
|
126
|
- PRD_ID: '',
|
|
|
127
|
F_URL: $dom.find('a').attr('href'),
|
125
|
F_URL: $dom.find('a').attr('href'),
|
128
|
F_INDEX: 1,
|
126
|
F_INDEX: 1,
|
129
|
I_INDEX: index % 2 + 1// banner,li是双倍的
|
127
|
I_INDEX: index % 2 + 1// banner,li是双倍的
|
130
|
- }))
|
128
|
+ }, speckParamApp))
|
131
|
}, true);
|
129
|
}, true);
|
132
|
} else if ($(event.target).closest('.speck-title-image a').length > 0) {
|
130
|
} else if ($(event.target).closest('.speck-title-image a').length > 0) {
|
133
|
// 各楼层埋点
|
131
|
// 各楼层埋点
|
|
@@ -136,15 +134,14 @@ plusstar = { |
|
@@ -136,15 +134,14 @@ plusstar = { |
136
|
|
134
|
|
137
|
window._yas.sendCustomInfo({
|
135
|
window._yas.sendCustomInfo({
|
138
|
op: 'YB_FASHION_FLR_C',
|
136
|
op: 'YB_FASHION_FLR_C',
|
139
|
- param: JSON.stringify($.extend(speckParamApp, {
|
137
|
+ param: JSON.stringify($.extend({
|
140
|
TAB_ID: that.ParentLiDom.index() + 1,
|
138
|
TAB_ID: that.ParentLiDom.index() + 1,
|
141
|
F_ID: $dom.data('fid'),
|
139
|
F_ID: $dom.data('fid'),
|
142
|
- PRD_ID: '',
|
|
|
143
|
F_NAME: $dom.data('name'),
|
140
|
F_NAME: $dom.data('name'),
|
144
|
F_URL: $domA.attr('href'),
|
141
|
F_URL: $domA.attr('href'),
|
145
|
F_INDEX: $dom.index() + 1,
|
142
|
F_INDEX: $dom.index() + 1,
|
146
|
I_INDEX: $domA.hasClass('more') ? 0 : ($domA.index() + 1)
|
143
|
I_INDEX: $domA.hasClass('more') ? 0 : ($domA.index() + 1)
|
147
|
- }))
|
144
|
+ }, speckParamApp))
|
148
|
}, true);
|
145
|
}, true);
|
149
|
}
|
146
|
}
|
150
|
});
|
147
|
});
|
|
@@ -152,16 +149,16 @@ plusstar = { |
|
@@ -152,16 +149,16 @@ plusstar = { |
152
|
// 潮流优选首页加载时
|
149
|
// 潮流优选首页加载时
|
153
|
window._yas.sendCustomInfo({
|
150
|
window._yas.sendCustomInfo({
|
154
|
op: 'YB_FASHION_HOME_L',
|
151
|
op: 'YB_FASHION_HOME_L',
|
155
|
- param: JSON.stringify($.extend(speckParamApp, {
|
|
|
156
|
- TAB_ID: that.ParentLiDom.index() + 1,
|
|
|
157
|
- PRD_ID: ''
|
|
|
158
|
- }))
|
152
|
+ param: JSON.stringify($.extend({
|
|
|
153
|
+ TAB_ID: that.ParentLiDom.index() + 1
|
|
|
154
|
+ }, speckParamApp))
|
159
|
}, true);
|
155
|
}, true);
|
160
|
},
|
156
|
},
|
161
|
tabNav: function(code) {
|
157
|
tabNav: function(code) {
|
162
|
var that = this;
|
158
|
var that = this;
|
163
|
|
159
|
|
164
|
this.common.codeDefault = code;// 记住最后一次的tab code
|
160
|
this.common.codeDefault = code;// 记住最后一次的tab code
|
|
|
161
|
+ this.common.page = 1;// 商品列表从第一页开始
|
165
|
|
162
|
|
166
|
$.ajax({
|
163
|
$.ajax({
|
167
|
type: 'GET',
|
164
|
type: 'GET',
|
|
@@ -185,20 +182,12 @@ plusstar = { |
|
@@ -185,20 +182,12 @@ plusstar = { |
185
|
|
182
|
|
186
|
$('.plusstar-resources').find('img.lazy').lazyload();
|
183
|
$('.plusstar-resources').find('img.lazy').lazyload();
|
187
|
|
184
|
|
188
|
- // 设置滚动条的位置
|
|
|
189
|
- if (window.localStorage) {
|
|
|
190
|
- $(document).scrollTop(localStorage.getItem(code) || 0);
|
|
|
191
|
- }
|
|
|
192
|
-
|
|
|
193
|
productSkns = $(data).find('.product-skns').val();
|
185
|
productSkns = $(data).find('.product-skns').val();
|
194
|
-
|
|
|
195
|
if (productSkns) {
|
186
|
if (productSkns) {
|
196
|
that.common.productSkns = productSkns.split(',');
|
187
|
that.common.productSkns = productSkns.split(',');
|
197
|
}
|
188
|
}
|
198
|
|
189
|
|
199
|
- setTimeout(function() {
|
|
|
200
|
- plusstar.goodsList();
|
|
|
201
|
- }, 10);
|
190
|
+ that.common.pageTotal = Math.round(that.common.productSkns.length / that.common.pagesize);
|
202
|
},
|
191
|
},
|
203
|
error: function() {
|
192
|
error: function() {
|
204
|
tip.show('网络断开连接了~');
|
193
|
tip.show('网络断开连接了~');
|
|
@@ -224,18 +213,32 @@ plusstar = { |
|
@@ -224,18 +213,32 @@ plusstar = { |
224
|
var that = this,
|
213
|
var that = this,
|
225
|
skn = [];
|
214
|
skn = [];
|
226
|
|
215
|
|
|
|
216
|
+ if (searching) {
|
|
|
217
|
+ return;
|
|
|
218
|
+ }
|
|
|
219
|
+ searching = true;
|
|
|
220
|
+
|
|
|
221
|
+ if (that.common.page > that.common.pageTotal) {
|
|
|
222
|
+ return false;
|
|
|
223
|
+ }
|
|
|
224
|
+
|
|
|
225
|
+ loading.showLoadingMask();
|
|
|
226
|
+ skn = that.common.productSkns.slice((that.common.page - 1) * that.common.pagesize, that.common.page * that.common.pagesize);
|
227
|
$.ajax({
|
227
|
$.ajax({
|
228
|
type: 'POST',
|
228
|
type: 'POST',
|
229
|
url: '/guang/plusstar/resources-goodsList',
|
229
|
url: '/guang/plusstar/resources-goodsList',
|
230
|
timeout: 5000,
|
230
|
timeout: 5000,
|
231
|
data: {
|
231
|
data: {
|
232
|
- productSkn: that.common.productSkns.join(','),
|
232
|
+ productSkn: skn.join(','),
|
233
|
app_version: isApp,
|
233
|
app_version: isApp,
|
|
|
234
|
+ limit: that.common.pagesize,
|
234
|
yh_channel: that.ParentLiDom.index() + 1
|
235
|
yh_channel: that.ParentLiDom.index() + 1
|
235
|
},
|
236
|
},
|
236
|
dataType: 'html',
|
237
|
dataType: 'html',
|
237
|
success: function(data) {
|
238
|
success: function(data) {
|
238
|
skn = [];
|
239
|
skn = [];
|
|
|
240
|
+ loading.hideLoadingMask();
|
|
|
241
|
+ searching = false;
|
239
|
|
242
|
|
240
|
if (data === '') {
|
243
|
if (data === '') {
|
241
|
return true;
|
244
|
return true;
|
|
@@ -245,13 +248,14 @@ plusstar = { |
|
@@ -245,13 +248,14 @@ plusstar = { |
245
|
skn.push($(this).data('good-id'));
|
248
|
skn.push($(this).data('good-id'));
|
246
|
});
|
249
|
});
|
247
|
|
250
|
|
248
|
- window.givePoint($.extend(speckParamApp, {
|
251
|
+ window.givePoint($.extend({
|
249
|
REC_POSE: RECPOSE,
|
252
|
REC_POSE: RECPOSE,
|
250
|
PRD_ID: skn.join(','),
|
253
|
PRD_ID: skn.join(','),
|
251
|
ORDER_CODE: '',
|
254
|
ORDER_CODE: '',
|
252
|
- PRD_NUM: skn.length,
|
|
|
253
|
- ACTION_ID: 0
|
|
|
254
|
- }));
|
255
|
+ PRD_NUM: that.common.pagesize,
|
|
|
256
|
+ ACTION_ID: 0,
|
|
|
257
|
+ page_num: that.common.page++
|
|
|
258
|
+ }, speckParamApp));
|
255
|
|
259
|
|
256
|
$('.plusstar-resources .goods').append(data);
|
260
|
$('.plusstar-resources .goods').append(data);
|
257
|
|
261
|
|
|
@@ -259,16 +263,22 @@ plusstar = { |
|
@@ -259,16 +263,22 @@ plusstar = { |
259
|
$('.resources .goods .page-total').remove();
|
263
|
$('.resources .goods .page-total').remove();
|
260
|
},
|
264
|
},
|
261
|
error: function() {
|
265
|
error: function() {
|
|
|
266
|
+ searching = false;
|
262
|
tip.show('网络断开连接了~');
|
267
|
tip.show('网络断开连接了~');
|
|
|
268
|
+ loading.hideLoadingMask();
|
263
|
}
|
269
|
}
|
264
|
});
|
270
|
});
|
265
|
}
|
271
|
}
|
266
|
};
|
272
|
};
|
267
|
|
273
|
|
268
|
scrollFn = debounce(function() {
|
274
|
scrollFn = debounce(function() {
|
269
|
- if (window.localStorage) {
|
|
|
270
|
- localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop());
|
275
|
+ scrollTop = $(document).scrollTop();
|
|
|
276
|
+
|
|
|
277
|
+ // 当scroll到最后一列商品的高度后继续请求下一页数据
|
|
|
278
|
+ if (400 + scrollTop >= $(document).height() - windowHeight) {
|
|
|
279
|
+ plusstar.goodsList();
|
271
|
}
|
280
|
}
|
|
|
281
|
+
|
272
|
}, 200);
|
282
|
}, 200);
|
273
|
|
283
|
|
274
|
$(function() {
|
284
|
$(function() {
|