123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- <?php
- /*
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/7/10
- * Time: 上午9:44
- * 装修品鉴
- **/
- namespace backend\controllers;
- use backend\base\CommonController;
- use backend\base\Help;
- use common\models\NewsRenovationcontent;
- use Yii;
- use backend\server\UploadFile;
- use common\models\NewsRenovation;
- class RoutinedecorationController extends CommonController{
- /*
- * 常规管理 - 装修品鉴 - 页面
- **/
- public function actionHome()
- {
- return $this->render('home');
- }
- /*
- *常规管理 - 装修品鉴 - 数据
- ***/
- public function actionHomeform()
- {
- $model = new NewsRenovation();
- $model->title = Yii::$app->request->post('title');
- $result = $model->getList(Yii::$app->request->post());
- if(!empty($result))
- {
- $content = new \common\models\NewsRenovationcontent();
- foreach ($result as &$val)
- {
- $content->nid = $val['id'];
- $val['count'] = $content->Total();
- $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
- }
- return Help::JsonData(0,Yii::t('app','get_success'),$model->getListTotal(),$result);
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
- }
- /*
- *常规管理 - 装修品鉴 - 添加页面
- **/
- public function actionHomeadd()
- {
- $label = new \common\models\CategoryLabel();
- $label->type = 4;
- $labelList = $label->getList([]);
- return $this->render('homeadd',['label'=>$labelList]);
- }
- /*
- * 常规管理 - 装修品鉴 - 添加数据
- **/
- public function actionHomeaddform()
- {
- $model = new \common\models\NewsRenovation();
- $auth = $model->Authenticator(Yii::$app->request->post());
- if(is_object($auth))
- {
- $img = UploadFile::InstanceImgName('img',Yii::$app->params['img_url']['pj']);
- if(is_string($img))
- {
- $auth->img = $img;
- }
- if($auth->save())
- {
- return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
- }
- UploadFile::delImg(Yii::$app->params['img_url']['pj'],$img);
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','add_error'),$auth);
- }
- /*
- * 常规管理 - 装修品鉴 - 修改页面
- **/
- public function actionHomeedit()
- {
- $model = new NewsRenovation();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if(!empty($row))
- {
- $row['img'] = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['pj'].$row['img'];
- return $this->render('homeedit',['model'=>$row,'housename'=>Yii::$app->request->get('name')]);
- }
- }
- /*
- * 常规管理 - 装修品鉴 - 修改数据
- **/
- public function actionHomeeditform()
- {
- $model = new NewsRenovation();
- $input = Yii::$app->request->post();
- $row = $model->Authenticator($input);
- if(is_object($row))
- {
- $row = $model->FindById($input['id']);
- if(!empty($row))
- {
- $row = Help::SetAttr($input,$model,$row);
- if(!empty($_FILES['img']))
- {
- $url = Yii::$app->params['img_url']['pj'];
- $img = UploadFile::InstanceImgName('img',$url);
- if(is_string($img))
- {
- UploadFile::delImg($url,$row->img);
- $row->img = $img;
- }
- }
- if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'),$row);
- }
- /*
- * 常规管理 - 装修品鉴 - 批量删除
- **/
- public function actionHomedel()
- {
- $id = Yii::$app->request->post('id');
- if(is_array($id))
- {
- $model = NewsRenovation::updateAll(['del'=>2,'update_at'=>$_SERVER['REQUEST_TIME']],['id'=>$id]);
- if($model >0)
- {
- return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- }
- return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_error'));
- }
- /*
- * 常规管理 - 装修品鉴 - 隐藏和显示
- **/
- public function actionHomeshow()
- {
- $model = new NewsRenovation();
- $row = $model->FindById(Yii::$app->request->post('id'));
- $input = Yii::$app->request->post();
- if(!empty($row))
- {
- switch ($input['type'])
- {
- case 'clicks':
- $row->click = $input['clicks'];
- break;
- case 'show':
- if($row->is_show == 1)
- {
- $row->is_show = 2;
- }
- else
- {
- $row->is_show = 1;
- }
- break;
- }
- if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
- }
- /*
- * 常规管理 - 装修品鉴 - 内容页面
- **/
- public function actionCont()
- {
- return $this->render('cont',['post'=>Yii::$app->request->get()]);
- }
- /*
- * 常规管理 - 装修品鉴 - 内容数据
- **/
- public function actionContform()
- {
- $model = new NewsRenovationcontent();
- $model->nid = Yii::$app->request->post('nid');
- $rows = $model->getList(Yii::$app->request->post());
- if(!empty($rows))
- {
- foreach ($rows as &$val)
- {
- $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
- }
- return Help::JsonData(0,Yii::t('app','get_success'),$model->getListTotal(),$rows);
- }
- }
- /*
- *
- **/
- public function actionContadd()
- {
- $model = new \common\models\CategoryLabel();
- $model->type = 4;
- $rows = $model->getList([]);
- return $this->render('contadd',['post'=>Yii::$app->request->get(),'model'=>$rows]);
- }
- /*
- *
- **/
- public function actionContaddform()
- {
- $model = new NewsRenovationcontent();
- $model->scenario = 'add';
- $auth = $model->Authenticator(Yii::$app->request->post());
- if(is_object($auth) && $auth->save())
- {
- return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','add_error'),$auth);
- }
- /*
- *常规管理 - 装修品鉴 - 内容排序
- **/
- public function actionConteditsort()
- {
- $model = new NewsRenovationcontent();
- $input = Yii::$app->request->post();
- $rows = $model->FindById($input['id']);
- if(!empty($rows))
- {
- if(!empty($input['sort']))
- {
- $rows->sort = $input['sort'];
- }
- if($input['is_show'] == 1)
- {
- if( $rows->is_show == 1)
- {
- $rows->is_show =2;
- }
- else
- {
- $rows->is_show = 1;
- }
- }
- if($rows->save()) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'));
- }
- /*
- *
- **/
- public function actionContedit()
- {
- $model = new NewsRenovationcontent();
- $rows = $model->FindById(Yii::$app->request->get('id'));
- if(!empty($rows))
- {
- $label = new \common\models\CategoryLabel();
- $label->type = 4;
- $labelList = $label->getList([]);
- return $this->render('contedit',['model'=>$rows,'label'=>$labelList,'post'=>Yii::$app->request->get()]);
- }
- }
- /*
- *
- **/
- public function actionConteditform()
- {
- $model = new NewsRenovationcontent();
- $row = $model->FindById(Yii::$app->request->post('id'));
- if (!empty($row))
- {
- $row->content = Yii::$app->request->post('content');
- if($row->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_error'));
- }
- }
|