|
@@ -5,9 +5,16 @@ var $ = require('yoho.zepto'), |
|
@@ -5,9 +5,16 @@ var $ = require('yoho.zepto'), |
5
|
var $curNav,
|
5
|
var $curNav,
|
6
|
$navList = $('#discount-nav'),
|
6
|
$navList = $('#discount-nav'),
|
7
|
$newArrivalList = $('#discount-goods-list'),
|
7
|
$newArrivalList = $('#discount-goods-list'),
|
8
|
- $goods = $newArrivalList.children('.goods-list');
|
8
|
+ $goods = $newArrivalList.children('.goods-list'),
|
|
|
9
|
+ $goodList = $('.goods-list');
|
9
|
|
10
|
|
10
|
var swiper;
|
11
|
var swiper;
|
|
|
12
|
+var index = 0,
|
|
|
13
|
+ winH = $(window).height(),
|
|
|
14
|
+ loadMoreH = $('#load-more').height(),
|
|
|
15
|
+ loading = false,
|
|
|
16
|
+ page = 0,
|
|
|
17
|
+ pd = "";
|
11
|
|
18
|
|
12
|
swiper = new Swiper('.swiper-container', {
|
19
|
swiper = new Swiper('.swiper-container', {
|
13
|
lazyLoading: true,
|
20
|
lazyLoading: true,
|
|
@@ -19,14 +26,14 @@ $curNav = $navList.children('.focus'); |
|
@@ -19,14 +26,14 @@ $curNav = $navList.children('.focus'); |
19
|
|
26
|
|
20
|
$('#discount-nav').delegate('li', 'touchstart', function() {
|
27
|
$('#discount-nav').delegate('li', 'touchstart', function() {
|
21
|
var $this = $(this),
|
28
|
var $this = $(this),
|
22
|
- $content,
|
|
|
23
|
- index;
|
29
|
+ $content;
|
24
|
|
30
|
|
25
|
if ($this.hasClass('focus')) {
|
31
|
if ($this.hasClass('focus')) {
|
26
|
return;
|
32
|
return;
|
27
|
}
|
33
|
}
|
28
|
|
34
|
|
29
|
index = $this.index();
|
35
|
index = $this.index();
|
|
|
36
|
+ pd = getSalePdByChoose(index);
|
30
|
|
37
|
|
31
|
$this.addClass('focus');
|
38
|
$this.addClass('focus');
|
32
|
$curNav.removeClass('focus');
|
39
|
$curNav.removeClass('focus');
|
|
@@ -38,4 +45,70 @@ $('#discount-nav').delegate('li', 'touchstart', function() { |
|
@@ -38,4 +45,70 @@ $('#discount-nav').delegate('li', 'touchstart', function() { |
38
|
$curNav = $this;
|
45
|
$curNav = $this;
|
39
|
|
46
|
|
40
|
$(document).trigger('scroll'); //Trigger lazyLoad
|
47
|
$(document).trigger('scroll'); //Trigger lazyLoad
|
41
|
-}); |
|
|
|
|
48
|
+});
|
|
|
49
|
+
|
|
|
50
|
+//srcoll to load more
|
|
|
51
|
+$(window).scroll(function () {
|
|
|
52
|
+ if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
|
|
|
53
|
+ if (loading) {
|
|
|
54
|
+ return;
|
|
|
55
|
+ }
|
|
|
56
|
+ loading = true;
|
|
|
57
|
+ num = $goodList.children('.good-info').length;
|
|
|
58
|
+ $.ajax({
|
|
|
59
|
+ type: 'GET',
|
|
|
60
|
+ url: '/product/newsale/selectNewSale',
|
|
|
61
|
+ data: {
|
|
|
62
|
+ p_d: pd,
|
|
|
63
|
+ page: page + 1
|
|
|
64
|
+ },
|
|
|
65
|
+ success: function(data) {
|
|
|
66
|
+ if (data === ' ') {
|
|
|
67
|
+
|
|
|
68
|
+ //opt.end = true;
|
|
|
69
|
+ loading = false;
|
|
|
70
|
+ return;
|
|
|
71
|
+ }
|
|
|
72
|
+
|
|
|
73
|
+ $goodList.append(data);
|
|
|
74
|
+
|
|
|
75
|
+ //lazyLoad
|
|
|
76
|
+ //lazyLoad($goodList.children('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
|
|
|
77
|
+ lazyLoad($('.good-info').find('img.lazy'));
|
|
|
78
|
+
|
|
|
79
|
+ loading = false;
|
|
|
80
|
+ page++;
|
|
|
81
|
+ },
|
|
|
82
|
+ error: function() {
|
|
|
83
|
+ tip.show('网络断开连接了~');
|
|
|
84
|
+ loading = false;
|
|
|
85
|
+ }
|
|
|
86
|
+ });
|
|
|
87
|
+ }
|
|
|
88
|
+
|
|
|
89
|
+});
|
|
|
90
|
+
|
|
|
91
|
+/**
|
|
|
92
|
+ * 根据用户的选择获取商品折扣值
|
|
|
93
|
+ *
|
|
|
94
|
+ * @param int index
|
|
|
95
|
+ * @return string
|
|
|
96
|
+ */
|
|
|
97
|
+function getSalePdByChoose(index) {
|
|
|
98
|
+ var pd = "0.1,0.3";
|
|
|
99
|
+ switch (index) {
|
|
|
100
|
+ case 0:
|
|
|
101
|
+ pd = "0.1,0.3";
|
|
|
102
|
+ break;
|
|
|
103
|
+ case 1:
|
|
|
104
|
+ pd = "0.4,0.6";
|
|
|
105
|
+ break;
|
|
|
106
|
+ case 2:
|
|
|
107
|
+ pd = "0.7,0.9";
|
|
|
108
|
+ break;
|
|
|
109
|
+ case 3:
|
|
|
110
|
+ pd = "0.1,0.9";
|
|
|
111
|
+ break;
|
|
|
112
|
+ }
|
|
|
113
|
+ return pd;
|
|
|
114
|
+} |