Showing
1 changed file
with
12 additions
and
14 deletions
@@ -103,26 +103,32 @@ module.exports = function(data) { | @@ -103,26 +103,32 @@ module.exports = function(data) { | ||
103 | var loadAjax; | 103 | var loadAjax; |
104 | var url = data.url; | 104 | var url = data.url; |
105 | 105 | ||
106 | + data.pageIndex=0; | ||
107 | + | ||
106 | delete data.url; | 108 | delete data.url; |
107 | 109 | ||
108 | loadAjax = function(url, data, count) { | 110 | loadAjax = function(url, data, count) { |
111 | + | ||
112 | + data.pageIndex++; | ||
113 | + | ||
109 | var options = { | 114 | var options = { |
110 | type: 'POST', | 115 | type: 'POST', |
111 | url: url, | 116 | url: url, |
112 | data: data, | 117 | data: data, |
113 | - success: function(data) { | ||
114 | - var code = data.code; | 118 | + success: function(result) { |
119 | + var code = result.code; | ||
115 | var myTemplate,len,pos; | 120 | var myTemplate,len,pos; |
116 | 121 | ||
117 | if (code === 200) { | 122 | if (code === 200) { |
118 | - len = data.goods.length % count; | ||
119 | - pos = data.goods.length - len - 1; | 123 | + len = result.goods.length % count; |
124 | + pos = result.goods.length - len - 1; | ||
120 | 125 | ||
121 | - data.goods.splice(pos, len); | 126 | + result.goods.splice(pos, len); |
122 | 127 | ||
123 | myTemplate = Handlebars.compile(load.tpl); | 128 | myTemplate = Handlebars.compile(load.tpl); |
124 | 129 | ||
125 | - $container.append(myTemplate(data.goods)); | 130 | + $container.append(myTemplate(result.goods)); |
131 | + data.pageIndex += result.goods.length; | ||
126 | 132 | ||
127 | //懒加载插件貌似有点问题,图片先直接展示 | 133 | //懒加载插件貌似有点问题,图片先直接展示 |
128 | lazyload($container.find('img.lazy')); | 134 | lazyload($container.find('img.lazy')); |
@@ -146,10 +152,6 @@ module.exports = function(data) { | @@ -146,10 +152,6 @@ module.exports = function(data) { | ||
146 | 152 | ||
147 | 153 | ||
148 | load.on('after', function(p) { | 154 | load.on('after', function(p) { |
149 | - data = $.extend({}, data, { | ||
150 | - pageIndex: p.index | ||
151 | - }); | ||
152 | - | ||
153 | 155 | ||
154 | data.pageCount = data.count * data.rows[1]; | 156 | data.pageCount = data.count * data.rows[1]; |
155 | 157 | ||
@@ -212,10 +214,6 @@ module.exports = function(data) { | @@ -212,10 +214,6 @@ module.exports = function(data) { | ||
212 | load.tpl += '</div>'; | 214 | load.tpl += '</div>'; |
213 | load.tpl += '{{/each}}'; | 215 | load.tpl += '{{/each}}'; |
214 | 216 | ||
215 | - data = $.extend({}, data, { | ||
216 | - pageIndex: p.index | ||
217 | - }); | ||
218 | - | ||
219 | 217 | ||
220 | data.pageCount = data.count * data.rows[0]; | 218 | data.pageCount = data.count * data.rows[0]; |
221 | 219 |
-
Please register or login to post a comment