|
@@ -17,27 +17,32 @@ var winH = $(window).height(); |
|
@@ -17,27 +17,32 @@ var winH = $(window).height(); |
17
|
|
17
|
|
18
|
var activeType = $navLi.filter('.active').data('type'); //当前active的项的index
|
18
|
var activeType = $navLi.filter('.active').data('type'); //当前active的项的index
|
19
|
|
19
|
|
20
|
-var orderPage = {};
|
20
|
+var order = {
|
|
|
21
|
+ page: 0,
|
|
|
22
|
+ end: false
|
|
|
23
|
+};
|
21
|
|
24
|
|
22
|
var inAjax = false;
|
25
|
var inAjax = false;
|
23
|
|
26
|
|
24
|
var loading = require('../plugin/loading');
|
27
|
var loading = require('../plugin/loading');
|
25
|
|
28
|
|
26
|
-var navHammer, orderHammer;
|
29
|
+var orderHammer;
|
27
|
|
30
|
|
28
|
//加载订单
|
31
|
//加载订单
|
29
|
-function getOrders() {
|
32
|
+function getOrders(option) {
|
30
|
var opt = {
|
33
|
var opt = {
|
31
|
type: activeType,
|
34
|
type: activeType,
|
32
|
- page: orderPage[activeType] ? (orderPage[activeType] + 1) : 1
|
35
|
+ page: order.page + 1
|
33
|
};
|
36
|
};
|
34
|
|
37
|
|
|
|
38
|
+ var show = option && option.showLoadingMask;
|
|
|
39
|
+
|
35
|
if (inAjax) {
|
40
|
if (inAjax) {
|
36
|
return;
|
41
|
return;
|
37
|
}
|
42
|
}
|
38
|
|
43
|
|
39
|
inAjax = true;
|
44
|
inAjax = true;
|
40
|
- loading.showLoadingMask();
|
45
|
+ show && loading.showLoadingMask();
|
41
|
|
46
|
|
42
|
$.ajax({
|
47
|
$.ajax({
|
43
|
type: 'GET',
|
48
|
type: 'GET',
|
|
@@ -46,23 +51,27 @@ function getOrders() { |
|
@@ -46,23 +51,27 @@ function getOrders() { |
46
|
success: function(data) {
|
51
|
success: function(data) {
|
47
|
var num;
|
52
|
var num;
|
48
|
|
53
|
|
49
|
- if (data.code === 200) {
|
|
|
50
|
- orderPage[opt.type] = opt.page;
|
54
|
+ if (data !== ' ') {
|
|
|
55
|
+ order.page = opt.page;
|
51
|
|
56
|
|
52
|
if (opt.page === 1) {
|
57
|
if (opt.page === 1) {
|
53
|
- $curContainer.html(data.data);
|
58
|
+ $curContainer.html(data);
|
54
|
lazyLoad($curContainer.find('.lazy'));
|
59
|
lazyLoad($curContainer.find('.lazy'));
|
55
|
} else {
|
60
|
} else {
|
56
|
num = $curContainer.children('.order').length;
|
61
|
num = $curContainer.children('.order').length;
|
57
|
- $curContainer.append(data.data);
|
62
|
+ $curContainer.append(data);
|
58
|
|
63
|
|
59
|
//lazyload
|
64
|
//lazyload
|
60
|
- lazyLoad($curContainer.children('.order:gt(' + (num - 1) + ') .lazy'));
|
65
|
+ lazyLoad($curContainer.children('.order:gt(' + (num - 1) + ')').find('.lazy'));
|
61
|
}
|
66
|
}
|
|
|
67
|
+
|
|
|
68
|
+ window.rePosFooter(); //重新计算底部位置
|
|
|
69
|
+ } else {
|
|
|
70
|
+ order.end = true;
|
62
|
}
|
71
|
}
|
63
|
|
72
|
|
64
|
inAjax = false;
|
73
|
inAjax = false;
|
65
|
- loading.hideLoadingMask();
|
74
|
+ show && loading.hideLoadingMask();
|
66
|
}
|
75
|
}
|
67
|
});
|
76
|
});
|
68
|
}
|
77
|
}
|
|
@@ -83,33 +92,6 @@ lazyLoad(); |
|
@@ -83,33 +92,6 @@ lazyLoad(); |
83
|
|
92
|
|
84
|
loading.init($('body')); //满屏loading
|
93
|
loading.init($('body')); //满屏loading
|
85
|
|
94
|
|
86
|
-//导航切换
|
|
|
87
|
-navHammer = new Hammer(document.getElementById('order-nav'));
|
|
|
88
|
-navHammer.on('tap', function(e) {
|
|
|
89
|
- var $cur = $(e.target).closest('li'),
|
|
|
90
|
- index;
|
|
|
91
|
-
|
|
|
92
|
- if ($cur.length === 0 || $cur.hasClass('active')) {
|
|
|
93
|
- return;
|
|
|
94
|
- }
|
|
|
95
|
-
|
|
|
96
|
- index = $cur.index();
|
|
|
97
|
-
|
|
|
98
|
- $navLi.filter('.active').removeClass('active');
|
|
|
99
|
- $cur.addClass('active');
|
|
|
100
|
-
|
|
|
101
|
- $curContainer.addClass('hide');
|
|
|
102
|
- $curContainer = $orderContainer.children(':eq(' + index + ')').removeClass('hide');
|
|
|
103
|
-
|
|
|
104
|
- activeType = $cur.data('type');
|
|
|
105
|
-
|
|
|
106
|
- if (orderPage[activeType]) {
|
|
|
107
|
- return;
|
|
|
108
|
- } else {
|
|
|
109
|
- getOrders();
|
|
|
110
|
- }
|
|
|
111
|
-});
|
|
|
112
|
-
|
|
|
113
|
//点击订单区域跳转订单详情页
|
95
|
//点击订单区域跳转订单详情页
|
114
|
orderHammer = new Hammer(document.getElementById('order-container'));
|
96
|
orderHammer = new Hammer(document.getElementById('order-container'));
|
115
|
orderHammer.on('tap', function(e) {
|
97
|
orderHammer.on('tap', function(e) {
|
|
@@ -168,9 +150,13 @@ orderHammer.on('tap', function(e) { |
|
@@ -168,9 +150,13 @@ orderHammer.on('tap', function(e) { |
168
|
});
|
150
|
});
|
169
|
|
151
|
|
170
|
$(window).scroll(function() {
|
152
|
$(window).scroll(function() {
|
171
|
- if ($(window).scrollTop() + winH >
|
153
|
+ if (order.end === false && $(window).scrollTop() + winH >
|
172
|
$(document).height() - 0.25 * $orderContainer.height()) {
|
154
|
$(document).height() - 0.25 * $orderContainer.height()) {
|
173
|
- getOrders();
|
155
|
+
|
|
|
156
|
+ //下拉请求时不显示mask
|
|
|
157
|
+ getOrders({
|
|
|
158
|
+ noLoadingMask: true
|
|
|
159
|
+ });
|
174
|
}
|
160
|
}
|
175
|
});
|
161
|
});
|
176
|
|
162
|
|