feat: 收口多品牌与模板构建基础

This commit is contained in:
que01 committed 2026-09-25 02:55:46 +08:00
1 parent 0425a1c672
commit 77224ea51f
317 files changed
+11290 -1158

No files matched your search

+34 -23
View File
@@ -1,5 +1,5 @@
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
const { request, customerRequest } = require("../../utils/request");
const { request, customerRequest, customerTokenKey } = require("../../utils/request");
Page({
data: {
offering: null,
@@ -8,31 +8,42 @@ Page({
title: "需求咨询",
subtitle: "提交信息后由主理人与你联系",
submitLabel: "提交需求",
presentation: {},
values: {},
fields: [],
formId: "",
error: "",
templateKey: "",
navigation: [],
},
onLoad(options) {
loadWorkspaceWithFallback().then((workspace) => {
const offering =
(workspace.offerings || []).find((item) => item.id === options.offeringId) || null;
const forms = workspace.inquiryForms || [];
const form =
forms.find((item) => item.targetId && item.targetId === options.offeringId) ||
forms.find((item) => item.target === "brand") ||
forms[0];
const isQuote =
form?.purpose === "quote-request" ||
(workspace.plugins || []).some((plugin) => plugin.key === "quote-request");
this.setData({
offering,
fields: form?.fields || workspace.fields || [],
formId: form?.key || form?.id || "",
title: isQuote ? "获取报价方案" : "需求咨询",
eyebrow: isQuote ? "QUOTE REQUEST" : "CONSULTATION",
submitLabel: isQuote ? "提交报价需求" : "提交需求",
});
});
loadWorkspaceWithFallback()
.then((workspace) => {
const offering =
(workspace.offerings || []).find((item) => item.id === options.offeringId) || null;
const forms = workspace.inquiryForms || [];
const form =
forms.find((item) => item.targetId && item.targetId === options.offeringId) ||
forms.find((item) => item.target === "brand") ||
forms[0];
const isQuote =
form?.purpose === "quote-request" ||
(workspace.plugins || []).some((plugin) => plugin.key === "quote-request");
const presentation = workspace.brand?.visualPresentation?.inquiry || {};
this.setData({
offering,
fields: form?.fields || workspace.fields || [],
formId: form?.key || form?.id || "",
title: isQuote ? "获取报价方案" : presentation.title || "需求咨询",
eyebrow: isQuote ? "QUOTE REQUEST" : presentation.eyebrow || "CONSULTATION",
subtitle: presentation.subtitle || "提交信息后由主理人与你联系",
submitLabel: isQuote ? "提交报价需求" : presentation.submitLabel || "提交需求",
presentation,
templateKey: workspace.visualTemplate?.key || "",
navigation: workspace.navigation || [],
});
})
.catch((error) => this.setData({ error: error.message }));
},
onInput(e) {
this.setData({ ["values." + e.currentTarget.dataset.key]: e.detail.value });
@@ -69,12 +80,12 @@ Page({
this.setData({ submitting: false });
wx.showToast({ title: error.message || "提交失败,请重试", icon: "none" });
};
if (wx.getStorageSync("customerToken")) return send().catch(fail);
if (wx.getStorageSync(customerTokenKey())) return send().catch(fail);
wx.login({
success: (login) =>
request("/customer/session/wechat", { method: "POST", data: { code: login.code } })
.then((result) => {
wx.setStorageSync("customerToken", result.token);
wx.setStorageSync(customerTokenKey(), result.token);
return send();
})
.catch(fail),