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', ]; // 获取用户信息 $this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select(); } /** * 数据列表 */ public function index() { if (request()->isAjax()) { $params= get_params(); $where['status']=1; 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)->order('community_id desc')->select(); }else{ $list2=[]; } $result = ['total' => $total, 'data' => $list2]; return table_assign(0, '', $result); } else{ return view('nk/community/index',['url'=>$this->url]); } } public function edit(){ $param = get_params(); if (request()->isAjax()) { $is_show = $param['status'] == 1 ? 1 : 0; $data = [ 'refusal' => $param['refusal'], 'status' => $param['status'], 'is_show' => $is_show, ]; $res = Db::connect('shop')->name('community') ->where('community_id', $param['id']) ->strict(false) ->update($data); if ($res){ return to_assign(0, '操作成功'); }else{ return to_assign(1, '操作失败,原因:'.$res); } }else{ $id = isset($param['id']) ? $param['id'] : 0; $detail = Db::connect('shop')->name('community')->where('community_id',$id)->find(); View::assign('editor', get_system_config('other','editor')); if (!empty($detail)) { View::assign('detail', $detail); View::assign('users', $this->users); return view(); } else{ throw new \think\exception\HttpException(404, '找不到页面'); } } } /** * 查看信息 */ 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); } } }