Example #1
0
 public function run()
 {
     //上传用户id
     $user_id = intval($this->getDataItem('user_id', 0));
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $this->beautyCanons = CosBeautyCanon::query()->columns(['id', 'title', 'img_url', 'settime', 'fit', 'summary', 'assist'])->where("state != 3")->orderBy('settime DESC')->limit($limit, $offset)->execute()->toArray();
     $this->beautyCanons = $this->beautyCanons ? $this->beautyCanons : [];
     for ($i = 0; $i < count($this->beautyCanons); $i++) {
         if ($user_id > 0) {
             //判断是否已经点过赞
             $bc_assist = CosBeautyCanonAssist::count(["conditions" => "user_id = :sign: AND beauty_canon_id = :bc_id: ", "bind" => ['sign' => $user_id, 'bc_id' => $this->beautyCanons[$i]['id']]]);
         } else {
             $bc_assist = 0;
         }
         if ($bc_assist > 0) {
             $this->beautyCanons[$i]['is_assist'] = true;
         } else {
             $this->beautyCanons[$i]['is_assist'] = false;
         }
         if ($this->beautyCanons[$i]['summary'] == null) {
             $this->beautyCanons[$i]['summary'] = '';
         }
         $this->beautyCanons[$i]['img_url'] = "http://img.meelier.com/" . $this->beautyCanons[$i]['img_url'];
         if (empty($this->beautyCanons[$i]['fit'])) {
             $this->beautyCanons[$i]['fit'] = 0;
         }
         if (empty($this->beautyCanons[$i]['assist'])) {
             $this->beautyCanons[$i]['assist'] = 0;
         }
     }
     $this->setResult($this->beautyCanons);
 }
 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);
 }
Example #3
0
 public function run()
 {
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $this->beautyCanons = CosBeautyCanon::query()->columns(['id', 'title', 'img_url', 'settime', 'fit', 'assist'])->where("state != 3")->orderBy('settime DESC')->limit($limit, $offset)->execute()->toArray();
     $this->beautyCanons = $this->beautyCanons ? $this->beautyCanons : [];
     for ($i = 0; $i < count($this->beautyCanons); $i++) {
         $this->beautyCanons[$i]['img_url'] = "http://img.meelier.com/" . $this->beautyCanons[$i]['img_url'];
         if (empty($this->beautyCanons[$i]['fit'])) {
             $this->beautyCanons[$i]['fit'] = 0;
         }
         if (empty($this->beautyCanons[$i]['assist'])) {
             $this->beautyCanons[$i]['assist'] = 0;
         }
     }
     $this->setResult($this->beautyCanons);
 }
 /**
  * 美粒宝典列表
  * @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'));
 }
Example #5
0
 public function run()
 {
     $id = intval($this->getDataItem('id', 0));
     if (0 < $id) {
         $this->bcanonInfo = CosBeautyCanon::query()->columns(['content', 'fit'])->where('state != 3 and id = ' . $id)->execute()->getFirst();
     } else {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '参数异常');
     }
     if ($this->bcanonInfo) {
         if ($this->bcanonInfo->fit == null) {
             $this->bcanonInfo->fit = 0;
         }
         //浏览量加1
         $query = new CosBeautyCanon();
         $model = $query->findFirst(' id = ' . $id);
         $model->fit = $this->bcanonInfo->fit + 1;
         $model->save();
         //循环处理内容中的图片
         $this->bcanonInfo->content = str_replace('src="/ueditor/php/upload/image/', 'src="http://meelier.com/ueditor/php/upload/image/', $this->bcanonInfo->content);
     } else {
         $this->bcanonInfo = null;
     }
     $this->setResult($this->bcanonInfo);
 }
Example #6
0
 /**
  * 美粒宝典预览
  * @date: 2016年1月4日 
  * @author: chenxiaolin
  */
 public function beautyCanonAction()
 {
     $id = $this->request->getQuery('id');
     if (empty($id)) {
         echo '美粒宝典不存在!';
         $this->view->disable();
         return;
     }
     $canon = CosBeautyCanon::query()->columns(['title', 'content'])->where('id=:id:')->bind(['id' => $id])->execute()->getFirst();
     if (!$canon) {
         echo '美粒宝典不存在!';
         $this->view->disable();
         return;
     }
     $this->view->setVar('canon', $canon);
     //$this->tag->setTitle($data['beauty_parlor']->name);
 }