123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- <?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 backend\server\UploadFile;
- use Yii;
- use common\models\PushFreshimg;
- use common\models\PushFreshcity;
- use common\models\PushFreshcityhouse;
- class PushfreshController extends CommonController
- {
- /*
- * 新房- 大图 页面
- * */
- public function actionFreshimg()
- {
- return $this->render('freshimg');
- }
- /*
- * 新房- 大图 数据
- * */
- public function actionFreshimgform()
- {
- $url = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['fresh'];
- $model = new PushFreshimg();
- $rows = $model->getList(Yii::$app->request->post());
- if(!empty($rows))
- {
- foreach ($rows as &$val)
- {
- $val['img'] = $url.$val['img'];
- $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
- }
- return Help::JsonData(0,Yii::t('app','get_error'),$model->Total(),$rows);
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
- }
- /*
- * 新房- 大图 添加页面
- * */
- public function actionFreshimgadd()
- {
- return $this->render('freshimgadd');
- }
- /*
- * 新房- 大图 添加数据
- * */
- public function actionFreshimgaddform()
- {
- $model = new PushFreshimg();
- $input = Yii::$app->request->post();
- $auth = $model->Authenticator($input);
- if(is_object($auth))
- {
- Yii::$app->params['img_url']['fresh'];
- $img = UploadFile::InstanceImgName('img', Yii::$app->params['img_url']['fresh']);
- 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_erroe'),$auth);
- }
- /*
- * 新房- 大图 修改页面
- * */
- public function actionFreshimgedit()
- {
- $input = Yii::$app->request->get();
- $model = new PushFreshimg();
- $row = $model->FindById($input['id']);
- if(!empty($row))
- {
- $row['img'] = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['fresh'].$row['img'];
- return $this->render('freshimgedit',['model'=>$row]);
- }
- }
- /*
- * 新房- 大图 修改数据
- * */
- public function actionFresheditform()
- {
- $input = Yii::$app->request->post();
- $model = new PushFreshimg();
- $auth = $model->Authenticator($input);
- if(is_object($auth))
- {
- $row = $model->FindById($input['id']);
- if(!empty($row))
- {
- $row = Help::SetAttr($input,$auth,$row);
- $url = Yii::$app->params['img_url']['fresh'];;
- $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'));
- }
- /*
- * 新房- 大图 删除和隐藏
- * */
- public function actionFreshdelandsow()
- {
- $model = new PushFreshimg();
- $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;
- }
- 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 actionFreshcity()
- {
- return $this->render('freshcity');
- }
- /*
- * 新房 - 推荐楼盘区域数据
- * */
- public function actionFreshcityform()
- {
- $model = new PushFreshcity();
- $rows = $model->getList(Yii::$app->request->post());
- if(!empty($rows))
- {
- foreach ($rows as &$val)
- {
- $val['img'] = Yii::$app->params['httpImg']['host']. Yii::$app->params['httpImg']['city'].$val['img'];
- $val['create_at'] = date('Y-m-d H:i',$val['create_at']);
- }
- return Help::JsonData(0,Yii::t('app','get_success'),$model->Total(),$rows);
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
- }
- /*
- * 新房 - 推荐楼盘区域 添加页面
- * */
- public function actionFreshcityadd()
- {
- return $this->render('freshcityadd');
- }
- /*
- * 新房 - 推荐楼盘区域 添加数据
- * */
- public function actionFreshcityaddform()
- {
- $input = Yii::$app->request->post();
- $model = new PushFreshcity();
- $auth = $model->Authenticator($input);
- if(is_object($auth))
- {
- $img = UploadFile::InstanceImgName('img',Yii::$app->params['img_url']['city']);
- 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 actionFreshcityedit()
- {
- $model = new PushFreshcity();
- $row = $model->FindById(Yii::$app->request->get('id'));
- if(!empty($row))
- {
- $row['img'] = Yii::$app->params['httpImg']['host']. Yii::$app->params['httpImg']['city'].$row['img'];
- return $this->render('freshcityedit',['model'=>$row,'name'=>Yii::$app->request->get('name')]);
- }
- }
- /*
- * 新房 - 推荐楼盘区域 修改数据
- * */
- public function actionFreshcityeditform()
- {
- $model = new PushFreshcity();
- $input = Yii::$app->request->post();
- $auth = $model->Authenticator($input);
- if(is_object($auth))
- {
- $row = $model->FindById($input['id']);
- if(!empty($row))
- {
- $rows = Help::SetAttr($input,$auth,$row);
- $img = UploadFile::InstanceImgName('img',Yii::$app->params['img_url']['city']);
- if(is_string($img))
- {
- UploadFile::delImg(Yii::$app->params['img_url']['city'],$row->img);
- $rows->img = $img;
- }
- if($rows->save(false)) return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success'));
- }
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'),$auth);
- }
- public function actionCitydelandshow()
- {
- $model = new PushFreshcity();
- $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 actionCityhouse()
- {
- return $this->render('cityhouse',['id'=>Yii::$app->request->get('id')]);
- }
- /*
- * 新房 - 推荐楼盘区域 关联楼盘
- * */
- public function actionCityhouseform()
- {
- $model = new PushFreshcityhouse();
- $rows = $model->getList(Yii::$app->request->post());
- if(!empty($rows))
- {
- $model->city_id = Yii::$app->request->post('city_id');
- 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);
- }
- return Help::JsonCode(Help::ERROR,Yii::t('app','get_error'));
- }
- /*
- * 新房 - 推荐楼盘区域 关联楼盘
- * */
- public function actionCityhouseadd()
- {
- return $this->render('cityhouseadd',['id'=>Yii::$app->request->get('id')]);
- }
- /*
- * 新房 - 推荐楼盘区域 关联楼盘
- * */
- public function actionCityhouseaddform()
- {
- $model = new PushFreshcityhouse();
- $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 actionCityhousedelandshow()
- {
- $model = new PushFreshcityhouse();
- $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'));
- }
- }
|