NewsController.php 3.7 KB

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