Authored by weiqingting

翻页计算修改

... ... @@ -94,6 +94,7 @@ module.exports = function(data) {
var $load = $('.loading a');
var load = new InfiniteLoad({
index: 1,
isload:false,
offset: {
height: function() {
return parseFloat($container.offset().top) + parseFloat($container.height()) - 200;
... ... @@ -101,20 +102,21 @@ module.exports = function(data) {
}
});
var loadAjax;
var url = data.url;
var url = data.url,
count = data.count,
rows = data.rows;
data.pageIndex=0;
data.pageIndex = 0;
delete data.url;
delete data.count;
delete data.rows;
loadAjax = function(url, data, count) {
data.pageIndex++;
var options = {
type: 'POST',
url: url,
data: data,
success: function(result) {
var code = result.code;
var myTemplate,len,pos;
... ... @@ -128,7 +130,7 @@ module.exports = function(data) {
myTemplate = Handlebars.compile(load.tpl);
$container.append(myTemplate(result.goods));
data.pageIndex += result.goods.length;
data.pageIndex = data.pageIndex + result.goods.length;
//懒加载插件貌似有点问题,图片先直接展示
lazyload($container.find('img.lazy'));
... ... @@ -147,13 +149,15 @@ module.exports = function(data) {
}
};
options.data = data;
$.ajax(options);
};
load.on('after', function(p) {
data.pageCount = data.count * data.rows[1];
data.pageCount = count * rows[1];
loadAjax(url, data);
});
... ... @@ -215,11 +219,11 @@ module.exports = function(data) {
load.tpl += '{{/each}}';
data.pageCount = data.count * data.rows[0];
data.pageCount = count * rows[0];
loadAjax(url, data, data.count);
load.emit();
//load.emit();
});
load.init();
... ...