From 6d2c12c3df928dec24bc971ddab335b3426888f4 Mon Sep 17 00:00:00 2001 From: que01 Date: Wed, 23 Sep 2026 09:45:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=92=A8=E8=AF=A2=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/src/main.ts | 19 ++++++++++++++++++- .../modules/inquiry-form/inquiry-form.js | 8 ++++++++ .../modules/inquiry-form/inquiry-form.wxml | 2 +- .../modules/inquiry-form/inquiry-form.wxss | 2 +- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 315273a..5252309 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -282,7 +282,24 @@ export class PublicWorkspaceController { ].includes(String(value.type)) ? (value.type as RuntimeInquiryField["type"]) : "text"; - return [{ key: value.key, label: value.label, type, required: value.required === true }]; + const options = Array.isArray(value.options) + ? value.options.flatMap((option) => { + if (!option || typeof option !== "object") return []; + const item = option as Record; + return typeof item.label === "string" && typeof item.value === "string" + ? [{ label: item.label, value: item.value }] + : []; + }) + : undefined; + return [ + { + key: value.key, + label: value.label, + type, + required: value.required === true, + ...(options?.length ? { options } : {}), + }, + ]; }); const inquiryForm = inquiryForms[0] ?? null; const runtimeWorkspace: RuntimeWorkspace = { diff --git a/apps/miniapp/components/modules/inquiry-form/inquiry-form.js b/apps/miniapp/components/modules/inquiry-form/inquiry-form.js index cd99bc2..425dab1 100644 --- a/apps/miniapp/components/modules/inquiry-form/inquiry-form.js +++ b/apps/miniapp/components/modules/inquiry-form/inquiry-form.js @@ -9,6 +9,14 @@ Component({ input(e) { this.triggerEvent("input", { key: e.currentTarget.dataset.key, value: e.detail.value }); }, + choose(e) { + const field = this.data.fields.find((item) => item.key === e.currentTarget.dataset.key); + const option = field?.options?.[e.detail.value]; + if (option) this.triggerEvent("input", { key: field.key, value: option.value }); + }, + dateChange(e) { + this.triggerEvent("input", { key: e.currentTarget.dataset.key, value: e.detail.value }); + }, submit() { this.triggerEvent("submit"); }, diff --git a/apps/miniapp/components/modules/inquiry-form/inquiry-form.wxml b/apps/miniapp/components/modules/inquiry-form/inquiry-form.wxml index 42990d9..c2551d2 100644 --- a/apps/miniapp/components/modules/inquiry-form/inquiry-form.wxml +++ b/apps/miniapp/components/modules/inquiry-form/inquiry-form.wxml @@ -1 +1 @@ -{{item.label}}信息仅用于本次方案沟通,我们不会向第三方披露。 +{{item.label}}{{item.required ? ' *' : ''}}