$template_type, 'uniacid' => $_W['uniacid'], 'aid' => $_W['aid']]; $diyFrom = pdo_getall(PDO_NAME . 'diyform' , $where , ['id','info'],'','create_time desc',1); if (!$diyFrom) $this->renderError('未设置报名表单'); $diyFromInfo = json_decode(base64_decode($diyFrom[0]['info']) , true); $data = [ 'diyform' => $diyFromInfo, //页面的配置信息 'template_type' => $template_type, 'diyformid' => $diyFrom[0]['id'] ]; $this->renderSuccess('数据返回成功',$data); } /** * 保存填写模板数据 */ public function saveDiyForm() { global $_W, $_GPC; try { $mid = $_W['mid']; $diyformid = $_GPC['diyformid']; $form_data = $_GPC['form_data']; $template_type = $_GPC['template_type']; $activities_id = $_GPC['activities_id']; if (empty($diyformid) || !is_numeric($diyformid)) throw new Exception('表单id不能为空'); if (empty($form_data)) throw new Exception('表单数据不能为空'); if (empty($template_type)) throw new Exception('模板类型不能为空'); if (!in_array($template_type,array_keys(FormTemplate::$template_type))) throw new Exception('模板类型数据错误'); if (empty($activities_id) || !is_numeric($activities_id)) throw new Exception('活动id不能为空'); $activitiesData = FormTemplate::getTemplateTableData($template_type,$activities_id); if (empty($activitiesData)) throw new Exception('该活动不存在'); $query = pdo_get(PDO_NAME . 'member_enroll',['template_type' => $template_type,'mid' => $mid,'activities_id' => $activities_id],'id'); if ($query) throw new Exception('已报名该活动'); $diyFormInfo = html_entity_decode($form_data); $diyFormInfo = base64_encode($diyFormInfo); $insert = [ 'uniacid' => $_W['uniacid'], 'mid' => $mid, 'diyformid' => $diyformid, 'form_data' => $diyFormInfo, 'template_type' => $template_type, 'activities_id' => $activities_id, 'create_time' => date("Y-m-d H:i:s",time()) ]; pdo_insert(PDO_NAME . 'member_enroll',$insert); $this->renderSuccess('报名成功'); } catch (Exception $e) { $this->renderError($e->getMessage()); } } /** * 取消报名 */ public function cancelEnroll() { global $_W, $_GPC; $mid = $_W['mid']; $enroll_id = $_GPC['enroll_id']; if (empty($enroll_id)) $this->renderError('enroll_id is null'); $query = pdo_get(PDO_NAME . 'member_enroll',['id' => $enroll_id, 'mid' => $mid]); if (!$query) $this->renderError('报名信息不存在'); pdo_delete(PDO_NAME . 'member_enroll',$enroll_id); $this->renderSuccess('已取消'); } /** * 报名列表 */ public function getUserEnrollList() { global $_W, $_GPC; $mid = $_W['mid']; } }