From 842cd5584e2b217bbd5c05400d14c76da0e6ab14 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Mon, 30 Oct 2023 11:05:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B4=BB=E5=8A=A8=E6=8A=A5?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/weliam_smartcity/api/Enroll.php | 13 ++++--- addons/weliam_smartcity/api/Student.php | 4 +-- .../core/class/FormTemplate.class.php | 36 +++++++++++++------ .../member/campusActivities.ctrl.php | 2 ++ .../member/campus_activities/edit.html | 11 ++++++ 5 files changed, 47 insertions(+), 19 deletions(-) diff --git a/addons/weliam_smartcity/api/Enroll.php b/addons/weliam_smartcity/api/Enroll.php index ac71888..966bc3f 100644 --- a/addons/weliam_smartcity/api/Enroll.php +++ b/addons/weliam_smartcity/api/Enroll.php @@ -12,19 +12,18 @@ class EnrollModuleUniapp extends Uniapp { global $_W, $_GPC; - $template_type = $_GPC['template_type'] ?: 1; + $diyformid = $_GPC['diyformid']; + if (empty($diyformid)) $this->renderError('模板id不能为空'); - $where = ['template_type' => $template_type, 'uniacid' => $_W['uniacid'], 'aid' => $_W['aid']]; + $where = ['id' => $diyformid, 'uniacid' => $_W['uniacid'], 'aid' => $_W['aid']]; - $diyFrom = pdo_getall(PDO_NAME . 'diyform' , $where , ['id','info'],'','create_time desc',1); + $diyFrom = pdo_get(PDO_NAME . 'diyform' , $where , ['id','info'],'','create_time desc',1); if (!$diyFrom) $this->renderError('未设置报名表单'); - $diyFromInfo = json_decode(base64_decode($diyFrom[0]['info']) , true); + $diyFromInfo = json_decode(base64_decode($diyFrom['info']) , true); $data = [ - 'diyform' => $diyFromInfo, //页面的配置信息 - 'template_type' => $template_type, - 'diyformid' => $diyFrom[0]['id'] + 'diyform' => $diyFromInfo //页面的配置信息 ]; $this->renderSuccess('数据返回成功',$data); diff --git a/addons/weliam_smartcity/api/Student.php b/addons/weliam_smartcity/api/Student.php index 2706909..19a35a8 100644 --- a/addons/weliam_smartcity/api/Student.php +++ b/addons/weliam_smartcity/api/Student.php @@ -201,7 +201,7 @@ class StudentModuleUniapp extends Uniapp $id = $_GPC['id']; if (empty($id)) $this->renderError('请求失败'); - $fields = ['id','title','describe','promotional_img','publish_time','create_place','create_user_id']; + $fields = ['id','title','describe','promotional_img','publish_time','create_place','create_user_id','diyformid']; $data = pdo_get(PDO_NAME . 'member_campus_activities',['id' => $id],$fields); #发布人 $data['nickname'] = '小粤'; @@ -226,7 +226,7 @@ class StudentModuleUniapp extends Uniapp $data['is_collect'] = $is_collect ? true : false; // 是否收藏 $data['publish_time'] = date("Y-m-d H:i:s",$data['publish_time']); - $enrollInfo = FormTemplate::isEnroll('member_campus_activities',$id); + $enrollInfo = FormTemplate::isEnroll(1,$id); $data['is_enroll'] = $enrollInfo ? $enrollInfo['id'] : 0; unset($data['create_place'],$data['create_user_id']); diff --git a/addons/weliam_smartcity/core/class/FormTemplate.class.php b/addons/weliam_smartcity/core/class/FormTemplate.class.php index e39b3ec..d9a760b 100644 --- a/addons/weliam_smartcity/core/class/FormTemplate.class.php +++ b/addons/weliam_smartcity/core/class/FormTemplate.class.php @@ -19,8 +19,8 @@ class FormTemplate */ public static $template_relation = [ 1 => 'member_campus_activities', - 2 => '', - 3 => '' + 2 => 'rush_activity', + 3 => 'headline_content' ]; /** @@ -45,14 +45,13 @@ class FormTemplate /** * 是否已报名 - * @param $relation + * @param $template_type * @param $activities_id * @return array|false|mixed */ - public static function isEnroll($relation,$activities_id) + public static function isEnroll($template_type,$activities_id) { - $template_type = array_search($relation,self::$template_relation); - if ($template_type === false) return []; + #$template_type = self::$template_relation[$template_type]; $where = [ 'template_type' => $template_type, @@ -65,15 +64,32 @@ class FormTemplate /** * 返回模板信息 * @param $id - * @param $template_type * @return array|false|mixed */ - public static function getDiyFormData($id,$template_type = 1) + public static function getDiyFormData($id) { - $res = pdo_get(PDO_NAME . 'diyform',['id' => $id,'template_type' => $template_type]); - return $res ? : []; + $res = pdo_get(PDO_NAME . 'diyform', ['id' => $id]); + return $res ?: []; } + /** + * 获取所有自定义表单 + * @param $_W + * @param $dataWhere + * @param $order + * @return array|false|mixed + */ + public static function getAllDiyFormList($_W,$dataWhere = [],$order = 'create_time DESC,id DESC') + { + //自定义表单 + $formWhere = ['uniacid'=>$_W['uniacid'],'aid'=>$_W['aid']]; + if(is_store()) $formWhere['sid'] = $_W['storeid']; + if (!empty($dataWhere['id'])) $formWhere['id'] = $dataWhere['id']; + + $diyform = pdo_getall(PDO_NAME."diyform",$formWhere,['id','title'],'',$order); + + return $diyform ?: []; + } /** * 加密 diff --git a/addons/weliam_smartcity/sys/controller/member/campusActivities.ctrl.php b/addons/weliam_smartcity/sys/controller/member/campusActivities.ctrl.php index 7030a14..a12bd61 100644 --- a/addons/weliam_smartcity/sys/controller/member/campusActivities.ctrl.php +++ b/addons/weliam_smartcity/sys/controller/member/campusActivities.ctrl.php @@ -58,6 +58,7 @@ class campusActivities_WeliamController { $data['recommend'] = $data['recommend'] ?: 0; $data['promotional_img'] = MemberCampusActivities::promotionalImgStr($data['promotional_img']); $data['describe'] = htmlspecialchars_decode($data['describe']); + $data['diyformid'] = $data['diyformid'] ?: 0; $where = ['title' => $data['title']]; if ($id) $where['id!='] = $id; @@ -85,6 +86,7 @@ class campusActivities_WeliamController { } $category = Category::getChildCategoryAll(6,'*',true); + $diyform = FormTemplate::getAllDiyFormList($_W); include wl_template('member/campus_activities/edit'); } diff --git a/addons/weliam_smartcity/sys/view/default/member/campus_activities/edit.html b/addons/weliam_smartcity/sys/view/default/member/campus_activities/edit.html index 66c0087..b77ac02 100644 --- a/addons/weliam_smartcity/sys/view/default/member/campus_activities/edit.html +++ b/addons/weliam_smartcity/sys/view/default/member/campus_activities/edit.html @@ -49,6 +49,17 @@ +
+ +
+ +
+