Authored by mark

add devidepage

... ... @@ -837,20 +837,6 @@ function fetchComment() {
loadingComments,
loadingConsults;
$('.comments ul').on('click', 'a', function() {
var $this = $(this);
var href = $this.data('page');
var data = href.split('?')[1].split('&');
var result = data.map(function(i) {
return i.split('=')[1];
});
loadAllComments(currentType, result[2]);
});
function loadComments(type, nowPage) {
if (loadingComments) {
return;
... ... @@ -873,7 +859,7 @@ function fetchComment() {
// 购买评价
function loadAllComments(type, nowPage) {
loadComments(type, nowPage).then(function(data) {
var res, filter, $ul, totalnum;
var res, filter, $ul, totalnum, baseUrl;
if (data.code === 200) {
res = data.data;
... ... @@ -897,7 +883,7 @@ function fetchComment() {
}
if (fit.filterId == type) {
if (fit.filterId === type) {
totalnum = fit.num;
}
... ... @@ -911,8 +897,10 @@ function fetchComment() {
comments: res
}));
var baseUrl = '/product/detail/comment?productId=' + id + '&filterId=' + '7';
$ul.append(setPager({baseUrl: baseUrl, totalRecords: totalnum, page: nowPage, type: 'ellipsis', theme: 'msg-pager'}));
baseUrl = '/product/detail/comment?productId=' + id + '&filterId=7';
$ul.append(
setPager({baseUrl: baseUrl, totalRecords: totalnum, page: nowPage, type: 'ellipsis', theme: 'msg-pager'})
);
}
}).always(function() {
... ... @@ -920,6 +908,19 @@ function fetchComment() {
});
}
$('.comments ul').on('click', 'a', function() {
var $this = $(this);
var href = $this.data('page');
var data = href.split('?')[1].split('&');
var result = data.map(function(i) {
return i.split('=')[1];
});
loadAllComments(currentType, result[2]);
});
// 顾客咨询
function loadConsults() {
if (loadingConsults) {
... ...
... ... @@ -48,19 +48,19 @@ module.exports = function(opts) {
pageVar + '=';
function getPageNums(ntype) {
/** 分页展示页码个数begin 规则:展示最靠近当前页的指定个数 **/
var pageShowMax = num % 2 === 0 ? page - 1 : page;
var pageShowMin = page;
var pageNums = [];
var num = showNum;
var i, n;
if (ntype === 'e') {
num = num - 2;
num = num > 2 ? num : 2;
}
/** 分页展示页码个数begin 规则:展示最靠近当前页的指定个数 **/
var pageShowMax = num % 2 === 0 ? page - 1 : page;
var pageShowMin = page;
for (var i = 0; i < Math.floor(num / 2); i++) {
for (i = 0; i < Math.floor(num / 2); i++) {
pageShowMax++;
pageShowMin--;
if (pageShowMax > totalPages) {
... ... @@ -77,7 +77,7 @@ module.exports = function(opts) {
}
}
for (var n = pageShowMin; n <= pageShowMax; n++) {
for (n = pageShowMin; n <= pageShowMax; n++) {
pageNums.push(n);
}
... ... @@ -112,9 +112,9 @@ module.exports = function(opts) {
if (val === '.') {
ret += '<a>...</a>';
} else {
ret += '<a href="javascript:void(0)" data-page="'+ base + val +'"' +
(page === val ? 'class="'+ currentClass +'"' : '') +
' title="第'+ val +'页">'+ val + '</a>';
ret += '<a href="javascript:void(0)" data-page="' + base + val + '"' +
(page === val ? 'class="' + currentClass + '"' : '') +
' title="第' + val + '页">' + val + '</a>';
}
});
}
... ... @@ -143,32 +143,32 @@ module.exports = function(opts) {
items = $.isArray(items) ? items : (items || ALL_TYPES.stand).split('-');
var hasPage = false; // 配置中如果配置了多次 page/pe 则将忽略,只第一次有效
var ret = '<div class="pager'+' '+theme +'">';
var ret = '<div class="pager' + ' ' + theme + '">';
items.forEach(function(val) {
switch (val) {
case 'f' :
if (page > 1) {
ret += '<a href="javascript:void(0)" title="首页" data-page="'+ base +'1">首页</a>';
ret += '<a href="javascript:void(0)" title="首页" data-page="' + base + '1">首页</a>';
}
break;
case 'p' :
if (page > 1) {
ret += '<a href="javascript:void(0)" data-page="'+ base + (page - 1) +
ret += '<a href="javascript:void(0)" data-page="' + base + (page - 1) +
'" title="上一页"><span class="iconfont">&#xe60e;</span>上一页</a>';
}
break;
case 'n' :
if (page < totalPages) {
ret += '<a href="javascript:void(0)" data-page="'+ base + (page + 1) +
ret += '<a href="javascript:void(0)" data-page="' + base + (page + 1) +
'" title="下一页">下一页<span class="iconfont">&#xe60c;</span></a>';
}
break;
case 'l' :
if (page < totalPages) {
ret += '<a href="javascript:void(0)" data-page="'+ base + totalPages +'" title="尾页">尾页</a>';
ret += '<a href="javascript:void(0)" data-page="' + base + totalPages + '" title="尾页">尾页</a>';
}
break;
case 'info' :
... ...