示例#1
0
 /**
  * 分页处理
  * @param  int  $count     总条数
  * @param  integer $page      当前页
  * @param  integer $page_size 每页条数
  * @return array              分页数据
  */
 public function page($count, $page = 1, $page_size = 10)
 {
     $Page = new Page($count, $page, $page_size);
     $page_list = $Page->show();
     $get = I('get.');
     foreach ($page_list as $_k => $_v) {
         $page_list[$_k]['url'] = U(CONTROLLER_NAME . '/index', array_merge($get, array('page' => $_v['page'], 'page_size' => $page_size, 'order' => $order)));
     }
     return $page_list;
 }
示例#2
0
 /**
  * 公告列表页
  */
 public function index()
 {
     $page_index = I('page', 1);
     $page_size = 10;
     $model = D('About');
     $list = $model->_list(array(), '', 'id desc', $page_index, $page_size);
     $count = $model->count();
     //分页数组
     $page = new Page($count, $page_index, $page_size);
     $page_list = $page->show();
     $this->assign('list', $list);
     $this->assign('count', $count);
     $this->assign('page_list', $page_list);
     $this->display();
 }
 /**
  * 发件箱
  */
 public function out()
 {
     $page_index = I('page', 1);
     $page_size = 10;
     $model = D('Letter');
     $map['user_id'] = session('user_info.id');
     $list = $model->lists($map, '', 'id desc', $page_index, $page_size);
     $count = $model->count();
     //分页数组
     $page = new Page($count, $page_index, $page_size);
     $page_list = $page->show();
     $this->assign('list', $list);
     $this->assign('count', $count);
     $this->assign('page_list', $page_list);
     $this->display();
 }
示例#4
0
 public function index()
 {
     $page_index = I('page', 1);
     $page_size = 10;
     $model = D(CONTROLLER_NAME);
     $map = method_exists($this, '_filter') ? $this->_filter() : array();
     if (method_exists($model, 'lists')) {
         $list = $model->lists($map, '', 'id desc', $page_index, $page_size);
     } else {
         $list = $model->_list($map, '', 'id desc', $page_index, $page_size);
     }
     $count = $model->_count($map);
     //分页数组
     $page = new Page($count, $page_index, $page_size);
     $page_list = $page->show();
     $this->assign('list', $list);
     $this->assign('count', $count);
     $this->assign('page_list', $page_list);
     $this->display();
 }
示例#5
0
/**
 * TODO 基础分页的相同代码封装,使前台的代码更少
 * @param $count 要分页的总记录数
 * @param int $pagesize 每页查询条数
 * @return \Think\Page
 */
function getpage($count, $pagesize = 10)
{
    $page = new Page($count, $pagesize);
    $page->rollPage = 6;
    $page->lastSuffix = false;
    $page->setConfig('last', '… %TOTAL_PAGE%');
    $page->setConfig('first', '1 …');
    $page->setConfig('prev', '<');
    $page->setConfig('next', '>');
    $page->setConfig('theme', '%UP_PAGE% %FIRST% %LINK_PAGE% %END% %DOWN_PAGE%');
    return $page;
}
示例#6
0
 public function order()
 {
     $page_index = I('page', 1);
     $page_size = 10;
     $model = D(CONTROLLER_NAME);
     $map = method_exists($this, '_filter') ? $this->_filter() : array();
     if (method_exists($model, 'lists')) {
         $list = $model->lists($map, '', 'id desc', $page_index, $page_size);
     } else {
         $list = $model->_list($map, '', 'id desc', $page_index, $page_size);
     }
     if (!empty($list)) {
         //查找订单
         $orderModel = D('Order');
         $earn_id = array_column($list, 'id');
         $earn_id = array_unique($earn_id);
         $order_map['earn_id'] = array('in', $earn_id);
         $order_map['status'] = 1;
         $order_list = $orderModel->lists($order_map);
         if (!empty($order_list)) {
             $user_id = array_column($order_list, 'assist_user_id');
             $user_id = array_filter($user_id);
             $user_id = array_unique($user_id);
             $user_list = D('User')->_list(array('id' => array('in', $user_id)), 'pid');
             $superior_user_id = array_column($user_list, 'pid');
             $superior_user_id = array_filter($superior_user_id);
             $superior_user_id = array_unique($superior_user_id);
             if (!empty($superior_user_id)) {
                 $superior = D('User')->_list(array('id' => array('in', $superior_user_id)), 'id as user_id,name,phone');
                 $superior = array_column($list, null, 'id');
             } else {
                 $superior = array();
             }
             $list = array_column($list, null, 'id');
             foreach ($order_list as $_k => $_v) {
                 if (isset($superior[$_v['assist_user_id']])) {
                     $_v['assist_superior_name'] = $superior[$_v['assist_user_id']]['name'];
                     $_v['assist_superior_phone'] = $superior[$_v['assist_user_id']]['phone'];
                 } else {
                     $_v['assist_superior_name'] = $_v['assist_name'];
                     $_v['assist_superior_phone'] = $_v['assist_phone'];
                 }
                 $list[$_v['earn_id']]['order_list'][] = $_v;
             }
         }
         //查询当前用户的上级用户
         $user_info = D('User')->_get(array('id' => $map['user_id']));
         if ($user_info['pid'] == 0) {
             $superior['name'] = $user_info['name'];
             $superior['phone'] = $user_info['phone'];
         } else {
             $superior = D('User')->_get(array('id' => $user_info['pid'], 'name,phone'));
         }
         $this->assign('superior', $superior);
     }
     $count = $model->_count($map);
     //分页数组
     $page = new Page($count, $page_index, $page_size);
     $page_list = $page->show();
     $this->assign('list', $list);
     $this->assign('count', $count);
     $this->assign('page_list', $page_list);
     $this->display();
 }