123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/4/19
- * Time: 下午2:52
- */
- namespace mobile\controllers;
- use common\models\CategoryCity;
- use common\models\CategoryTelCity;
- use common\models\PushmRotation;
- use common\models\PushmCity;
- use common\models\PushmColumn;
- use mobile\base\CommonController;
- use mobile\server\IndexServer;
- use Yii;
- use mobile\base\Help;
- class IndexController extends CommonController
- {
- public $enableCsrfValidation = false;
-
-
- /**
- * 移动端 - 首页
- * @return string
- */
- public function actionIndex()
- {
- //获取当前模块
- $module = Yii::$app->controller->action->id;
- //导航
- $sysmenu = new \common\models\Frontend();
- $sysmenu->pid = 5;
- $sysrows = $sysmenu->SonList(8, ['name', 'url', 'icon', 'id', 'function']);
-
- $lunbo = (new PushmRotation())->getRoationChart(5); //轮播图
-
- $IndexModel = new IndexServer();
-
- $news = $IndexModel->newslist(); //咨询列表
-
- $housetou = $IndexModel->getHouseTouTiao(1,3); //获取房产头条推送
-
- $hothouse = $IndexModel->getHotHouse(12,3); //获取首页热榜楼盘
-
- $PCIndexModel = new \frontend\server\IndexServer();
- $vrhouse = $PCIndexModel->getVrHouse(4); //获取VR看房
- $pushaerial = $PCIndexModel->getPushAerial(4); //获取航拍实景
-
- //区域
- $gCity = Yii::$app->request->get('city');
- if (empty($gCity)) {
- $gCity = 68;
- if ($gCity != 0) {
- $cityName = CategoryCity::findOne($gCity)['city_name'];
- } else {
- $cityName = '海南';
- }
- } else {
- $cityName = CategoryCity::findOne($gCity)['city_name'];
- }
-
-
- return $this->render($this->action->id, [
- 'module' => $module,
- 'sysmenu' => $sysrows,
- 'cityname' => $cityName,
- 'news' => $news,
- 'lunbo'=>$lunbo,
- 'housetou'=>$housetou,
- 'hothouse'=>$hothouse,
- 'vrhouse'=>$vrhouse,
- 'pushaerial'=>$pushaerial
- ]);
-
- }
- public function actionHothouses()
- {
- // $model = new IndexServer();
- // $hot = $model->Hothouse(Yii::$app->request->post());
- // if(!empty($hot))
- // {
- // foreach ($hot as &$val)
- // {
- // $val['thumb'] = Yii::$app->params['httpImg']['hosts'].Yii::$app->params['httpImg']['houses'].$val['thumb'];
- // }
- // return Help::JsonCode(Help::SUCCESS,'成功',$hot);
- // }
- return Help::JsonCode(Help::SUCCESS, '成功', []);
- }
- public function actionSearchalert()
- {
- $model = new IndexServer();
- $shaixuan = $model->shaixuan();
- $price = $model->PriceList();
- //热门区域
- $CityModel = new PushmCity();
- $CityModel->type = 1;
- $CityModel->abroad = 1;
- $HotCity = $CityModel->Homelist(7);
- $Housetype = \common\models\CategoryHousetype::find()->andWhere(['del' => 1])->andWhere(['state' => 1])->orderBy(['sort' => SORT_ASC])->limit(4)->asArray()->all();
- return $this->renderPartial('searchalert', ['shaixuan' => $Housetype, 'hot_city' => $HotCity]);
- }
- /**
- * 首页-底部 拨打电话图标
- * @return mixed
- */
- public function actionTelrand()
- {
- //二级域名,mhainan.xxx.com
- if (Yii::$app->hostserver->hostId != 0) {
- $input = Yii::$app->request->post();
- //没有选择区域的情况下
- if (empty($input['city']) || $input['city'] == 0) {
- $tel = new CategoryTelCity();
- //调取二级域名hostId的电话
- $hostid = Yii::$app->hostserver->hostId;
- $tel->cid = $hostid;
- if ($hostid == 37) {
- $tel->cid = 40; //防城港
- }
- if ($hostid == 48) {
- $tel->cid = 49; //昆明
- }
- if ($hostid == 28) {
- $tel->cid = 62; //珠海
- }
- $resultTel = $tel->CityTelOne();
- if (!empty($resultTel)) {
- $telArr = explode(',', $resultTel['tel']);
- $index = array_rand($telArr, 1);
- if (!empty($telArr[$index])) {
- return Help::JsonCode(Help::SUCCESS, '成功', ['tel' => $telArr[$index]]);
- }
- }
- }
- //有选择区域的情况下
- if (!empty($input['city']) && $input['city'] != 0) {
- $tel = new CategoryTelCity();
- //调取二级域名hostId的电话
- $tel->cid = $input['city'];
- $resultTel = $tel->CityTelOne();
- if (!empty($resultTel)) {
- $telArr = explode(',', $resultTel['tel']);
- $index = array_rand($telArr, 1);
- if (!empty($telArr[$index])) {
- return Help::JsonCode(Help::SUCCESS, '成功', ['tel' => $telArr[$index]]);
- }
- } else { //如果区域市县没有电话,返回域名的电话
- $tel = new CategoryTelCity();
- $tel->cid = Yii::$app->hostserver->hostId;
- $resultTel = $tel->CityTelOne();
- if (!empty($resultTel)) {
- $telArr = explode(',', $resultTel['tel']);
- $index = array_rand($telArr, 1);
- if (!empty($telArr[$index])) {
- return Help::JsonCode(Help::SUCCESS, '成功', ['tel' => $telArr[$index]]);
- }
- }
- }
- }
- } else if (Yii::$app->hostserver->hostId == 0) {
- //m.shuofangw.com//全国,一级域名
- $input = Yii::$app->request->post();
- //没有选择区域的情况下
- if (empty($input['city']) || $input['city'] == 0) {
- //调取三亚的电话
- $tel = new CategoryTelCity();
- $tel->cid = 6;
- $resultTel = $tel->CityTelOne();
- if (!empty($resultTel)) {
- $telArr = explode(',', $resultTel['tel']);
- $index = array_rand($telArr, 1);
- if (!empty($telArr[$index])) {
- return Help::JsonCode(Help::SUCCESS, '成功', ['tel' => $telArr[$index]]);
- }
- }
- }
- //有选择区域的情况下
- if (!empty($input['city']) && $input['city'] != 0) {
- $city = CategoryCity::findOne($input['city']);
- $tel = new CategoryTelCity();
- $tel->cid = $input['city'];
- if ($input['city'] == 37) {
- $tel->cid = 40; //防城港
- }
- if ($input['city'] == 48) {
- $tel->cid = 49; //昆明
- }
- if ($input['city'] == 28) {
- $tel->cid = 62; //珠海
- }
- //选择的是省
- if ($city['pid'] == 0) {
- $resultTel = $tel->CityTelOne();
- if (!empty($resultTel)) {
- $telArr = explode(',', $resultTel['tel']);
- $index = array_rand($telArr, 1);
- if (!empty($telArr[$index])) {
- return Help::JsonCode(Help::SUCCESS, '成功', ['tel' => $telArr[$index]]);
- }
- }
- }
- //选择的是市县
- if ($city['pid'] != 0) {
- $resultTel = $tel->CityTelOne();
- if (!empty($resultTel)) {
- $telArr = explode(',', $resultTel['tel']);
- $index = array_rand($telArr, 1);
- if (!empty($telArr[$index])) {
- return Help::JsonCode(Help::SUCCESS, '成功', ['tel' => $telArr[$index]]);
- }
- } else { //如果为空,返回省的电话
- $telmodel = new CategoryTelCity();
- $telmodel->cid = $city['pid'];
- $result = $telmodel->CityTelOne();
- if (!empty($result)) {
- $telArr = explode(',', $result['tel']);
- $index = array_rand($telArr, 1);
- if (!empty($telArr[$index])) {
- return Help::JsonCode(Help::SUCCESS, '成功', ['tel' => $telArr[$index]]);
- }
- }
- }
- }
- }
- }
- return Help::JsonCode(Help::SUCCESS, '成功', ['tel' => Yii::$app->params['default_dialtel']]);
- }
- // /**
- // * 需求定制 价格-户型-区域
- // */
- // public function actionCustomized()
- // {
- // $arr['price'] = [10,20,30,40,50,60,70,80,90];
- // $typeModel = new \common\models\CategoryHousetype();
- // $typeModel->state = 1;
- // $arr['type'] = $typeModel->getList([],['id','huxing_name']);
- // $city = new \common\models\CategoryCity();
- // $city->pid = 0;
- // $arr['province'] = $city->getList([],['id','city_name']);
- // p($arr);
- // }
- /**
- * 传递父类区域ID
- * 返回子类区域信息
- */
- public function actionCityson()
- {
- $input = Yii::$app->request->post();
- if (!empty($input['pid'])) {
- $city = new \common\models\CategoryCity();
- $city->pid = $input['pid'];
- $rows = $city->getList([], ['id', 'city_name']);
- if (!empty($rows)) {
- return Help::JsonCode(Help::SUCCESS, '成功', $rows);
- }
- }
- return Help::JsonCode(Help::ERROR, '暂无区域信息');
- }
- /**
- * 区域价格走势
- */
- public function actionCityprice()
- {
- $model = new \common\models\PushCityprice();
- $model->city_id = Yii::$app->request->post('id');
- $rows = $model->FindCityRecordPrice();
- if (!empty($rows)) {
- $timestrap = strtotime($rows['price_at']);
- $rows['price_at'] = trim(date('m', $timestrap) . '月', '0');
- return Help::JsonCode(Help::SUCCESS, '成功', $rows);
- }
- }
- //需求数据
- // public function actionCustomizedform()
- // {
- //
- // }
- /**
- * 楼盘价格走势
- */
- 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, '失败');
- }
- }
|