RoutinevideoController.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/4/8
  6. * Time: 上午11:52
  7. */
  8. namespace backend\controllers;
  9. use backend\base\CommonController;
  10. use backend\base\Help;
  11. use Yii;
  12. use common\models\CategoryVideo;
  13. use common\models\CategoryCity;
  14. use common\models\House;
  15. use common\models\Video;
  16. use backend\server\UploadFile;
  17. use backend\server\RoutineVideo;
  18. class RoutinevideoController extends CommonController
  19. {
  20. /*
  21. * 常规管理-视频列表显示页面
  22. * */
  23. public function actionHome()
  24. {
  25. $model = new CategoryVideo();
  26. $typeVideo = $model->getList([]);
  27. $cityModel = new CategoryCity();
  28. $cityModel->level = 2;
  29. $city = $cityModel->getList([]);
  30. return $this->render('home',['city'=>$city,'video'=>$typeVideo]);
  31. }
  32. /*
  33. * 常规管理-视频-列表数据
  34. * */
  35. public function actionHomeform()
  36. {
  37. $model = new Video();
  38. $input = Yii::$app->request->post();
  39. if(!empty($input['title']))
  40. {
  41. $model->title = $input['title'];
  42. }
  43. if(!empty($input['type_name']))
  44. {
  45. $model->video_category = $input['type_name'];
  46. }
  47. if(!empty($input['city']))
  48. {
  49. $model->city = $input['city'];
  50. }
  51. if(!empty($input['house_name']))
  52. {
  53. $model->hid = $input['house_name'];
  54. }
  55. $rows = $model->getList(Yii::$app->request->post());
  56. if($rows != null)
  57. {
  58. foreach ($rows as &$val)
  59. {
  60. $val['create_at'] = date('Y-m-d',$val['create_at']);
  61. }
  62. return Help::JsonData(0,'成功',$model->Total(),$rows);
  63. }
  64. return Help::JsonCode(Help::ERROR,'暂无信息');
  65. }
  66. /*
  67. * 常规管理-视频-添加页面
  68. * */
  69. public function actionVideoadd()
  70. {
  71. $model = new CategoryVideo();
  72. $typeVideo = $model->getList([]);
  73. $cityModel = new CategoryCity();
  74. $cityModel->level = 2;
  75. $city = $cityModel->getList([]);
  76. return $this->render('videoadd',['video'=>$typeVideo,'city'=>$city]);
  77. }
  78. /*
  79. * 常规管理-视频-添加数据
  80. * */
  81. public function actionVideoaddform()
  82. {
  83. $input = Yii::$app->request->post();
  84. $input['uid'] = Yii::$app->session['user_info']['uid'];
  85. $model = new Video();
  86. $model->scenario = 'add';
  87. $auth = $model->Authenticator($input);
  88. if(is_object($auth))
  89. {
  90. $url = Yii::$app->params['img_url']['video'];
  91. $img = UploadFile::InstanceImgName('img',$url);
  92. if($img != false)
  93. {
  94. $auth->thumb = $img;
  95. //压缩图片
  96. $compressParams = [];
  97. $compressParams['data']['imgname'] = $img;
  98. $compressParams['data']['url'] = $url;
  99. $compressParams['data']['source'] = '视频封面图@添加';
  100. $model = new \backend\event\TinifyEvent();
  101. $model->CompressImg($compressParams);
  102. }
  103. if($auth->save(false) == true) return Help::JsonCode(Help::SUCCESS,'添加成功');
  104. }
  105. return Help::JsonCode(Help::ERROR,'添加失败',$auth);
  106. }
  107. /*
  108. * 常规管理-视频-编辑页面
  109. * */
  110. public function actionVideoedit()
  111. {
  112. $model = new CategoryVideo();
  113. $typeVideo = $model->getList([]);
  114. $cityModel = new CategoryCity();
  115. $cityModel->level = 2;
  116. $city = $cityModel->getList([]);
  117. $video = new Video();
  118. $videoData = $video->FindById(Yii::$app->request->get('id'));
  119. if($videoData != null)
  120. {
  121. $url = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['video'];
  122. $videoData['thumb'] = $url.$videoData['thumb'];
  123. return $this->render('videoedit',['video'=>$typeVideo,'city'=>$city,'model'=>$videoData,'post'=>Yii::$app->request->get()]);
  124. }
  125. }
  126. /*
  127. * 常规管理-视频-编辑数据
  128. * */
  129. public function actionVideoeditform()
  130. {
  131. $model = new Video();
  132. $input = Yii::$app->request->post();
  133. $auth = $model->Authenticator($input);
  134. if(is_object($auth))
  135. {
  136. $video = $model->FindById($input['id']);
  137. $setAttr = Help::SetAttr($input,$auth,$video);
  138. $url = Yii::$app->params['img_url']['video'];
  139. $img = UploadFile::InstanceImgName('img',$url);
  140. if($img != false)
  141. {
  142. UploadFile::delImg($url,$video['thumb']);
  143. $setAttr->thumb = $img;
  144. //压缩图片
  145. $compressParams = [];
  146. $compressParams['data']['imgname'] = $img;
  147. $compressParams['data']['url'] = $url;
  148. $compressParams['data']['source'] = '视频封面图@修改';
  149. $model = new \backend\event\TinifyEvent();
  150. $model->CompressImg($compressParams);
  151. }
  152. if($setAttr->save(false) == true) return Help::JsonCode(Help::SUCCESS,'修改成功');
  153. }
  154. return Help::JsonCode(Help::ERROR,'修改失败',$auth);
  155. }
  156. /*
  157. * 常规管理-视频-修改状态
  158. * */
  159. public function actionVideostate()
  160. {
  161. $model = new RoutineVideo();
  162. if($model->StateAndDel(1) === true) return Help::JsonCode(Help::SUCCESS,'操作成功');
  163. return Help::JsonCode(Help::ERROR,'操作失败');
  164. }
  165. /*
  166. * 常规管理-视频-删除
  167. * */
  168. public function actionVideodel()
  169. {
  170. $model = new RoutineVideo();
  171. if($model->StateAndDel(2) === true) return Help::JsonCode(Help::SUCCESS,'操作成功');
  172. return Help::JsonCode(Help::ERROR,'操作失败');
  173. }
  174. /*
  175. * 显示所有楼盘信息页面
  176. * */
  177. public function actionAllhouse()
  178. {
  179. return $this->render('allhouse');
  180. }
  181. /*
  182. * 获取所有楼盘数据
  183. * */
  184. public function actionAllhouseform()
  185. {
  186. $model = new House;
  187. $input = Yii::$app->request->post();
  188. if(!empty($input['name']))
  189. {
  190. $model->name = $input['name'];
  191. }
  192. $rows = $model->getList($input);
  193. if($rows != null)
  194. {
  195. return Help::JsonData(0,'成功',$model->getListTotal($input),$rows);
  196. }
  197. }
  198. }