推广员首页开服信息添加AJAX分页

master
zhengchanglong 5 years ago
parent 999f3af068
commit 0b046abc68

@ -66,9 +66,17 @@ class PromoteController extends BaseController
->join("left join tab_game gm on gm.id=sv.game_id")
->field('sv.*,gm.icon')
->order("sv.start_time desc")
//->page(1, 20)
->page(1, 5)
->select();
$count = M("server", "tab_")
->where(
array("start_time"=>array("BETWEEN", array($today_start, $today_end)),
"show_status"=>1))
->count();
$page = $this->ajax_page($count,5,'seach');
$this->assign("_page",$page);
$user_count = M("user","tab_")->where("promote_id=".get_pid())->count();
$total_money = $this->pay_total(0,0);
@ -88,7 +96,6 @@ class PromoteController extends BaseController
->count();
$yesterday_total_money = $this->pay_total(1,0);
$this->assign("user_count",$user_count);
$this->assign("total_money", $total_money);
$this->assign("today_add_user_money", $today_add_user_money);
@ -199,24 +206,37 @@ class PromoteController extends BaseController
public function home_read_data(){
$type = I("type","0");
$game_id = I("game_id");
$start = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
$pg = I("page","0");
$today_start = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$today_end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
if($game_id){
$map['game_id'] = $game_id;
$map['sv.game_id'] = $game_id;
$count_map['game_id']= $game_id;
}
if($type>0){
$map['sv.start_time']=array("GT", $end);
$map['sv.start_time']=array("GT", $today_end);
$count_map['start_time']= array("GT", $today_end);
}else{
$map['sv.start_time']=array("BETWEEN", array($start, $end));
$map['sv.start_time']=array("BETWEEN", array($today_start, $today_end));
$count_map['start_time']= array("BETWEEN", array($today_start, $today_end));
}
$map['sv.show_status'] = 1;
$count_map['show_status'] = 1;
$open_server_list = M("server as sv","tab_")->where($map)
->join("left join tab_game gm on gm.id=sv.game_id")
->field('sv.*,gm.icon')
->order("sv.start_time desc")
//->page(1, 20)
->select();;
->page($pg, 5)
->select();
$count = M("server", "tab_")
->where($count_map)
->count();
//var_dump($count);
$page = $this->ajax_page($count,5,'seach',$pg);
//$this->assign("_page",$page);
//$count = M("server", "tab_")->where($map)->count();
foreach ($open_server_list as $key => $server){
$open_server_list[$key]['icon']=get_cover($server['icon'],'path');
if($server['pay_type']==1){
@ -229,7 +249,8 @@ class PromoteController extends BaseController
$open_server_list[$key]['pay_type'];
$open_server_list[$key]['start_time'] = date('Y-m-s h:i',$server['start_time']);
}
$this->ajaxReturn(['status'=>1,'info'=>'调用成功','data'=>$open_server_list],"JSON");
//$content = $this->fetch('Promote/home_read_data');
$this->ajaxReturn(['status'=>1,'info'=>'调用成功','data'=>$open_server_list,'_page'=>$page],"JSON");
}
@ -1780,6 +1801,24 @@ class PromoteController extends BaseController
}
}
}
function ajax_page($count, $row,$ajax_func='index',$current=1) {
$aside = '<select id="pagechange" name="row" onchange="seach(this)"><option value="5">每页5条</option><option value="10">每页10条</option><option value="25">每页25条</option><option value="50">每页50条</option><option value="100">每页100条</option></select>';
$count=$count?$count:0;
$row=$row?$row:10;
if ($count > $row) {
$p = new \Think\AjaxPage($count,$row,$ajax_func);
$p->nowpage($count,$row,$current,$ajax_func);
$p->setConfig('theme', '%first% %upPage% %linkPage% %downPage% %end% %header%');
//产生分页信息
$html=$p->show();
return "<div>".$html."</div>";
} else {
//return '<div>' .$aside. '<span class="rows">共 '.$count.' 条记录</span></div>';
return '<div><span class="rows">共 '.$count.' 条记录</span></div>';
}
}
}

@ -5,37 +5,37 @@
<block name="body">
<div class="page-overview promote-index-overview index-overview clearfix poll">
<ul>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi1.png"/></span></div><!-- <div class="text text2"><p>推广总用户</p><span>{$user_count}</span></div> --></li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi2.png"/></span></div><!-- <div class="text text1"><p>推广总充值</p><span>¥{$total_money}</span></div> --></li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi3.png"/></span></div><!-- <div class="text text3"><p>当日新增用户充值</p><span>¥{$today_add_user_money}</span></div> --></li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi5.png"/></span></div><!-- <div class="text text5"><p>当月新增用户充值</p><span>¥{$month_add_user_money}</span></div> --></li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi1.png"/></span></div> <div class="text text2"><p>推广总用户</p><span>{$user_count}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi2.png"/></span></div> <div class="text text1"><p>推广总充值</p><span>¥{$total_money}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi3.png"/></span></div> <div class="text text3"><p>当日新增用户充值</p><span>¥{$today_add_user_money}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi5.png"/></span></div> <div class="text text5"><p>当月新增用户充值</p><span>¥{$month_add_user_money}</span></div> </li>
</ul>
<ul style="margin-top: 10px">
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi1.png"/></span></div><!-- <div class="text text2"><p>昨日注册用户</p><span>{$yesterday_user_regist_count}</span></div> --></li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi2.png"/></span></div><!-- <div class="text text1"><p>昨日充值金额</p><span>¥{$yesterday_total_money}</span></div> --></li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi3.png"/></span></div><!-- <div class="text text3"><p>今日注册用户</p><span>{$yesterday_regist_user_count}</span></div> --></li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi5.png"/></span></div><!-- <div class="text text5"><p>今日充值金额</p><span>¥{$yesterday_total_money}</span></div> --></li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi1.png"/></span></div> <div class="text text2"><p>昨日注册用户</p><span>{$yesterday_user_regist_count}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi2.png"/></span></div> <div class="text text1"><p>昨日充值金额</p><span>¥{$yesterday_total_money}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi3.png"/></span></div> <div class="text text3"><p>今日注册用户</p><span>{$yesterday_regist_user_count}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi5.png"/></span></div> <div class="text text5"><p>今日充值金额</p><span>¥{$yesterday_total_money}</span></div> </li>
</ul>
</div>
<div class="index-tab-list">
<ul>
<li>
<div class="qcl-box">
<div class="qcl-box-hand"><span class="qcl-tit">快捷菜单</span><span class="more"><!--<a href="{:U('quick_menu_list')}">自定义></a>--></span></div>
<div class="qcl-box-hand"><span class="qcl-tit">快捷菜单</span><span class="more"><a href="{:U('quick_menu_list')}">自定义></a></span></div>
<div class="qcl-bnt">
<empty name="menu_list">
暂无数据
<else/>
<!-- <ul>
<volist name="menu_list" id="menu">
<li>
<a href="{/*$menu.url*/}">
<span><img src="https://fileuc.37376.com/180912-80cfe5b6e68941f4bfe4cd697765abb4.png"></span>
<span>{/*$menu.name*/}</span>
</a>
</li>
</volist>
</ul> -->
<ul>
<volist name="menu_list" id="menu">
<li>
<a href="{$menu.url}">
<span><img src="https://fileuc.37376.com/180912-80cfe5b6e68941f4bfe4cd697765abb4.png"></span>
<span>{$menu.name}</span>
</a>
</li>
</volist>
</ul>
</empty>
</div>
</div>
@ -118,19 +118,19 @@
<th>开服时间</th>
<th>服务器信息</th>
</tr>
<empty name="today_open_server_list">
<tr><td colspan="8" style="text-align: center;height: 38vh;"><img src="__IMG__/20180207/icon_wushujv2.png"/><p style="line-height: 40px;color: #A5A5A5;">暂无数据</p></td></tr>
<else />
<volist name="today_open_server_list" id="data">
<tr>
<td><img src="{$data.icon|get_cover='path'}"></td>
<td>{$data.game_name}</td>
<td><if condition="$data.pay_type eq 0">安卓、iOS<elseif condition="$data.pay_type eq 1">安卓<else />iOS</if></td>
<td>{$data.start_time|date="m-d H:i",###}</td>
<td>{$data.server_name}</td>
</tr>
</volist>
</empty>
<empty name="today_open_server_list">
<tr><td colspan="8" style="text-align: center;height: 38vh;"><img src="__IMG__/20180207/icon_wushujv2.png"/><p style="line-height: 40px;color: #A5A5A5;">暂无数据</p></td></tr>
<else />
<volist name="today_open_server_list" id="data">
<tr>
<td><img src="{$data.icon|get_cover='path'}"></td>
<td>{$data.game_name}</td>
<td><if condition="$data.pay_type eq 0">安卓、iOS<elseif condition="$data.pay_type eq 1">安卓<else />iOS</if></td>
<td>{$data.start_time|date="m-d H:i",###}</td>
<td>{$data.server_name}</td>
</tr>
</volist>
</empty>
</table>
</div>
<div class="pagenation clearfix">
@ -158,7 +158,7 @@
})
});
function seach() {
function seach(page=1) {
var game_id = $("select[name=game_id]").val();
var type = $("input[name=type]").val();
jQuery.ajax({
@ -167,6 +167,7 @@
data: {
'type':type,
'game_id':game_id,
'page':page
},
dataType: 'JSON',
cache: false,
@ -195,6 +196,7 @@
});
$(".odd").after(show);
$(".pagenation").html(result._page);
}
}
});

@ -0,0 +1,149 @@
<?php
namespace Think;
class AjaxPage
{
// 分页栏每页显示的页数
public $rollPage = 5;
// 页数跳转时要带的参数
public $parameter ;
// 默认列表每页显示行数
public $listRows = 20;
// 起始行数
public $firstRow ;
// 分页总页面数
protected $totalPages ;
// 总行数
protected $totalRows ;
// 当前页数
public $nowPage ;
// 分页的栏的总页数
protected $coolPages ;
// 分页显示定制
private $config = array(
'header' => '<span class="rows">共 %totalRow% 条记录</span>',
'prev' => '<<',
'next' => '>>',
'first' => '1...',
'last' => '...%totalPage%',
'theme' => '%first% %upPage% %linkPage% %downPage% %end%',
);
// 默认分页变量名
protected $varPage;
public function __construct($totalRows,$listRows='',$ajax_func,$parameter='') {
$this->totalRows = $totalRows;
$this->ajax_func = $ajax_func;
$this->parameter = $parameter;
$this->varPage = C('VAR_PAGE') ? C('VAR_PAGE') : 'p' ;
if(!empty($listRows)) {
$this->listRows = intval($listRows);
}
$this->totalPages = ceil($this->totalRows/$this->listRows); //总页数
$this->coolPages = ceil($this->totalPages/$this->rollPage);
$this->nowPage = !empty($_GET[$this->varPage])?intval($_GET[$this->varPage]):1;
if(!empty($this->totalPages) && $this->nowPage>$this->totalPages) {
$this->nowPage = $this->totalPages;
}
$this->firstRow = $this->listRows*($this->nowPage-1);
}
public function nowpage($totalRows,$listRows='',$nowPage=1,$ajax_func,$parameter='') {
$this->totalRows = $totalRows;
$this->ajax_func = $ajax_func;
$this->parameter = $parameter;
$this->varPage = C('VAR_PAGE') ? C('VAR_PAGE') : 'p' ;
//$this->varPage = $nowPage;
$this->nowPage = $nowPage;
if(!empty($listRows)) {
$this->listRows = intval($listRows);
}
$this->totalPages = ceil($this->totalRows/$this->listRows); //总页数
$this->coolPages = ceil($this->totalPages/$this->rollPage);
//$this->nowPage = !empty($_GET[$this->varPage])?intval($_GET[$this->varPage]):1;
if(!empty($this->totalPages) && $this->nowPage>$this->totalPages) {
$this->nowPage = $this->totalPages;
}
$this->firstRow = $this->listRows*($this->nowPage-1);
return $this->nowPage;
}
public function setConfig($name,$value) {
if(isset($this->config[$name])) {
$this->config[$name] = $value;
}
}
public function show() {
if(0 == $this->totalRows) return '';
$p = $this->varPage;
$nowCoolPage = ceil($this->nowPage/$this->rollPage);
$url = $_SERVER['REQUEST_URI'].(strpos($_SERVER['REQUEST_URI'],'?')?'':"?").$this->parameter;
$parse = parse_url($url);
if(isset($parse['query'])) {
parse_str($parse['query'],$params);
unset($params[$p]);
$url = $parse['path'].'?'.http_build_query($params);
}
//上下翻页字符串
$upRow = $this->nowPage-1;
$downRow = $this->nowPage+1;
if ($upRow>0){
$upPage="<a class='prev' id='big' href='JavaScript:".$this->ajax_func."(".$upRow.")'>".$this->config['prev']."</a>";
}else{
$upPage="";
}
if ($downRow <= $this->totalPages){
$downPage="<a class='next' id='big' href='javascript:".$this->ajax_func."(".$downRow.")'>".$this->config['next']."</a>";
}else{
$downPage="";
}
// << < > >>
if($nowCoolPage == 1){
$theFirst = "";
$prePage = "";
}else{
$preRow = $this->nowPage-$this->rollPage;
$prePage = "<a class='prev' id='big' href='javascript:".$this->ajax_func."(".$preRow.")'>上".$this->rollPage."页</a>";
$theFirst = "<a class='first' id='big' href='javascript:".$this->ajax_func."(1)' >".$this->config['first']."</a>";
}
if($nowCoolPage == $this->coolPages){
$nextPage = "";
$theEnd="";
}else{
$nextRow = $this->nowPage+$this->rollPage;
$theEndRow = $this->totalPages;
$nextPage = "<a class='next' id='big' href='javascript:".$this->ajax_func."(".$nextRow.")' >下".$this->rollPage."页</a>";
$theEnd = "<a class='end' id='big' href='javascript:".$this->ajax_func."(".$theEndRow.")' >".$this->config['last']."</a>";
}
// 1 2 3 4 5
$linkPage = "";
for($i=1;$i<=$this->rollPage;$i++){
$page=($nowCoolPage-1)*$this->rollPage+$i;
if($page!=$this->nowPage){
if($page<=$this->totalPages){
$linkPage .= " <a class='num' id='big' href='javascript:".$this->ajax_func."(".$page.")'> ".$page." </a>";
}else{
break;
}
}else{
if($this->totalPages != 1){
$linkPage .= " <span class='current'>".$page."</span>";
}
}
}
$pageStr = str_replace(
array('%header%','%nowPage%','%totalRow%','%totalPage%','%upPage%','%downPage%','%first%','%prePage%','%linkPage%','%nextPage%','%end%'),
array($this->config['header'],$this->nowPage,$this->totalRows,$this->totalPages,$upPage,$downPage,$theFirst,$prePage,$linkPage,$nextPage,$theEnd),
$this->config['theme']);
return $pageStr;
}
}
Loading…
Cancel
Save