request->param(); $page = empty($param['page']) ? 1 : $param['page']; $size = empty($param['size']) ? 10 : $param['size']; //搜索条件 $where = [ ['is_show','=',1] ]; if (!empty($param['keyword'])) { $where[] = ['title', 'like', "%{$param['keyword']}%"]; } $list = BusinessModel::where($where)->page($page, $size)->select(); //数据处理 if (!$list->isEmpty()) { foreach ($list as $v) { $v['main_image'] = cmf_get_image_preview_url($v['main_image']); } } $this->success('成功', $list); } /** * 详情 */ public function detail() { $id = $this->request->post('id'); $info = BusinessModel::get($id); //信息处理 if (!empty($info['main_image'])) { $info['main_image'] = cmf_get_image_preview_url($info['main_image']); } if (!empty($info['tags'])) { $info['tags'] = json_decode($info['tags'], true); } else { $info['tags'] = []; } $this->success('成功', $info); } /** * 参加活动 */ public function join() { $user_id = $this->getUserId(); $user = UserModel::get($user_id); if (empty($user['user_name']) || empty($user['mobile'])) { $this->success('', ['code' => 1001, 'msg' => '请完善信息']); } $param = $this->request->post(); $param['user_id'] = $user_id; $param['create_time'] = time(); BusinessJoinModel::create($param); $this->success('提交成功'); } }