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; 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); } } }