order('sort desc') ->select(); if ($data) { foreach ($data as &$v) { $v['image'] = config('site.httpurl') . $v['image']; } return $this->success('', $data); } else { return $this->success('暂无数据'); } } /** * 企业服务分类 */ public function type() { $data = Db::name('business_type') ->where('switch',1) ->order('sort desc') ->select(); if ($data) { foreach ($data as &$v) { $v['image'] = config('site.httpurl') . $v['image']; } return $this->success('', $data); } else { return $this->success('暂无数据'); } } /** * 企业服务列表 * @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 (!$page) { $pages = '0,10'; } else { $page = $page - 1; if ($page < 0) $page = 0; $pages = $page . ',' . $limit; } $businessModel = new BusinessModel(); $data = $businessModel->where('switch', 1) ->where('type_id',$type) ->order('sort desc') ->limit($pages) ->select(); if ($data) { return $this->success('', $data); } else { return $this->success('暂无数据'); } } /** * 企业服务详情 * @param string $id id * */ public function listInfo() { $id = $this->request->get('id'); if (!isset($id) || empty($id)) return $this->error('缺少参数'); $businessModel = new BusinessModel(); $data = $businessModel ->where('id', $id) ->where('switch', 1) ->order('sort desc') ->find(); if ($data) { return $this->success('', $data); } else { return $this->success('暂无数据'); } } /** * 政策入住申请 * @ApiMethod (POST) * @param string $lid id * @param string $name id * @param string $mobile id * @param string $notice id * */ public function declare() { $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('business_declare')->where('uid',$user['id'])->where('lid',$data['lid'])->find(); if ($isert) return $this->error('您已经申请过了'); $add = Db::name('business_declare')->insert($data); if ($add ) { $id = Db::name('business_declare')->getLastInsID(); $data['id'] = $id; return $this->success('提交成功',$data); } else { return $this->error('提交失败'); } } /** * 申报返回数据 * @param string $id 注册返回的id */ public function shenbaoInfo() { $data = $this->request->param(); if (!isset($data['id']) || empty($data['id'])) return $this->error('参数错误'); $res = Db::name('business_declare')->where('id',$data['id'])->find(); return $this->success('',$res); } }