IndexController.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <?php
  2. namespace wechat\controllers;
  3. use common\models\CategoryCity;
  4. use common\models\PushmCity;
  5. use common\models\PushmColumn;
  6. use wechat\base\CommonController;
  7. use wechat\server\IndexServer;
  8. use Yii;
  9. use wechat\base\Help;
  10. class IndexController extends CommonController{
  11. public $enableCsrfValidation = false;
  12. public function actionIndex()
  13. {
  14. //区域
  15. $cityM = new \wechat\server\CityServer();
  16. $Abroad_a = $cityM->CityAbroad_a();
  17. $Abroad_b = $cityM->CityAbroad_b();
  18. $city_a = getTree($Abroad_a,0);
  19. $city_b = getTree($Abroad_b,0);
  20. $model = new IndexServer();
  21. $lunbo = $model->Lunbo();
  22. $tuijian = $model->tuijian(); //易购头条
  23. $news = $model->newslist();
  24. $newsc = $model->NewsColumn();
  25. //分站后 区域id
  26. $gCity = Yii::$app->request->get('city');
  27. if(empty($gCity))
  28. {
  29. $gCity = Yii::$app->hostserver->hostId;
  30. }
  31. //精选楼盘
  32. $hot = $model->Hothouse(['city'=>!empty($gCity) ? $gCity : 0,'type'=>4,'rand'=>null]);
  33. if(!empty($hot))
  34. {
  35. foreach ($hot as &$val)
  36. {
  37. $val['thumb'] = Yii::$app->params['httpImg']['hosts'].Yii::$app->params['httpImg']['houses'].$val['thumb'].Yii::$app->params['pfgwatermark'];
  38. }
  39. }
  40. //品牌商
  41. $PushmColumn = new PushmColumn();
  42. $PushmColumn->type = 1;
  43. $pinpai = $PushmColumn->getList(['page'=>1,'limit'=>5])['data'];
  44. if($pinpai)
  45. {
  46. $m = new \common\models\PushmHouse();
  47. $m->developers_id = array_column($pinpai,'did');
  48. $result = $m->getListGroup();
  49. if($result)
  50. {
  51. $resultArr = array_column($result,'total','developers_id');
  52. }
  53. foreach ($pinpai as &$val)
  54. {
  55. $val['house_count'] = 0;
  56. if(isset($resultArr[$val['did']]))
  57. {
  58. $val['house_count'] = $resultArr[$val['did']];
  59. }
  60. $val['img'] = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['push_lb'].$val['img'];
  61. }
  62. }
  63. if(empty($gCity))
  64. {
  65. $gCity = Yii::$app->hostserver->hostId;
  66. if($gCity !=0)
  67. {
  68. $cityName = \common\models\CategoryCity::findOne($gCity)['city_name'];
  69. }
  70. else
  71. {
  72. $cityName = '全国';
  73. }
  74. }
  75. else
  76. {
  77. $gCity = Yii::$app->hostserver->hostId;
  78. $cityName = \common\models\CategoryCity::findOne($gCity)['city_name'];
  79. }
  80. //导航
  81. $sysmenu = new \common\models\Frontend();
  82. $sysmenu->pid = 105;
  83. $SysRows = $sysmenu->SonList(8,['name','url','icon','function']);
  84. //热门区域
  85. $CityModel = new PushmCity();
  86. $CityModel->type = 1;
  87. $CityModel->abroad = 1;
  88. $HotCity = $CityModel->Homelist(7);
  89. $CityModel->abroad = 2;
  90. $HotCityb = $CityModel->Homelist(8);
  91. return $this->render('index',[
  92. 'lunbo'=>$lunbo,
  93. // 'tese'=>$tese,
  94. 'tuijian'=>$tuijian,
  95. 'news'=>$news,
  96. 'newsc'=>$newsc,
  97. 'city_all'=>['abroad_a'=>$city_a,'abroad_b'=>$city_b],
  98. 'gcity'=>$gCity,
  99. 'cityname'=>$cityName,
  100. 'sysmenu'=>$SysRows,
  101. 'hot_house'=>$hot,
  102. 'pinpai'=>$pinpai,
  103. 'hotcity'=>$HotCity,
  104. 'hotcityb'=>$HotCityb
  105. ]);
  106. }
  107. public function actionHothouses()
  108. {
  109. // $model = new IndexServer();
  110. // $hot = $model->Hothouse(Yii::$app->request->post());
  111. // if(!empty($hot))
  112. // {
  113. // foreach ($hot as &$val)
  114. // {
  115. // $val['thumb'] = Yii::$app->params['httpImg']['hosts'].Yii::$app->params['httpImg']['houses'].$val['thumb'];
  116. // }
  117. // return Help::JsonCode(Help::SUCCESS,'成功',$hot);
  118. // }
  119. return Help::JsonCode(Help::SUCCESS,'成功',[]);
  120. }
  121. public function actionSearchalert()
  122. {
  123. $model = new IndexServer();
  124. $shaixuan = $model->shaixuan();
  125. $price = $model->PriceList();
  126. //热门区域
  127. $CityModel = new PushmCity();
  128. $CityModel->type = 1;
  129. $CityModel->abroad = 1;
  130. $HotCity = $CityModel->Homelist(7);
  131. $Housetype = \common\models\CategoryHousetype::find()->andWhere(['del'=>1])->andWhere(['state'=>1])->orderBy(['sort'=>SORT_ASC])->limit(4)->asArray()->all();
  132. return $this->renderPartial('searchalert',[ 'shaixuan'=>$Housetype, 'hot_city'=>$HotCity]);
  133. }
  134. /*renderPartial
  135. * 首页-底部 拨打电话图标
  136. * */
  137. public function actionTelrand()
  138. {
  139. //有获取区域的情况下
  140. $input = Yii::$app->request->post();
  141. $tel = new \common\models\CategoryTelCity();
  142. if(!empty($input['city']))
  143. {
  144. $tel->cid =$input['city'];
  145. $resultTel = $tel->CityTelOne();
  146. if(!empty($resultTel))
  147. {
  148. $telArr = explode(',',$resultTel['tel']);
  149. $index = array_rand($telArr,1);
  150. if(!empty($telArr[$index]))
  151. {
  152. return Help::JsonCode(Help::SUCCESS,'成功',['tel'=>$telArr[$index]]);
  153. }
  154. }
  155. }
  156. //没获取区域的情况下
  157. $model = new \common\models\PushmCity();
  158. $model->type = 2;
  159. $randRow = $model->RandFind();
  160. if(!empty($randRow))
  161. {
  162. $tel->cid =$randRow['city_id'];
  163. $resultTel = $tel->CityTelOne();
  164. if(!empty($resultTel))
  165. {
  166. $telArr = explode(',',$resultTel['tel']);
  167. $index = array_rand($telArr,1);
  168. if(!empty($telArr[$index]))
  169. {
  170. return Help::JsonCode(Help::SUCCESS,'成功',['tel'=>$telArr[$index]]);
  171. }
  172. }
  173. }
  174. return Help::JsonCode(Help::SUCCESS,'成功',['tel'=>Yii::$app->params['default_dialtel']]);
  175. }
  176. //
  177. // /**
  178. // * 需求定制 价格-户型-区域
  179. // */
  180. // public function actionCustomized()
  181. // {
  182. // $arr['price'] = [10,20,30,40,50,60,70,80,90];
  183. // $typeModel = new \common\models\CategoryHousetype();
  184. // $typeModel->state = 1;
  185. // $arr['type'] = $typeModel->getList([],['id','huxing_name']);
  186. // $city = new \common\models\CategoryCity();
  187. // $city->pid = 0;
  188. // $arr['province'] = $city->getList([],['id','city_name']);
  189. // p($arr);
  190. // }
  191. /**
  192. * 传递父类区域ID
  193. * 返回子类区域信息
  194. */
  195. public function actionCityson()
  196. {
  197. $input = Yii::$app->request->post();
  198. if(!empty($input['pid']))
  199. {
  200. $city = new \common\models\CategoryCity();
  201. $city->pid = $input['pid'];
  202. $rows = $city->getList([],['id','city_name']);
  203. if(!empty($rows))
  204. {
  205. return Help::JsonCode(Help::SUCCESS,'成功',$rows);
  206. }
  207. }
  208. return Help::JsonCode(Help::ERROR,'暂无区域信息');
  209. }
  210. /**
  211. * 区域价格走势
  212. */
  213. public function actionCityprice()
  214. {
  215. $model = new \common\models\PushCityprice();
  216. $model->city_id = Yii::$app->request->post('id');
  217. $rows = $model->FindCityRecordPrice();
  218. if(!empty($rows))
  219. {
  220. $timestrap = strtotime($rows['price_at']);
  221. $rows['price_at'] = trim(date('m',$timestrap).'月','0');
  222. return Help::JsonCode(Help::SUCCESS,'成功',$rows);
  223. }
  224. }
  225. //需求数据
  226. // public function actionCustomizedform()
  227. // {
  228. //
  229. // }
  230. }