HomeController.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. namespace mobile\modules\live\controllers;
  3. use common\Helps\Time;
  4. use common\models\CategoryCity;
  5. use common\models\House;
  6. use common\models\HouseType;
  7. use common\models\Live;
  8. use common\models\Sendcoderecord;
  9. use mobile\modules\live\base\BaseController;
  10. use Yii;
  11. use mobile\base\Help;
  12. class HomeController extends BaseController
  13. {
  14. public $enableCsrfValidation = false;
  15. //楼盘直播评论---增加
  16. public function actionAddliveremark()
  17. {
  18. $input = Yii::$app->request->post();
  19. }
  20. public function actionGetlive()
  21. {
  22. $input = Yii::$app->request->get();
  23. if (!empty($input['city'])) {
  24. $cmodel = new CategoryCity();
  25. $input['city'] = array_column($cmodel->GetAllSon($input['city']), 'id');
  26. }
  27. $lmodel = new Live();
  28. $data = $lmodel->showList($input);
  29. // p($data);die;
  30. if (!empty($data)) {
  31. foreach ($data as &$val) {
  32. $val['pid'] = CategoryCity::find()->select(['pid'])->andWhere(['del' => 1, 'id' => $val['city']])->asArray()->one()['pid'];
  33. if (!empty($val['pid'])) $val['house']['f'] = CategoryCity::find()->select(['id', 'city_name'])->andWhere(['del' => 1, 'id' => $val['pid']])->asArray()->one();
  34. $val['state'] = Time::getLiveState($val['video_url'], $val['time']);
  35. $house = House::findOne($val['hid']);
  36. if (!empty($house['area'])) {
  37. $val['swt'] = $house['area'];
  38. }else{
  39. $val['swt'] = $house['city'];
  40. }
  41. }
  42. return Help::JsonCode(Help::SUCCESS, '成功', $data);
  43. }
  44. return Help::JsonCode(Help::ERROR, '暂无数据');
  45. }
  46. public function actionDetail()
  47. {
  48. //获取模块内容
  49. $module = Yii::$app->hostserver->module;
  50. $input = Yii::$app->request->get();
  51. $model = new Live();
  52. // $htmodel = new HouseType();
  53. $res = $model::findOne($input['id']);
  54. if (empty($res)) $this->goBack('/live/');
  55. //直播状态
  56. $state = Time::getLiveState($res['video_url'], $res['time']);
  57. $typeGroup = array_column($res->houseInfo->houseTypesGroup, 'houseTypeName');
  58. // 去户型分组第一条数据的内容
  59. // $housetype = $htmodel::find()->andWhere(['hid'=>$res->hid,'type_id'=>$typeGroup[0]['id'],'del'=>1,'state'=>1])->asArray()->all();
  60. // if(!empty($housetype)){
  61. // array_walk($housetype,function(&$val){
  62. // $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housetypes'] . $val['img'] . Yii::$app->params['pfgwatermark'];
  63. // });
  64. // }
  65. //推送直播--随机同一区域其他楼盘直播
  66. $pushLive = $model->getLiveBySameArea($res->city, $res->id);
  67. // //记录浏览记录
  68. // $server = new \common\api\HttpServer();
  69. // $record = new LiveHttprecord();
  70. // $record->Add($ip = Yii::$app->request->userIP, $vid = $input['id'], $url = $server->GetCurUrl());
  71. return $this->render($this->action->id, [
  72. 'module' => $module['module'],
  73. 'Data' => $res,
  74. 'pushLive' => $pushLive,
  75. 'info' => $res->houseInfo->housedetail->info,
  76. 'typeGroup' => $typeGroup,
  77. 'state' => $state
  78. // 'housetype'=>$housetype,
  79. ]);
  80. }
  81. public function actionRequesthousetype()
  82. {
  83. //获取模块内容
  84. $module = Yii::$app->hostserver->module;
  85. $input = Yii::$app->request->get();
  86. $htmodel = new HouseType();
  87. // 去户型分组第一条数据的内容
  88. $housetype = $htmodel::find()->andWhere(['hid' => $input['id'], 'type_id' => $input['value'], 'del' => 1, 'state' => 1])->asArray()->all();
  89. if (!empty($housetype)) {
  90. array_walk($housetype, function (&$val) {
  91. $val['img'] = Yii::$app->params['httpImg']['hosts'] . Yii::$app->params['httpImg']['housetypes'] . $val['img'] . Yii::$app->params['pfgwatermark'];
  92. });
  93. }
  94. if (!empty($housetype)) return Help::JsonCode(Help::SUCCESS, '成功', $housetype);
  95. return Help::JsonCode(Help::ERROR, '暂无数据');
  96. }
  97. public function actionSendcode()
  98. {
  99. $input = Yii::$app->request->post();
  100. $input['purpose'] = '视频播放验证';
  101. $smsServer = new \mobile\server\SendCode();
  102. return $smsServer->easySms($input);
  103. }
  104. public function actionCheckcode()
  105. {
  106. $input = Yii::$app->request->post();
  107. $session = Yii::$app->session;
  108. $skey = 'live_' . $input['mobile'];
  109. if (empty($session[$skey])) {
  110. return Help::JsonCode(Help::ERROR, '请输入正确手机号');
  111. }
  112. //验证码有效期5分钟
  113. if ($session[$skey]['expire_time'] < time()) {
  114. return Help::JsonCode(Help::ERROR, '验证码已失效');
  115. }
  116. if ($input['code'] != $session[$skey]['code']) {
  117. return Help::JsonCode(Help::ERROR, '验证码不正确');
  118. }
  119. Yii::$app->session->set('adopt', $input['mobile']);
  120. if (!empty(Yii::$app->session['adopt']) && !empty(Yii::$app->session[$skey])) {
  121. $record = Sendcoderecord::find()->andWhere(['mobilephone' => $input['mobile'], 'code' => $session[$skey]['code']])->one();
  122. $record->status = 2;
  123. $record->save();
  124. }
  125. return Help::JsonCode(Help::SUCCESS, '验证通过');//验证通过继续播放视频
  126. }
  127. }