where('switch', 1) ->order('sort desc') ->select(); foreach ($data as &$v) { $v['image'] = config('site.httpurl') . $v['image']; } return $this->success('', $data); } /** * 政策分类 */ public function type() { $data = Db::name('policy_type')->where('switch',1)->order('sort desc')->select(); return $this->success('',$data); } /** * 政策集锦列表 * @param string $page 页数 * @param string $limit 条数 * @param string $type 分类id */ public function lists() { $page = $this->request->get('page'); $limit = $this->request->get('limit'); $type = $this->request->get('type'); if (!isset($type) || empty($type)) return $this->error('请选择分类'); if (!$page) { $pages = '0,10'; } else { $page = $page - 1; if ($page < 0) $page = 0; $pages = $page . ',' . $limit; } $policyMdoel = new PolicyModel(); $data = $policyMdoel->where('switch', 1) ->where('t_id',$type) ->order('sort desc') ->limit($pages) ->select(); return $this->success('', $data); } /** * 政策集锦详情 * @param string $id id * */ public function listInfo() { $id = $this->request->get('id'); if (!isset($id) || empty($id)) return $this->error('缺少参数'); $policyMdoel = new PolicyModel(); $data = $policyMdoel ->where('id', $id) ->where('switch', 1) ->order('sort desc') ->find(); return $this->success('', $data); } /** * 政策入住申请 * @ApiMethod (POST) * @param string $lid id * @param string $name id * @param string $mobile id * @param string $notice id * */ public function ruzhu() { $data = $this->request->post(); if (!isset($data['lid']) || empty($data['lid'])) return $this->error('参数错误'); if (!isset($data['name']) || empty($data['name'])) return $this->error('请输入姓名'); if (!isset($data['mobile']) || empty($data['mobile'])) return $this->error('请输入手机号'); if (!isset($data['notice']) || empty($data['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',time()); $isert = Db::name('policy_ruzhu')->where('uid',$user['id'])->where('lid',$data['lid'])->find(); if ($isert) return $this->error('您已经申请过了'); $add = Db::name('policy_ruzhu')->insert($data); if ($add ) { $id = Db::name('policy_ruzhu')->getLastInsID(); $data['id'] = $id; return $this->success('提交成功',$data); } else { return $this->error('提交失败'); } } /** * 入住返回数据 * @param string $id 注册返回的id */ public function ruzhuInfo() { $data = $this->request->param(); if (!isset($data['id']) || empty($data['id'])) return $this->error('参数错误'); $res = Db::name('policy_ruzhu')->where('id',$data['id'])->find(); return $this->success('',$res); } }