<script src="/static/js/lib/jquery-pages/kkpager.min.js"></script>
<script>
$(function () {
/*分页*/
paging();
});
function paging() {
var totalPage = 20;
var totalRecords = 12;
var pageNo = getParameter('page');
if (!pageNo) {
pageNo = 1;
}
//生成分页
//有些参数是可选的,比如lang,若不传有默认值
kkpager.generPageHtml({
pno: pageNo,
//总页码
total: totalPage,
//总数据条数
totalRecords: totalRecords,
mode: 'click',//默认值是link,可选link或者click
click: function (n) { // n就是页码
//手动选中按钮
this.selectPage(n);
// 把页码传给后台
var sort = $('.screen-left a.active').data('sort');
console.log(n);
$.get('getGoods', {'page': n, 'sort': sort,}, function (result) {
if (result.code === 1) {
var result = template("goodsTemplate", result);
$('.all-goods').html(result);
$.getScript("/static/js/module/web/search.js"); //加载js文件
}
}, 'json');
return false;
}
// getLink : function(n){
// return this.hrefFormer + this.hrefLatter + "?page="+n;
// }
});
}
function getParameter(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
</script>