render('home'); } public function actionHomeform() { // p($this->cache['zt']); $model = new \common\models\SpecialTopic(); $rows = $model->getList(Yii::$app->request->post()); $imgUrl = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['push_lb']; if(!empty($rows['data'])) { array_walk($rows['data'],function(&$val) use ($imgUrl){ $val['hids'] = implode(',',json_decode($val['hids'],true)); list($val['pc_img'],$val['m_img']) = [(empty($val['pc_img'])? '' : $imgUrl.$val['pc_img']),(empty($val['m_img'])? '' : $imgUrl.$val['m_img'])]; }); return Help::JsonData(0,'成功',$rows['count'],$rows['data']); } return Help::JsonCode(Help::ERROR,'暂无数据'); } public function actionAdd() { return $this->render('add'); } public function actionAddform() { $model = new \common\models\SpecialTopic(); $input = Yii::$app->request->post(); $url = Yii::$app->params['img_url']['push_lb']; $img = UploadFile::InstanceImgName('img',$url); $img1 = UploadFile::InstanceImgName('img1',$url); if(empty($input['hid'])) return Help::JsonCode(Help::ERROR,'请选择推送的楼盘'); $input['hids'] = json_encode($input['hid']); if(is_string($img) && is_string($img1)){ list($input['pc_img'],$input['m_img']) = [$img,$img1]; } $model->load($input,''); if($model->validate() && $model->save()){ return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_success')); } return Help::JsonCode(Help::SUCCESS,Yii::t('app','add_error'),$model->errors); } public function actionEdit() { $model = new \common\models\SpecialTopic(); $zid = Yii::$app->request->get('id'); $row = $model::findOne($zid); $imgUrl = Yii::$app->params['httpImg']['host'].Yii::$app->params['httpImg']['push_lb']; if(!empty($row)){ $hmodel = new \common\models\House(); $query = $hmodel::find(); $hid = json_decode($row['hids'],true); $house = $query->select(['id','name'])->andWhere(['id'=>$hid])->asArray()->all(); list($row['pc_img'],$row['m_img']) = [(empty($row['pc_img'])? '' : $imgUrl.$row['pc_img']),(empty($row['m_img'])? '' : $imgUrl.$row['m_img'])]; } // p($house);die; return $this->render('edit',['model'=>$row,'house'=>$house]); } public function actionEditform() { $model = new \common\models\SpecialTopic(); $input = Yii::$app->request->post(); $row = $model::findOne($input['id']); $url = Yii::$app->params['img_url']['push_lb']; if(empty($input['hid'])) return Help::JsonCode(Help::ERROR,'请选择推送的楼盘'); if(!empty($_FILES)){ if(!empty($_FILES['img']['name'])){ UploadFile::delImg($url,$row->pc_img); $img = UploadFile::InstanceImgName('img',$url); is_string($img)? $input['pc_img'] = $img : '' ; } if(!empty($_FILES['img1']['name'])){ UploadFile::delImg($url,$row->m_img); $img1 = UploadFile::InstanceImgName('img1',$url); is_string($img1)? $input['m_img'] = $img1 : '' ; } } $input['hids'] = json_encode($input['hid']); $row->load($input,''); if($row->validate() && $row->save()){ return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success')); } return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error'),$row->errors); } public function actionDel() { // p('没做');die; $input = Yii::$app->request->post(); $model = new \common\models\SpecialTopic(); $url = Yii::$app->params['img_url']['push_lb']; $row = $model::findOne($input['id']); if(!empty($row)){ empty($row->pc_img)? '' : UploadFile::delImg($url,$row->pc_img); empty($row->m_img)? '' : UploadFile::delImg($url,$row->m_img); $row->delete(); return Help::JsonCode(Help::SUCCESS,Yii::t('app','edit_success')); } return Help::JsonCode(Help::ERROR,Yii::t('app','edit_error')); } /* * ********************写字楼专题*********************** * */ public function actionGulfcitystate() { $input = Yii::$app->request->post(); if (is_numeric($input['id'])) { $row = PushplaceType::findOne($input['id']); $row->state = $input['state']; if ($row->update(false)) return Help::JsonCode(Help::SUCCESS, '设置成功'); return Help::JsonCode(Help::SUCCESS, '设置失败'); } else { return Help::JsonCode(Help::SUCCESS, '设置失败'); } } public function actionGulfcitysort() { $input = Yii::$app->request->post(); if (is_numeric($input['id'])) { $row = PushplaceType::findOne($input['id']); $row->sort = $input['sort']; if ($row->update(false)) return Help::JsonCode(Help::SUCCESS, '排序成功'); return Help::JsonCode(Help::SUCCESS, '排序失败'); } else { return Help::JsonCode(Help::SUCCESS, '排序失败'); } } public function actionGulfcitydel() { $id = Yii::$app->request->post('id'); if (is_numeric($id)) { if (PushplaceType::findOne($id)->delete()) return Help::JsonCode(Help::SUCCESS, '删除成功'); return Help::JsonCode(Help::ERROR, '删除失败'); } else { return Help::JsonCode(Help::ERROR, '删除失败'); } } //海南站专题别墅 public function actionHainanville() { return $this->render('hainanville'); } public function actionHainanvilleform() { $data = PushplaceType::find()->where(['type' => 1])->asArray()->all(); return help::JsonData(0, '成功', 0, $data); } public function actionHainanvillestate() { $input = Yii::$app->request->post(); if (is_numeric($input['id'])) { $row = PushplaceType::findOne($input['id']); $row->state = $input['state']; if ($row->update(false)) return Help::JsonCode(Help::SUCCESS, '设置成功'); return Help::JsonCode(Help::SUCCESS, '设置失败'); } else { return Help::JsonCode(Help::SUCCESS, '设置失败'); } } public function actionTohainanvilleadd() { $input = Yii::$app->request->post('data'); $row = PushplaceType::find(); if (!$row->where(['title' => $input['title'], 'type' => 1])->exists()) { $query = new PushplaceType(); $query->title = $input['title']; $query->type = 1; if ($query->save()) return Help::JsonCode(Help::SUCCESS, '添加成功'); Help::JsonCode(Help::ERROR, '添加失败'); } else { return Help::JsonCode(Help::SUCCESS, '地区已存在'); } } public function actionHainanvilleadd() { return $this->render('hainanvilleadd'); } public function actionHainanvillegl() { $id = Yii::$app->request->get('id'); return $this->render('hainanvillegl', ['id' => $id]); } public function actionHainanvilleglform() { $previd = Yii::$app->request->get('previd'); $data = PushhouseType::find() ->select('pfg_pushhouse_type.*,pfg_pushplace_type.title,pfg_house.name,') ->where(['pfg_pushhouse_type.previd' => $previd, 'pfg_pushhouse_type.type' => 2]) ->leftJoin('pfg_house', 'pfg_house.id = pfg_pushhouse_type.hid') ->leftJoin('pfg_pushplace_type', 'pfg_pushplace_type.id = pfg_pushhouse_type.previd') ->orderBy(['pfg_pushhouse_type.sort' => SORT_DESC])->asArray()->all(); return help::JsonData(0, '成功', 0, $data); } public function actionHainanvillegladd() { $previd = Yii::$app->request->get('previd'); return $this->render('hainanvillegladd', ['previd' => $previd]); } public function actionGulfcitygledit() { $id = Yii::$app->request->get('id'); $data = PushhouseType::find() ->select('pfg_pushhouse_type.*,pfg_house.name,') ->where(['pfg_pushhouse_type.id' => $id]) ->leftJoin('pfg_house', 'pfg_house.id = pfg_pushhouse_type.hid') ->asArray()->one(); return $this->render('gulfcitygledit', ['data' => $data]); } public function actionGulfcitygleditto() { $input = Yii::$app->request->post('data'); $row = PushhouseType::find(); if (!$row->where("id <> {$input['id']} AND previd = {$input['previd']} AND hid = {$input['hid']}")->exists()) { $query = PushhouseType::findOne($input['id']); $query->hid = $input['hid']; if ($query->update(false)) return Help::JsonCode(Help::SUCCESS, '编辑成功'); return Help::JsonCode(Help::SUCCESS, '编辑失败'); } else { return Help::JsonCode(Help::ERROR, '楼盘已存在'); } } public function actionHainanvillegladdto() { $input = Yii::$app->request->post('data'); $row = PushhouseType::find(); if (!$row->where(['previd' => $input['previd'], 'type' => 2, 'hid' => $input['hid']])->exists()) { $query = new PushhouseType(); $query->hid = $input['hid']; $query->previd = $input['previd']; $query->type = 2; if ($query->save()) return Help::JsonCode(Help::SUCCESS, '添加成功'); Help::JsonCode(Help::ERROR, '添加失败'); } else { Help::JsonCode(Help::ERROR, '楼盘已存在'); } } public function actionTohainanvilleedit() { $input = Yii::$app->request->post('data'); $rows = PushplaceType::find(); if (!$rows->where(['type' => 1, 'title' => $input['title']])->exists()) { $qurey = PushplaceType::findOne($input['id']); $qurey->title = $input['title']; if ($qurey->update(false)) return Help::JsonCode(Help::SUCCESS, '编辑成功'); return Help::JsonCode(Help::ERROR, '编辑失败'); } else { return Help::JsonCode(Help::SUCCESS, '地区已存在'); } } public function actionGulfcityglstate() { $input = Yii::$app->request->post(); if (is_numeric($input['id'])) { $row = PushhouseType::findOne($input['id']); $row->state = $input['state']; if ($row->update(false)) return Help::JsonCode(Help::SUCCESS, '设置成功'); return Help::JsonCode(Help::SUCCESS, '设置失败'); } else { return Help::JsonCode(Help::SUCCESS, '设置失败'); } } public function actionGulfcityglsort() { $input = Yii::$app->request->post(); if (is_numeric($input['id'])) { $row = PushhouseType::findOne($input['id']); $row->sort = $input['sort']; if ($row->update(false)) return Help::JsonCode(Help::SUCCESS, '排序成功'); return Help::JsonCode(Help::SUCCESS, '排序失败'); } else { return Help::JsonCode(Help::SUCCESS, '排序失败'); } } public function actionGulfcitygldel() { $id = Yii::$app->request->post('id'); if (is_numeric($id)) { if (PushhouseType::findOne($id)->delete()) return Help::JsonCode(Help::SUCCESS, '删除成功'); return Help::JsonCode(Help::ERROR, '删除失败'); } else { return Help::JsonCode(Help::ERROR, '删除失败'); } } public function actionOfficezt() { return $this->render('officezt'); } //获取地区列表 public function actionOfficeztform() { $dataInfo = PushplaceType::find() ->where(['type' => 4]) ->orderBy(['sort' => SORT_DESC]) ->asArray()->all(); return help::JsonData(0, '成功', 0, $dataInfo); } public function actionOfficeztadd() { return $this->render('officeztadd'); } public function actionOfficeztaddform() { $input = Yii::$app->request->post('data'); $rows = PushplaceType::find(); if (!$rows->where(['type' => 4, 'title' => $input['title']])->exists()) { $query = new PushplaceType(); $query->title = $input['title']; $query->type = 4; if ($query->save()) return Help::JsonCode(Help::SUCCESS, '添加成功'); Help::JsonCode(Help::ERROR, '添加失败'); } else { return Help::JsonCode(Help::ERROR, '地区已存在'); } } public function actionOfficeztdel() { $id = Yii::$app->request->post('id'); $rows = PushplaceType::findOne($id); if ($rows->delete()) return Help::JsonCode(Help::SUCCESS, '删除成功'); Help::JsonCode(Help::ERROR, '删除失败'); } public function actionOfficeztedit() { $id = Yii::$app->request->get('id'); $data = PushplaceType::findOne($id); return $this->render('officeztedit', ['data' => $data]); } public function actionOfficezteditform() { $input = Yii::$app->request->post(); $rows = PushplaceType::findOne($input['id']); $rows->title = $input['title']; if ($rows->update(false)) return Help::JsonCode(Help::SUCCESS, '编辑成功'); Help::JsonCode(Help::ERROR, '编辑失败'); } public function actionOfficeztgl() { $id = Yii::$app->request->get('id'); return $this->render('officeztgl', ['id' => $id]); } public function actionOfficeztglform() { $previd = Yii::$app->request->get('previd'); $data = PushhouseType::find() ->select('pfg_pushhouse_type.*,pfg_pushplace_type.title,pfg_house.name,') ->where(['pfg_pushhouse_type.previd' => $previd, 'pfg_pushhouse_type.type' => 4]) ->leftJoin('pfg_house', 'pfg_house.id = pfg_pushhouse_type.hid') ->leftJoin('pfg_pushplace_type', 'pfg_pushplace_type.id = pfg_pushhouse_type.previd') ->orderBy(['pfg_pushhouse_type.sort' => SORT_DESC])->asArray()->all(); return help::JsonData(0, '成功', 0, $data); } public function actionOfficeztgladd() { $id = Yii::$app->request->get('id'); return $this->render('officeztgladd', ['id' => $id]); } public function actionOfficeztgladdform() { $input = Yii::$app->request->post('data'); $row = PushhouseType::find(); if (!$row->where(['previd' => $input['previd'], 'type' => 4, 'hid' => $input['hid']])->exists()) { $query = new PushhouseType(); $query->hid = $input['hid']; $query->previd = $input['previd']; $query->type = 4; if ($query->save()) return Help::JsonCode(Help::SUCCESS, '添加成功'); Help::JsonCode(Help::ERROR, '添加失败'); } else { Help::JsonCode(Help::ERROR, '楼盘已存在'); } } public function actionHainanvilledel() { $id = Yii::$app->request->post('id'); if (is_numeric($id)) { if (PushplaceType::findOne($id)->delete()) return Help::JsonCode(Help::SUCCESS, '删除成功'); return Help::JsonCode(Help::ERROR, '删除失败'); } else { return Help::JsonCode(Help::ERROR, '删除失败'); } } public function actionHainanvilleedit() { $id = Yii::$app->request->get('id'); $data = PushplaceType::findOne($id); return $this->render('hainanvilleedit', ['data' => $data]); } }