PjController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/4/26
  6. * Time: 上午11:13
  7. */
  8. namespace frontend\controllers;
  9. use frontend\base\CommonController;
  10. use Yii;
  11. use frontend\base\Help;
  12. use common\models\NewsRenovation;
  13. use common\models\NewsRenovationcontent;
  14. use yii\data\Pagination;
  15. class PjController extends CommonController
  16. {
  17. public function actionHome()
  18. {
  19. $model = new NewsRenovation();
  20. $pages = new Pagination(['totalCount' => $model->PcgetListTotal(),'pageSize'=>8, 'pageSizeParam' => false, 'validatePage' => false ]);
  21. $rows = $model->PcgetList($pages);
  22. // p($rows);
  23. $houseModel = new \common\models\House();
  24. $houseModel->is_push = 2;
  25. $house = $houseModel->randList(10);
  26. // p($rows);
  27. // [title] => 111111
  28. // [id] => 14
  29. // [img] => ada881080c30d77d64b4a0c3e3eca44e.jpg
  30. // [click] => 0
  31. // [type] => 2
  32. return $this->render('home',['model'=>$rows,'page'=>$pages,'house'=>$house]);
  33. }
  34. public function actionDetails()
  35. {
  36. //楼盘
  37. $houseModel = new \common\models\House();
  38. $houseModel->is_push = 2;
  39. $house = $houseModel->randList(4);
  40. //
  41. $model = new NewsRenovation();
  42. $row = $model->FindById(Yii::$app->request->get('pid'));
  43. $h = [];
  44. if(!empty($row['hid']))
  45. {
  46. $houseModel->id = $row['hid'];
  47. $h = $houseModel->OneDetails(['name','id']);
  48. }
  49. //上一篇,和下一篇
  50. $ss = $model->RandList(2,['title','id']);
  51. //装修品鉴
  52. $weirdo = new \common\models\NewsWeirdo();
  53. $weirdoList = $weirdo->Mhomelist(['page'=>1,'limit'=>3]);
  54. // p($weirdoList);
  55. //品鉴相关信息
  56. $f = new NewsRenovationcontent();
  57. $f->nid = Yii::$app->request->get('pid');
  58. $col = $f->PcLabel();
  59. // [subject] => 1111111222
  60. // [click] => 12
  61. // [abstract] => 222222222222222222
  62. // [thumb] => cd7c7c5e9c75636db2de40ad183da3c9.jpg
  63. // [short_subject] =>
  64. // [id] => 3
  65. //记录查看次数
  66. $iprecord = new \common\models\AllclickRecord();
  67. $arr['id'] = Yii::$app->request->get('pid');
  68. $arr['ip'] = Yii::$app->request->userIP;;
  69. $arr['type'] = 1;
  70. $re = $iprecord->RecordQuery($arr);
  71. if(empty($re)){
  72. if($iprecord->addRecord($arr))
  73. {
  74. $model->Clickadd(Yii::$app->request->get('pid'));
  75. }
  76. }
  77. return $this->render('details',['house'=>$house,'model'=>$row,'col'=>$col,'h'=>$h,'f'=>$ss,'weirdo'=>$weirdoList]);
  78. }
  79. public function actionContent()
  80. {
  81. $input = Yii::$app->request->post();
  82. $f = new NewsRenovationcontent();
  83. $res = $f->FindById($input['id']);
  84. if(!empty($res))
  85. {
  86. return Help::JsonCode(Help::SUCCESS,'成功',$res);
  87. }
  88. }
  89. public function actionSlice()
  90. {
  91. $model = new NewsRenovation();
  92. $page = Yii::$app->request->post();
  93. $m = new \stdClass();
  94. $m->offset = ($page['page'] - 1) * $page['limit'];
  95. $m->limit = $page['limit'];
  96. $row = $model->PcgetList($m);
  97. if(!empty($row))
  98. {
  99. $row[0]['title'] = mb_substr($row[0]['title'],0,5).'...';
  100. return Help::JsonCode(Help::SUCCESS,'成功',$row);
  101. }
  102. return Help::JsonCode(Help::ERROR,'失败');
  103. }
  104. }