From 7b593aea1f4a0085b9a448c41f0f2276a40383df Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 6 Feb 2023 14:35:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/nk/Community.php | 121 ++++++++++++++++++++++ app/admin/controller/nk/RuralWelfare.php | 83 +++++++++++++++ app/admin/view/nk/community/index.html | 122 +++++++++++++++++++++++ app/admin/view/nk/community/read.html | 29 ++++++ 4 files changed, 355 insertions(+) create mode 100644 app/admin/controller/nk/Community.php create mode 100644 app/admin/controller/nk/RuralWelfare.php create mode 100644 app/admin/view/nk/community/index.html create mode 100644 app/admin/view/nk/community/read.html diff --git a/app/admin/controller/nk/Community.php b/app/admin/controller/nk/Community.php new file mode 100644 index 0000000..6f4b190 --- /dev/null +++ b/app/admin/controller/nk/Community.php @@ -0,0 +1,121 @@ +adminInfo = get_login_admin(); + $this->url=[ + '/admin/nk.community/index', + '/admin/nk.community/add', + '/admin/nk.community/edit', + '/admin/nk.community/del', + '/admin/nk.community/read', + ]; + } + /** + * 数据列表 + */ + public function index() + { + if (request()->isAjax()) { + $params= get_params(); + $where['status']=1; + $where = []; + if (isset($params['keywords'])){ +// $where[]=['title','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if ($user_address['auth_range'] == 2){ + $where['street_id'] = $user_address['street_id']; + }elseif ($user_address['auth_range'] == 3){ + $where['area_id'] = $user_address['area_id']; + }else{ + $where['village_id'] = $user_address['village_id']; + } + }else{ + $where['village_id'] = ''; + } + } + + $total = Db::connect('shop')->name('community_address') + ->where($where) + ->count(); + if ($total!=0){ + $list = Db::connect('shop')->name('community_address') + ->where($where) + ->page($params['page']) + ->limit($params['limit']) + ->select(); + $arr=[]; + foreach ($list as $k=>$v){ + $arr[]=$v['community_id']; + } + $list2=Db::connect('shop')->name('community')->where('community_id','in',$arr)->select(); + }else{ + $list2=[]; + } + + $result = ['total' => $total, 'data' => $list2]; + return table_assign(0, '', $result); + } + else{ + return view('nk/community/index',['url'=>$this->url]); + } + } + + + /** + * 查看信息 + */ + public function read() + { + $param= get_params(); + $id = isset($param['id']) ? $param['id'] : 0; + $detail = Db::connect('shop')->name('community')->where('community_id',$id)->find(); + if (!empty($detail)) { + View::assign('detail', $detail); + return view(); + } + else{ + throw new \think\exception\HttpException(404, '找不到页面'); + } + } + /** + * 删除 + */ + public function del() + { + $param= get_params(); + $id = isset($param['id']) ? $param['id'] : 0; + $res = Db::connect('shop')->name('community')->where('community_id',$id)->delete(); + Db::connect('shop')->name('community_address')->where('community_id',$id)->delete(); + if ($res){ + return to_assign(); + }else{ + return to_assign(1, '操作失败,原因:'.$res); + } + } + + +} diff --git a/app/admin/controller/nk/RuralWelfare.php b/app/admin/controller/nk/RuralWelfare.php new file mode 100644 index 0000000..711ab66 --- /dev/null +++ b/app/admin/controller/nk/RuralWelfare.php @@ -0,0 +1,83 @@ +adminInfo = get_login_admin(); + $this->category_id=352; + $this->url=[ + '/admin/nk.ruralwelfare/index?category_id='.$this->category_id, + '/admin/nk.ruralwelfare/add', + '/admin/nk.ruralwelfare/edit', + '/admin/nk.ruralwelfare/del', + '/admin/nk.ruralwelfare/read', + ]; + } + /** + * 查看 + */ + public function index() + { + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + (new Article())->index($params); + } + return view('nk/article/index',['url'=>$this->url]); + } + /** + * 添加 + */ + public function add() + { + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + (new Article())->add($params); + }else{ + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + return view('nk/article/add'); + } + } + /** + * 修改 + */ + public function edit() + { + $params= get_params(); + (new Article())->edit($params); + return view('nk/article/edit',['url'=>$this->url]); + } + /** + * 查看信息 + */ + public function read() + { + $params = get_params(); + (new Article())->read($params); + + return view('nk/article/read',['url'=>$this->url]); + + } + /** + * 修改 + */ + public function del() + { + $params= get_params(); + (new Article())->del($params); + } +} \ No newline at end of file diff --git a/app/admin/view/nk/community/index.html b/app/admin/view/nk/community/index.html new file mode 100644 index 0000000..2b9c2e6 --- /dev/null +++ b/app/admin/view/nk/community/index.html @@ -0,0 +1,122 @@ +{extend name="common/base"/} + +{block name="body"} + +
标题* | +{$detail.title} | +||||||
内容 | +|||||||
+ {$detail.content|raw} + | +