|
@@ -24,7 +24,8 @@ var tip = require('../plugin/tip'), |
|
@@ -24,7 +24,8 @@ var tip = require('../plugin/tip'), |
24
|
filter = require('../plugin/filter'),
|
24
|
filter = require('../plugin/filter'),
|
25
|
loading = require('../plugin/loading');
|
25
|
loading = require('../plugin/loading');
|
26
|
|
26
|
|
27
|
-var $goodsContainer = $('#goods-container'),
|
27
|
+var $subNav = $('.home-sub-nav'),
|
|
|
28
|
+ $goodsContainer = $('#goods-container'),
|
28
|
$goodsChildren = $goodsContainer.children(),
|
29
|
$goodsChildren = $goodsContainer.children(),
|
29
|
$ngc = $($goodsChildren.get(0)),
|
30
|
$ngc = $($goodsChildren.get(0)),
|
30
|
$pgc = $($goodsChildren.get(1)),
|
31
|
$pgc = $($goodsChildren.get(1)),
|
|
@@ -37,9 +38,22 @@ var winH = $(window).height(), |
|
@@ -37,9 +38,22 @@ var winH = $(window).height(), |
37
|
var defaultOpt = require('./query-param');
|
38
|
var defaultOpt = require('./query-param');
|
38
|
|
39
|
|
39
|
var $listNav = $('#list-nav'),
|
40
|
var $listNav = $('#list-nav'),
|
|
|
41
|
+ $posList = $('#pos-list'),
|
40
|
|
42
|
|
41
|
//导航数据信息
|
43
|
//导航数据信息
|
42
|
navInfo = {
|
44
|
navInfo = {
|
|
|
45
|
+ new: {
|
|
|
46
|
+ order: 1,
|
|
|
47
|
+ reload: true,
|
|
|
48
|
+ page: 0,
|
|
|
49
|
+ end: false
|
|
|
50
|
+ },
|
|
|
51
|
+ hot: {
|
|
|
52
|
+ order: 1,
|
|
|
53
|
+ reload: true,
|
|
|
54
|
+ page: 0,
|
|
|
55
|
+ end: false
|
|
|
56
|
+ },
|
43
|
newest: {
|
57
|
newest: {
|
44
|
order: 1,
|
58
|
order: 1,
|
45
|
reload: true,
|
59
|
reload: true,
|
|
@@ -60,6 +74,7 @@ var $listNav = $('#list-nav'), |
|
@@ -60,6 +74,7 @@ var $listNav = $('#list-nav'), |
60
|
}
|
74
|
}
|
61
|
},
|
75
|
},
|
62
|
$pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项
|
76
|
$pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项
|
|
|
77
|
+ $lie = $posList.find('.active'),
|
63
|
searching;
|
78
|
searching;
|
64
|
|
79
|
|
65
|
var viewType = 1; // 1-首页,2-上新,3-人气
|
80
|
var viewType = 1; // 1-首页,2-上新,3-人气
|
|
@@ -105,8 +120,11 @@ function tabChange(dom, index) { |
|
@@ -105,8 +120,11 @@ function tabChange(dom, index) { |
105
|
$.jqtab = function(nav, posNav, main) {
|
120
|
$.jqtab = function(nav, posNav, main) {
|
106
|
|
121
|
|
107
|
$(nav + ' li, ' + posNav + ' li').on('touchstart', function() {
|
122
|
$(nav + ' li, ' + posNav + ' li').on('touchstart', function() {
|
|
|
123
|
+
|
108
|
var index = $(this).index(),
|
124
|
var index = $(this).index(),
|
109
|
activeTab = $(this).attr('tab');
|
125
|
activeTab = $(this).attr('tab');
|
|
|
126
|
+
|
|
|
127
|
+ $nav1.removeClass('fixed-top');
|
110
|
|
128
|
|
111
|
tabChange($(nav + ' li'), index);
|
129
|
tabChange($(nav + ' li'), index);
|
112
|
tabChange($(posNav + ' li'), index);
|
130
|
tabChange($(posNav + ' li'), index);
|
|
@@ -114,6 +132,12 @@ $.jqtab = function(nav, posNav, main) { |
|
@@ -114,6 +132,12 @@ $.jqtab = function(nav, posNav, main) { |
114
|
$(main).hide();
|
132
|
$(main).hide();
|
115
|
$('#' + activeTab).fadeIn();
|
133
|
$('#' + activeTab).fadeIn();
|
116
|
|
134
|
|
|
|
135
|
+ if(activeTab == 'new-arrival'){
|
|
|
136
|
+ newData();
|
|
|
137
|
+ }else if(activeTab == 'popularity'){
|
|
|
138
|
+ hotData();
|
|
|
139
|
+ }
|
|
|
140
|
+
|
117
|
return false;
|
141
|
return false;
|
118
|
});
|
142
|
});
|
119
|
};
|
143
|
};
|
|
@@ -140,8 +164,11 @@ function getPageGoods(info) { |
|
@@ -140,8 +164,11 @@ function getPageGoods(info) { |
140
|
data: info.data,
|
164
|
data: info.data,
|
141
|
success: function(data) {
|
165
|
success: function(data) {
|
142
|
info.callBack(data);
|
166
|
info.callBack(data);
|
143
|
- myScroll && myScroll.refresh();
|
|
|
144
|
- scH = $('#scroller').outerHeight();
|
167
|
+ setTimeout(function () {
|
|
|
168
|
+ myScroll.refresh();
|
|
|
169
|
+ scH = $('#scroller').outerHeight();
|
|
|
170
|
+ }, 1000);
|
|
|
171
|
+
|
145
|
searching = false;
|
172
|
searching = false;
|
146
|
},
|
173
|
},
|
147
|
error: function() {
|
174
|
error: function() {
|
|
@@ -151,22 +178,39 @@ function getPageGoods(info) { |
|
@@ -151,22 +178,39 @@ function getPageGoods(info) { |
151
|
});
|
178
|
});
|
152
|
}
|
179
|
}
|
153
|
|
180
|
|
154
|
-function homeData() {
|
181
|
+function newData() {
|
155
|
var req = {};
|
182
|
var req = {};
|
156
|
|
183
|
|
157
|
- req.url = '/product/newsale/selectNewSale';
|
184
|
+ req.url = '/index/search/search';
|
|
|
185
|
+ req.data = {
|
|
|
186
|
+ type: 'newest',
|
|
|
187
|
+ order: '1',
|
|
|
188
|
+ page: '1',
|
|
|
189
|
+ shop_id: '102'
|
|
|
190
|
+
|
|
|
191
|
+ };
|
158
|
req.callBack = function(data) {
|
192
|
req.callBack = function(data) {
|
159
|
- $ngc.html(data);
|
193
|
+ $('#new-arrival').append(data);
|
|
|
194
|
+ navInfo.new.page++;
|
160
|
}
|
195
|
}
|
161
|
getPageGoods(req);
|
196
|
getPageGoods(req);
|
162
|
}
|
197
|
}
|
163
|
|
198
|
|
164
|
-function newData() {
|
|
|
165
|
- console.log('newData');
|
|
|
166
|
-}
|
|
|
167
|
-
|
|
|
168
|
function hotData() {
|
199
|
function hotData() {
|
169
|
- console.log('hotData');
|
200
|
+ var req = {};
|
|
|
201
|
+
|
|
|
202
|
+ req.url = '/index/search/search';
|
|
|
203
|
+ req.data = {
|
|
|
204
|
+ type: 'sales',
|
|
|
205
|
+ order: '1',
|
|
|
206
|
+ page: '1',
|
|
|
207
|
+ shop_id: '102'
|
|
|
208
|
+ };
|
|
|
209
|
+ req.callBack = function(data) {
|
|
|
210
|
+ $('#popularity').append(data);
|
|
|
211
|
+ navInfo.hot.page++;
|
|
|
212
|
+ }
|
|
|
213
|
+ getPageGoods(req);
|
170
|
}
|
214
|
}
|
171
|
|
215
|
|
172
|
myScroll.on('scroll', function() {
|
216
|
myScroll.on('scroll', function() {
|
|
@@ -174,9 +218,7 @@ myScroll.on('scroll', function() { |
|
@@ -174,9 +218,7 @@ myScroll.on('scroll', function() { |
174
|
|
218
|
|
175
|
if (sTop + winH * 2 > scH) {
|
219
|
if (sTop + winH * 2 > scH) {
|
176
|
switch(viewType) {
|
220
|
switch(viewType) {
|
177
|
- case 1:
|
|
|
178
|
- homeData();
|
|
|
179
|
- break;
|
221
|
+
|
180
|
case 2:
|
222
|
case 2:
|
181
|
newData();
|
223
|
newData();
|
182
|
break;
|
224
|
break;
|
|
@@ -185,6 +227,7 @@ myScroll.on('scroll', function() { |
|
@@ -185,6 +227,7 @@ myScroll.on('scroll', function() { |
185
|
break;
|
227
|
break;
|
186
|
}
|
228
|
}
|
187
|
}
|
229
|
}
|
|
|
230
|
+
|
188
|
if (sTop < imgH) {
|
231
|
if (sTop < imgH) {
|
189
|
if (!$nav1.hasClass('hide')) {
|
232
|
if (!$nav1.hasClass('hide')) {
|
190
|
$nav1.addClass('hide');
|
233
|
$nav1.addClass('hide');
|
|
@@ -234,16 +277,7 @@ myScroll.on('scroll', function() { |
|
@@ -234,16 +277,7 @@ myScroll.on('scroll', function() { |
234
|
});
|
277
|
});
|
235
|
}
|
278
|
}
|
236
|
}
|
279
|
}
|
237
|
- // else {
|
|
|
238
|
- // if (!$nav2.hasClass('absolute')) {
|
|
|
239
|
- // $nav1.addClass('absolute')
|
|
|
240
|
- // .removeClass('fixed-top');
|
|
|
241
|
- // }
|
|
|
242
|
- // $nav2.css({
|
|
|
243
|
- // transform: 'translate(0, ' + (imgH + nav1H + main1oH + main2oH -sTop - scH) + 'px)'
|
|
|
244
|
- // });
|
|
|
245
|
- // }
|
|
|
246
|
- }
|
280
|
+ }//
|
247
|
|
281
|
|
248
|
$("#scroller").trigger('scroll');
|
282
|
$("#scroller").trigger('scroll');
|
249
|
});
|
283
|
});
|
|
@@ -270,7 +304,6 @@ $(window).load(function() { |
|
@@ -270,7 +304,6 @@ $(window).load(function() { |
270
|
main2oH = $('#goods-container').outerHeight();
|
304
|
main2oH = $('#goods-container').outerHeight();
|
271
|
setTimeout(function(){
|
305
|
setTimeout(function(){
|
272
|
scH = $('#scroller').outerHeight();
|
306
|
scH = $('#scroller').outerHeight();
|
273
|
- console.log(scH)
|
|
|
274
|
},2000);
|
307
|
},2000);
|
275
|
});
|
308
|
});
|
276
|
|
309
|
|
|
@@ -282,7 +315,6 @@ function search(opt) { |
|
@@ -282,7 +315,6 @@ function search(opt) { |
282
|
nav, navType,
|
315
|
nav, navType,
|
283
|
page;
|
316
|
page;
|
284
|
|
317
|
|
285
|
-return;
|
|
|
286
|
if (searching) {
|
318
|
if (searching) {
|
287
|
return;
|
319
|
return;
|
288
|
}
|
320
|
}
|
|
@@ -296,11 +328,12 @@ return; |
|
@@ -296,11 +328,12 @@ return; |
296
|
}
|
328
|
}
|
297
|
}
|
329
|
}
|
298
|
|
330
|
|
299
|
- //处理active状态
|
|
|
300
|
- $listNav.children('.active').removeClass('active');
|
|
|
301
|
- $pre.addClass('active');
|
|
|
302
|
-
|
|
|
303
|
switch (opt.type) {
|
331
|
switch (opt.type) {
|
|
|
332
|
+ case 'shop_id':
|
|
|
333
|
+ ext = {
|
|
|
334
|
+ shop_id: opt.id
|
|
|
335
|
+ };
|
|
|
336
|
+ break;
|
304
|
case 'gender':
|
337
|
case 'gender':
|
305
|
ext = {
|
338
|
ext = {
|
306
|
gender: opt.id
|
339
|
gender: opt.id
|
|
@@ -373,7 +406,7 @@ return; |
|
@@ -373,7 +406,7 @@ return; |
373
|
|
406
|
|
374
|
$.ajax({
|
407
|
$.ajax({
|
375
|
type: 'GET',
|
408
|
type: 'GET',
|
376
|
- url: '/product/newsale/selectNewSale',
|
409
|
+ url: opt.url ? opt.url : '',
|
377
|
data: setting,
|
410
|
data: setting,
|
378
|
success: function(data) {
|
411
|
success: function(data) {
|
379
|
var $container,
|
412
|
var $container,
|
|
@@ -418,16 +451,17 @@ return; |
|
@@ -418,16 +451,17 @@ return; |
418
|
|
451
|
|
419
|
window.rePosFooter();
|
452
|
window.rePosFooter();
|
420
|
|
453
|
|
421
|
- scH = $('#scroller').outerHeight();
|
|
|
422
|
- console.log(scH)
|
|
|
423
|
- },
|
454
|
+ setTimeout(function () {
|
|
|
455
|
+ myScroll.refresh();
|
|
|
456
|
+ scH = $('#scroller').outerHeight();
|
|
|
457
|
+ }, 1000);
|
|
|
458
|
+ },
|
424
|
error: function() {
|
459
|
error: function() {
|
425
|
tip.show('网络断开连接了~');
|
460
|
tip.show('网络断开连接了~');
|
426
|
searching = false;
|
461
|
searching = false;
|
427
|
loading.hideLoadingMask();
|
462
|
loading.hideLoadingMask();
|
428
|
}
|
463
|
}
|
429
|
});
|
464
|
});
|
430
|
-
|
|
|
431
|
}
|
465
|
}
|
432
|
|
466
|
|
433
|
$.ajax({
|
467
|
$.ajax({
|
|
@@ -437,6 +471,13 @@ $.ajax({ |
|
@@ -437,6 +471,13 @@ $.ajax({ |
437
|
success: function(data) {
|
471
|
success: function(data) {
|
438
|
$goodsContainer.append(data);
|
472
|
$goodsContainer.append(data);
|
439
|
|
473
|
|
|
|
474
|
+ setTimeout(function () {
|
|
|
475
|
+ myScroll.refresh();
|
|
|
476
|
+ scH = $('#scroller').outerHeight();
|
|
|
477
|
+ }, 1000);
|
|
|
478
|
+
|
|
|
479
|
+
|
|
|
480
|
+
|
440
|
//初始化filter&注册filter回调
|
481
|
//初始化filter&注册filter回调
|
441
|
filter.initFilter({
|
482
|
filter.initFilter({
|
442
|
fCbFn: search,
|
483
|
fCbFn: search,
|
|
@@ -455,8 +496,13 @@ $listNav.bind('contextmenu', function(e) { |
|
@@ -455,8 +496,13 @@ $listNav.bind('contextmenu', function(e) { |
455
|
return false;
|
496
|
return false;
|
456
|
});
|
497
|
});
|
457
|
|
498
|
|
458
|
-$listNav.on('touchend touchcancel', function(e) {
|
499
|
+$posList.bind('contextmenu', function(e) {
|
|
|
500
|
+ return false;
|
|
|
501
|
+});
|
|
|
502
|
+
|
|
|
503
|
+$subNav.on('touchend touchcancel', function(e) {
|
459
|
var $this = $(e.target).closest('li'),
|
504
|
var $this = $(e.target).closest('li'),
|
|
|
505
|
+ cname,
|
460
|
nav,
|
506
|
nav,
|
461
|
navType,
|
507
|
navType,
|
462
|
$active;
|
508
|
$active;
|
|
@@ -485,12 +531,14 @@ $listNav.on('touchend touchcancel', function(e) { |
|
@@ -485,12 +531,14 @@ $listNav.on('touchend touchcancel', function(e) { |
485
|
filter.showFilter();
|
531
|
filter.showFilter();
|
486
|
}
|
532
|
}
|
487
|
} else {
|
533
|
} else {
|
488
|
-
|
|
|
489
|
if ($this.hasClass('new')) {
|
534
|
if ($this.hasClass('new')) {
|
|
|
535
|
+ cname = '.new';
|
490
|
navType = 'newest';
|
536
|
navType = 'newest';
|
491
|
} else if ($this.hasClass('price')) {
|
537
|
} else if ($this.hasClass('price')) {
|
|
|
538
|
+ cname = '.price';
|
492
|
navType = 'price';
|
539
|
navType = 'price';
|
493
|
} else if ($this.hasClass('discount')) {
|
540
|
} else if ($this.hasClass('discount')) {
|
|
|
541
|
+ cname = '.discount';
|
494
|
navType = 'discount';
|
542
|
navType = 'discount';
|
495
|
}
|
543
|
}
|
496
|
|
544
|
|
|
@@ -504,6 +552,7 @@ $listNav.on('touchend touchcancel', function(e) { |
|
@@ -504,6 +552,7 @@ $listNav.on('touchend touchcancel', function(e) { |
504
|
}
|
552
|
}
|
505
|
|
553
|
|
506
|
if ($this.hasClass('price') || $this.hasClass('discount')) {
|
554
|
if ($this.hasClass('price') || $this.hasClass('discount')) {
|
|
|
555
|
+ $this = $subNav.find(cname);
|
507
|
|
556
|
|
508
|
// 价格/折扣切换排序状态
|
557
|
// 价格/折扣切换排序状态
|
509
|
$this.find('.icon > .iconfont').toggleClass('cur');
|
558
|
$this.find('.icon > .iconfont').toggleClass('cur');
|
|
@@ -512,7 +561,7 @@ $listNav.on('touchend touchcancel', function(e) { |
|
@@ -512,7 +561,7 @@ $listNav.on('touchend touchcancel', function(e) { |
512
|
nav.order = nav.order === 0 ? 1 : 0; //切换排序
|
561
|
nav.order = nav.order === 0 ? 1 : 0; //切换排序
|
513
|
}
|
562
|
}
|
514
|
} else {
|
563
|
} else {
|
515
|
- $active = $this.siblings('.active');
|
564
|
+ $active = $subNav.find('.active');
|
516
|
|
565
|
|
517
|
$pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
|
566
|
$pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
|
518
|
|
567
|
|
|
@@ -540,25 +589,36 @@ $listNav.on('touchend touchcancel', function(e) { |
|
@@ -540,25 +589,36 @@ $listNav.on('touchend touchcancel', function(e) { |
540
|
}
|
589
|
}
|
541
|
}
|
590
|
}
|
542
|
|
591
|
|
543
|
- $active.removeClass('active');
|
|
|
544
|
- $this.addClass('active');
|
592
|
+ $subNav.children().removeClass('active');
|
|
|
593
|
+ $subNav.find(cname).addClass('active');
|
545
|
}
|
594
|
}
|
546
|
|
595
|
|
547
|
if (nav.reload) {
|
596
|
if (nav.reload) {
|
548
|
- search();
|
597
|
+ search({
|
|
|
598
|
+ type: 'shop_id',
|
|
|
599
|
+ id: '111',
|
|
|
600
|
+ url: '/index/search/search'
|
|
|
601
|
+ });
|
549
|
}
|
602
|
}
|
550
|
}
|
603
|
}
|
551
|
e.stopPropagation();
|
604
|
e.stopPropagation();
|
552
|
});
|
605
|
});
|
553
|
|
606
|
|
|
|
607
|
+
|
554
|
function scrollHandler() {
|
608
|
function scrollHandler() {
|
555
|
|
609
|
|
556
|
//当scroll到1/4$goodsContainer高度后继续请求下一页数据
|
610
|
//当scroll到1/4$goodsContainer高度后继续请求下一页数据
|
557
|
myScroll && myScroll.refresh();
|
611
|
myScroll && myScroll.refresh();
|
558
|
|
612
|
|
559
|
- if (sTop + winH > $('#scroller').height() - 0.25 * $goodsContainer.height() - 50){
|
613
|
+ if (sTop + winH > $('#scroller').height() - 0.25 *
|
|
|
614
|
+
|
|
|
615
|
+$goodsContainer.height() - 50){
|
560
|
if ($pre !== undefined) {
|
616
|
if ($pre !== undefined) {
|
561
|
- search();
|
617
|
+ search({
|
|
|
618
|
+ type: 'shop_id',
|
|
|
619
|
+ id: '1111',
|
|
|
620
|
+ url: '/index/search/search'
|
|
|
621
|
+ });
|
562
|
}
|
622
|
}
|
563
|
}
|
623
|
}
|
564
|
}
|
624
|
}
|
|
@@ -569,7 +629,12 @@ $(window).scroll(function() { |
|
@@ -569,7 +629,12 @@ $(window).scroll(function() { |
569
|
});
|
629
|
});
|
570
|
|
630
|
|
571
|
//初始请求最新第一页数据
|
631
|
//初始请求最新第一页数据
|
572
|
-search();
|
632
|
+search({
|
|
|
633
|
+ type: 'shop_id',
|
|
|
634
|
+ id: '1111',
|
|
|
635
|
+ url: '/index/search/search'
|
|
|
636
|
+ }
|
|
|
637
|
+);
|
573
|
|
638
|
|
574
|
$listNav.on('touchstart', 'li', function(e) {
|
639
|
$listNav.on('touchstart', 'li', function(e) {
|
575
|
$(this).addClass('bytouch');
|
640
|
$(this).addClass('bytouch');
|
|
@@ -577,6 +642,13 @@ $listNav.on('touchstart', 'li', function(e) { |
|
@@ -577,6 +642,13 @@ $listNav.on('touchstart', 'li', function(e) { |
577
|
$listNav.find('li').removeClass('bytouch');
|
642
|
$listNav.find('li').removeClass('bytouch');
|
578
|
});
|
643
|
});
|
579
|
|
644
|
|
|
|
645
|
+$posList.on('touchstart', 'li', function(e) {
|
|
|
646
|
+ $(this).addClass('bytouch');
|
|
|
647
|
+}).on('touchend touchcancel', function() {
|
|
|
648
|
+ $posList.find('li').removeClass('bytouch');
|
|
|
649
|
+});
|
|
|
650
|
+
|
|
|
651
|
+
|
580
|
|
652
|
|
581
|
//底部导航点击
|
653
|
//底部导航点击
|
582
|
function fotterClick(group) {
|
654
|
function fotterClick(group) {
|
|
@@ -604,4 +676,3 @@ $(document).bind('touchstart',function(){ |
|
@@ -604,4 +676,3 @@ $(document).bind('touchstart',function(){ |
604
|
$('.shop-foot-wrapper').bind('touchstart',function(e){
|
676
|
$('.shop-foot-wrapper').bind('touchstart',function(e){
|
605
|
stopPropagation(e);
|
677
|
stopPropagation(e);
|
606
|
}); |
678
|
}); |
607
|
- |
|
|