WeirdoController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/7/16
  6. * Time: 上午9:36
  7. */
  8. namespace frontend\controllers;
  9. use frontend\base\CommonController;
  10. use common\models\NewsWeirdo;
  11. use yii\data\Pagination;
  12. use Yii;
  13. class WeirdoController extends CommonController{
  14. public function actionHome()
  15. {
  16. $model = new NewsWeirdo();
  17. $pages = new Pagination(['totalCount' => $model->HomeListTotal(),'pageSize'=>8, 'pageSizeParam' => false, 'validatePage' => false, ]);
  18. $rows = $model->HomeList($pages);
  19. // p($rows);
  20. return $this->render('home',['model'=>$rows,'page'=>$pages]);
  21. }
  22. public function actionDetails()
  23. {
  24. $model = new NewsWeirdo();
  25. $rows = $model->FindById(Yii::$app->request->get('qid'));
  26. //记录查看次数
  27. $iprecord = new \common\models\AllclickRecord();
  28. $arr['id'] = $rows->id;
  29. $arr['ip'] = Yii::$app->request->userIP;;
  30. $arr['type'] = 2;
  31. $re = $iprecord->RecordQuery($arr);
  32. if(empty($re)){
  33. if($iprecord->addRecord($arr))
  34. {
  35. $model->Clickadd($rows->id);
  36. }
  37. }
  38. //推荐楼盘
  39. $house = new \common\models\House();
  40. $house->is_push = 2;
  41. $houseRes = $house->randList(4,[]);
  42. return $this->render('details',['model'=>$rows,'cityhouse'=>$houseRes]);
  43. }
  44. }