1.不多逼逼
model 代码
<?php
namespace appcommonmodel;
use thinkModel;
class Fpage{
private $page;//当前页
private $pagenum;//总页数
private $peytype;//矿机类型
public function __construct($page,$pagenum,$peytype){
$this->page=$page;
$this->pagenum=$pagenum;
$this->peytype=$peytype;
}
//首页
private function first(){
if($this->page==1){
@$html.='<span>1</span>';
}else{
@$html.='<a href="/index/transfer/jjrecord.html?page=1&peytype='.($this->peytype).'">1...</a>';
}
return $html;
}
//上一页
private function prev(){
if($this->page==1){
@$html.='<span>上一页</span>';
}else{
@$html.='<a href="/index/transfer/jjrecord.html?page='.($this->page-1).'&peytype='.($this->peytype).'">上一页</a>';
}
return $html;
}
//下一页
private function next(){
if($this->page == $this->pagenum){
@$html.='<span>下一页</span>';
}else{
@$html.='<a href="/index/transfer/jjrecord.html?page='.($this->page+1).'&peytype='.($this->peytype).'">下一页</a>';
}
return $html;
}
//尾页
private function last(){
if($this->page==$this->pagenum){
@$html.='<span>'.$this->pagenum.'</span>';
}else{
@$html.='<a href="/index/transfer/jjrecord.html?page='.($this->pagenum).'&peytype='.($this->peytype).'">...'.$this->pagenum.'</a>';
}
return $html;
}
//当前页
private function currentpage(){
return '<spanc>第'.$this->page.'页</spanc>';
}
public function pagelist(){
return array('first'=>$this->first(),'prev'=>$this->prev(),'aaa'=>$this->currentpage(),'next'=>$this->next(),'last'=>$this->last());
}
}
?>
2.控制器代码
//实例化自己写的分页类
$page=new Fpage($result->currentPage(),$result->lastPage(),$peytypes); // 第三个参数是自定义参数,例如有下来选项的时候带参数
//echo '<pre>';print_r($page->pagelist());exit;
//渲染到模板的分页样式
$this->assign('page', $page->pagelist());
3.模板渲染代码
{$page['first']}
{$page['prev']}
{$page['aaa']}
{$page['next']}
{$page['last']}