123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/5/29
- * Time: 上午11:35
- */
- namespace backend\controllers;
- use backend\base\CommonController;
- use backend\base\Help;
- use Yii;
- use common\models\PushNews;
- use common\models\PushNewscolumn;
- use backend\server\UploadFile;
- /**
- * Class PushnewsController
- * @package backend\controllers
- * 1=>资讯页面 头部-左边位置
- * 2=>资讯首页顶部 右边
- * 3=>资讯首页底部 热门专题
- * 4=>
- * 5=>首页-底部 购房攻略
- */
- class PushnewsController extends CommonController
- {
- /*
- * 资讯推送 - 头部 - 左边
- * */
- public function actionPone()
- {
- return $this->render('pone',['type'=>1]);
- }
- /*
- * 资讯推送 - 头部 - 左边数据
- * */
- public function actionPoneform()
- {
- $model = new PushNews();
- $model->type = Yii::$app->request->post('type');
- $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']);
- $val['img'] = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['pushnews'].$val['img'];
- }
- return Help::JsonData(0,Yii::t('app','get_success'),$model->Total(),$rows);
- }
- }
- public function actionPoneadd()
- {
- return $this->render('poneadd',['type'=>Yii::$app->request->get('type')]);
- }
- /*
- * 资讯推送 - 添加数据
- * */
- public function actionPoneaddform()
- {
- $model = new PushNews();
- $model->scenario = 'add';
- $auth = $model->Authenticator(Yii::$app->request->post());
- if(is_object($auth))
- {
- $img = UploadFile::InstanceImgName('img',Yii::$app->params['img_url']['pushnews']);
- if(is_string($img))
- {
- $auth->img = $img;
- }
- if($auth->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','add_error'),$auth);
- }
- /*
- * 资讯推送 - 资讯首页顶部 右边
- * */
- public function actionPtwo()
- {
- return $this->render('ptwo',['type'=>2]);
- }
- /*
- * 资讯推送 - 资讯首页底部 热门专题
- * */
- public function actionPthree()
- {
- return $this->render('pthree',['type'=>3]);
- }
- /**
- * 首页 - 购房攻略
- */
- public function actionGoufang()
- {
- return $this->render('pthree',['type'=>5]);
- }
- /*
- * 资讯推送 - 首页 最新攻略
- * */
- public function actionNewpone()
- {
- return $this->render('newpone',['type'=>6]);
- }
- /*
- * 禁用 and 删除
- * */
- public function actionNewsdelandshow()
- {
- $model = new PushNews();
- $input = Yii::$app->request->post();
- $row = $model->FindById($input['id']);
- if($row != null)
- {
- switch ($input['type'])
- {
- case 'show':
- if($row->is_show == 1)
- {
- $row->is_show = 2;
- }
- else if($row->is_show == 2)
- {
- $row->is_show = 1;
- }
- break;
- case 'del':
- $row->del = 2;
- break;
- case 'sort':
- $row->sort = $input['sort'];
- 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 actionHomenewscolumn()
- {
- return $this->render('homenewscolumn');
- }
- /*
- * 首页 - 资讯 栏目
- * */
- public function actionHomenewscolumnform()
- {
- $model = new PushNewscolumn();
- $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->Total(),$rows);
- }
- }
- /*
- * 首页 - 资讯 栏目 添加
- * */
- public function actionNewscolumnadd()
- {
- return $this->render('newscolumnadd');
- }
- /*
- * 首页 - 资讯 栏目 添加
- * */
- public function actionNewscolumnaddform()
- {
- $model = new PushNewscolumn();
- $model->scenario = 'add';
- $model->cid = Yii::$app->request->post('nid');
- $auth = $model->Authenticator(Yii::$app->request->post());
- if(is_object($auth))
- {
- if($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 actionNewscolumnedit()
- {
- $model = new PushNewscolumn();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if(!empty($row))
- {
- return $this->render('newscolumnedit',['model'=>$row,'name'=>Yii::$app->request->get('name')]);
- }
- }
- /*
- * 首页 - 资讯 栏目 修改 数据
- * */
- public function actionNewscolumnaeditform()
- {
- $model = new PushNewscolumn();
- $input = Yii::$app->request->post();
- $row = $model->FindById($input['id']);
- if(!empty($row))
- {
- $row->cid = $input['nid'];
- $row->short = $input['short'];
- 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 actionNewscolumndelandshow()
- {
- $model = new PushNewscolumn();
- $input = Yii::$app->request->post();
- $row = $model->FindById($input['id']);
- if($row != null)
- {
- switch ($input['type'])
- {
- case 'show':
- if($row->is_show == 1)
- {
- $row->is_show = 2;
- }
- else if($row->is_show == 2)
- {
- $row->is_show = 1;
- }
- break;
- case 'del':
- $row->del = 2;
- break;
- case 'sort':
- $row->sort = $input['sort'];
- 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 actionNewcontent()
- {
- return $this->render('newcontent',['cid'=>Yii::$app->request->get('cid')]);
- }
- /*
- * 首页 - 资讯 栏目所属内容 数据
- * */
- public function actionNewcontentform()
- {
- $model = new PushNews();
- $model->type = Yii::$app->request->post('type');
- $model->cid = Yii::$app->request->post('cid');
- $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']);
- $val['img'] = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['pushnews'].$val['img'];
- }
- return Help::JsonData(0,Yii::t('app','get_success'),$model->Total(),$rows);
- }
- }
- /*
- * 首页 - 资讯 添加跟栏目相关的内容 页面
- * */
- public function actionNewcontentadd()
- {
- return $this->render('newcontentadd',['cid'=>Yii::$app->request->get('type')]);
- }
- /*
- * 首页 - 资讯 添加跟栏目相关的内容 数据
- * */
- public function actionNewcontentaddform()
- {
- $model = new PushNews();
- $row = $model->Authenticator(Yii::$app->request->post());
- if(is_object($row))
- {
- if($row->save()) return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success'));
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','add_error'),$row);
- }
- public function actionNewcontentdelandshow()
- {
- $model = new PushNews();
- $input = Yii::$app->request->post();
- $row = $model->FindById($input['id']);
- if($row != null)
- {
- switch ($input['type'])
- {
- case 'show':
- if($row->is_show == 1)
- {
- $row->is_show = 2;
- }
- else if($row->is_show == 2)
- {
- $row->is_show = 1;
- }
- break;
- case 'del':
- $row->del = 2;
- break;
- case 'sort':
- $row->sort = $input['sort'];
- 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'));
- }
- }
|