model = new \app\api\model\wanlshop\Complaint; } /** * 投诉举报列表 */ public function lists() { //设置过滤方法 $this->request->filter(['strip_tags']); $list = $this->model ->where('user_id', $this->auth->id) ->order('createtime desc') ->paginate(); foreach ($list as $row) { // 举报类型:0=用户举报,1=商品举报,2=店铺举报,3=拼团举报 if($row['type'] === '1'){ $row->goods ? $row->goods->visible(['id','title','image','price']) : []; } if($row['type'] === '3'){ $row->groups ? $row->groups->visible(['id','title','image','price']) : []; } } $this->success('ok',$list); } /** * 举报新增、读取 */ public function add() { //设置过滤方法 $this->request->filter(['strip_tags']); if ($this->request->isPost()) { $params = $this->request->post(); $params['user_id'] = $this->auth->id; $data = $this->model->allowField(true)->save($params); $data? $this->success('ok',$data) : $this->error(__('服务器繁忙')); } $list = $this->model ->where('user_id', $this->auth->id) ->order('createtime desc') ->paginate(); $this->success('ok',$list); } }