找到page.php 修改
<?phpnamespace think\\paginator\\driver;use think\\Paginator;class Page extends Paginator{//首页protected function home() {if ($this->currentPage() > 1) {return \"<a href=\'javascript:cg_ajax_page(1)\' class=\'page_click\' page=\'1\' >首页</a>\";} else {return \"<p>首页</p>\";}}//上一页protected function prev() {if ($this->currentPage() > 1) {$page = $this->currentPage-1;return \"<a href=\'javascript:cg_ajax_page(\".$page.\")\' class=\'page_click\' page=\'\".$page.\"\' >上一页</a>\";} else {return \"<p>上一页</p>\";}}//下一页protected function next() {if ($this->hasMore) {$page = $this->currentPage+1;return \"<a href=\'javascript:cg_ajax_page(\".$page.\")\' class=\'page_click\' page=\'\".$page.\"\' >下一页</a>\";} else {return\"<p>下一页</p>\";}}//尾页protected function last() {if ($this->hasMore) {return \"<a href=\'javascript:cg_ajax_page(\".$this->lastPage.\")\' class=\'page_click\' page=\'\".$this->lastPage.\"\' >末页</a>\";} else {return \"<p>末页</p>\";}}//统计信息protected function info(){return \"\";return \"<p class=\'pageRemark\'>共<b>\" . $this->lastPage .\"</b>页<b>\" . $this->total . \"</b>条数据</p>\";}/*** 页码按钮* @return string*/protected function getLinks(){$block = [\'first\' => null,\'slider\' => null,\'last\' => null];$side = 3;$window = $side * 2;if ($this->lastPage < $window + 6) {$block[\'first\'] = $this->getUrlRange(1, $this->lastPage);} elseif ($this->currentPage <= $window) {$block[\'first\'] = $this->getUrlRange(1, $window + 2);$block[\'last\'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage);} elseif ($this->currentPage > ($this->lastPage - $window)) {$block[\'first\'] = $this->getUrlRange(1, 2);$block[\'last\'] = $this->getUrlRange($this->lastPage - ($window + 2), $this->lastPage);} else {$block[\'first\'] = $this->getUrlRange(1, 2);$block[\'slider\'] = $this->getUrlRange($this->currentPage - $side, $this->currentPage + $side);$block[\'last\'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage);}$html = \'\';if (is_array($block[\'first\'])) {$html .= $this->getUrlLinks($block[\'first\']);}if (is_array($block[\'slider\'])) {$html .= $this->getDots();$html .= $this->getUrlLinks($block[\'slider\']);}if (is_array($block[\'last\'])) {$html .= $this->getDots();$html .= $this->getUrlLinks($block[\'last\']);}return $html;}/*** 渲染分页html* @return mixed*/public function render(){if ($this->hasPages()) {if ($this->simple) {return sprintf(\'%s<div class=\"pagination\">%s %s %s</div>\',$this->css(),$this->prev(),$this->getLinks(),$this->next());} else {return sprintf(\'%s<div class=\"pagination\">%s %s %s %s %s %s</div>\',$this->css(),$this->home(),$this->prev(),$this->getLinks(),$this->next(),$this->last(),$this->info());}}}/*** 生成一个可点击的按钮** @param string $url* @param int $page* @return string*/protected function getAvailablePageWrapper($url, $page){return \'<a href=\"javascript:cg_ajax_page(\'.$page.\')\" class=\"page_click\" page=\"\'.$page.\'\" >\' . $page . \'</a>\';}/*** 生成一个禁用的按钮** @param string $text* @return string*/protected function getDisabledTextWrapper($text){return \'<p class=\"pageEllipsis\">\' . $text . \'</p>\';}/*** 生成一个激活的按钮** @param string $text* @return string*/protected function getActivePageWrapper($url,$text){header(\"Content-type:text/html;charset=utf-8\");return \'<a href=\"javascript:;\" class=\"cur\">\' . $text . \'</a>\';}/*** 生成省略号按钮** @return string*/protected function getDots(){return $this->getDisabledTextWrapper(\'...\');}/*** 批量生成页码按钮.** @param array $urls* @return string*/protected function getUrlLinks(array $urls){$html = \'\';foreach ($urls as $page => $url) {$html .= $this->getPageLinkWrapper($url, $page);}return $html;}/*** 生成普通页码按钮** @param string $url* @param int $page* @return string*/protected function getPageLinkWrapper($url, $page){if ($page == $this->currentPage()) {return $this->getActivePageWrapper($url,$page);}return $this->getAvailablePageWrapper($url, $page);}/*** 分页样式* 如果分页样式不生效 可以把样式放到公用css文件里 或自己重写*/protected function css(){return \'.pagination{ width:100%;margin:0 auto; overflow:hidden; box-sizing:border-box; padding:0px 0;}.pagination p{ float:left;margin-right:10px; margin-bottom:10px;}.pagination a{ float:left;margin-right:10px; margin-bottom:10px;}.pagination p{display:block;box-sizing:border-box; font-size:14px; color:#555;padding:6px 14px; border-radius:3px;border:1px solid #aaa;cursor:pointer;transition:0.3s; background:#fff;}.pagination a{display:block;box-sizing:border-box; font-size:14px; color:#555;padding:6px 14px; border-radius:3px;border:1px solid #aaa;cursor:pointer;transition:0.3s; background:#fff;}.pagination a:hover { border:1px solid #d31919; background:#d31919; color:#fff;}.pagination a.cur{ border:1px solid #d31919; background:#d31919; color:#fff;}\';}}
HTML中引入jq
<script type=\"text/javascript\">function cg_ajax_page(page){var url = \"/admin.php/index/ajax/getdatapage?page=\"+page;// 表名 where条件 排序 条数$.post(url,{table:\"{$data_table}\",where:\"{$data_where}\",order:\"{$data_order}\",limit:\"{$data_limit}\"},function(data){//console.log(data[\'data\'][\'data\'].length);var html = \"\";//查询之后返回 遍历 追加到HTML中 data[\'data\']为返回值for (var i=0; data[\'data\'][\'data\'].length>i;i++) {html +=\'<li><a href=\"/new/\'+data[\'data\'][\'data\'][i][\'id\']+\'.html\"><div class=\"nttop\"><div class=\"ntll\"><img src=\"__TEMP__/images/lbwj.png\" alt=\"\"/><h3>\'+data[\'data\'][\'data\'][i][\'title\']+\'</h3></div><div class=\"djzz\"><img src=\"__TEMP__/images/rh.png\"/><h4>立即下载</h4></div></div><div class=\"sjllb\"><h5 class=\"sjjh\">\'+data[\'data\'][\'data\'][i][\'issuetime\']+\'</h5><h5 class=\"liula\">\'+data[\'data\'][\'data\'][i][\'pv\']+\'</h5></div></a></li>\';}//给class 命为ull 的追加遍历好的html$(\".ull\").html(html);// 分页输出$(\".fyan\").html(data[\'page\']);},\"json\")}</script>
PHP文件
//根据表名条件等查询出之后 返回json格式的数据 其中部分内容做了一些数据处理 可删减public function getdatapage(){$data[\'data\'] = db(input(\"table\"),\"\",false)->where(input(\"where\"))->order(input(\"order\"))->paginate(input(\"limit\"));$data[\'page\'] = $data[\'data\']->render();$data[\'data\'] = json_decode(json_encode($data[\'data\']),true);if(input(\"table\")==\"article\"){foreach ($data[\'data\'][\'data\'] as &$v) {$v[\'img\'] = json_decode($v[\'img\'],true);$v[\'img\'] = $v[\'img\'][0];$v[\'content\'] = de_e($v[\'content\'],200);$v[\'Y\'] = date(\"Y\",$v[\'issuetime\']);$v[\'y\'] = date(\"y\",$v[\'issuetime\']);$v[\'m\'] = date(\"m\",$v[\'issuetime\']);/*$v[\'d\'] = date(\"d\",$v[\'issuetime\']);$v[\'H\'] = date(\"H\",$v[\'issuetime\']);$v[\'i\'] = date(\"i\",$v[\'issuetime\']);$v[\'s\'] = date(\"s\",$v[\'issuetime\']);*/$v[\'issuetime\'] = date(\"Y-m-d\",$v[\'issuetime\']);$v[\'cname\'] = db(\"category\")->where(\'id\',$v[\'cid\'])->field(\'title\')->find();}}else if(input(\"table\")==\"pv\"){foreach ($data[\'data\'][\'data\'] as &$v) {$v[\'lyurl\'] = de_e($v[\'lyurl\'],100);}}else if(input(\"table\") == \"friendship\"){foreach ($data[\'data\'][\'data\'] as &$v) {$v[\'img\'] = json_decode($v[\'img\'],true);$v[\'img\'] = $v[\'img\'][0];}}echo json_encode($data);}
———————————————— The end ————————————————
感谢臣哥