request->get('page'); $limit = $this->request->get('limit'); if (!$page) { $pages = '0,10'; } else { $page = $page - 1; if ($page<0) $page = 0; $pages = $page.','.$limit; } $proposalModel = new ProposalModel(); $data = $proposalModel->where('switch',1) ->limit($pages) ->order('sort desc') ->select(); if ($data) { return $this->success('',$data); } else { return $this->success('',[]); } } /** * 报修与建议详情 * @param string $id id */ public function proposalInfo() { $id = $this->request->get('id'); $proposalModel = new ProposalModel(); $data = $proposalModel ->where('id',$id) ->find(); if ($data) { return $this->success('', $data); } else { return $this->success('暂无数据'); } } /** * 保修与建议提交 * @ApiMethod (POST) * @param string $tid 报修id * @param string $images 配图多图,号拼接 * @param string $str 文字 */ public function proposalSub() { $data = $this->request->post(); if (!isset($data['tid']) || empty($data['tid'])) return $this->error('请选择所报修内容'); if (!isset($data['images'])) return $this->error('参数错误'); if (!isset($data['str'])) return $this->error('参数错误'); if (empty($data['images']) && empty($data['str'])) return $this->error('文字和图片最少输入一样'); $user = $this->auth->getUser(); if (!$user) return $this->error(__('Please login first'), null, 401); $data['uid'] = $user['id']; $data['create_time'] = date('Y-m-d H:i:s'); $add = Db::name('proposal_info')->insert($data); if ($add) { return $this->success('提交成功'); } else { return $this->error('提交失败'); } } /** * 报修反馈 * @ApiMethod (POST) * @param string $notice 文字 */ public function fankui() { $notice = $this->request->post('notice'); if (!isset($notice) || empty($notice)) return $this->error('请输入要提交的内容'); $user = $this->auth->getUser(); if (!$user) return $this->error(__('Please login first'), null, 401); $data['uid'] = $user['id']; $data['create_time'] = date('Y-m-d H:i:s'); $data['notice'] = $notice; $isert = Db::name('proposal_fankui')->where('uid',$user['id'])->where('notice',$data['notice'])->find(); if ($isert) return $this->error('您已经反馈过了'); $add = Db::name('proposal_fankui')->insert($data); if ($add) { return $this->success('提交成功'); } else { return $this->error('提交失败'); } } }