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 ? ' *' : ''}}