feat: 让咨询页适配报价能力语义

This commit is contained in:
que01 committed 2026-09-23 09:17:37 +08:00
1 parent 52f741cc2c
commit 16b0967dc5
7 files changed
+76 -11

No files matched your search

+55 -5
View File
@@ -1,8 +1,58 @@
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
Page({
data: { offering: null, submitting: false, values: { name: "", phone: "", city: "", doorType: "", note: "" }, fields: [{ key: "name", label: "联系人", placeholder: "请输入称呼" }, { key: "phone", label: "手机号码", placeholder: "请输入手机号" }, { key: "city", label: "项目所在城市", placeholder: "例如:上海 · 佘山" }, { key: "doorType", label: "希望定制的门类型", placeholder: "入户门 / 庭院门 / 室内门" }, { key: "note", label: "补充说明", placeholder: "告诉我们你的空间和需求" }] },
onLoad(options) { loadWorkspaceWithFallback().then((workspace) => { const offering = (workspace.offerings || []).find((item) => item.id === options.offeringId) || null; this.setData({ offering, fields: workspace.fields?.length ? workspace.fields : this.data.fields }); }); },
onInput(e) { this.setData({ ["values." + e.currentTarget.dataset.key]: e.detail.value }); },
onComponentInput(e) { this.setData({ ["values." + e.detail.key]: e.detail.value }); },
submit() { const values = this.data.values; if (!values.name || !values.phone) return wx.showToast({ title: "请填写联系人和手机号", icon: "none" }); this.setData({ submitting: true }); setTimeout(() => { const id = "LJ" + Date.now().toString().slice(-8); const record = { id, offeringName: this.data.offering ? this.data.offering.name : "门系统定制咨询", type: values.doorType || "门系统定制", project: values.city || "待确认项目", status: "待主理人复核图纸", createdAt: new Date().toLocaleDateString("zh-CN"), values }; const records = wx.getStorageSync("linjingInquiryRecords") || []; wx.setStorageSync("linjingInquiryRecords", [record].concat(records)); this.setData({ submitting: false }); wx.redirectTo({ url: "/pages/inquiry-success/index?id=" + id }); }, 500); },
data: {
offering: null,
submitting: false,
eyebrow: "CONSULTATION",
title: "需求咨询",
subtitle: "提交信息后由主理人与你联系",
submitLabel: "提交需求",
values: {},
fields: [],
},
onLoad(options) {
loadWorkspaceWithFallback().then((workspace) => {
const offering =
(workspace.offerings || []).find((item) => item.id === options.offeringId) || null;
const form = (workspace.inquiryForms || [])[0];
const isQuote =
form?.purpose === "quote-request" ||
(workspace.plugins || []).some((plugin) => plugin.key === "quote-request");
this.setData({
offering,
fields: form?.fields || workspace.fields || [],
title: isQuote ? "获取报价方案" : "需求咨询",
eyebrow: isQuote ? "QUOTE REQUEST" : "CONSULTATION",
submitLabel: isQuote ? "提交报价需求" : "提交需求",
});
});
},
onInput(e) {
this.setData({ ["values." + e.currentTarget.dataset.key]: e.detail.value });
},
onComponentInput(e) {
this.setData({ ["values." + e.detail.key]: e.detail.value });
},
submit() {
const values = this.data.values;
if (!values.name || !values.phone)
return wx.showToast({ title: "请填写联系人和手机号", icon: "none" });
this.setData({ submitting: true });
setTimeout(() => {
const id = "LJ" + Date.now().toString().slice(-8);
const record = {
id,
offeringName: this.data.offering ? this.data.offering.name : "门系统定制咨询",
type: values.doorType || "门系统定制",
project: values.city || "待确认项目",
status: "待主理人复核图纸",
createdAt: new Date().toLocaleDateString("zh-CN"),
values,
};
const records = wx.getStorageSync("linjingInquiryRecords") || [];
wx.setStorageSync("linjingInquiryRecords", [record].concat(records));
this.setData({ submitting: false });
wx.redirectTo({ url: "/pages/inquiry-success/index?id=" + id });
}, 500);
},
});