|
@@ -13,55 +13,92 @@ $('#close-message').click(function() { |
|
@@ -13,55 +13,92 @@ $('#close-message').click(function() { |
13
|
$('.message-tip').slideUp(200);
|
13
|
$('.message-tip').slideUp(200);
|
14
|
});
|
14
|
});
|
15
|
|
15
|
|
|
|
16
|
+/**
|
|
|
17
|
+ *
|
|
|
18
|
+ * @param self 点击的控件
|
|
|
19
|
+ * @param $ul 列表父
|
|
|
20
|
+ * @param page 总共页数
|
|
|
21
|
+ * @param itemWith 子元素宽
|
|
|
22
|
+ * @param curPage 当前页码
|
|
|
23
|
+ * @param num 一页商品数量
|
|
|
24
|
+ */
|
|
|
25
|
+function pageChange(self, $ul, page, itemWith, curPage, num) {
|
|
|
26
|
+ var $this = self,
|
|
|
27
|
+ left;
|
|
|
28
|
+
|
|
|
29
|
+ if ($this.hasClass('next')) {
|
|
|
30
|
+
|
|
|
31
|
+ //第2页显示前翻按钮
|
|
|
32
|
+ if (curPage === 2) {
|
|
|
33
|
+ $this.siblings().removeClass('no-visible');
|
|
|
34
|
+ }
|
|
|
35
|
+
|
|
|
36
|
+ //最后一页隐藏后翻按钮
|
|
|
37
|
+ if (curPage === page) {
|
|
|
38
|
+ $this.addClass('no-visible');
|
|
|
39
|
+ }
|
|
|
40
|
+ } else {
|
|
|
41
|
+
|
|
|
42
|
+ //倒数第2页显示后翻按钮
|
|
|
43
|
+ if (curPage === page - 1) {
|
|
|
44
|
+ $this.siblings().removeClass('no-visible');
|
|
|
45
|
+ }
|
|
|
46
|
+
|
|
|
47
|
+ //第1页隐藏前翻按钮
|
|
|
48
|
+ if (curPage === 1) {
|
|
|
49
|
+ $this.addClass('no-visible');
|
|
|
50
|
+ }
|
|
|
51
|
+ }
|
|
|
52
|
+
|
|
|
53
|
+ left = -num * (curPage - 1) * itemWith;
|
|
|
54
|
+
|
|
|
55
|
+ $ul.animate({
|
|
|
56
|
+ marginLeft: left
|
|
|
57
|
+ }, 400);
|
|
|
58
|
+}
|
|
|
59
|
+
|
16
|
//新品上架
|
60
|
//新品上架
|
17
|
(function() {
|
61
|
(function() {
|
18
|
var $naPager = $('.na-pager'),
|
62
|
var $naPager = $('.na-pager'),
|
|
|
63
|
+ $rcPager = $('.rc-pager'),
|
19
|
$naUl = $('.new-arrival ul'),
|
64
|
$naUl = $('.new-arrival ul'),
|
|
|
65
|
+ $rcUl = $('.recommend ul'),
|
20
|
naPage = Math.ceil($naUl.children('li').length / 5),
|
66
|
naPage = Math.ceil($naUl.children('li').length / 5),
|
|
|
67
|
+ rcPage = Math.ceil($rcUl.children('li').length / 6),
|
21
|
naItemWith = $naUl.children('li:last-child').outerWidth(),
|
68
|
naItemWith = $naUl.children('li:last-child').outerWidth(),
|
22
|
- naCurPage = 1;
|
69
|
+ rcItemWith = $rcUl.children('li:last-child').outerWidth(),
|
|
|
70
|
+ naCurPage = 1,
|
|
|
71
|
+ rcCurPage = 1;
|
23
|
|
72
|
|
24
|
$naUl.width($naUl.width() * naPage);
|
73
|
$naUl.width($naUl.width() * naPage);
|
|
|
74
|
+ $rcUl.width($rcUl.width() * rcPage);
|
25
|
|
75
|
|
26
|
//最新上架翻页
|
76
|
//最新上架翻页
|
27
|
$naPager.click(function() {
|
77
|
$naPager.click(function() {
|
28
|
- var $this = $(this),
|
|
|
29
|
- left;
|
|
|
30
|
-
|
|
|
31
|
- if ($this.hasClass('next')) {
|
|
|
32
|
-
|
|
|
33
|
- //后翻
|
|
|
34
|
- ++naCurPage;
|
|
|
35
|
-
|
|
|
36
|
- //第2页显示前翻按钮
|
|
|
37
|
- if (naCurPage === 2) {
|
|
|
38
|
- $this.siblings().removeClass('no-visible');
|
|
|
39
|
- }
|
78
|
+ var $this = $(this);
|
40
|
|
79
|
|
41
|
- //最后一页隐藏后翻按钮
|
|
|
42
|
- if (naCurPage === naPage) {
|
|
|
43
|
- $this.addClass('no-visible');
|
80
|
+ if (naPage > 1) {
|
|
|
81
|
+ if ($this.hasClass('next')) {
|
|
|
82
|
+ ++naCurPage;
|
|
|
83
|
+ } else {
|
|
|
84
|
+ --naCurPage;
|
44
|
}
|
85
|
}
|
45
|
- } else {
|
86
|
+ pageChange($this, $naUl, naPage, naItemWith, naCurPage, 5);
|
|
|
87
|
+ }
|
|
|
88
|
+ });
|
46
|
|
89
|
|
47
|
- //前翻
|
|
|
48
|
- --naCurPage;
|
90
|
+ //为你推荐翻页
|
|
|
91
|
+ $rcPager.click(function() {
|
|
|
92
|
+ var $this = $(this);
|
49
|
|
93
|
|
50
|
- //倒数第2页显示后翻按钮
|
|
|
51
|
- if (naCurPage === naPage - 1) {
|
|
|
52
|
- $this.siblings().removeClass('no-visible');
|
94
|
+ if (rcPage > 1) {
|
|
|
95
|
+ if ($this.hasClass('next')) {
|
|
|
96
|
+ ++rcCurPage;
|
|
|
97
|
+ } else {
|
|
|
98
|
+ --rcCurPage;
|
53
|
}
|
99
|
}
|
54
|
|
100
|
|
55
|
- //第1页隐藏前翻按钮
|
|
|
56
|
- if (naCurPage === 1) {
|
|
|
57
|
- $this.addClass('no-visible');
|
|
|
58
|
- }
|
101
|
+ pageChange($this, $rcUl, rcPage, rcItemWith, rcCurPage, 6);
|
59
|
}
|
102
|
}
|
60
|
-
|
|
|
61
|
- left = -5 * (naCurPage - 1) * naItemWith;
|
|
|
62
|
-
|
|
|
63
|
- $naUl.animate({
|
|
|
64
|
- marginLeft: left
|
|
|
65
|
- }, 400);
|
|
|
66
|
});
|
103
|
});
|
67
|
}()); |
104
|
}()); |