NewsController.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/4/20
  6. * Time: 上午12:50
  7. */
  8. namespace frontend\controllers;
  9. use common\fm\HouseHandle;
  10. use common\models\CategoryNews;
  11. use common\models\House;
  12. use common\models\HouseComment;
  13. use common\models\HouseNews;
  14. use common\models\News;
  15. use common\models\PushHousesale;
  16. use common\models\Video;
  17. use frontend\base\CommonController;
  18. use frontend\base\Help;
  19. use frontend\server\HouseServer;
  20. use Yii;
  21. use frontend\server\NewsServer;
  22. use yii\widgets\LinkPager;
  23. class NewsController extends CommonController
  24. {
  25. public $enableCsrfValidation = false;
  26. // public function init()
  27. // {
  28. // parent::init();
  29. // return $this->goHome();
  30. // }
  31. public function actionHome()
  32. {
  33. $pushModel = new NewsServer();
  34. $one = $pushModel->Pushinfo(1);
  35. $two = $pushModel->Pushinfo(2);
  36. $three = $pushModel->Pushinfo(3);
  37. //热点直达
  38. // $ctype = new \common\models\PushCharacteristic();
  39. $cmodel = $pushModel->hotArrive();
  40. $clickNews = $pushModel->clickList(10);
  41. $column = $pushModel->ColumnInfo();
  42. $model = new \common\models\News();
  43. if (is_numeric(Yii::$app->request->get('cid'))) {
  44. $model->category = Yii::$app->request->get('cid');
  45. }
  46. $newsList = $model->HomeList(Yii::$app->request->get());
  47. $dynamic = (new News())->GetDynamic(6); //优惠动态
  48. $comment = (new HouseComment())->GetComment(5); //热门点评
  49. if (!empty($comment)) {
  50. foreach ($comment as &$val) {
  51. $val['mobile'] = preg_replace("/(\d{3})\d\d(\d{2})/", "\$1****\$3", $val['mobile']);
  52. $val['create_at'] = date('Y-m-d H:i:s', $val['create_at']);
  53. }
  54. }
  55. //实景看房
  56. $vrhouse = (new Video())->RandList(3, 2);
  57. //底部热销推荐
  58. $housemodel = new House();
  59. $housemodel->is_push = 2;
  60. $house = $housemodel->ispush(8);
  61. //资讯标题
  62. $title = '';
  63. if (!empty(Yii::$app->request->get('cid'))) {
  64. $title = CategoryNews::findOne(Yii::$app->request->get('cid'));
  65. }
  66. return $this->render('home', ['title' => $title, 'house' => $house, 'vrhouse' => $vrhouse, 'comment' => $comment, 'dynamic' => $dynamic, 'one' => $one, 'two' => $two, 'three' => $three, 'ctype' => $cmodel, 'click' => $clickNews, 'column' => $column, 'all' => $newsList, 'page' => $newsList['page']]);
  67. }
  68. public function actionDetails()
  69. {
  70. $input = Yii::$app->request->get();
  71. $model = new NewsServer();
  72. $row = $model->NewsDetails($input);
  73. if (empty($row)) {
  74. $m = new \common\models\House();
  75. $m->is_push = 2;
  76. $data = $m->HomegetList(4);
  77. return $this->render('@app/views/news/newsxiajia', ['model' => $data]);
  78. }
  79. $housetel = new HouseServer();
  80. $tel = $housetel->RandTel($row['city']);
  81. $category = $model->Relevant($row['category']);
  82. //点击量排序
  83. $clickNews = $model->clickList(5);
  84. //热点直达
  85. $cityHouse = $model->NewsCityHouse($row['city']);
  86. //热销楼盘
  87. $model = new \common\models\PushHousesale();
  88. $model->type = 1;
  89. $hotHouse = $model->Homegetlist(4);
  90. //获取最新资讯
  91. $todaynews = (new NewsServer())->GetNews(5);
  92. //老业主推荐页数
  93. $datacount = $m = new \common\models\House();
  94. $m->is_push = 2;
  95. $count = ceil($m->ispushcount()) / 5;
  96. //查询资讯相关楼盘
  97. // $HouseNewsMdoel = new HouseNews();
  98. // $HouseNews = $HouseNewsMdoel->GetHouse($input);
  99. // $NewsHouse = '';
  100. $NewsHouse = [];
  101. if (!empty($row['hid'])) {
  102. $NewsHouse = (new House())->GetOneHouse($row['hid']);
  103. if (!empty($NewsHouse)) {
  104. $NewsHouse['tel'] = HouseHandle::ChangeCityTel($NewsHouse['city']);
  105. $NewsHouse['chara'] = HouseHandle::ChangeCharacteristic($NewsHouse['characteristic']);
  106. }
  107. }
  108. return $this->render('details', [
  109. 'model' => $row,
  110. 'category' => $category,
  111. 'hotnews' => $clickNews,
  112. 'cityhouse' => $cityHouse,
  113. 'hothouse' => $hotHouse,
  114. 'tel' => $tel,
  115. 'todaynews' => $todaynews,
  116. 'count' => $count,
  117. 'newshouse' => $NewsHouse,
  118. ]);
  119. }
  120. //资讯详情页-老业主推荐
  121. public function actionNewshouse()
  122. {
  123. $get = Yii::$app->request->get();
  124. $modle = new \common\models\HouseNews();
  125. $data = $modle::find()->andWhere(['nid' => $get['nid'], 'del' => 1, 'is_view' => 1])->one();
  126. $housemodel = new House();
  127. if (!empty($data)) {
  128. $housemodel->city = $data->houseCity;
  129. }
  130. $housemodel->is_push = 2;
  131. $house = $housemodel->ispush(5, $get);
  132. if (!empty($house)) {
  133. foreach ($house as &$val) {
  134. $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'] . '/same';
  135. }
  136. return Help::JsonCode(Help::SUCCESS, '成功', $house);
  137. }
  138. return Help::JsonCode(Help::ERROR, '暂无数据');
  139. }
  140. }