html:
<div class="goods-list-pagination">
<div class="pagination">
<{$show}>
<if condition="$totalPages neq 1">
<div>
//提交到本页面对应的方法
<from action="" mothed='get' id="header">
<span class="f">跳转至</span>
<input id="max-page" type="hidden" value="<{$totalPages}>">
<input id="jump-page" class="page-select" type="text" value="1">
<span class="f">页</span>
<input id="jump-btn" class="page-btn"type="submit"value="跳转">
</from>
</div>
</if>
</div>
</div>
jq:
<script type="text/javascript">
$(document).ready(function(){
var current_page=$(".current").html();
$('.page-select').val(current_page)
});
//分页跳转按钮
$("#jump-btn").on("click", function() {
var page = $("#jump-page").val();
var Str=$(".end").attr('href');
if(Str!=undefined){
location.href=Str.substring(0,Str.length-3)+"p="+page;
}
});
</script>
end类:
php:
/**
* [getPage 封装分页类]
* @Author:hkz
* @DateTime:2016-03-11
* @param:$count [传入总记录数]
* @param:$number [每页显示的记录数]
* @return [type] [description]
*/
public function getPage($count=10,$number=8){
$page=new \Think\Page($count,$number);
return $page;
}
// 更多
public function index(){
$notice=M("notice");
$count = $notice->where('is_show',1)->count();
$Pager=$this->getPage($count,13);
$notice_list = $notice->where('is_show',1)->order(array('sort'=>'desc','posttime'=>'desc'))->limit($Pager->firstRow.','.$Pager->listRows)->select();
$totalPages=$Pager->totalPages;//取得分页页数
$this->assign('notice_list',$notice_list);
$this->assign('show',$Pager->show());
$this->assign('totalPages',$totalPages);
$this->display('index');
}