public function listAction() { $this->setLeftNav('list'); $req = $this->request; $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); if ($req->getQuery('title') != '') { $wherearr[] = "title like '%" . $req->getQuery('title') . "%'"; $this->view->setVar("title", $req->getQuery("title")); } $timeSlotarr = explode("至", $req->getQuery('timeSlot')); if ($req->getQuery('timeSlot')) { $wherearr[] = "settime > '" . $timeSlotarr[0] . "'"; $wherearr[] = "settime < '" . $timeSlotarr[1] . "'"; $this->view->setVar("timeSlot", $req->getQuery("timeSlot")); } $wherearr[] = "state <> 3"; $where = implode(" and ", $wherearr); $query = CosBeautyCanon::query(); $total = CosBeautyCanon::count(['conditions' => $where]); $list = $query->where($where)->orderBy('settime DESC')->limit($limit, $offset)->execute()->toArray(); foreach ($list as $k => $v) { $list[$k]['img_url'] = PicUrl::BeautyParlorPic($list[$k]['img_url'], $this->getDi()); } $this->view->setVar("total", $total); $this->view->setVar("limit", $limit); $this->view->setVar("page", $page); $this->view->setVar("list", $list); }
/** * 美粒宝典列表 * @date: 2016年1月4日 * @author: chenxiaolin */ public function listAction() { $this->setLeftNav('list'); $req = $this->request; $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $title = $req->getQuery('title'); $filterCity = intval($req->getQuery('filterCity', null, -10000)); if ($title != '') { $wherearr[] = "title like '%" . $title . "%'"; $this->view->setVar("title", $title); } if ($filterCity > -10000) { $wherearr[] = "Apps\\Common\\Models\\CosBeautyCanon.city_id = {$filterCity}"; } $state = $req->getQuery('state'); $this->view->setVar("state", $state); //$wherearr[]="state <> 3"; $wherearr[] = "state = {$state}"; $where = implode(" and ", $wherearr); $query = CosBeautyCanon::query(); $total = CosBeautyCanon::count(['conditions' => $where]); $list = $query->columns(['Apps\\Common\\Models\\CosBeautyCanon.id', 'Apps\\Common\\Models\\CosBeautyCanon.title', 'Apps\\Common\\Models\\CosBeautyCanon.img_url', 'soc.city_name', 'Apps\\Common\\Models\\CosBeautyCanon.fit', 'Apps\\Common\\Models\\CosBeautyCanon.assist', 'Apps\\Common\\Models\\CosBeautyCanon.state', 'Apps\\Common\\Models\\CosBeautyCanon.settime', 'Apps\\Common\\Models\\CosBeautyCanon.city_id'])->leftJoin('Apps\\Common\\Models\\SysOpenCity', 'soc.city_id=Apps\\Common\\Models\\CosBeautyCanon.city_id', 'soc')->where($where)->orderBy('Apps\\Common\\Models\\CosBeautyCanon.settime DESC')->limit($limit, $offset)->execute()->toArray(); //封面图片地址处理 foreach ($list as $k => $v) { $list[$k]['img_url'] = PicUrl::BeautyParlorPic($list[$k]['img_url'], $this->getDi()); } $this->view->setVar("total", $total); $this->view->setVar("limit", $limit); $this->view->setVar("page", $page); $this->view->setVar("list", $list); $this->view->setVar("filterCity", $filterCity); $this->view->setVar('openCity', SysOpenCity::find('city_state = 1')); }