Showing
1 changed file
with
13 additions
and
9 deletions
@@ -94,6 +94,7 @@ module.exports = function(data) { | @@ -94,6 +94,7 @@ module.exports = function(data) { | ||
94 | var $load = $('.loading a'); | 94 | var $load = $('.loading a'); |
95 | var load = new InfiniteLoad({ | 95 | var load = new InfiniteLoad({ |
96 | index: 1, | 96 | index: 1, |
97 | + isload:false, | ||
97 | offset: { | 98 | offset: { |
98 | height: function() { | 99 | height: function() { |
99 | return parseFloat($container.offset().top) + parseFloat($container.height()) - 200; | 100 | return parseFloat($container.offset().top) + parseFloat($container.height()) - 200; |
@@ -101,20 +102,21 @@ module.exports = function(data) { | @@ -101,20 +102,21 @@ module.exports = function(data) { | ||
101 | } | 102 | } |
102 | }); | 103 | }); |
103 | var loadAjax; | 104 | var loadAjax; |
104 | - var url = data.url; | 105 | + var url = data.url, |
106 | + count = data.count, | ||
107 | + rows = data.rows; | ||
105 | 108 | ||
106 | - data.pageIndex=0; | 109 | + data.pageIndex = 0; |
107 | 110 | ||
108 | delete data.url; | 111 | delete data.url; |
112 | + delete data.count; | ||
113 | + delete data.rows; | ||
109 | 114 | ||
110 | loadAjax = function(url, data, count) { | 115 | loadAjax = function(url, data, count) { |
111 | 116 | ||
112 | - data.pageIndex++; | ||
113 | - | ||
114 | var options = { | 117 | var options = { |
115 | type: 'POST', | 118 | type: 'POST', |
116 | url: url, | 119 | url: url, |
117 | - data: data, | ||
118 | success: function(result) { | 120 | success: function(result) { |
119 | var code = result.code; | 121 | var code = result.code; |
120 | var myTemplate,len,pos; | 122 | var myTemplate,len,pos; |
@@ -128,7 +130,7 @@ module.exports = function(data) { | @@ -128,7 +130,7 @@ module.exports = function(data) { | ||
128 | myTemplate = Handlebars.compile(load.tpl); | 130 | myTemplate = Handlebars.compile(load.tpl); |
129 | 131 | ||
130 | $container.append(myTemplate(result.goods)); | 132 | $container.append(myTemplate(result.goods)); |
131 | - data.pageIndex += result.goods.length; | 133 | + data.pageIndex = data.pageIndex + result.goods.length; |
132 | 134 | ||
133 | //懒加载插件貌似有点问题,图片先直接展示 | 135 | //懒加载插件貌似有点问题,图片先直接展示 |
134 | lazyload($container.find('img.lazy')); | 136 | lazyload($container.find('img.lazy')); |
@@ -147,13 +149,15 @@ module.exports = function(data) { | @@ -147,13 +149,15 @@ module.exports = function(data) { | ||
147 | } | 149 | } |
148 | }; | 150 | }; |
149 | 151 | ||
152 | + | ||
153 | + options.data = data; | ||
150 | $.ajax(options); | 154 | $.ajax(options); |
151 | }; | 155 | }; |
152 | 156 | ||
153 | 157 | ||
154 | load.on('after', function(p) { | 158 | load.on('after', function(p) { |
155 | 159 | ||
156 | - data.pageCount = data.count * data.rows[1]; | 160 | + data.pageCount = count * rows[1]; |
157 | 161 | ||
158 | loadAjax(url, data); | 162 | loadAjax(url, data); |
159 | }); | 163 | }); |
@@ -215,11 +219,11 @@ module.exports = function(data) { | @@ -215,11 +219,11 @@ module.exports = function(data) { | ||
215 | load.tpl += '{{/each}}'; | 219 | load.tpl += '{{/each}}'; |
216 | 220 | ||
217 | 221 | ||
218 | - data.pageCount = data.count * data.rows[0]; | 222 | + data.pageCount = count * rows[0]; |
219 | 223 | ||
220 | loadAjax(url, data, data.count); | 224 | loadAjax(url, data, data.count); |
221 | 225 | ||
222 | - load.emit(); | 226 | + //load.emit(); |
223 | }); | 227 | }); |
224 | 228 | ||
225 | load.init(); | 229 | load.init(); |
-
Please register or login to post a comment