123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <?php
- namespace frontend\controllers;
- use common\models\Brand;
- use common\models\MiniRotation;
- use frontend\base\CommonController;
- use frontend\server\IndexServer;
- use frontend\server\HouseServer;
- use common\models\Characteristic;
- use frontend\base\Help;
- use Yii;
- class IndexController extends CommonController
- {
-
-
- public function actionIndex ()
- {
-
- // $IndexModel = new IndexServer();
- // $city = $IndexModel->CityList(); //区域
- //
- // $price = $IndexModel->PriceList(); //价格区间
- //
- // $sub = $IndexModel->Subject(); //特色主题
- //
- // $type = $IndexModel->HouseType(); //楼盘户型
- //
- // $lunbo = $IndexModel->Lunbo(); //轮播图
- //
- // $Hotactivity = $IndexModel->Hotactivity(); //热门活动
- //
- // $pushCity = $IndexModel->getPushCity( 5 ); //获取首页推送地区栏位区域数据
- //
- // $Choice = $IndexModel->Choice(); //本周精选
- //
- // $hotHouse = $IndexModel->HotHouse(); //热销楼盘
- // $cityInfo = $IndexModel->CityInfo(); //区域介绍
- // $KnowledgeBase = $IndexModel->getKnowledgeBase(); //知识库
- //
- // $pushaerial = $IndexModel->getPushAerial( 4 );
- //
- // $recommendcat = $IndexModel->RecommendCat(); //精选新房
- // $recommendcatone = $IndexModel->RecommendCatOne(); //精选新房根据地区读一条 大坑,注意排序
- // $tuijian = new \common\models\PushHousesale();
- // $tuijian->type = 2;
- // $Hot = $tuijian->Homegetlist( 4 );
- //
- // $Ctype = $IndexModel->Characteristic();
- // $news = $IndexModel->newsColumn();
- // $CityPrice = $IndexModel->Pricetrend();
- // $Gouf = $IndexModel->Goufang( 5 );
- // $newsGouf = $IndexModel->Goufang( 6 );
- // $Villa = $IndexModel->Villa(); //别墅专区
- //获取当前模块
- $IndexModel = new IndexServer();
- $city = $IndexModel->CityList(); //热门区域
- $price = $IndexModel->PriceList(); //价格区间
- $BrandModel = new Brand();
- $brand = $BrandModel->getPcSearchBrand(1, 12); //品牌筛选
- $hotHouse = $IndexModel->getHomeHotHouse(6); //首页热门楼盘
- $VrHouse = $IndexModel->getVrHouse(4); //首页VR全景看房推送
- $pushCity = $IndexModel->getPushCity(5); //获取首页推送地区栏位区域数据
- $pushaerial = $IndexModel->getPushAerial(4); //获取首页航拍看房推送
- $voluntarilylive = $IndexModel->getVoluntarilylive(3); //自动获取直播回放3个
- $allcity = $IndexModel->getAllCityList(); //获取所有地区
- $pushnews = $IndexModel->getPushNews(5); //获取推送资讯栏目
- $readhouseword = $IndexModel->getPushTitle(3,8); //首页热搜词
- $gourylist = $IndexModel->getPushTitle(4,3); //首页优惠团购列表
- $lunbo = $IndexModel->Lunbo( 5); //轮播图
- $choice = $IndexModel->Lunbo(2); //本周精选
-
- return $this->render( 'index' ,[
- 'city' => $city,
- 'price' => $price,
- 'lb' => $lunbo,
- 'brand' => $brand,
- 'hotHouse' => $hotHouse,
- 'VrHouse' => $VrHouse,
- 'pushCity' => $pushCity,
- 'pushaerial'=>$pushaerial,
- 'voluntarilylive'=>$voluntarilylive,
- 'allcity'=>$allcity,
- 'pushnews'=>$pushnews,
- 'readhouseword'=>$readhouseword,
- 'gourylist'=>$gourylist,
- 'choice'=>$choice
- ]);
-
- }
-
- public function actionRecommendlist ()
- {
- $model = new \common\models\PushHouserecommend();
- $input = Yii::$app->request->get();
- if ( !empty( Yii::$app->request->get( 'city' ) ) ) {
- $cityModel = new \common\models\CategoryCity();
- $city_ids = $cityModel->TestingId( Yii::$app->request->get( 'city' ) );
- $input[ 'city' ] = $city_ids;
- }
- $recommend = $model->getList( $input );
- foreach ( $recommend as $k => $v ) {
- $recommend[ $k ][ 'characteristic' ] = $this->Subject( json_decode( $v[ 'characteristic' ] ) , 3 );
- }
- $recommendData[ 'recommend' ] = $recommend;
- $IndexModel = new IndexServer();
- $recommendData[ 'city' ] = $IndexModel->CityList();
- if ( !empty( $recommendData ) ) {
- return Help::JsonCode( Help::SUCCESS , '成功' , $recommendData );
- }
- return Help::JsonCode( Help::ERROR , '暂无数据' );
- }
-
- public function actionSearch ()
- {
- $IndexModel = new IndexServer();
- $city = $IndexModel->CityList(); //区域
-
- $price = $IndexModel->PriceList(); //价格区间
-
- $sub = $IndexModel->Subject(); //特色主题
-
- $type = $IndexModel->HouseType(); //楼盘户型
-
- $tuijian = new \common\models\PushHousesale();
- $tuijian->type = 2;
- $Hot = $tuijian->Homegetlist( 4 );
- $tuijian->type = 4;
- $sea = $tuijian->Homegetlist( 6 );
-
- //热门区域
- $hotcity = ( new MiniRotation() )->getAll( 4 , 3 );
-
- return $this->renderPartial( 'search' , [ 'city' => $city ,
- 'price' => $price ,
- 'type' => $type ,
- 'sub' => $sub ,
- 'hot' => $Hot ,
- 'sea' => $sea ,
- 'hotcity' => $hotcity ,
- ] );
- }
-
- /*
- * 弹窗搜索结果
- * */
- public function actionSearchresult ()
- {
- $model = new HouseServer();
- $res = $model->SearchHouseName( Yii::$app->request->get() );
- if ( !empty( $res ) ) {
- return Help::JsonCode( Help::SUCCESS , '成功' , $res );
- }
- return Help::JsonCode( Help::ERROR , '暂无数据' );
-
- }
-
-
- /**
- * 区域价格走势
- */
- public function actionCityprice ()
- {
- $model = new \common\models\PushCityprice();
- $model->city_id = Yii::$app->request->get( 'id' );
- $rows = $model->CityRecordPrice();
- if ( !empty( $rows ) ) {
- $arr = [];
- foreach ( $rows as &$val ) {
- // $timestrap = strtotime($val['price_at']);
- $time = $val[ 'price_at' ];
- $val[ 'price_at' ] = trim( date( 'm' , $time ) . '月' , '0' );
- $arr[ 'price_at_n' ][] = trim( date( 'Y' , $time ) . '年' , '0' );
- $arr[ 'categories' ][] = $val[ 'price_at' ];
- $arr[ 'data' ][] = $val[ 'price' ];
- $arr[ 'region' ][] = $val[ 'city_name' ];
- }
- return Help::JsonCode( Help::SUCCESS , '成功' , $arr );
- }
- }
-
- /**
- * 楼盘价格走势
- */
- public function actionHouseprice ()
- {
- $input = Yii::$app->request->post();
- if ( is_numeric( $input[ 'id' ] ) ) {
- $model = new \common\models\HousePriceRecord();
- $model->hid = $input[ 'id' ];
- $rows = $model->getList( [] );
- if ( !empty( $rows ) ) {
- $arr = [];
- foreach ( $rows as $val ) {
- $arr[ 'categories' ][] = $val[ 'create_time' ];
- $arr[ 'data' ][] = $val[ 'price' ];
- $arr[ 'unit' ][] = $val[ 'price_unit' ];
- }
- return Help::JsonCode( Help::SUCCESS , '成功' , $arr );
- }
- }
- return Help::JsonCode( Help::ERROR , '失败' );
- }
-
- public function actionAa ()
- {
- phpinfo();
- }
-
- //特色主题 超过3个随机返回3个元素
- public function Subject ( $id , $num = 3 )
- {
- $char = new Characteristic();
- if ( is_array( $id ) && !empty( $id ) ) {
- $char->id = $id;
- }
- $charMode = array_column( $char->getList( [] , [ 'id' , 'name' ] ) , 'name' , 'id' );
- if ( $charMode != null ) {
- $count = count( $charMode );
- $arr = [];
- if ( $count >= 3 ) {
- $rand = array_rand( $charMode , $num );
- foreach ( $rand as $key => $val ) {
- $arr[ $key ] = $charMode[ $val ];
- }
- } else {
- $arr = $charMode;
- }
- return $arr;
- }
- }
- }
|