NewsController.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/4/19
  6. * Time: 下午2:52
  7. */
  8. namespace mobile\controllers;
  9. use mobile\base\CommonController;
  10. use mobile\server\NewsServer;
  11. use Yii;
  12. use mobile\base\Help;
  13. class NewsController extends CommonController{
  14. // public function init()
  15. // {
  16. // parent::init();
  17. // return $this->goHome();
  18. // }
  19. public function actionAa()
  20. {
  21. p($_SERVER['HTTP_REFERER']);
  22. }
  23. public function actionHome()
  24. {
  25. $model = new NewsServer();
  26. $lei = $model->ColumnInfo(); //栏目
  27. if ($lei){
  28. foreach ($lei as &$val){
  29. $val['img'] = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['newsthumb'].$val['img'];
  30. }
  31. }
  32. $rows = $model->Pushinfo(2);
  33. return $this->render('home',['lei'=>$lei,'top'=>$rows]);
  34. }
  35. public function actionHomeform()
  36. {
  37. $model = new \common\models\News();
  38. if( is_numeric(Yii::$app->request->get('cid')))
  39. {
  40. $model->category = Yii::$app->request->get('cid');
  41. if($model->category == 0) $model->category = null;
  42. }
  43. $newsList = $model->Mhomelist(Yii::$app->request->get());
  44. if(empty($newsList))
  45. {
  46. $m = new \common\models\House();
  47. $data = $m->HomegetList(5);
  48. $label = new \common\api\Label;
  49. foreach ($data as &$val)
  50. {
  51. if(!empty($val['characteristic']))
  52. {
  53. $val['characteristic'] = $label->Characteristic(json_decode($val['characteristic'],true),3);
  54. }
  55. }
  56. return $this->render('@app/views/news/newsxiajia.php',['model'=>$data]);
  57. }
  58. if(!empty($newsList))
  59. {
  60. foreach ($newsList as &$val)
  61. {
  62. if(!empty($val['thumb']))
  63. {
  64. $val['thumb'] = json_decode($val['thumb']);
  65. }
  66. }
  67. $arr['url'] = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['newsthumb'];
  68. $arr['data'] = $newsList;
  69. return Help::JsonCode(Help::SUCCESS,'成功',$arr);
  70. }
  71. return Help::JsonCode(Help::ERROR,'失败');
  72. }
  73. public function actionDetails()
  74. {
  75. $input = Yii::$app->request->get();
  76. $model= new NewsServer();
  77. $hserver= new \mobile\server\HouseServer();
  78. $row = $model->NewsDetails($input);
  79. if(!isset($row) || empty($row))
  80. {
  81. $m = new \common\models\House();
  82. $data = $m->HomegetList(5);
  83. $label = new \common\api\Label;
  84. foreach ($data as &$val)
  85. {
  86. if(!empty($val['characteristic']))
  87. {
  88. $val['characteristic'] = $label->Characteristic(json_decode($val['characteristic'],true),3);
  89. }
  90. $val['tel'] = $hserver->RandTel($val['city']);
  91. }
  92. return $this->render('@app/views/news/newsxiajia.php',['model'=>$data]);
  93. }
  94. $housetel = new \mobile\server\IndexServer();
  95. $tel = $housetel->RandTel($row['city']);
  96. $category = $model->Relevant($row['category']);
  97. //点击量排序
  98. $clickNews = $model->clickList(2);
  99. //该区域相关楼盘
  100. $cityHouse = $model->NewsCityHouse($row['city']);
  101. //热销楼盘
  102. // $model = new \common\models\PushHousesale();
  103. // $model->type = 1;
  104. // $hotHouse = $model->Homegetlist(4);
  105. return $this->render('details',[
  106. 'model'=>$row,
  107. 'category'=>$category,
  108. 'hotnews'=>$clickNews,
  109. 'cityhouse'=>$cityHouse,
  110. // 'hothouse'=>$hotHouse,
  111. 'tel'=>$tel
  112. ]);
  113. }
  114. }