render('housetype'); } /* * 户型获取数据 * */ public function actionHousetypeform() { $model = new HouseType(); $row = $model->getList(Yii::$app->request->post()); if ($row != null) { foreach ($row as &$val) { $val['create_at'] = date('Y-m-d H:i', $val['create_at']); $val['update_at'] = date('Y-m-d H:i', $val['update_at']); } return Help::JsonData(0, '成功', $model->Total(), $row); } } /* * 添加户型页面 * */ public function actionHousetypeadd() { return $this->render('housetypeadd'); } /* * 添加户型数据 * */ public function actionHousetypeaddform() { $model = new HouseType(); $model->load(Yii::$app->request->post('data'), ''); if (!$model->validate()) return Help::JsonCode(Help::ERROR, '添加失败', $model->errors); if ($model->save() == true) return Help::JsonCode(Help::SUCCESS, '添加成功'); return Help::JsonCode(Help::ERROR, '添加失败'); } /* * 修改户型界面 * */ public function actionHousetypeedit() { $model = new HouseType(); $model->id = Yii::$app->request->get('id'); $row = $model->getOne(); if ($row != null) { return $this->render('housetypeedit', ['model' => $row]); } } /* * 修改户型数据 * */ public function actionHousetypeeditform() { $model = new HouseType(); $model->load(Yii::$app->request->post('data'), ''); if (!$model->validate()) return Help::JsonCode(Help::SUCCESS, '修改失败', $model->errors); $row = $model->FindById(Yii::$app->request->post('data')['id']); if ($row != null) { $row->huxing_name = $model->huxing_name; $row->sort = $model->sort; $row->state = $model->state; if ($row->save() == true) return Help::JsonCode(Help::SUCCESS, '修改成功'); } return Help::JsonCode(Help::ERROR, '修改失败'); } /* * 删除户型 * */ public function actionHosttypedel() { $model = new HouseType(); $row = $model->FindById(Yii::$app->request->post('id')); if ($row != null) { $row->del = 2; if ($row->update() == true) return Help::JsonCode(Help::SUCCESS, '删除成功'); } return Help::JsonCode(Help::ERROR, '删除失败'); } /* * 户型审核上架 * */ public function actionHousetypestate() { $input = Yii::$app->request->post(); $query = CategoryHousetype::findOne($input['id']); if ($query != null) { if ($query->state == 1) { $query->state = 2; $msg = '下架成功'; } else { $query->state = 1; $msg = '上架成功'; } if ($query->update() == true) return Help::JsonCode(Help::SUCCESS, $msg); } return Help::JsonCode(Help::ERROR, $msg); } /* * 户型排序 * */ public function actionHousetypesort() { $input = Yii::$app->request->post(); $query = CategoryHousetype::findOne($input['id']); if ($query != null) { if (!is_numeric($input['sort'])) { return Help::JsonCode(Help::ERROR, '请输入数字'); } $query->sort = $input['sort']; if ($query->update() == true) return Help::JsonCode(Help::SUCCESS, '排序成功'); } return Help::JsonCode(Help::ERROR, '排序失败'); } // ===================================资讯=========================================== /* * 资讯列表显示页面 * */ public function actionNews() { return $this->render('news'); } /* * 资讯列表数据 * */ public function actionNewsform() { $model = new CategoryNews(); $rows = $model->getList(Yii::$app->request->post()); if ($rows != null) { $imgUrl = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['newsthumb']; foreach ($rows as &$val) { $val['create_at'] = date('Y-m-d H:i', $val['create_at']); $val['update_at'] = date('Y-m-d H:i', $val['update_at']); // $val['recommend'] = Yii::$app->params['RecommendedState'][$val['recommend']]; $val['img'] = $imgUrl . $val['img']; } return Help::JsonData(0, '成功', $model->Total(), $rows); } } /* * 添加资讯页面 * */ public function actionNewsadd() { return $this->render('newsadd'); } /* * 添加资讯分类数据 * */ public function actionNewsaddform() { $model = new CategoryNews(); $model->load(Yii::$app->request->post(), ''); if ($model) { if (!$model->validate()) return Help::JsonCode(Help::ERROR, '添加失败', $model->errors); $url = Yii::$app->params['img_url']['news']; $img = UploadFile::InstanceImgName('img', $url); if (is_string($img)) { $model->img = $img; } if ($model->insert() == true) return Help::JsonCode(Help::SUCCESS, '添加成功'); } return Help::JsonCode(Help::Error, '添加失败'); } /* * 资讯修改页面 * */ public function actionNewsedit() { $model = new CategoryNews(); $row = $model->FindById(Yii::$app->request->get('id')); if ($row != null) { $imgUrl = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['newsthumb']; $row['img'] = $imgUrl . $row['img']; return $this->render('newsedit', ['model' => $row]); } } /* * 资讯修改数据 * */ public function actionNewseditform() { $model = new CategoryNews(); $model->load(Yii::$app->request->post(), ''); if (!$model->validate()) return Help::JsonCode(Help::ERROR, '修改失败', $model->errors); $row = $model->FindById(Yii::$app->request->post('id')); if ($row != null) { $row->setAttributes($model->attributes); $url = Yii::$app->params['img_url']['news']; $img = UploadFile::InstanceImgName('img', $url); if (is_string($img)) { UploadFile::delImg($url, $row->img); $row->img = $img; } if ($row->update() == true) return Help::JsonCode(Help::SUCCESS, '修改成功'); } return Help::JsonCode(Help::ERROR, '修改失败'); } /* * 资讯删除 * */ public function actionNewsdel() { $model = new CategoryNews(); $row = $model->FindById(Yii::$app->request->post('id')); if ($row != null) { $row->del = 2; if ($row->update() == true) return Help::JsonCode(Help::SUCCESS, '删除成功'); } return Help::JsonCode(Help::ERROR, '删除失败'); } //资讯审核 public function actionNewsstate() { $model = new CategoryNews(); $row = $model->FindById(Yii::$app->request->post('id')); if ($row != null) { if ($row->state == 1) { $row->state = 2; } else { $row->state = 1; } if ($row->update(false) == true) return Help::JsonCode(Help::SUCCESS, '审核成功'); } return Help::JsonCode(Help::ERROR, '审核失败'); } /* * 2020.6.24 lyy 资讯设置排序 * */ public function actionNewssetsort() { $model = new CategoryNews(); $row = $model->FindById(Yii::$app->request->post('id')); if ($row != null) { $row->sort = Yii::$app->request->post('sort'); if ($row->update(false) == true) return Help::JsonCode(Help::SUCCESS, '设置成功'); } return Help::JsonCode(Help::ERROR, '设置失败'); } // ===================================相册=========================================== /* * 相册分类显示页面 * */ public function actionPhotoalbum() { return $this->render('photoalbum'); } /* * 相册分类数据 * */ public function actionPhotoalbumform() { $model = new CategoryAlbum(); $rows = $model->getList(Yii::$app->request->post()); if ($rows != null) { foreach ($rows as &$val) { $val['create_at'] = date('Y-m-d H:i', $val['create_at']); $val['update_at'] = date('Y-m-d H:i', $val['update_at']); } return Help::JsonData(0, '成功', $model->Total(), $rows); } return Help::JsonCode(Help::ERROR, '暂无数据'); } /* * 添加相册分类页面 * */ public function actionPhotoalbumadd() { return $this->render('photoalbumadd'); } /* * 添加相册分类数据 * */ public function actionPhotoalbumaddform() { $model = new CategoryAlbum(); $model->load(Yii::$app->request->post('data'), ''); if (!$model->validate()) return Help::JsonCode(Help::ERROR, '添加失败', $model->errors); if ($model->insert() == true) return Help::JsonCode(Help::SUCCESS, '添加成功'); return Help::JsonCode(Help::ERROR, '添加失败'); } /* * 修改相册分类页面 * */ public function actionPhotoalbumedit() { $model = new CategoryAlbum(); $row = $model->FindById(Yii::$app->request->get('id')); if ($row != null) { return $this->render('photoalbumedit', ['model' => $row]); } } /* *修改相册分类数据 * */ public function actionPhotoalbumeditform() { $model = new CategoryAlbum(); $model->load(Yii::$app->request->post('data'), ''); if (!$model->validate()) return Help::JsonCode(Help::ERROR, '修改失败', $model->errors); $row = $model->FindById(Yii::$app->request->post('data')['id']); $row->name = $model->name; if ($row->update() == true) return Help::JsonCode(Help::SUCCESS, '修改成功'); return Help::JsonCode(Help::ERROR, '修改失败'); } /* * 删除相册分类 * */ public function actionPhotoalbumdel() { $model = new CategoryAlbum(); $input = Yii::$app->request->post(); $row = $model->FindById(Yii::$app->request->post('id')); if ($row != null) { switch ($input['type']) { case 'del': $row->del = 2; $msg = '删除成功'; break; case 'is_show': $row->is_show = $input['is_show']; if ($input['is_show'] == 2) { $msg = '下架成功'; } else { $msg = '上架成功'; } break; case 'sort': $row->sort = intval($input['sort']); $msg = '排序成功'; break; } if ($row->save() == true) return Help::JsonCode(Help::SUCCESS, Yii::t('app', $msg)); } return Help::JsonCode(Help::ERROR, Yii::t('app', '操作失败')); } // ===================================周边配套=========================================== /* * 周边配套列表显示页面 * */ public function actionFacilities() { return $this->render('facilities'); } /* * 周边配套列表数据 * */ public function actionFacilitiesform() { $model = new CategoryFacilities(); $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); } } /* * 周边配套数据添加页面 * */ public function actionFacilitiesadd() { return $this->render('facilitiesadd'); } /* * 周边配套数据添加 * */ public function actionFacilitiesaddform() { $model = new CategoryFacilities(); $model->scenario = 'add'; $row = $model->Authenticator(Yii::$app->request->post()); if (is_array($row)) return Help::JsonCode(Help::ERROR, '添加失败', $row); $url = Yii::$app->params['img_url']['facilities']; $img = \backend\server\UploadFile::InstanceImgName('img', $url); $imga = \backend\server\UploadFile::InstanceImgName('mobile_img', $url); $imgb = \backend\server\UploadFile::InstanceImgName('map_img', $url); if ($img != false) $row->img = $img; if ($imga != false) $row->mobile_img = $imga; if ($imgb != false) $row->map_img = $imgb; if ($row->insert() == true) return Help::JsonCode(Help::SUCCESS, '添加成功', $row); } /* * 周边配套修改页面 * */ public function actionFacilitiessave() { $model = new CategoryFacilities(); $row = $model->FindById(Yii::$app->request->get('id')); if ($row != null) { if (!empty($row['img'])) { $row['img'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['facilities'] . $row['img']; } if (!empty($row['mobile_img'])) { $row['mobile_img'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['facilities'] . $row['mobile_img']; } if (!empty($row['map_img'])) { $row['map_img'] = Yii::$app->params['httpImg']['host'] . Yii::$app->params['httpImg']['facilities'] . $row['map_img']; } return $this->render('facilitiessave', ['model' => $row]); } } /* * 周边配套修改数据 * */ public function actionFacilitiessaveform() { $model = new CategoryFacilities(); $input = Yii::$app->request->post(); $check = $model->Authenticator($input); if (is_array($check)) return Help::JsonCode(Help::ERROR, '操作失败', $check); $row = $model->FindById($input['id']); if ($row != null) { $url = Yii::$app->params['img_url']['facilities']; $img = \backend\server\UploadFile::InstanceImgName('img', $url); $imga = \backend\server\UploadFile::InstanceImgName('mobile_img', $url); $imgb = \backend\server\UploadFile::InstanceImgName('map_img', $url); if ($img != false) { \backend\server\UploadFile::delImg($url, $row->img); $row->img = $img; } if ($imga != false) { \backend\server\UploadFile::delImg($url, $row->mobile_img); $row->mobile_img = $imga; } if ($imgb != false) { \backend\server\UploadFile::delImg($url, $row->map_img); $row->map_img = $imgb; } $save = Help::SetAttr($input, $check, $row); if ($save->save() == true) return Help::JsonCode(Help::SUCCESS, '操作成功'); } } /* * 周边配套删除数据 * */ public function actionFacilitiesdel() { $model = new CategoryFacilities(); $row = $model->FindById(Yii::$app->request->post('id')); if ($row != null) { // $url = Yii::$app->params['img_url']['facilities']; // \backend\server\UploadFile::delImg($url,$row->img); // \backend\server\UploadFile::delImg($url,$row->mobile_img); // \backend\server\UploadFile::delImg($url,$row->map_img); $row->del = 2; if ($row->save(false)) return Help::JsonCode(Help::SUCCESS, '操作成功'); } return Help::JsonCode(Help::ERROR, '操作失败'); } /* * 周边配套审核上架 * */ public function actionFacilitiesstate() { $model = new CategoryFacilities(); $input = Yii::$app->request->post(); $query = $model->FindById($input['id']); if ($query != null) { if ($query->is_show == 1) { $query->is_show = 2; $msg = '下架成功'; } else { $query->is_show = 1; $msg = '上架成功'; } if ($query->update() == true) return Help::JsonCode(Help::SUCCESS, $msg); } return Help::JsonCode(Help::ERROR, $msg); } /* * 周边配套 * */ public function actionFacilitiessort() { $input = Yii::$app->request->post(); $query = CategoryFacilities::findOne($input['id']); if ($query != null) { if (!is_numeric($input['sort'])) { return Help::JsonCode(Help::ERROR, '请输入数字'); } $query->sort = $input['sort']; if ($query->update() == true) return Help::JsonCode(Help::SUCCESS, '排序成功'); } return Help::JsonCode(Help::ERROR, '排序失败'); } }