Authored by whb

index,js样式

... ... @@ -3721,6 +3721,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;
... ... @@ -3728,28 +3729,35 @@ module.exports = function(data) {
}
});
var loadAjax;
var url = data.url;
var url = data.url,
count = data.count,
rows = data.rows;
data.pageIndex = 0;
delete data.url;
delete data.count;
delete data.rows;
loadAjax = function(url, data, count) {
var options = {
type: 'POST',
url: url,
data: data,
success: function(data) {
var code = data.code;
success: function(result) {
var code = result.code;
var myTemplate,len,pos;
if (code === 200) {
len = data.goods.length % count;
pos = data.goods.length - len - 1;
len = result.goods.length % count;
pos = result.goods.length - len - 1;
data.goods.splice(pos, len);
result.goods.splice(pos, len);
myTemplate = Handlebars.compile(load.tpl);
$container.append(myTemplate(data.goods));
$container.append(myTemplate(result.goods));
data.pageIndex = data.pageIndex + result.goods.length;
//懒加载插件貌似有点问题,图片先直接展示
lazyload($container.find('img.lazy'));
... ... @@ -3768,17 +3776,14 @@ module.exports = function(data) {
}
};
options.data = data;
$.ajax(options);
};
load.on('after', function(p) {
data = $.extend({}, data, {
pageIndex: p.index
});
data.pageCount = data.count * data.rows[1];
data.pageCount = count * rows[1];
loadAjax(url, data);
});
... ... @@ -3839,16 +3844,12 @@ module.exports = function(data) {
load.tpl += '</div>';
load.tpl += '{{/each}}';
data = $.extend({}, data, {
pageIndex: p.index
});
data.pageCount = data.count * data.rows[0];
data.pageCount = count * rows[0];
loadAjax(url, data, data.count);
load.emit();
//load.emit();
});
load.init();
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.