123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/4/8
- * Time: 上午11:52
- */
- namespace backend\controllers;
- use backend\base\CommonController;
- use backend\base\Help;
- use Yii;
- use common\models\CategoryVideo;
- use common\models\CategoryCity;
- use common\models\House;
- use common\models\Video;
- use backend\server\UploadFile;
- use backend\server\RoutineVideo;
- class RoutinevideoController extends CommonController
- {
- /*
- * 常规管理-视频列表显示页面
- * */
- public function actionHome()
- {
- $model = new CategoryVideo();
- $typeVideo = $model->getList([]);
- $cityModel = new CategoryCity();
- $cityModel->level = 2;
- $city = $cityModel->getList([]);
- return $this->render('home',['city'=>$city,'video'=>$typeVideo]);
- }
- /*
- * 常规管理-视频-列表数据
- * */
- public function actionHomeform()
- {
- $model = new Video();
- $input = Yii::$app->request->post();
- if(!empty($input['title']))
- {
- $model->title = $input['title'];
- }
- if(!empty($input['type_name']))
- {
- $model->video_category = $input['type_name'];
- }
- if(!empty($input['city']))
- {
- $model->city = $input['city'];
- }
- if(!empty($input['house_name']))
- {
- $model->hid = $input['house_name'];
- }
- $rows = $model->getList(Yii::$app->request->post());
- if($rows != null)
- {
- foreach ($rows as &$val)
- {
- $val['create_at'] = date('Y-m-d',$val['create_at']);
- }
- return Help::JsonData(0,'成功',$model->Total(),$rows);
- }
- return Help::JsonCode(Help::ERROR,'暂无信息');
- }
- /*
- * 常规管理-视频-添加页面
- * */
- public function actionVideoadd()
- {
- $model = new CategoryVideo();
- $typeVideo = $model->getList([]);
- $cityModel = new CategoryCity();
- $cityModel->level = 2;
- $city = $cityModel->getList([]);
- return $this->render('videoadd',['video'=>$typeVideo,'city'=>$city]);
- }
- /*
- * 常规管理-视频-添加数据
- * */
- public function actionVideoaddform()
- {
- $input = Yii::$app->request->post();
- $input['uid'] = Yii::$app->session['user_info']['uid'];
- $model = new Video();
- $model->scenario = 'add';
- $auth = $model->Authenticator($input);
- if(is_object($auth))
- {
- $url = Yii::$app->params['img_url']['video'];
- $img = UploadFile::InstanceImgName('img',$url);
- if($img != false)
- {
- $auth->thumb = $img;
- //压缩图片
- $compressParams = [];
- $compressParams['data']['imgname'] = $img;
- $compressParams['data']['url'] = $url;
- $compressParams['data']['source'] = '视频封面图@添加';
- $model = new \backend\event\TinifyEvent();
- $model->CompressImg($compressParams);
- }
- if($auth->save(false) == true) return Help::JsonCode(Help::SUCCESS,'添加成功');
- }
- return Help::JsonCode(Help::ERROR,'添加失败',$auth);
- }
- /*
- * 常规管理-视频-编辑页面
- * */
- public function actionVideoedit()
- {
- $model = new CategoryVideo();
- $typeVideo = $model->getList([]);
- $cityModel = new CategoryCity();
- $cityModel->level = 2;
- $city = $cityModel->getList([]);
- $video = new Video();
- $videoData = $video->FindById(Yii::$app->request->get('id'));
- if($videoData != null)
- {
- $url = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['video'];
- $videoData['thumb'] = $url.$videoData['thumb'];
- return $this->render('videoedit',['video'=>$typeVideo,'city'=>$city,'model'=>$videoData,'post'=>Yii::$app->request->get()]);
- }
- }
- /*
- * 常规管理-视频-编辑数据
- * */
- public function actionVideoeditform()
- {
- $model = new Video();
- $input = Yii::$app->request->post();
- $auth = $model->Authenticator($input);
- if(is_object($auth))
- {
- $video = $model->FindById($input['id']);
- $setAttr = Help::SetAttr($input,$auth,$video);
- $url = Yii::$app->params['img_url']['video'];
- $img = UploadFile::InstanceImgName('img',$url);
- if($img != false)
- {
- UploadFile::delImg($url,$video['thumb']);
- $setAttr->thumb = $img;
- //压缩图片
- $compressParams = [];
- $compressParams['data']['imgname'] = $img;
- $compressParams['data']['url'] = $url;
- $compressParams['data']['source'] = '视频封面图@修改';
- $model = new \backend\event\TinifyEvent();
- $model->CompressImg($compressParams);
- }
- if($setAttr->save(false) == true) return Help::JsonCode(Help::SUCCESS,'修改成功');
- }
- return Help::JsonCode(Help::ERROR,'修改失败',$auth);
- }
- /*
- * 常规管理-视频-修改状态
- * */
- public function actionVideostate()
- {
- $model = new RoutineVideo();
- if($model->StateAndDel(1) === true) return Help::JsonCode(Help::SUCCESS,'操作成功');
- return Help::JsonCode(Help::ERROR,'操作失败');
- }
- /*
- * 常规管理-视频-删除
- * */
- public function actionVideodel()
- {
- $model = new RoutineVideo();
- if($model->StateAndDel(2) === true) return Help::JsonCode(Help::SUCCESS,'操作成功');
- return Help::JsonCode(Help::ERROR,'操作失败');
- }
- /*
- * 显示所有楼盘信息页面
- * */
- public function actionAllhouse()
- {
- return $this->render('allhouse');
- }
- /*
- * 获取所有楼盘数据
- * */
- public function actionAllhouseform()
- {
- $model = new House;
- $input = Yii::$app->request->post();
- if(!empty($input['name']))
- {
- $model->name = $input['name'];
- }
- $rows = $model->getList($input);
- if($rows != null)
- {
- return Help::JsonData(0,'成功',$model->getListTotal($input),$rows);
- }
- }
- }
|