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

@@ -1 +1,16 @@
Component({ properties: { fields: { type: Array, value: [] }, values: { type: Object, value: {} }, submitting: { type: Boolean, value: false } }, methods: { input(e) { this.triggerEvent("input", { key: e.currentTarget.dataset.key, value: e.detail.value }); }, submit() { this.triggerEvent("submit"); } } });
Component({
properties: {
fields: { type: Array, value: [] },
values: { type: Object, value: {} },
submitting: { type: Boolean, value: false },
submitLabel: { type: String, value: "提交需求" },
},
methods: {
input(e) {
this.triggerEvent("input", { key: e.currentTarget.dataset.key, value: e.detail.value });
},
submit() {
this.triggerEvent("submit");
},
},
});
@@ -1 +1 @@
<view class="form"><view wx:for="{{fields}}" wx:key="key" class="field"><text>{{item.label}}</text><input data-key="{{item.key}}" placeholder="{{item.placeholder}}" value="{{values[item.key]}}" bindinput="input"/></view><button class="submit" loading="{{submitting}}" bindtap="submit">提交定制需求</button><text class="privacy">信息仅用于本次方案沟通,我们不会向第三方披露。</text></view>
<view class="form"><view wx:for="{{fields}}" wx:key="key" class="field"><text>{{item.label}}</text><input data-key="{{item.key}}" placeholder="{{item.placeholder}}" value="{{values[item.key]}}" bindinput="input"/></view><button class="submit" loading="{{submitting}}" bindtap="submit">{{submitLabel || '提交需求'}}</button><text class="privacy">信息仅用于本次方案沟通,我们不会向第三方披露。</text></view>
+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);
},
});
+1 -1
View File
@@ -1 +1 @@
<view class="page"><view class="head"><text class="eyebrow">PRIVATE CONSULTATION</text><text class="title">私享测量预约</text><text class="sub">{{offering ? offering.name : '主理人亲自沟通,72 小时内反馈空间构想'}}</text></view><inquiry-form fields="{{fields}}" values="{{values}}" submitting="{{submitting}}" bind:input="onComponentInput" bind:submit="submit" /></view>
<view class="page"><view class="head"><text class="eyebrow">{{eyebrow}}</text><text class="title">{{title}}</text><text class="sub">{{offering ? offering.name : subtitle}}</text></view><inquiry-form fields="{{fields}}" values="{{values}}" submitting="{{submitting}}" submit-label="{{submitLabel}}" bind:input="onComponentInput" bind:submit="submit" /></view>
+1 -1
View File
@@ -5,7 +5,7 @@
"home": { "page": "pages/index/index", "anchors": ["founder-card", "brand-hero", "trust-proof", "offering-list"] },
"offerings": { "page": "pages/services/index", "anchors": ["作品与系统", "查看详情"] },
"detail": { "page": "pages/offering/detail", "anchors": ["预约测量"] },
"inquiry": { "page": "pages/inquiry/index", "anchors": ["PRIVATE CONSULTATION", "提交"] },
"inquiry": { "page": "pages/inquiry/index", "anchors": [ "提交"] },
"success": { "page": "pages/inquiry-success/index", "anchors": ["已收到", "查看"] },
"records": { "page": "pages/records/index", "anchors": ["咨询记录", "咨询"] },
"profile": { "page": "pages/bookings/index", "anchors": ["直派服务区域与履约说明", "一门一档"] }
+1 -1
View File
@@ -1 +1 @@
{"templateKey":"linjing-door","viewport":{"width":375,"height":812},"states":{"home":{"page":"pages/index/index","anchors":["founder-card","brand-hero","trust-proof","trust-manifesto","offering-list"]},"offerings":{"page":"pages/services/index","anchors":["作品与系统","查看详情"]},"detail":{"page":"pages/offering/detail","anchors":["预约测量"]},"inquiry":{"page":"pages/inquiry/index","anchors":["PRIVATE CONSULTATION","提交"]},"success":{"page":"pages/inquiry-success/index","anchors":["已收到","查看"]},"records-empty":{"page":"pages/records/index","anchors":["咨询记录","咨询"]},"profile":{"page":"pages/bookings/index","anchors":["直派服务区域与履约说明","一门一档"]}}}
{"templateKey":"linjing-door","viewport":{"width":375,"height":812},"states":{"home":{"page":"pages/index/index","anchors":["founder-card","brand-hero","trust-proof","trust-manifesto","offering-list"]},"offerings":{"page":"pages/services/index","anchors":["作品与系统","查看详情"]},"detail":{"page":"pages/offering/detail","anchors":["预约测量"]},"inquiry":{"page":"pages/inquiry/index","anchors":["提交"]},"success":{"page":"pages/inquiry-success/index","anchors":["已收到","查看"]},"records-empty":{"page":"pages/records/index","anchors":["咨询记录","咨询"]},"profile":{"page":"pages/bookings/index","anchors":["直派服务区域与履约说明","一门一档"]}}}
+1 -1
View File
@@ -1 +1 @@
{"templateKey":"personal+minimal-neutral","viewport":{"width":375,"height":812},"states":{"home":{"page":"pages/index/index","anchors":["brand-hero","founder-card","offering-list","trust-proof"]},"offerings":{"page":"pages/services/index","anchors":["作品与系统","查看详情"]},"detail":{"page":"pages/offering/detail","anchors":["预约测量"]},"inquiry":{"page":"pages/inquiry/index","anchors":["PRIVATE CONSULTATION","提交"]},"success":{"page":"pages/inquiry-success/index","anchors":["已收到","查看"]},"records-empty":{"page":"pages/records/index","anchors":["咨询记录","咨询"]},"profile":{"page":"pages/bookings/index","anchors":["直派服务区域与履约说明","一门一档"]}}}
{"templateKey":"personal+minimal-neutral","viewport":{"width":375,"height":812},"states":{"home":{"page":"pages/index/index","anchors":["brand-hero","founder-card","offering-list","trust-proof"]},"offerings":{"page":"pages/services/index","anchors":["作品与系统","查看详情"]},"detail":{"page":"pages/offering/detail","anchors":["预约测量"]},"inquiry":{"page":"pages/inquiry/index","anchors":["提交"]},"success":{"page":"pages/inquiry-success/index","anchors":["已收到","查看"]},"records-empty":{"page":"pages/records/index","anchors":["咨询记录","咨询"]},"profile":{"page":"pages/bookings/index","anchors":["直派服务区域与履约说明","一门一档"]}}}