VideoController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/4/26
  6. * Time: 上午11:13
  7. */
  8. namespace frontend\controllers;
  9. use frontend\base\CommonController;
  10. use Yii;
  11. use frontend\base\Help;
  12. class VideoController extends CommonController
  13. {
  14. public function actionHome()
  15. {
  16. $mode = new \common\models\Video();
  17. $cityGroup = $mode->GroupCity();
  18. if(!empty($cityGroup))
  19. {
  20. $id = array_column($cityGroup,'city','city_name');
  21. $mode->city = $id;
  22. $list = $mode->homeList();
  23. $arr = [];
  24. foreach ($list as $key=>$val)
  25. {
  26. if(in_array($val['city'],$id))
  27. {
  28. $arr[$val['city']][] = $val;
  29. }
  30. }
  31. }
  32. return $this->render('home',['city'=>$id,'model'=>$arr]);
  33. }
  34. public function actionDetails()
  35. {
  36. $model = new \common\models\Video();
  37. $model->id = Yii::$app->request->get('vid');
  38. $row = $model->HomeFind();
  39. return $this->render('details',['model'=>$row]);
  40. }
  41. public function actionRandvideo()
  42. {
  43. $mode = new \common\models\Video();
  44. $rows = $mode->RandList(5);
  45. if(!empty($rows))
  46. {
  47. foreach ($rows as &$val)
  48. {
  49. $val['thumb'] = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['video'].$val['thumb'];
  50. }
  51. return Help::JsonCode(Help::SUCCESS,'成功',$rows);
  52. }
  53. return Help::JsonCode(Help::ERROR,'失败');
  54. }
  55. public function actionTest()
  56. {
  57. p($_SERVER);
  58. }
  59. }