123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/4/20
- * Time: 上午12:50
- */
- namespace frontend\controllers;
- use common\fm\HouseHandle;
- use common\models\CategoryNews;
- use common\models\House;
- use common\models\HouseComment;
- use common\models\HouseNews;
- use common\models\News;
- use common\models\PushHousesale;
- use common\models\Video;
- use frontend\base\CommonController;
- use frontend\base\Help;
- use frontend\server\HouseServer;
- use Yii;
- use frontend\server\NewsServer;
- use yii\widgets\LinkPager;
- class NewsController extends CommonController
- {
- public $enableCsrfValidation = false;
- // public function init()
- // {
- // parent::init();
- // return $this->goHome();
- // }
- public function actionHome()
- {
- $pushModel = new NewsServer();
- $one = $pushModel->Pushinfo(1);
- $two = $pushModel->Pushinfo(2);
- $three = $pushModel->Pushinfo(3);
- //热点直达
- // $ctype = new \common\models\PushCharacteristic();
- $cmodel = $pushModel->hotArrive();
- $clickNews = $pushModel->clickList(10);
- $column = $pushModel->ColumnInfo();
- $model = new \common\models\News();
- if (is_numeric(Yii::$app->request->get('cid'))) {
- $model->category = Yii::$app->request->get('cid');
- }
- $newsList = $model->HomeList(Yii::$app->request->get());
- $dynamic = (new News())->GetDynamic(6); //优惠动态
- $comment = (new HouseComment())->GetComment(5); //热门点评
- if (!empty($comment)) {
- foreach ($comment as &$val) {
- $val['mobile'] = preg_replace("/(\d{3})\d\d(\d{2})/", "\$1****\$3", $val['mobile']);
- $val['create_at'] = date('Y-m-d H:i:s', $val['create_at']);
- }
- }
- //实景看房
- $vrhouse = (new Video())->RandList(3, 2);
- //底部热销推荐
- $housemodel = new House();
- $housemodel->is_push = 2;
- $house = $housemodel->ispush(8);
- //资讯标题
- $title = '';
- if (!empty(Yii::$app->request->get('cid'))) {
- $title = CategoryNews::findOne(Yii::$app->request->get('cid'));
- }
- 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']]);
- }
- public function actionDetails()
- {
- $input = Yii::$app->request->get();
- $model = new NewsServer();
-
- $row = $model->NewsDetails($input);
-
- if (empty($row)) {
- $m = new \common\models\House();
- $m->is_push = 2;
- $data = $m->HomegetList(4);
- return $this->render('@app/views/news/newsxiajia', ['model' => $data]);
- }
- $housetel = new HouseServer();
- $tel = $housetel->RandTel($row['city']);
-
- $category = $model->Relevant($row['category']);
- //点击量排序
- $clickNews = $model->clickList(5);
- //热点直达
- $cityHouse = $model->NewsCityHouse($row['city']);
- //热销楼盘
- $model = new \common\models\PushHousesale();
- $model->type = 1;
- $hotHouse = $model->Homegetlist(4);
-
- //获取最新资讯
- $todaynews = (new NewsServer())->GetNews(5);
- //老业主推荐页数
- $datacount = $m = new \common\models\House();
- $m->is_push = 2;
- $count = ceil($m->ispushcount()) / 5;
- //查询资讯相关楼盘
- // $HouseNewsMdoel = new HouseNews();
- // $HouseNews = $HouseNewsMdoel->GetHouse($input);
- // $NewsHouse = '';
- $NewsHouse = [];
- if (!empty($row['hid'])) {
- $NewsHouse = (new House())->GetOneHouse($row['hid']);
- if (!empty($NewsHouse)) {
- $NewsHouse['tel'] = HouseHandle::ChangeCityTel($NewsHouse['city']);
- $NewsHouse['chara'] = HouseHandle::ChangeCharacteristic($NewsHouse['characteristic']);
- }
- }
- return $this->render('details', [
- 'model' => $row,
- 'category' => $category,
- 'hotnews' => $clickNews,
- 'cityhouse' => $cityHouse,
- 'hothouse' => $hotHouse,
- 'tel' => $tel,
- 'todaynews' => $todaynews,
- 'count' => $count,
- 'newshouse' => $NewsHouse,
- ]);
- }
- //资讯详情页-老业主推荐
- public function actionNewshouse()
- {
- $get = Yii::$app->request->get();
- $modle = new \common\models\HouseNews();
- $data = $modle::find()->andWhere(['nid' => $get['nid'], 'del' => 1, 'is_view' => 1])->one();
- $housemodel = new House();
- if (!empty($data)) {
- $housemodel->city = $data->houseCity;
- }
- $housemodel->is_push = 2;
- $house = $housemodel->ispush(5, $get);
- if (!empty($house)) {
- foreach ($house as &$val) {
- $val['thumb'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['houses'] . $val['thumb'] . '/same';
- }
- return Help::JsonCode(Help::SUCCESS, '成功', $house);
- }
- return Help::JsonCode(Help::ERROR, '暂无数据');
- }
- }
|