123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- namespace wechat\controllers;
- use wechat\base\CommonController;
- use wechat\server\NewsServer;
- use Yii;
- use wechat\base\Help;
- class NewsController extends CommonController{
- // public function init()
- // {
- // parent::init();
- // return $this->goHome();
- // }
- public function actionAa()
- {
- p($_SERVER['HTTP_REFERER']);
- }
- public function actionHome()
- {
- $model = new NewsServer();
- $lei = $model->ColumnInfo(); //栏目
- if ($lei){
- foreach ($lei as &$val){
- $val['img'] = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['newsthumb'].$val['img'];
- }
- }
- $rows = $model->Pushinfo(2);
- return $this->render('home',['lei'=>$lei,'top'=>$rows]);
- }
- public function actionHomeform()
- {
- $model = new \common\models\News();
- if( is_numeric(Yii::$app->request->get('cid')))
- {
- $model->category = Yii::$app->request->get('cid');
- if($model->category == 0) $model->category = null;
- }
- $newsList = $model->Mhomelist(Yii::$app->request->get());
- if(empty($newsList))
- {
- $m = new \common\models\House();
- $data = $m->HomegetList(5);
- $label = new \common\api\Label;
- foreach ($data as &$val)
- {
- if(!empty($val['characteristic']))
- {
- $val['characteristic'] = $label->Characteristic(json_decode($val['characteristic'],true),3);
- }
- }
- return $this->render('@app/views/news/newsxiajia.php',['model'=>$data]);
- }
- if(!empty($newsList))
- {
- foreach ($newsList as &$val)
- {
- if(!empty($val['thumb']))
- {
- $val['thumb'] = json_decode($val['thumb']);
- }
- }
- $arr['url'] = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['newsthumb'];
- $arr['data'] = $newsList;
- return Help::JsonCode(Help::SUCCESS,'成功',$arr);
- }
- return Help::JsonCode(Help::ERROR,'失败');
- }
- public function actionDetails()
- {
- $input = Yii::$app->request->get();
- $model= new NewsServer();
- $row = $model->NewsDetails($input);
- if(!isset($row) || empty($row))
- {
- $m = new \common\models\House();
- $data = $m->HomegetList(5);
- $label = new \common\api\Label;
- foreach ($data as &$val)
- {
- if(!empty($val['characteristic']))
- {
- $val['characteristic'] = $label->Characteristic(json_decode($val['characteristic'],true),3);
- }
- }
- return $this->render('@app/views/news/newsxiajia.php',['model'=>$data]);
- }
- $housetel = new \wechat\server\IndexServer();
- $tel = $housetel->RandTel($row['city']);
- $category = $model->Relevant($row['category']);
- //点击量排序
- $clickNews = $model->clickList(2);
- //该区域相关楼盘
- $cityHouse = $model->NewsCityHouse($row['city']);
- //热销楼盘
- // $model = new \common\models\PushHousesale();
- // $model->type = 1;
- // $hotHouse = $model->Homegetlist(4);
- // p($hotHouse);
- return $this->render('details',[
- 'model'=>$row,
- 'category'=>$category,
- 'hotnews'=>$clickNews,
- 'cityhouse'=>$cityHouse,
- // 'hothouse'=>$hotHouse,
- 'tel'=>$tel
- ]);
- }
- }
|