fix: 收敛模板编辑发布契约并还原餐饮页面视觉
No files matched your search
@@ -10,8 +10,18 @@ export function TemplateListField({
|
||||
}) {
|
||||
return (
|
||||
<Form.Item label={field.label} help={field.help}>
|
||||
<Form.List name={name}>
|
||||
{(rows, { add, remove }) => (
|
||||
<Form.List
|
||||
name={name}
|
||||
rules={[
|
||||
{
|
||||
validator: (_rule, values: unknown) =>
|
||||
field.required && (!Array.isArray(values) || values.length === 0)
|
||||
? Promise.reject(new Error(`请至少填写一项${field.label}`))
|
||||
: Promise.resolve(),
|
||||
},
|
||||
]}
|
||||
>
|
||||
{(rows, { add, remove }, { errors }) => (
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
{rows.map((row, index) => (
|
||||
<Space key={row.key} align="start" wrap>
|
||||
@@ -32,6 +42,7 @@ export function TemplateListField({
|
||||
<Button onClick={() => remove(row.name)}>删除</Button>
|
||||
</Space>
|
||||
))}
|
||||
<Form.ErrorList errors={errors} />
|
||||
<Button onClick={() => add()}>新增{field.label}</Button>
|
||||
</Space>
|
||||
)}
|
||||
|
||||
@@ -33,7 +33,7 @@ export function BrandPage() {
|
||||
{!brand.data ? null : (
|
||||
<>
|
||||
<AdminPageHeader
|
||||
title="品牌表达"
|
||||
title="品牌资料"
|
||||
description="先让访客理解你是谁、服务谁,以及为什么值得信任。"
|
||||
extra={<Tag color="blue">{template.data?.name ?? "当前模板"}</Tag>}
|
||||
/>
|
||||
@@ -152,7 +152,9 @@ export function BrandPage() {
|
||||
</Col>
|
||||
<Col xs={24} xl={9}>
|
||||
<Card title="公开表达预览" style={{ position: "sticky", top: 24 }}>
|
||||
<Typography.Text type="secondary">小程序首页将优先使用以下信息</Typography.Text>
|
||||
<Typography.Text type="secondary">
|
||||
这些资料会用于小程序首页和联系区域
|
||||
</Typography.Text>
|
||||
<Typography.Title level={3}>{brand.data.name || "品牌名称"}</Typography.Title>
|
||||
<Typography.Title level={5}>{brand.data.tagline || "一句话定位"}</Typography.Title>
|
||||
<Typography.Paragraph>
|
||||
|
||||
@@ -2,17 +2,23 @@ import {
|
||||
Alert,
|
||||
Button,
|
||||
Card,
|
||||
Divider,
|
||||
Col,
|
||||
Form,
|
||||
Grid,
|
||||
Input,
|
||||
InputNumber,
|
||||
Row,
|
||||
Select,
|
||||
Segmented,
|
||||
Space,
|
||||
Tag,
|
||||
Typography,
|
||||
message,
|
||||
} from "antd";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useEffect, useMemo } from "react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import type { AdminTemplateContent, TemplateAdminField } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { ImageUrlField } from "../../components/ImageUrlField.js";
|
||||
@@ -46,6 +52,22 @@ function renderField(field: TemplateAdminField) {
|
||||
return <ImageUrlField {...(field.placeholder ? { placeholder: field.placeholder } : {})} />;
|
||||
if (field.input === "number")
|
||||
return <InputNumber style={{ width: "100%" }} placeholder={field.placeholder} />;
|
||||
if (field.input === "boolean")
|
||||
return (
|
||||
<Select
|
||||
options={[
|
||||
{ value: true, label: "是" },
|
||||
{ value: false, label: "否" },
|
||||
]}
|
||||
/>
|
||||
);
|
||||
if (field.input === "select" || field.input === "multi-select")
|
||||
return (
|
||||
<Select
|
||||
{...(field.input === "multi-select" ? { mode: "multiple" as const } : {})}
|
||||
options={field.options ?? []}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<Input
|
||||
type={field.input === "phone" ? "tel" : "text"}
|
||||
@@ -63,15 +85,88 @@ export function PresentationEditor({
|
||||
}: PresentationEditorProps) {
|
||||
const [form] = Form.useForm<PresentationValues>();
|
||||
const queryClient = useQueryClient();
|
||||
const sections = useMemo(
|
||||
() =>
|
||||
(templateContent?.admin.sections ?? [])
|
||||
.map((section) => ({
|
||||
...section,
|
||||
fields: section.fields.filter((field) => field.binding.startsWith("brand.config.")),
|
||||
}))
|
||||
.filter((section) => section.fields.length > 0),
|
||||
[templateContent],
|
||||
const navigate = useNavigate();
|
||||
const breakpoints = Grid.useBreakpoint();
|
||||
const [activePage, setActivePage] = useState<string>();
|
||||
const sections = useMemo(() => {
|
||||
const declaredTemplateFields = (templateContent?.templateFields ?? []).map((field) => ({
|
||||
...field,
|
||||
binding: field.binding ?? `brand.config.templateData.${field.key}`,
|
||||
}));
|
||||
return [
|
||||
...(declaredTemplateFields.length
|
||||
? [
|
||||
{
|
||||
key: "template-data",
|
||||
title: "模板专属内容",
|
||||
description: "这些字段由当前小程序模板定义,保存后发布才会对外展示。",
|
||||
page: templateContent?.templateFields?.[0]?.page ?? "home",
|
||||
target: "brand" as const,
|
||||
fields: declaredTemplateFields,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(templateContent?.admin.sections ?? []),
|
||||
]
|
||||
.map((section) => ({
|
||||
...section,
|
||||
fields: section.fields.filter(
|
||||
(field) =>
|
||||
field.binding.startsWith("brand.config.") ||
|
||||
[
|
||||
"brand.avatarUrl",
|
||||
"brand.description",
|
||||
"brand.contactPhone",
|
||||
"brand.contactWechat",
|
||||
"brand.address",
|
||||
].includes(field.binding),
|
||||
),
|
||||
}))
|
||||
.filter((section) => section.fields.length > 0);
|
||||
}, [templateContent]);
|
||||
const pageOptions = useMemo(() => {
|
||||
const pages = new Map<string, string>();
|
||||
for (const item of templateContent?.navigation ?? []) pages.set(item.page, item.label);
|
||||
for (const section of templateContent?.admin.sections ?? []) {
|
||||
const navigation = templateContent?.navigation.find((item) => item.page === section.page);
|
||||
if (!pages.has(section.page))
|
||||
pages.set(section.page, navigation?.label ?? pageTitle(section.page));
|
||||
}
|
||||
return [...pages].map(([value, label]) => ({ value, label }));
|
||||
}, [templateContent]);
|
||||
const selectedPage = pageOptions.some((item) => item.value === activePage)
|
||||
? activePage
|
||||
: pageOptions[0]?.value;
|
||||
const visibleSections = sections.filter((section) => section.page === selectedPage);
|
||||
const relatedTargets = [
|
||||
...(templateContent?.admin.sections ?? [])
|
||||
.filter((section) => section.page === selectedPage && section.target !== "brand")
|
||||
.map((section) => section.target),
|
||||
...((templateContent?.trustContentTypes ?? []).some((item) =>
|
||||
item.pages?.includes(selectedPage ?? ""),
|
||||
)
|
||||
? ["trust"]
|
||||
: []),
|
||||
];
|
||||
const pageLinks = [...new Set(relatedTargets)].flatMap((target) =>
|
||||
target === "trust"
|
||||
? (templateContent?.trustContentTypes ?? [])
|
||||
.filter((item) => item.pages?.includes(selectedPage ?? ""))
|
||||
.map((item) => ({
|
||||
target: `trust:${item.type}`,
|
||||
label: `编辑${item.label}`,
|
||||
}))
|
||||
: [
|
||||
{
|
||||
target,
|
||||
label: (
|
||||
{ offering: "管理此页展示的业务内容", inquiry: "管理此页的咨询表单" } as Record<
|
||||
string,
|
||||
string
|
||||
>
|
||||
)[target],
|
||||
},
|
||||
],
|
||||
);
|
||||
const initialValues = useMemo(() => {
|
||||
const values: PresentationValues = {};
|
||||
@@ -105,10 +200,20 @@ export function PresentationEditor({
|
||||
form.setFieldsValue(initialValues);
|
||||
}, [form, initialValues]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!pageOptions.some((item) => item.value === activePage))
|
||||
setActivePage(pageOptions[0]?.value);
|
||||
}, [activePage, pageOptions]);
|
||||
|
||||
return (
|
||||
<Card title="小程序页面内容" style={{ marginTop: 24 }}>
|
||||
<Card
|
||||
title="小程序页面配置"
|
||||
extra={templateContent ? <Tag color="blue">{templateContent.displayName}</Tag> : null}
|
||||
style={{ marginTop: 32 }}
|
||||
styles={{ body: { minHeight: breakpoints.md ? 760 : 620 } }}
|
||||
>
|
||||
<Typography.Paragraph type="secondary">
|
||||
编辑访客在小程序中看到的文字和图片。不同模板会提供适合本行业的内容项目。
|
||||
按小程序页面查找内容。这里修改的是草稿,发布后访客才会看到更新。
|
||||
</Typography.Paragraph>
|
||||
{loading ? <Alert type="info" showIcon message="正在读取当前模板的编辑项目" /> : null}
|
||||
{error ? (
|
||||
@@ -119,51 +224,108 @@ export function PresentationEditor({
|
||||
) : null}
|
||||
{templateContent ? (
|
||||
<>
|
||||
<Typography.Title level={5}>{templateContent.displayName}</Typography.Title>
|
||||
<Space wrap style={{ marginBottom: 24 }}>
|
||||
{breakpoints.xs ? (
|
||||
<Select
|
||||
aria-label="选择小程序页面"
|
||||
value={selectedPage}
|
||||
options={pageOptions}
|
||||
onChange={setActivePage}
|
||||
style={{ minWidth: 180 }}
|
||||
/>
|
||||
) : (
|
||||
<Segmented
|
||||
value={selectedPage}
|
||||
options={pageOptions}
|
||||
onChange={(value) => setActivePage(String(value))}
|
||||
/>
|
||||
)}
|
||||
</Space>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
initialValues={initialValues}
|
||||
onFinish={(values) => save.mutate(values)}
|
||||
style={{ minHeight: 540, display: "flex", flexDirection: "column" }}
|
||||
>
|
||||
{sections.map((section) => (
|
||||
<Card
|
||||
key={section.key}
|
||||
size="small"
|
||||
title={section.title}
|
||||
style={{ marginBottom: 16 }}
|
||||
>
|
||||
<Typography.Paragraph type="secondary">{section.description}</Typography.Paragraph>
|
||||
<Row gutter={16}>
|
||||
{section.fields.map((field) => (
|
||||
<Col
|
||||
key={field.key}
|
||||
xs={24}
|
||||
md={field.input === "textarea" || field.input === "list" ? 24 : 12}
|
||||
>
|
||||
{field.input === "list" ? (
|
||||
<TemplateListField
|
||||
field={field}
|
||||
name={presentationFieldName(section.key, field.key)}
|
||||
/>
|
||||
) : (
|
||||
<Form.Item
|
||||
name={presentationFieldName(section.key, field.key)}
|
||||
label={field.label}
|
||||
{...(field.help ? { help: field.help } : {})}
|
||||
{...(field.required
|
||||
? { rules: [{ required: true, message: `请填写${field.label}` }] }
|
||||
: {})}
|
||||
<div style={{ flex: 1 }}>
|
||||
{visibleSections.map((section, index) => (
|
||||
<section key={section.key} aria-labelledby={`section-${section.key}`}>
|
||||
{index > 0 ? <Divider /> : null}
|
||||
<Typography.Title id={`section-${section.key}`} level={5}>
|
||||
{section.title}
|
||||
</Typography.Title>
|
||||
<Typography.Paragraph type="secondary">
|
||||
{section.description}
|
||||
</Typography.Paragraph>
|
||||
<Row gutter={16}>
|
||||
{section.fields.map((field) => (
|
||||
<Col
|
||||
key={field.key}
|
||||
xs={24}
|
||||
md={field.input === "textarea" || field.input === "list" ? 24 : 12}
|
||||
>
|
||||
{field.input === "list" ? (
|
||||
<TemplateListField
|
||||
field={field}
|
||||
name={presentationFieldName(section.key, field.key)}
|
||||
/>
|
||||
) : (
|
||||
<Form.Item
|
||||
name={presentationFieldName(section.key, field.key)}
|
||||
label={field.label}
|
||||
{...(field.help ? { help: field.help } : {})}
|
||||
{...(field.required
|
||||
? { rules: [{ required: true, message: `请填写${field.label}` }] }
|
||||
: {})}
|
||||
>
|
||||
{renderField(field)}
|
||||
</Form.Item>
|
||||
)}
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
</section>
|
||||
))}
|
||||
{pageLinks.length ? (
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
style={{ marginBottom: 24 }}
|
||||
message="这个页面还有关联内容"
|
||||
description={
|
||||
<Space wrap>
|
||||
{pageLinks.map((item) => (
|
||||
<Button
|
||||
key={item.target}
|
||||
type="link"
|
||||
onClick={() => {
|
||||
if (item.target.startsWith("trust:")) {
|
||||
void navigate(
|
||||
`/admin/trust?type=${encodeURIComponent(item.target.slice(6))}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
void navigate(
|
||||
item.target === "offering" ? "/admin/services" : "/admin/workspace",
|
||||
);
|
||||
}}
|
||||
style={{ padding: 0 }}
|
||||
>
|
||||
{renderField(field)}
|
||||
</Form.Item>
|
||||
)}
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
</Card>
|
||||
))}
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
{item.label}
|
||||
</Button>
|
||||
))}
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
{!visibleSections.length && !pageLinks.length ? (
|
||||
<Typography.Paragraph type="secondary">
|
||||
这个页面没有单独的品牌文案配置。
|
||||
</Typography.Paragraph>
|
||||
) : null}
|
||||
</div>
|
||||
<Space direction="vertical" style={{ width: "100%", marginTop: 24 }}>
|
||||
<MutationError error={save.error} />
|
||||
<Button type="primary" htmlType="submit" loading={save.isPending}>
|
||||
保存页面内容
|
||||
@@ -175,3 +337,20 @@ export function PresentationEditor({
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function pageTitle(page: string): string {
|
||||
return (
|
||||
(
|
||||
{
|
||||
home: "首页",
|
||||
offerings: "业务展示",
|
||||
service: "服务说明",
|
||||
detail: "详情页",
|
||||
inquiry: "咨询页",
|
||||
success: "提交成功页",
|
||||
records: "记录页",
|
||||
profile: "主理人页",
|
||||
} as Record<string, string>
|
||||
)[page] ?? page
|
||||
);
|
||||
}
|
||||
@@ -48,7 +48,10 @@ export function readPresentationValue(
|
||||
? (value as unknown[]).map((item) => ({ [field.itemValueKey as string]: item }))
|
||||
: value;
|
||||
}
|
||||
return typeof value === "string" || typeof value === "number" ? value : undefined;
|
||||
if (field?.input === "multi-select") return Array.isArray(value) ? value : [];
|
||||
return typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
||||
? value
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function writePath(
|
||||
|
||||
@@ -98,7 +98,7 @@ export function OverviewPage() {
|
||||
<Col xs={24} sm={12} lg={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="信任内容"
|
||||
title="信任证明"
|
||||
value={trust?.filter((item) => item.isPublished).length ?? 0}
|
||||
suffix="条已发布"
|
||||
/>
|
||||
@@ -107,7 +107,7 @@ export function OverviewPage() {
|
||||
<Col xs={24} sm={12} lg={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="业务提供项"
|
||||
title="业务展示内容"
|
||||
value={offerings?.filter((item) => item.isEnabled).length ?? 0}
|
||||
suffix="项公开"
|
||||
/>
|
||||
|
||||
@@ -98,8 +98,12 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
});
|
||||
const importSample = useMutation({
|
||||
mutationFn: () => client.importAdminSampleContent(),
|
||||
onSuccess: () => {
|
||||
message.success("示例内容已导入草稿");
|
||||
onSuccess: ({ counts }) => {
|
||||
message.success(
|
||||
counts.inquiryForms
|
||||
? "示例内容和客户咨询表单已导入草稿"
|
||||
: "示例内容已导入草稿,现有客户咨询表单已保留",
|
||||
);
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
@@ -259,9 +263,9 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
.join("、") || "无"}
|
||||
</Typography.Text>
|
||||
<Space wrap>
|
||||
<Button onClick={() => navigate("/admin/brand")}>编辑品牌</Button>
|
||||
<Button onClick={() => navigate("/admin/services")}>编辑业务项</Button>
|
||||
<Button onClick={() => navigate("/admin/trust")}>编辑信任内容</Button>
|
||||
<Button onClick={() => navigate("/admin/brand")}>编辑小程序页面</Button>
|
||||
<Button onClick={() => navigate("/admin/services")}>编辑业务展示和详情</Button>
|
||||
<Button onClick={() => navigate("/admin/trust")}>编辑信任证明</Button>
|
||||
</Space>
|
||||
</Space>
|
||||
</section>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Form,
|
||||
Input,
|
||||
Modal,
|
||||
@@ -47,6 +46,18 @@ export function ServicesPage() {
|
||||
.flatMap((section) =>
|
||||
section.fields.filter((field) => field.binding.startsWith("offering.config.")),
|
||||
);
|
||||
const offeringPageLabel =
|
||||
workspace.data?.templateContent?.navigation.find((item) => item.page === "offerings")?.label ??
|
||||
"业务展示页";
|
||||
const detailPageLabel =
|
||||
workspace.data?.templateContent?.navigation.find((item) => item.page === "detail")?.label ??
|
||||
"详情页";
|
||||
const detailSections = (workspace.data?.templateContent?.admin.sections ?? []).filter(
|
||||
(section) => section.target === "offering" && section.page === "detail",
|
||||
);
|
||||
const hasTemplateDetailCopy = templateFields.some(
|
||||
(field) => field.binding === "offering.config.details.background",
|
||||
);
|
||||
const saveOffering = useMutation({
|
||||
mutationFn: (values: Record<string, unknown>) => {
|
||||
const fields = Object.fromEntries(
|
||||
@@ -129,15 +140,28 @@ export function ServicesPage() {
|
||||
}}
|
||||
>
|
||||
<AdminPageHeader
|
||||
title="业务提供项"
|
||||
description="管理你向外提供的服务、产品、套餐和合作项目,让访客清楚知道如何与你合作。"
|
||||
title="小程序内容:业务展示与详情"
|
||||
description={`在「${offeringPageLabel}」管理访客能选择的服务、产品或案例;每项内容的补充资料会显示在对应的「${detailPageLabel}」。`}
|
||||
extra={
|
||||
<Button type="primary" onClick={() => beginOffering()}>
|
||||
新增业务提供项
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<Card title="公开业务提供项" extra={<Tag color="blue">小程序优先展示</Tag>}>
|
||||
<section aria-label="业务提供项列表">
|
||||
<Space wrap style={{ marginBottom: 16 }}>
|
||||
<Typography.Title level={5} style={{ margin: 0 }}>
|
||||
{offeringPageLabel}中的内容
|
||||
</Typography.Title>
|
||||
<Tag color="blue">已启用的项目会公开展示</Tag>
|
||||
</Space>
|
||||
{detailSections.length ? (
|
||||
<Typography.Paragraph type="secondary">
|
||||
编辑单项详情时,附加字段将用于:
|
||||
{detailSections.map((section) => section.title).join("、")}
|
||||
。列表中的名称、说明、价格和封面也会显示在业务展示页。
|
||||
</Typography.Paragraph>
|
||||
) : null}
|
||||
<Table
|
||||
scroll={{ x: 760 }}
|
||||
rowKey="id"
|
||||
@@ -211,7 +235,7 @@ export function ServicesPage() {
|
||||
<MutationError error={saveOffering.error} />
|
||||
<MutationError error={toggleOffering.error} />
|
||||
<MutationError error={deleteOffering.error} />
|
||||
</Card>
|
||||
</section>
|
||||
<Modal
|
||||
open={offeringOpen}
|
||||
title={editingOffering ? "编辑业务提供项" : "新增业务提供项"}
|
||||
@@ -244,9 +268,11 @@ export function ServicesPage() {
|
||||
<Form.Item name="summary" label="一句话说明">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="description" label="详细介绍">
|
||||
<Input.TextArea rows={5} />
|
||||
</Form.Item>
|
||||
{!hasTemplateDetailCopy ? (
|
||||
<Form.Item name="description" label="详细介绍">
|
||||
<Input.TextArea rows={5} />
|
||||
</Form.Item>
|
||||
) : null}
|
||||
<Form.Item name="priceText" label="价格展示">
|
||||
<Input placeholder="例如:按现场评估报价 / ¥ 2,800 起" />
|
||||
</Form.Item>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Divider,
|
||||
Form,
|
||||
Input,
|
||||
List,
|
||||
@@ -14,12 +14,14 @@ import {
|
||||
message,
|
||||
} from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { isTrustContentComplete } from "@personal-brand/api-client";
|
||||
import type {
|
||||
TemplateAdminField,
|
||||
TrustContent,
|
||||
TrustContentInput,
|
||||
} from "@personal-brand/api-client";
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useSearchParams } from "react-router-dom";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { ImageUrlField } from "../../components/ImageUrlField.js";
|
||||
@@ -61,14 +63,25 @@ const types = [
|
||||
type TrustTypeOption = {
|
||||
type: string;
|
||||
label: string;
|
||||
adminFields: {
|
||||
title: string;
|
||||
summary: string;
|
||||
content: string;
|
||||
summaryHelp?: string;
|
||||
summaryPlaceholder?: string;
|
||||
};
|
||||
pages?: string[];
|
||||
help?: string;
|
||||
placeholder?: string;
|
||||
required?: boolean;
|
||||
configFields?: TemplateAdminField[];
|
||||
hideStandardFields?: Array<"summary" | "content">;
|
||||
maxPublishedItems?: number;
|
||||
};
|
||||
const fallbackTypes: TrustTypeOption[] = types.map(({ value, label, help }) => ({
|
||||
type: value,
|
||||
label,
|
||||
adminFields: { title: "标题", summary: "摘要", content: "详细内容" },
|
||||
help,
|
||||
}));
|
||||
|
||||
@@ -78,6 +91,7 @@ export function TrustContentPage() {
|
||||
const [editing, setEditing] = useState<TrustContent | null>(null);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [form] = Form.useForm<TrustContentInput>();
|
||||
const [searchParams] = useSearchParams();
|
||||
const selectedType = Form.useWatch("type", form);
|
||||
const query = useQuery({
|
||||
queryKey: ["trust-content"],
|
||||
@@ -91,6 +105,21 @@ export function TrustContentPage() {
|
||||
?.length
|
||||
? workspace.data.templateContent.trustContentTypes
|
||||
: fallbackTypes;
|
||||
const pageLabel = (page: string) =>
|
||||
workspace.data?.templateContent?.navigation.find((item) => item.page === page)?.label ??
|
||||
(
|
||||
{ home: "首页", offerings: "业务展示页", detail: "详情页", profile: "主理人页" } as Record<
|
||||
string,
|
||||
string
|
||||
>
|
||||
)[page] ??
|
||||
page;
|
||||
const trustPageLabels = [
|
||||
...new Set(availableTypes.flatMap((item) => item.pages ?? []).map(pageLabel)),
|
||||
];
|
||||
const trustPlacement = trustPageLabels.length
|
||||
? `小程序的${trustPageLabels.join("、")}中`
|
||||
: "小程序对应的信任展示区域中";
|
||||
const selectedTypeMeta = availableTypes.find((item) => item.type === selectedType);
|
||||
const contentByType = new Map<string, TrustContent>();
|
||||
for (const item of query.data ?? []) {
|
||||
@@ -109,13 +138,14 @@ export function TrustContentPage() {
|
||||
availableTypes.find((item) => item.required && !contentByType.has(item.type))?.type ??
|
||||
availableTypes[0]?.type ??
|
||||
"credential";
|
||||
const requestedType = searchParams.get("type");
|
||||
const save = useMutation({
|
||||
mutationFn: (values: TrustContentInput) =>
|
||||
editing
|
||||
? client.updateAdminTrustContent(editing.id, values)
|
||||
: client.createAdminTrustContent(values),
|
||||
onSuccess: () => {
|
||||
message.success("信任内容已保存");
|
||||
message.success("品牌内容已保存为草稿,发布后小程序才会更新");
|
||||
setOpen(false);
|
||||
setEditing(null);
|
||||
form.resetFields();
|
||||
@@ -125,7 +155,7 @@ export function TrustContentPage() {
|
||||
const remove = useMutation({
|
||||
mutationFn: (id: string) => client.deleteAdminTrustContent(id),
|
||||
onSuccess: () => {
|
||||
message.success("内容已删除");
|
||||
message.success("品牌内容已删除");
|
||||
void queryClient.invalidateQueries({ queryKey: ["trust-content"] });
|
||||
},
|
||||
});
|
||||
@@ -146,6 +176,10 @@ export function TrustContentPage() {
|
||||
: { type: type ?? firstMissingRequiredType, isPublished: false, config: {} },
|
||||
);
|
||||
};
|
||||
useEffect(() => {
|
||||
if (!requestedType || !availableTypes.some((item) => item.type === requestedType)) return;
|
||||
begin(contentByType.get(requestedType), requestedType);
|
||||
}, [requestedType, availableTypes.length]);
|
||||
return (
|
||||
<QueryState
|
||||
loading={query.isLoading || workspace.isLoading}
|
||||
@@ -153,24 +187,32 @@ export function TrustContentPage() {
|
||||
onRetry={() => void Promise.all([query.refetch(), workspace.refetch()])}
|
||||
>
|
||||
<AdminPageHeader
|
||||
title="信任内容"
|
||||
description="用经历、案例、资历、流程和反馈,让访客知道为什么可以信任你。"
|
||||
title="小程序内容:品牌介绍与信任"
|
||||
description={`填写真实的经历、案例、资历、流程和服务说明。这些内容会显示在${trustPlacement};保存后需发布品牌,小程序才会更新。`}
|
||||
extra={
|
||||
<Button type="primary" onClick={() => begin()}>
|
||||
新增信任内容
|
||||
添加品牌内容
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<Card title="当前模板需要哪些信任内容?" style={{ marginBottom: 24 }}>
|
||||
<section aria-labelledby="trust-requirements-title">
|
||||
<Typography.Title id="trust-requirements-title" level={5}>
|
||||
当前模板需要配置的内容
|
||||
</Typography.Title>
|
||||
<Typography.Paragraph type="secondary">
|
||||
这些内容会帮助访客判断你是否值得信任。带有“发布必需”的项目需要填写完整后,才能发布小程序。
|
||||
标记为“发布必填”的项目需要填写完整后,才能发布小程序。
|
||||
</Typography.Paragraph>
|
||||
<List
|
||||
size="small"
|
||||
dataSource={availableTypes}
|
||||
renderItem={(item) => {
|
||||
const content = contentByType.get(item.type);
|
||||
const complete = Boolean(content?.title?.trim() && content?.content?.trim());
|
||||
const publishedCount = (query.data ?? []).filter(
|
||||
(record) => record.type === item.type && record.isPublished,
|
||||
).length;
|
||||
const tooMany =
|
||||
item.maxPublishedItems !== undefined && publishedCount > item.maxPublishedItems;
|
||||
const complete = Boolean(content && isTrustContentComplete(content, item) && !tooMany);
|
||||
return (
|
||||
<List.Item
|
||||
actions={[
|
||||
@@ -186,9 +228,18 @@ export function TrustContentPage() {
|
||||
>
|
||||
<Space wrap>
|
||||
<Typography.Text strong>{item.label}</Typography.Text>
|
||||
{item.required && <Tag color="orange">发布必需</Tag>}
|
||||
{item.required && <Tag color="orange">发布必填</Tag>}
|
||||
{(item.pages ?? []).map((page) => (
|
||||
<Tag key={page}>{pageLabel(page)}</Tag>
|
||||
))}
|
||||
<Tag color={complete ? "success" : "default"}>
|
||||
{complete ? "内容完整" : content ? "需要完善" : "尚未填写"}
|
||||
{tooMany
|
||||
? `公开内容过多(${publishedCount} 条)`
|
||||
: complete
|
||||
? "内容完整"
|
||||
: content
|
||||
? "需要完善"
|
||||
: "尚未填写"}
|
||||
</Tag>
|
||||
{item.help && <Typography.Text type="secondary">{item.help}</Typography.Text>}
|
||||
</Space>
|
||||
@@ -196,15 +247,16 @@ export function TrustContentPage() {
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
<Card>
|
||||
</section>
|
||||
<Divider />
|
||||
<section aria-label="已配置的品牌内容">
|
||||
<Table
|
||||
rowKey="id"
|
||||
dataSource={query.data ?? []}
|
||||
locale={{ emptyText: "还没有信任内容,请先按上方模板要求添加。" }}
|
||||
locale={{ emptyText: "还没有品牌内容,请先按上方模板要求添加。" }}
|
||||
columns={[
|
||||
{
|
||||
title: "证据类型",
|
||||
title: "内容类型",
|
||||
dataIndex: "type",
|
||||
render: (value) => (
|
||||
<Tag>{availableTypes.find((item) => item.type === value)?.label ?? value}</Tag>
|
||||
@@ -212,15 +264,32 @@ export function TrustContentPage() {
|
||||
},
|
||||
{ title: "标题", dataIndex: "title" },
|
||||
{
|
||||
title: "摘要",
|
||||
dataIndex: "summary",
|
||||
render: (value) => (typeof value === "string" && value ? value : "未填写"),
|
||||
title: "内容预览",
|
||||
ellipsis: { showTitle: true },
|
||||
render: (_value: unknown, item: TrustContent) => {
|
||||
const meta = availableTypes.find((type) => type.type === item.type);
|
||||
if (meta?.hideStandardFields?.includes("content")) {
|
||||
return (
|
||||
meta.configFields
|
||||
?.flatMap((field) => {
|
||||
const value = item.config?.[field.key];
|
||||
if (Array.isArray(value))
|
||||
return value.length ? [`${field.label}:${value.length} 项`] : [];
|
||||
return typeof value === "string" && value.trim()
|
||||
? [`${field.label}:${value}`]
|
||||
: [];
|
||||
})
|
||||
.join(";") || "尚未填写区块内容"
|
||||
);
|
||||
}
|
||||
return item.summary || item.content || "未填写";
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
title: "发布状态",
|
||||
dataIndex: "isPublished",
|
||||
render: (value) => (
|
||||
<Tag color={value ? "success" : "default"}>{value ? "已公开" : "草稿"}</Tag>
|
||||
<Tag color={value ? "success" : "default"}>{value ? "随发布展示" : "草稿"}</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -232,7 +301,7 @@ export function TrustContentPage() {
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title="确认删除这条信任内容?"
|
||||
description="删除后小程序将不再展示。"
|
||||
description="删除后需发布品牌,才会更新小程序展示。"
|
||||
onConfirm={() => remove.mutate(item.id)}
|
||||
>
|
||||
<Button size="small" danger loading={remove.isPending}>
|
||||
@@ -245,10 +314,10 @@ export function TrustContentPage() {
|
||||
]}
|
||||
/>
|
||||
<MutationError error={remove.error} />
|
||||
</Card>
|
||||
</section>
|
||||
<Modal
|
||||
open={open}
|
||||
title={editing ? "编辑信任内容" : "新增信任内容"}
|
||||
title={editing ? "编辑品牌内容" : "添加品牌内容"}
|
||||
onCancel={() => {
|
||||
setOpen(false);
|
||||
setEditing(null);
|
||||
@@ -258,48 +327,70 @@ export function TrustContentPage() {
|
||||
confirmLoading={save.isPending}
|
||||
destroyOnClose
|
||||
>
|
||||
<Form form={form} layout="vertical" onFinish={(values) => save.mutate(values)}>
|
||||
<Form.Item name="type" label="内容用途" rules={[{ required: true }]}>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
onFinish={(values) => save.mutate({ ...values, content: values.content ?? "" })}
|
||||
>
|
||||
<Form.Item name="type" label="内容类型" rules={[{ required: true }]}>
|
||||
<Select
|
||||
options={availableTypes.map((item) => ({ value: item.type, label: item.label }))}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="title" label="标题" rules={[{ required: true }]}>
|
||||
<Input placeholder="例如:服务过 30+ 位独立创作者" />
|
||||
</Form.Item>
|
||||
<Form.Item name="summary" label="摘要">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
{selectedTypeMeta?.pages?.length ? (
|
||||
<Typography.Paragraph type="secondary">
|
||||
这类内容会显示在:
|
||||
{selectedTypeMeta.pages.map(pageLabel).join("、")}
|
||||
</Typography.Paragraph>
|
||||
) : null}
|
||||
<Form.Item
|
||||
name="content"
|
||||
label="详细内容"
|
||||
help={
|
||||
selectedTypeMeta?.help ?? "每行写一项,页面会按模板样式展示。不要填写 HTML 或代码。"
|
||||
}
|
||||
name="title"
|
||||
label={selectedTypeMeta?.adminFields.title ?? "标题"}
|
||||
rules={[{ required: true }]}
|
||||
>
|
||||
<Input.TextArea
|
||||
rows={8}
|
||||
showCount
|
||||
maxLength={2000}
|
||||
placeholder={selectedTypeMeta?.placeholder ?? "例如:\n第一项内容\n第二项内容"}
|
||||
/>
|
||||
<Input placeholder="例如:服务过 30+ 位独立创作者" />
|
||||
</Form.Item>
|
||||
{(!editing || contentByType.get(selectedType)?.id === editing.id) &&
|
||||
selectedTypeMeta?.configFields?.map((field) =>
|
||||
field.input === "list" ? (
|
||||
<TemplateListField key={field.key} field={field} name={["config", field.key]} />
|
||||
) : (
|
||||
<Form.Item
|
||||
key={field.key}
|
||||
name={["config", field.key]}
|
||||
label={field.label}
|
||||
help={field.help}
|
||||
>
|
||||
{field.input === "textarea" ? <Input.TextArea rows={3} /> : <Input />}
|
||||
</Form.Item>
|
||||
),
|
||||
)}
|
||||
{!selectedTypeMeta?.hideStandardFields?.includes("summary") && (
|
||||
<Form.Item
|
||||
name="summary"
|
||||
label={selectedTypeMeta?.adminFields.summary ?? "摘要"}
|
||||
help={selectedTypeMeta?.adminFields.summaryHelp}
|
||||
>
|
||||
<Input placeholder={selectedTypeMeta?.adminFields.summaryPlaceholder} />
|
||||
</Form.Item>
|
||||
)}
|
||||
{!selectedTypeMeta?.hideStandardFields?.includes("content") && (
|
||||
<Form.Item
|
||||
name="content"
|
||||
label={selectedTypeMeta?.adminFields.content ?? "详细内容"}
|
||||
help={
|
||||
selectedTypeMeta?.help ?? "每行写一项,页面会按模板样式展示。不要填写 HTML 或代码。"
|
||||
}
|
||||
rules={[{ required: true }]}
|
||||
>
|
||||
<Input.TextArea
|
||||
rows={8}
|
||||
showCount
|
||||
maxLength={2000}
|
||||
placeholder={selectedTypeMeta?.placeholder ?? "例如:\n第一项内容\n第二项内容"}
|
||||
/>
|
||||
</Form.Item>
|
||||
)}
|
||||
{selectedTypeMeta?.configFields?.map((field) =>
|
||||
field.input === "list" ? (
|
||||
<TemplateListField key={field.key} field={field} name={["config", field.key]} />
|
||||
) : (
|
||||
<Form.Item
|
||||
key={field.key}
|
||||
name={["config", field.key]}
|
||||
label={field.label}
|
||||
help={field.help}
|
||||
rules={[{ required: field.required === true }]}
|
||||
>
|
||||
{field.input === "textarea" ? <Input.TextArea rows={3} /> : <Input />}
|
||||
</Form.Item>
|
||||
),
|
||||
)}
|
||||
<Form.Item
|
||||
name="coverUrl"
|
||||
label="配图地址"
|
||||
@@ -310,7 +401,7 @@ export function TrustContentPage() {
|
||||
<Form.Item name="isPublished" label="公开状态">
|
||||
<Select
|
||||
options={[
|
||||
{ value: true, label: "立即公开" },
|
||||
{ value: true, label: "随品牌发布展示" },
|
||||
{ value: false, label: "保存为草稿" },
|
||||
]}
|
||||
/>
|
||||
|
||||
@@ -256,16 +256,16 @@ export function WorkspacePage() {
|
||||
<Space direction="vertical" size="large" style={{ width: "100%" }}>
|
||||
<AdminPageHeader
|
||||
title="模板与表单设置"
|
||||
description="日常内容请从品牌表达、业务提供项和信任内容进入;这里主要管理模板、咨询入口和负责人设置。"
|
||||
description="日常小程序内容请从页面配置、业务展示和信任证明进入;这里主要管理模板、咨询入口和负责人设置。"
|
||||
/>
|
||||
<Card title="先完成日常配置" style={{ marginBottom: 24 }}>
|
||||
<Typography.Paragraph type="secondary">
|
||||
下面这些入口面向日常经营,不需要理解模板或技术设置。完成后回到“配置与发布”统一检查并上线。
|
||||
</Typography.Paragraph>
|
||||
<Space wrap>
|
||||
<Button onClick={() => navigate("/admin/brand")}>完善品牌表达</Button>
|
||||
<Button onClick={() => navigate("/admin/services")}>添加业务提供项</Button>
|
||||
<Button onClick={() => navigate("/admin/trust")}>补充信任内容</Button>
|
||||
<Button onClick={() => navigate("/admin/brand")}>配置小程序页面</Button>
|
||||
<Button onClick={() => navigate("/admin/services")}>添加业务展示内容</Button>
|
||||
<Button onClick={() => navigate("/admin/trust")}>补充信任证明</Button>
|
||||
<Button type="primary" onClick={() => navigate("/admin/publication")}>
|
||||
检查并发布
|
||||
</Button>
|
||||
|
||||
@@ -185,7 +185,7 @@ function Dashboard({ onLogout, role }: { onLogout: () => void; role: string }) {
|
||||
children: [
|
||||
{ key: "overview", label: "当前品牌概览" },
|
||||
{ key: "publication", label: "配置与发布" },
|
||||
{ key: "brand", label: "品牌表达" },
|
||||
{ key: "brand", label: "小程序页面" },
|
||||
{ key: "trust", label: "信任内容" },
|
||||
{ key: "services", label: "业务提供项" },
|
||||
{ key: "inquiries", label: "咨询记录" },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaClient, type Prisma } from "@prisma/client";
|
||||
import { getTemplatePackageManifestForVisualKey } from "@personal-brand/config";
|
||||
import bcrypt from "bcryptjs";
|
||||
import { buildBrandReleaseSnapshot } from "../src/brand-release.service.js";
|
||||
import { getTemplateSampleContent } from "@personal-brand/config";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
@@ -20,7 +20,7 @@ const runtimeImages = {
|
||||
"https://images.unsplash.com/photo-1556761175-b413da4baf72?auto=format&fit=crop&w=1000&q=85",
|
||||
"https://images.unsplash.com/photo-1521737711867-e3b97375f902?auto=format&fit=crop&w=1000&q=85",
|
||||
],
|
||||
};
|
||||
} as const;
|
||||
|
||||
type OfferingKind = "service" | "product" | "package" | "subscription";
|
||||
|
||||
@@ -41,9 +41,10 @@ interface RuntimeSeedTemplate {
|
||||
type: string;
|
||||
title: string;
|
||||
content: string;
|
||||
summary?: string;
|
||||
config?: Record<string, unknown>;
|
||||
}>;
|
||||
inquiryForm: { name: string; fieldsSnapshot: Array<Record<string, unknown>> };
|
||||
inquiryForm?: { name: string; fieldsSnapshot: Array<Record<string, unknown>> };
|
||||
}
|
||||
|
||||
const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTemplate> = {
|
||||
@@ -51,6 +52,7 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
|
||||
templateKey: "personal",
|
||||
brandConfig: {
|
||||
visualTemplateKey: "linjing-editorial",
|
||||
templateData: { designPhilosophy: "先厘清问题,再设计表达" },
|
||||
founder: "林然",
|
||||
title: "品牌策略顾问",
|
||||
slogan: "用清晰的定位与可执行的表达,让专业被看见。",
|
||||
@@ -186,8 +188,6 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
|
||||
flowTitle: "从预订到取餐",
|
||||
},
|
||||
service: {
|
||||
coverageLabel: "取餐与配送",
|
||||
stepLabel: "步骤",
|
||||
processAction: "立即预订",
|
||||
},
|
||||
offerings: {
|
||||
@@ -277,24 +277,6 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
|
||||
},
|
||||
],
|
||||
trustContent: [
|
||||
{
|
||||
type: "schedule",
|
||||
title: "每周出摊日程",
|
||||
summary: "周一至周五晚餐与夜宵档",
|
||||
content: "二号校门外小吃商业街 · 17:00 - 22:30\n周六、周日承接团体单与夜市流动出摊",
|
||||
},
|
||||
{
|
||||
type: "coverage",
|
||||
title: "取餐与配送范围",
|
||||
summary: "提前预订,按约定时间取餐或配送",
|
||||
content: "摊位现场自取;满 3 份可配送至校内宿舍楼栋或实验楼门前。",
|
||||
},
|
||||
{
|
||||
type: "process",
|
||||
title: "定制餐品流程",
|
||||
summary: "从需求沟通到保温交付",
|
||||
content: "提交基本需求\n确认菜单与预算\n当日新鲜烹饪打包\n保温直达交付",
|
||||
},
|
||||
{
|
||||
type: "credential",
|
||||
title: "食品安全与制作承诺",
|
||||
@@ -312,20 +294,13 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
|
||||
content: "备料期 15 分钟内联系,出摊高峰 1 小时内回复。",
|
||||
},
|
||||
],
|
||||
inquiryForm: {
|
||||
name: "家庭聚餐咨询",
|
||||
fieldsSnapshot: [
|
||||
{ key: "name", label: "您的称呼", type: "text", required: true },
|
||||
{ key: "phone", label: "联系电话", type: "phone", required: true },
|
||||
{ key: "remark", label: "需求说明", type: "textarea", required: false },
|
||||
],
|
||||
},
|
||||
},
|
||||
doors: {
|
||||
templateKey: "doors",
|
||||
retiredOfferingNames: ["别墅入户大门", "院门与围合系统", "室内户内门系统"],
|
||||
brandConfig: {
|
||||
visualTemplateKey: "linjing-editorial",
|
||||
templateData: { designPhilosophy: "让门与空间建立长期、克制的关系" },
|
||||
founder: "林叙安 (Lin XUAN)",
|
||||
title: "高端门系统建筑研造主理人",
|
||||
slogan: "为当代别墅空间,定制有秩序感与呼吸感的门",
|
||||
@@ -679,40 +654,39 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
|
||||
};
|
||||
|
||||
async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTemplate): Promise<void> {
|
||||
const packageSample = getTemplateSampleContent(template.templateKey);
|
||||
const sampleOfferings = packageSample?.offerings ?? [];
|
||||
const offerings = template.offerings.map((item, index) => ({
|
||||
...item,
|
||||
...(sampleOfferings[index]
|
||||
? {
|
||||
name: sampleOfferings[index].name,
|
||||
summary: sampleOfferings[index].summary,
|
||||
config: {
|
||||
...item.config,
|
||||
categoryKey: sampleOfferings[index].categoryKey,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
}));
|
||||
// 模板 package 的 sampleContent 只用于导入预览;演示品牌使用明确的品牌 fixture,
|
||||
// 避免把模板示例内容误当成所有品牌的数据库初始数据。
|
||||
const trustContent = template.trustContent;
|
||||
const inquiryFields = (packageSample?.fields ?? template.inquiryForm.fieldsSnapshot).map(
|
||||
(field) => ({
|
||||
...field,
|
||||
...(Array.isArray(field.options)
|
||||
? {
|
||||
options: field.options.map((option) =>
|
||||
typeof option === "string" ? { label: option, value: option } : option,
|
||||
),
|
||||
}
|
||||
: {}),
|
||||
}),
|
||||
);
|
||||
// 这里只初始化明确的开发演示品牌;餐饮结构化槽位和表单取自对应 package,
|
||||
// 新增生产模板无需添加 seed 分支,品牌样例内容仍须由管理员显式导入。
|
||||
const offerings = template.offerings;
|
||||
const foodSample =
|
||||
template.templateKey === "food"
|
||||
? getTemplatePackageManifestForVisualKey("acheng-campus-food")?.sampleContent?.food
|
||||
: undefined;
|
||||
if (template.templateKey === "food" && !foodSample)
|
||||
throw new Error("Food development sample is missing");
|
||||
const trustContent = foodSample
|
||||
? foodSample.trustContent.map((item) => {
|
||||
const fixture = template.trustContent.find((entry) => entry.type === item.type);
|
||||
return { ...item, ...fixture, config: { ...item.config, ...fixture?.config } };
|
||||
})
|
||||
: template.trustContent;
|
||||
const inquiryFields = foodSample?.fields ?? template.inquiryForm?.fieldsSnapshot;
|
||||
const inquiryFormName = foodSample?.inquiryFormName ?? template.inquiryForm?.name;
|
||||
if (!inquiryFields?.length || !inquiryFormName)
|
||||
throw new Error("Development inquiry fixture is missing");
|
||||
const existingBrand = await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } });
|
||||
const existingConfig =
|
||||
existingBrand.config &&
|
||||
typeof existingBrand.config === "object" &&
|
||||
!Array.isArray(existingBrand.config)
|
||||
? (existingBrand.config as Record<string, unknown>)
|
||||
: {};
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: brandId },
|
||||
data: {
|
||||
config: template.brandConfig,
|
||||
config: { ...existingConfig, ...template.brandConfig } as Prisma.InputJsonValue,
|
||||
...(existingBrand.slug === "default-brand" && !existingBrand.avatarUrl
|
||||
? { avatarUrl: "/assets/owner/portrait.jpg" }
|
||||
: {}),
|
||||
},
|
||||
});
|
||||
for (const [sortOrder, item] of offerings.entries()) {
|
||||
@@ -747,7 +721,8 @@ async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTempla
|
||||
select: { id: true, name: true },
|
||||
});
|
||||
for (const [index, item] of incompleteOfferings.entries()) {
|
||||
const image = template.offerings[index % template.offerings.length].image;
|
||||
const image = template.offerings[index % template.offerings.length]?.image;
|
||||
if (!image) throw new Error("Development fixture has no offering image");
|
||||
await prisma.offering.update({
|
||||
where: { id: item.id },
|
||||
data: {
|
||||
@@ -764,9 +739,17 @@ async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTempla
|
||||
}
|
||||
for (const [sortOrder, item] of trustContent.entries()) {
|
||||
const existing = await prisma.trustContent.findFirst({
|
||||
where: { brandId, type: item.type, title: item.title },
|
||||
where: { brandId, type: item.type },
|
||||
orderBy: [{ isPublished: "desc" }, { sortOrder: "asc" }],
|
||||
});
|
||||
const data = { ...item, brandId, sortOrder, isPublished: true };
|
||||
const { config, ...fields } = item;
|
||||
const data = {
|
||||
...fields,
|
||||
brandId,
|
||||
sortOrder,
|
||||
isPublished: true,
|
||||
...(config === undefined ? {} : { config: config as Prisma.InputJsonValue }),
|
||||
};
|
||||
if (existing) await prisma.trustContent.update({ where: { id: existing.id }, data });
|
||||
else await prisma.trustContent.create({ data });
|
||||
}
|
||||
@@ -775,7 +758,7 @@ async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTempla
|
||||
orderBy: { createdAt: "asc" },
|
||||
});
|
||||
const formData = {
|
||||
name: template.inquiryForm.name,
|
||||
name: inquiryFormName,
|
||||
purpose: "inquiry",
|
||||
targetType: "brand",
|
||||
submissionAction: "create-inquiry",
|
||||
@@ -788,14 +771,14 @@ async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTempla
|
||||
}
|
||||
|
||||
async function ensureSeedRelease(brandId: string, actorId: string): Promise<void> {
|
||||
if (await prisma.brandRelease.findFirst({ where: { brandId } })) return;
|
||||
const snapshot = await buildBrandReleaseSnapshot(prisma, brandId);
|
||||
await prisma.brandRelease.deleteMany({ where: { brandId } });
|
||||
await prisma.brandRelease.create({
|
||||
data: {
|
||||
brandId,
|
||||
version: 1,
|
||||
status: "published",
|
||||
snapshot,
|
||||
snapshot: snapshot as unknown as Prisma.InputJsonValue,
|
||||
actorId,
|
||||
note: "seed 基线发布版本",
|
||||
},
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/** 仅恢复开发餐饮品牌的原型视觉槽位,不覆盖已有结构化编辑和发布历史。 */
|
||||
import "reflect-metadata";
|
||||
import fs from "node:fs";
|
||||
import { PrismaClient, type Prisma } from "@prisma/client";
|
||||
import { getTemplatePackageManifestForVisualKey } from "@personal-brand/config";
|
||||
import { BrandReleaseService } from "../src/brand-release.service.js";
|
||||
import { BrandReleaseApiService } from "../src/brand-release-api.service.js";
|
||||
import type { PrismaService } from "../src/prisma.service.js";
|
||||
const prisma = new PrismaClient();
|
||||
const note = "餐饮主理人原型视觉槽位迁移 v1";
|
||||
try {
|
||||
const brand = await prisma.brandProfile.findUniqueOrThrow({ where: { slug: "default-brand" } });
|
||||
const config = (brand.config ?? {}) as Record<string, unknown>;
|
||||
if (brand.templateKey !== "food" || config.visualTemplateKey !== "acheng-campus-food")
|
||||
throw new Error("Migration is restricted to the development food brand");
|
||||
const previous = await prisma.brandRelease.findFirst({
|
||||
where: { brandId: brand.id },
|
||||
orderBy: { version: "desc" },
|
||||
});
|
||||
if (await prisma.brandRelease.findFirst({ where: { brandId: brand.id, note } })) {
|
||||
console.log("Already migrated; no changes");
|
||||
} else {
|
||||
const trust = await prisma.trustContent.findMany({
|
||||
where: { brandId: brand.id },
|
||||
orderBy: [{ sortOrder: "asc" }, { createdAt: "asc" }],
|
||||
});
|
||||
const backup = `/tmp/food-owner-visual-backup-${Date.now()}.json`;
|
||||
fs.writeFileSync(backup, JSON.stringify({ brand, trust, previous }, null, 2), { mode: 0o600 });
|
||||
console.log(`Backup: ${backup}`);
|
||||
if (!process.argv.includes("--apply"))
|
||||
console.log("Dry run; pass --apply to migrate and publish");
|
||||
else {
|
||||
const sample =
|
||||
getTemplatePackageManifestForVisualKey("acheng-campus-food")!.sampleContent!.food!;
|
||||
const service = new BrandReleaseService(prisma as PrismaService);
|
||||
const publisher = new BrandReleaseApiService(prisma as PrismaService, service);
|
||||
await prisma.$transaction(async (tx) => {
|
||||
await tx.brandProfile.update({
|
||||
where: { id: brand.id },
|
||||
data: { avatarUrl: brand.avatarUrl || "/assets/owner/portrait.jpg" },
|
||||
});
|
||||
for (const type of ["credential", "case", "promise"]) {
|
||||
const item = trust.find((item) => item.type === type && item.isPublished);
|
||||
if (!item) continue;
|
||||
const defaults = sample.trustContent.find((item) => item.type === type)!;
|
||||
const existing = (item.config ?? {}) as Record<string, unknown>;
|
||||
// 只补迁移前已确认的开发样例内容;用户改写的正文不能被模板样例遮挡。
|
||||
const known =
|
||||
type === "credential"
|
||||
? item.content === "当天采购,现做现出餐;食具每日清洁消毒,按约定标注和分装。"
|
||||
: item.content === defaults.content;
|
||||
if (!known) continue;
|
||||
await tx.trustContent.update({
|
||||
where: { id: item.id },
|
||||
data: {
|
||||
config: { ...defaults.config, ...existing } as Prisma.InputJsonValue,
|
||||
},
|
||||
});
|
||||
}
|
||||
const readiness = await publisher.readiness(brand.id, tx);
|
||||
if (!readiness.ready)
|
||||
throw new Error(JSON.stringify(readiness.checks.filter((check) => !check.passed)));
|
||||
const snapshot = await service.buildSnapshot(brand.id, tx);
|
||||
await tx.brandRelease.updateMany({
|
||||
where: { brandId: brand.id, status: "published" },
|
||||
data: { status: "superseded" },
|
||||
});
|
||||
await tx.brandRelease.create({
|
||||
data: {
|
||||
brandId: brand.id,
|
||||
version: (previous?.version ?? 0) + 1,
|
||||
actorId: previous?.actorId ?? "content-migration",
|
||||
note,
|
||||
snapshot: snapshot as unknown as Prisma.InputJsonValue,
|
||||
},
|
||||
});
|
||||
});
|
||||
console.log(
|
||||
"Owner visual slots migrated and published; existing edits and historical releases retained",
|
||||
);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
/** 开发餐饮品牌的幂等内容迁移。保留旧记录为草稿,历史快照和提交不变。 */
|
||||
import "reflect-metadata";
|
||||
import fs from "node:fs";
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { getTemplatePackageManifestForVisualKey } from "@personal-brand/config";
|
||||
import { BrandReleaseService } from "../src/brand-release.service.js";
|
||||
import { BrandReleaseApiService } from "../src/brand-release-api.service.js";
|
||||
import type { PrismaService } from "../src/prisma.service.js";
|
||||
const prisma = new PrismaClient();
|
||||
const note = "餐饮模板结构化内容迁移 v3";
|
||||
try {
|
||||
const brand = await prisma.brandProfile.findUniqueOrThrow({ where: { slug: "default-brand" } });
|
||||
if (
|
||||
brand.templateKey !== "food" ||
|
||||
(brand.config as Record<string, unknown>)?.visualTemplateKey !== "acheng-campus-food"
|
||||
)
|
||||
throw new Error("Migration is restricted to the development food brand");
|
||||
const previous = await prisma.brandRelease.findFirst({
|
||||
where: { brandId: brand.id },
|
||||
orderBy: { version: "desc" },
|
||||
});
|
||||
if (previous?.note === note) {
|
||||
console.log("Already migrated; no changes");
|
||||
} else {
|
||||
const trust = await prisma.trustContent.findMany({
|
||||
where: { brandId: brand.id },
|
||||
orderBy: { updatedAt: "desc" },
|
||||
});
|
||||
const forms = await prisma.inquiryForm.findMany({ where: { brandId: brand.id } });
|
||||
const backup = `/tmp/food-template-content-backup-${Date.now()}.json`;
|
||||
fs.writeFileSync(backup, JSON.stringify({ brand, trust, forms, previous }, null, 2), {
|
||||
mode: 0o600,
|
||||
});
|
||||
console.log(`Backup: ${backup}`);
|
||||
if (!process.argv.includes("--apply")) {
|
||||
console.log("Dry run; pass --apply to migrate and publish");
|
||||
} else {
|
||||
const sample =
|
||||
getTemplatePackageManifestForVisualKey("acheng-campus-food")!.sampleContent!.food!;
|
||||
const releaseService = new BrandReleaseService(prisma as PrismaService);
|
||||
const publisher = new BrandReleaseApiService(prisma as PrismaService, releaseService);
|
||||
await prisma.$transaction(async (tx) => {
|
||||
for (const type of ["schedule", "coverage", "process"]) {
|
||||
const candidates = trust.filter((item) => item.type === type);
|
||||
const structured = candidates.find(
|
||||
(item) => item.config && Object.keys(item.config as object).length,
|
||||
);
|
||||
const current = structured ?? candidates[0];
|
||||
const defaults = sample.trustContent.find((item) => item.type === type)!;
|
||||
const config = {
|
||||
...defaults.config,
|
||||
...((structured?.config as Record<string, unknown>) ?? {}),
|
||||
};
|
||||
// 已有的结构化配置保留。旧配送记录中的用户地点保留在自取说明中。
|
||||
if (type === "coverage") {
|
||||
const custom = candidates.find(
|
||||
(item) =>
|
||||
item.title !== defaults.title && item.content !== "示例内容,待品牌主理人完善。",
|
||||
);
|
||||
if (custom && !structured)
|
||||
config.pickupDetail = `${custom.content}。${String(config.pickupDetail)}`;
|
||||
}
|
||||
if (type === "schedule") {
|
||||
if (config.weekdayDetail === "二号校门外小吃商业街 #07 号铺位 · 17:00 - 22:30")
|
||||
config.weekdayDetail = defaults.config!.weekdayDetail;
|
||||
if (config.weekendDetail === "白天承接团体单;晚间 18:00 - 23:00 体育馆南侧流动出摊")
|
||||
config.weekendDetail = defaults.config!.weekendDetail;
|
||||
const custom = candidates.find((item) => !item.config && item.summary && item.content);
|
||||
if (custom) {
|
||||
config.weekdayHours = custom.summary!.replace(/^周一(?:到|至)周五\s*/, "");
|
||||
config.weekendHours = custom.content.replace(/^周六(?:到|至)周(?:天|日)\s*/, "");
|
||||
}
|
||||
}
|
||||
if (current)
|
||||
await tx.trustContent.update({
|
||||
where: { id: current.id },
|
||||
data: {
|
||||
title: defaults.title,
|
||||
content: "",
|
||||
summary: null,
|
||||
config: config as Prisma.InputJsonValue,
|
||||
isPublished: true,
|
||||
},
|
||||
});
|
||||
else
|
||||
await tx.trustContent.create({
|
||||
data: {
|
||||
brandId: brand.id,
|
||||
type,
|
||||
title: defaults.title,
|
||||
content: "",
|
||||
config: config as Prisma.InputJsonValue,
|
||||
isPublished: true,
|
||||
},
|
||||
});
|
||||
await tx.trustContent.updateMany({
|
||||
where: {
|
||||
brandId: brand.id,
|
||||
type,
|
||||
id: {
|
||||
in: candidates.filter((item) => item.id !== current?.id).map((item) => item.id),
|
||||
},
|
||||
},
|
||||
data: { isPublished: false },
|
||||
});
|
||||
}
|
||||
const supportedTypes = getTemplatePackageManifestForVisualKey(
|
||||
"acheng-campus-food",
|
||||
)!.trustContentTypes!.map((item) => item.type);
|
||||
await tx.trustContent.updateMany({
|
||||
where: { brandId: brand.id, type: { notIn: supportedTypes } },
|
||||
data: { isPublished: false },
|
||||
});
|
||||
const form = forms.find((item) => item.targetType === "brand" && item.isEnabled);
|
||||
if (!form) throw new Error("Expected existing brand inquiry form");
|
||||
const oldFields = form.fieldsSnapshot as Array<Record<string, unknown>>;
|
||||
const keys = new Set(sample.fields.map((field) => field.key));
|
||||
const fields = [
|
||||
...sample.fields.map((field) => ({
|
||||
...field,
|
||||
...oldFields.find((old) => old.key === field.key),
|
||||
})),
|
||||
...oldFields.filter((field) => !keys.has(String(field.key))),
|
||||
];
|
||||
await tx.inquiryForm.update({
|
||||
where: { id: form.id },
|
||||
data: {
|
||||
name: sample.inquiryFormName,
|
||||
fieldsSnapshot: fields as Prisma.InputJsonValue,
|
||||
version: { increment: 1 },
|
||||
},
|
||||
});
|
||||
const readiness = await publisher.readiness(brand.id, tx);
|
||||
if (!readiness.ready)
|
||||
throw new Error(JSON.stringify(readiness.checks.filter((check) => !check.passed)));
|
||||
const snapshot = await releaseService.buildSnapshot(brand.id, tx);
|
||||
await tx.brandRelease.updateMany({
|
||||
where: { brandId: brand.id, status: "published" },
|
||||
data: { status: "superseded" },
|
||||
});
|
||||
await tx.brandRelease.create({
|
||||
data: {
|
||||
brandId: brand.id,
|
||||
version: (previous?.version ?? 0) + 1,
|
||||
actorId: previous?.actorId ?? "content-migration",
|
||||
note,
|
||||
snapshot: snapshot as unknown as Prisma.InputJsonValue,
|
||||
},
|
||||
});
|
||||
});
|
||||
console.log("Migrated and published development food brand; old content retained as drafts");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": { "rootDir": "..", "noEmit": true },
|
||||
"include": ["*.ts", "../src/**/*.ts", "../prisma/seed.ts"]
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
import fs from "node:fs";
|
||||
import vm from "node:vm";
|
||||
import assert from "node:assert/strict";
|
||||
process.env.NODE_ENV = "test";
|
||||
const { createApp } = await import("../dist/main.js");
|
||||
const app = await createApp();
|
||||
try {
|
||||
await app.init();
|
||||
const response = await app
|
||||
.getHttpAdapter()
|
||||
.getInstance()
|
||||
.inject({ method: "GET", url: "/public/workspace?brandSlug=default-brand" });
|
||||
assert.equal(response.statusCode, 200);
|
||||
const workspace = JSON.parse(response.body) as Record<string, unknown>;
|
||||
const trustItems = workspace.trustItems as { id?: string }[];
|
||||
assert.ok(trustItems.every((item) => typeof item.id === "string"));
|
||||
const live = await fetch(
|
||||
`http://127.0.0.1:${process.env.API_PORT ?? 3001}/public/workspace?brandSlug=default-brand`,
|
||||
);
|
||||
assert.equal(live.status, 200);
|
||||
const liveWorkspace = (await live.json()) as Record<string, unknown>;
|
||||
assert.deepEqual(liveWorkspace.trustItems, workspace.trustItems);
|
||||
assert.deepEqual(liveWorkspace.inquiryForms, workspace.inquiryForms);
|
||||
fs.writeFileSync("/tmp/food-template-public-workspace.json", JSON.stringify(workspace, null, 2));
|
||||
let page:
|
||||
| {
|
||||
data: Record<string, unknown>;
|
||||
load: () => Promise<void>;
|
||||
setData: (value: Record<string, unknown>) => void;
|
||||
}
|
||||
| undefined;
|
||||
vm.runInNewContext(
|
||||
fs.readFileSync("../../dist/miniapp/default-brand/pages/stall-service/index.js", "utf8"),
|
||||
{
|
||||
Page(value: typeof page) {
|
||||
page = value;
|
||||
},
|
||||
require(name: string) {
|
||||
return name.includes("runtime-workspace")
|
||||
? { loadWorkspaceWithFallback: () => Promise.resolve(workspace) }
|
||||
: { openPage() {} };
|
||||
},
|
||||
},
|
||||
);
|
||||
assert.ok(page);
|
||||
page.setData = (data) => Object.assign(page!.data, data);
|
||||
await page.load();
|
||||
const data = page.data as {
|
||||
schedule: { rows: unknown[] };
|
||||
coverage: { config: { pickupDetail: string; deliveryDetail: string } };
|
||||
process: { steps: unknown[] };
|
||||
};
|
||||
assert.equal(data.schedule.rows.length, 2);
|
||||
assert.ok(data.coverage.config.pickupDetail && data.coverage.config.deliveryDetail);
|
||||
assert.equal(data.process.steps.length, 4);
|
||||
const forms = workspace.inquiryForms as { fields: { key: string }[] }[];
|
||||
for (const key of ["type", "people", "date", "budget", "delivery", "remark", "phone"])
|
||||
assert.ok(forms.some((form) => form.fields.some((field) => field.key === key)));
|
||||
fs.writeFileSync("/tmp/food-template-service-page-data.json", JSON.stringify(page.data, null, 2));
|
||||
let inquiry:
|
||||
| {
|
||||
data: Record<string, unknown>;
|
||||
onLoad: (options: Record<string, unknown>) => Promise<void>;
|
||||
setData: (value: Record<string, unknown>) => void;
|
||||
}
|
||||
| undefined;
|
||||
vm.runInNewContext(
|
||||
fs.readFileSync("../../dist/miniapp/default-brand/pages/inquiry/index.js", "utf8"),
|
||||
{
|
||||
Page(value: typeof inquiry) {
|
||||
inquiry = value;
|
||||
},
|
||||
require(name: string) {
|
||||
return name.includes("runtime-workspace")
|
||||
? { loadWorkspaceWithFallback: () => Promise.resolve(workspace) }
|
||||
: {};
|
||||
},
|
||||
},
|
||||
);
|
||||
assert.ok(inquiry);
|
||||
inquiry.setData = (value) => Object.assign(inquiry!.data, value);
|
||||
await inquiry.onLoad({});
|
||||
const inquiryFields = inquiry.data.fields as {
|
||||
key: string;
|
||||
useChips: boolean;
|
||||
halfWidth: boolean;
|
||||
}[];
|
||||
assert.equal(inquiryFields.find((field) => field.key === "type")?.useChips, true);
|
||||
assert.equal(inquiryFields.filter((field) => field.halfWidth).length, 4);
|
||||
fs.writeFileSync(
|
||||
"/tmp/food-template-inquiry-page-data.json",
|
||||
JSON.stringify(inquiry.data, null, 2),
|
||||
);
|
||||
console.log(
|
||||
"Actual database -> published API -> generated page: 2 schedule cards, 2 delivery columns, 4 steps, food inquiry fields verified",
|
||||
);
|
||||
const doorsResponse = await app
|
||||
.getHttpAdapter()
|
||||
.getInstance()
|
||||
.inject({ method: "GET", url: "/public/workspace?brandSlug=linjing-doors" });
|
||||
assert.equal(doorsResponse.statusCode, 200);
|
||||
const doors = JSON.parse(doorsResponse.body) as {
|
||||
trustItems: { type: string; content: string; config: Record<string, unknown> }[];
|
||||
trustPresentation: Record<string, unknown>;
|
||||
};
|
||||
assert.equal(
|
||||
doors.trustItems.some((item: { type: string }) => item.type === "profile"),
|
||||
false,
|
||||
);
|
||||
const credentials = doors.trustItems.filter(
|
||||
(item: { type: string }) => item.type === "credential",
|
||||
);
|
||||
const primary = credentials.find(
|
||||
(item: { config: object }) => Object.keys(item.config).length > 0,
|
||||
);
|
||||
assert.ok(primary);
|
||||
assert.deepEqual(doors.trustPresentation.stats, primary.config.stats);
|
||||
const liveDoors = await fetch(
|
||||
`http://127.0.0.1:${process.env.API_PORT ?? 3001}/public/workspace?brandSlug=linjing-doors`,
|
||||
);
|
||||
assert.equal(liveDoors.status, 200);
|
||||
const liveDoorsWorkspace = (await liveDoors.json()) as Record<string, unknown>;
|
||||
assert.deepEqual(liveDoorsWorkspace.trustPresentation, doors.trustPresentation);
|
||||
type DoorsPage = {
|
||||
data: { trustPresentation: { bio: string } };
|
||||
setData: (value: object) => void;
|
||||
onLoad: () => void;
|
||||
};
|
||||
let doorsPage: DoorsPage | undefined;
|
||||
vm.runInNewContext(
|
||||
fs.readFileSync("../../dist/miniapp/linjing-doors/pages/index/index.js", "utf8"),
|
||||
{
|
||||
Page(value: DoorsPage) {
|
||||
doorsPage = value;
|
||||
},
|
||||
require() {
|
||||
return { loadWorkspaceWithFallback: () => Promise.resolve(doors) };
|
||||
},
|
||||
wx: { setNavigationBarTitle() {} },
|
||||
},
|
||||
);
|
||||
assert.ok(doorsPage);
|
||||
doorsPage.setData = (value: object) => Object.assign(doorsPage!.data, value);
|
||||
doorsPage.onLoad();
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
assert.equal(doorsPage.data.trustPresentation.bio, primary.content);
|
||||
fs.writeFileSync("/tmp/linjing-template-page-data.json", JSON.stringify(doorsPage.data, null, 2));
|
||||
console.log(
|
||||
"Linjing published API -> generated page: declared credential stats and biography verified; obsolete profile excluded",
|
||||
);
|
||||
} finally {
|
||||
await app.close();
|
||||
}
|
||||
@@ -183,6 +183,11 @@ class AdminWorkspaceController {
|
||||
? {
|
||||
displayName: manifest.displayName,
|
||||
admin: manifest.admin,
|
||||
navigation: manifest.navigation.map(({ key, label, page }) => ({ key, label, page })),
|
||||
templateFields: (manifest.templateFields ?? []).map((field) => ({
|
||||
...field,
|
||||
binding: field.binding ?? `brand.config.templateData.${field.key}`,
|
||||
})),
|
||||
assetSlots: manifest.assetSlots,
|
||||
trustContentTypes: manifest.trustContentTypes ?? [],
|
||||
}
|
||||
@@ -244,7 +249,10 @@ class AdminWorkspaceController {
|
||||
offerings: sample.offerings.length,
|
||||
trustContent: sample.trustContent.length,
|
||||
fields: sample.fields.length,
|
||||
inquiryForms: 1,
|
||||
},
|
||||
willCreateInquiryForm:
|
||||
(await this.prisma.inquiryForm.count({ where: { brandId, isEnabled: true } })) === 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -255,6 +263,8 @@ class AdminWorkspaceController {
|
||||
const templateKey = await this.templateWorkspace.getEffectiveTemplateKey(brandId);
|
||||
const sample = getTemplateSampleContent(templateKey);
|
||||
if (!sample) throw new BadRequestException("模板示例内容不存在");
|
||||
const fieldIssues = validateFieldSnapshot(sample.fields);
|
||||
if (fieldIssues.length) throw new BadRequestException("模板咨询表单示例字段无效");
|
||||
const existing = await this.prisma.brandFieldDefinition.count({
|
||||
where: { brandId, source: "sample" },
|
||||
});
|
||||
@@ -280,6 +290,7 @@ class AdminWorkspaceController {
|
||||
type: item.type,
|
||||
title: item.title,
|
||||
content: item.content,
|
||||
...(item.config ? { config: item.config as Prisma.InputJsonValue } : {}),
|
||||
sortOrder,
|
||||
isPublished: false,
|
||||
})),
|
||||
@@ -296,6 +307,20 @@ class AdminWorkspaceController {
|
||||
required: item.required,
|
||||
})),
|
||||
});
|
||||
const hasEnabledForm = await tx.inquiryForm.count({ where: { brandId, isEnabled: true } });
|
||||
const inquiryForm = hasEnabledForm
|
||||
? null
|
||||
: await tx.inquiryForm.create({
|
||||
data: {
|
||||
brandId,
|
||||
name: sample.inquiryFormName,
|
||||
purpose: "inquiry",
|
||||
targetType: "brand",
|
||||
submissionAction: "create-inquiry",
|
||||
fieldsSnapshot: sample.fields,
|
||||
isEnabled: true,
|
||||
},
|
||||
});
|
||||
await tx.capabilityAuditLog.create({
|
||||
data: {
|
||||
brandId,
|
||||
@@ -303,10 +328,20 @@ class AdminWorkspaceController {
|
||||
actorId: identity.subject,
|
||||
action: "sample_content_imported",
|
||||
toStatus: "enabled",
|
||||
config: { offerings: offerings.count, trustContent: trust.count, fields: fields.count },
|
||||
config: {
|
||||
offerings: offerings.count,
|
||||
trustContent: trust.count,
|
||||
fields: fields.count,
|
||||
inquiryForms: inquiryForm ? 1 : 0,
|
||||
},
|
||||
},
|
||||
});
|
||||
return { offerings: offerings.count, trustContent: trust.count, fields: fields.count };
|
||||
return {
|
||||
offerings: offerings.count,
|
||||
trustContent: trust.count,
|
||||
fields: fields.count,
|
||||
inquiryForms: inquiryForm ? 1 : 0,
|
||||
};
|
||||
});
|
||||
return { imported: true, counts: result };
|
||||
}
|
||||
|
||||
@@ -56,28 +56,25 @@ export class ChangeAdminPasswordDto {
|
||||
}
|
||||
|
||||
export class CreateTrustContentDto {
|
||||
@IsIn(["schedule", "coverage", "process", "credential", "case", "promise"])
|
||||
type!: string;
|
||||
@IsString() type!: string;
|
||||
@IsString() title!: string;
|
||||
@IsOptional() @IsString() summary?: string;
|
||||
@IsString() content!: string;
|
||||
@IsOptional() @IsString() coverUrl?: string;
|
||||
@IsOptional() @IsInt() @Min(0) @Max(9999) sortOrder?: number;
|
||||
@IsOptional() @IsBoolean() isPublished?: boolean;
|
||||
@IsOptional() config?: Record<string, unknown>;
|
||||
@IsOptional() @IsObject() config?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class UpdateTrustContentDto {
|
||||
@IsOptional()
|
||||
@IsIn(["schedule", "coverage", "process", "credential", "case", "promise"])
|
||||
type?: string;
|
||||
@IsOptional() @IsString() type?: string;
|
||||
@IsOptional() @IsString() title?: string;
|
||||
@IsOptional() @IsString() summary?: string;
|
||||
@IsOptional() @IsString() content?: string;
|
||||
@IsOptional() @IsString() coverUrl?: string;
|
||||
@IsOptional() @IsInt() @Min(0) @Max(9999) sortOrder?: number;
|
||||
@IsOptional() @IsBoolean() isPublished?: boolean;
|
||||
@IsOptional() config?: Record<string, unknown>;
|
||||
@IsOptional() @IsObject() config?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class UpdateBookingStatusDto {
|
||||
@@ -125,7 +122,7 @@ export class CreateOfferingDto {
|
||||
@IsOptional() @IsInt() @Min(0) priceAmount?: number;
|
||||
@IsOptional() @IsInt() @Min(0) @Max(9999) sortOrder?: number;
|
||||
@IsOptional() @IsBoolean() isEnabled?: boolean;
|
||||
@IsOptional() config?: Record<string, unknown>;
|
||||
@IsOptional() @IsObject() config?: Record<string, unknown>;
|
||||
@IsOptional() sections?: Array<{
|
||||
type: string;
|
||||
title: string;
|
||||
@@ -146,7 +143,7 @@ export class UpdateOfferingDto {
|
||||
@IsOptional() @IsInt() @Min(0) priceAmount?: number;
|
||||
@IsOptional() @IsInt() @Min(0) @Max(9999) sortOrder?: number;
|
||||
@IsOptional() @IsBoolean() isEnabled?: boolean;
|
||||
@IsOptional() config?: Record<string, unknown>;
|
||||
@IsOptional() @IsObject() config?: Record<string, unknown>;
|
||||
@IsOptional() sections?: Array<{
|
||||
type: string;
|
||||
title: string;
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
getDefaultVisualTemplateKey,
|
||||
getTemplatePackageManifestForVisualKey,
|
||||
} from "@personal-brand/config";
|
||||
import { isTrustContentComplete } from "@personal-brand/types";
|
||||
import { PrismaService } from "./prisma.service.js";
|
||||
import { BrandReleaseService } from "./brand-release.service.js";
|
||||
import { validateFieldSnapshot } from "@personal-brand/validation";
|
||||
@@ -80,11 +81,14 @@ export class BrandReleaseApiService {
|
||||
}),
|
||||
database.trustContent.findMany({
|
||||
where: { brandId, isPublished: true },
|
||||
select: { type: true, title: true, content: true },
|
||||
select: { type: true, title: true, content: true, config: true },
|
||||
}),
|
||||
]);
|
||||
const validTrustItems = trustItems.filter(
|
||||
(item) => item.title.trim().length > 0 && item.content.trim().length > 0,
|
||||
const validTrustItems = trustItems.filter((item) =>
|
||||
isTrustContentComplete(
|
||||
item,
|
||||
packageManifest?.trustContentTypes?.find((type) => type.type === item.type),
|
||||
),
|
||||
);
|
||||
const offeringIds = new Set(offerings.map((item) => item.id));
|
||||
const usableForms = forms.filter(
|
||||
@@ -145,8 +149,19 @@ export class BrandReleaseApiService {
|
||||
checks.push({
|
||||
key: `trust:${type.type}`,
|
||||
label: `请完善${type.label}`,
|
||||
passed: publishedTrustTypes.has(type.type),
|
||||
help: ["标题和详细内容都填写后才能发布。", type.help].filter(Boolean).join(" "),
|
||||
passed:
|
||||
publishedTrustTypes.has(type.type) &&
|
||||
(type.maxPublishedItems === undefined ||
|
||||
trustItems.filter((item) => item.type === type.type).length <= type.maxPublishedItems),
|
||||
help: [
|
||||
"请完整填写该区块的可编辑字段。",
|
||||
type.maxPublishedItems === undefined
|
||||
? undefined
|
||||
: `此区块最多保留 ${type.maxPublishedItems} 条公开记录。`,
|
||||
type.help,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" "),
|
||||
destination: "/admin/trust",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -80,7 +80,15 @@ export class AdminConfigController {
|
||||
current?.config && typeof current.config === "object" && !Array.isArray(current.config)
|
||||
? (current.config as Record<string, unknown>)
|
||||
: {};
|
||||
const nextConfig = config ? { ...currentConfig, ...config } : undefined;
|
||||
const nextConfig = {
|
||||
...currentConfig,
|
||||
...(config ?? {}),
|
||||
// 兼容旧模板:品牌简介的唯一编辑入口是 BrandProfile.description,
|
||||
// 旧视觉模板仍从 config.slogan 读取,保存时保持两者同步。
|
||||
...(fields.description !== undefined && config?.slogan === undefined
|
||||
? { slogan: fields.description }
|
||||
: {}),
|
||||
};
|
||||
if (config?.visualTemplateKey && config.visualTemplateKey !== currentConfig.visualTemplateKey) {
|
||||
const templateKey = await this.templateWorkspace.getEffectiveTemplateKey(
|
||||
this.brandId(request),
|
||||
@@ -121,7 +129,7 @@ export class AdminConfigController {
|
||||
where: { id: this.brandId(request) },
|
||||
data: {
|
||||
...fields,
|
||||
...(nextConfig ? { config: nextConfig as Prisma.InputJsonValue } : {}),
|
||||
...(Object.keys(nextConfig).length ? { config: nextConfig } : {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -300,34 +308,17 @@ export class AdminConfigController {
|
||||
@Body() body: CreateTrustContentDto,
|
||||
): Promise<unknown> {
|
||||
this.requireAdmin(request);
|
||||
const { config, ...fields } = body;
|
||||
return this.prisma.trustContent.create({
|
||||
data: {
|
||||
...fields,
|
||||
brandId: this.brandId(request),
|
||||
...(config === undefined ? {} : { config: config as Prisma.InputJsonValue }),
|
||||
},
|
||||
});
|
||||
const brandId = this.brandId(request);
|
||||
return this.templateWorkspace.createTrustContent(brandId, body);
|
||||
}
|
||||
@Patch("trust-content/:id")
|
||||
async updateTrustContent(
|
||||
updateTrustContent(
|
||||
@Req() request: FastifyRequest,
|
||||
@Param("id") id: string,
|
||||
@Body() body: UpdateTrustContentDto,
|
||||
): Promise<unknown> {
|
||||
this.requireAdmin(request);
|
||||
const item = await this.prisma.trustContent.findFirst({
|
||||
where: { id, brandId: this.brandId(request) },
|
||||
});
|
||||
if (!item) throw new BadRequestException("信任内容不存在");
|
||||
const { config, ...fields } = body;
|
||||
return this.prisma.trustContent.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...fields,
|
||||
...(config === undefined ? {} : { config: config as Prisma.InputJsonValue }),
|
||||
},
|
||||
});
|
||||
return this.templateWorkspace.updateTrustContent(this.brandId(request), id, body);
|
||||
}
|
||||
@Delete("trust-content/:id")
|
||||
async deleteTrustContent(
|
||||
|
||||
@@ -18,6 +18,13 @@ import type {
|
||||
RuntimeTrustItem,
|
||||
RuntimeWorkspace,
|
||||
} from "@personal-brand/types";
|
||||
import {
|
||||
projectBrandAliases,
|
||||
projectOfferingDetails,
|
||||
projectTemplateData,
|
||||
projectTrustItem,
|
||||
projectTrustPresentation,
|
||||
} from "@personal-brand/types";
|
||||
|
||||
@Controller("public/workspace")
|
||||
export class PublicWorkspaceController {
|
||||
@@ -113,15 +120,19 @@ export class PublicWorkspaceController {
|
||||
const templatePackageManifest =
|
||||
releaseSnapshot.templatePackageManifest ??
|
||||
getTemplatePackageManifestForVisualKey(visualTemplateKey);
|
||||
const runtimeBrand = {
|
||||
...brandData,
|
||||
...brandConfig,
|
||||
};
|
||||
// 标准 BrandProfile 字段优先,兼容旧模板仍使用的 config 字段。
|
||||
// 这样后台编辑 description/contactPhone 等标准字段后,旧模板也会立即读取新值。
|
||||
const runtimeBrand = projectBrandAliases(brandData, brandConfig);
|
||||
const declaredTemplateFields = templatePackageManifest?.templateFields ?? [];
|
||||
const templateData = projectTemplateData(
|
||||
brandConfig,
|
||||
declaredTemplateFields.map((field) => field.key),
|
||||
);
|
||||
const runtimeOfferings: RuntimeOffering[] = offeringsData.map((raw) => {
|
||||
const item = raw;
|
||||
const config = this.jsonObject(item.config);
|
||||
const sections = Array.isArray(config.sections) ? config.sections : [];
|
||||
const details = this.jsonObject(config.details);
|
||||
const details = projectOfferingDetails(config);
|
||||
const media = Array.isArray(config.media)
|
||||
? config.media.flatMap((entry) => {
|
||||
const value = this.jsonObject(entry);
|
||||
@@ -139,14 +150,6 @@ export class PublicWorkspaceController {
|
||||
: [];
|
||||
})
|
||||
: [];
|
||||
const materialsList = Array.isArray(details.materialsList)
|
||||
? details.materialsList.flatMap((entry) => {
|
||||
const value = this.jsonObject(entry);
|
||||
return typeof value.name === "string" && typeof value.spec === "string"
|
||||
? [{ name: value.name, spec: value.spec }]
|
||||
: [];
|
||||
})
|
||||
: [];
|
||||
return {
|
||||
id: this.string(item.id),
|
||||
name: this.string(item.name),
|
||||
@@ -187,12 +190,10 @@ export class PublicWorkspaceController {
|
||||
: [],
|
||||
media,
|
||||
details: {
|
||||
background: typeof details.background === "string" ? details.background : "",
|
||||
designConcept: typeof details.designConcept === "string" ? details.designConcept : "",
|
||||
crafts: Array.isArray(details.crafts)
|
||||
? details.crafts.filter((craft): craft is string => typeof craft === "string")
|
||||
: [],
|
||||
materialsList,
|
||||
background: details.background,
|
||||
designConcept: details.designConcept,
|
||||
crafts: details.crafts,
|
||||
materialsList: details.materialsList,
|
||||
},
|
||||
},
|
||||
sections: sections
|
||||
@@ -211,18 +212,25 @@ export class PublicWorkspaceController {
|
||||
if (!field || typeof field !== "object") return [];
|
||||
const value = field as Record<string, unknown>;
|
||||
if (typeof value.key !== "string" || typeof value.label !== "string") return [];
|
||||
const type = [
|
||||
"text",
|
||||
"tel",
|
||||
"number",
|
||||
"select",
|
||||
"radio",
|
||||
"checkbox",
|
||||
"textarea",
|
||||
"date",
|
||||
].includes(this.string(value.type))
|
||||
? (value.type as RuntimeInquiryField["type"])
|
||||
: "text";
|
||||
const sourceType = this.string(value.type);
|
||||
const type =
|
||||
sourceType === "phone"
|
||||
? "tel"
|
||||
: sourceType === "multi-select"
|
||||
? "checkbox"
|
||||
: [
|
||||
"text",
|
||||
"tel",
|
||||
"number",
|
||||
"select",
|
||||
"radio",
|
||||
"checkbox",
|
||||
"checkbox",
|
||||
"textarea",
|
||||
"date",
|
||||
].includes(sourceType)
|
||||
? (sourceType as RuntimeInquiryField["type"])
|
||||
: "text";
|
||||
const options = Array.isArray(value.options)
|
||||
? value.options.flatMap((option) => {
|
||||
if (typeof option === "string") return [{ label: option, value: option }];
|
||||
@@ -243,28 +251,14 @@ export class PublicWorkspaceController {
|
||||
},
|
||||
];
|
||||
});
|
||||
const trustPresentation = trustData.reduce<Record<string, unknown>>((result, raw) => {
|
||||
const item = this.jsonObject(raw);
|
||||
const config = this.jsonObject(item.config);
|
||||
for (const [key, value] of Object.entries(config)) {
|
||||
if (!(key in result)) result[key] = value;
|
||||
}
|
||||
if (item.type === "profile" && typeof result.bio !== "string") result.bio = item.content;
|
||||
return result;
|
||||
}, {});
|
||||
const trustDeclarations = templatePackageManifest?.trustContentTypes ?? [];
|
||||
const trustItems: RuntimeTrustItem[] = trustData.flatMap((raw) => {
|
||||
const item = this.jsonObject(raw);
|
||||
if (typeof item.type !== "string" || typeof item.title !== "string") return [];
|
||||
return [
|
||||
{
|
||||
type: item.type,
|
||||
title: item.title,
|
||||
summary: typeof item.summary === "string" ? item.summary : null,
|
||||
content: typeof item.content === "string" ? item.content : "",
|
||||
config: this.jsonObject(item.config),
|
||||
},
|
||||
];
|
||||
const item = projectTrustItem(this.jsonObject(raw));
|
||||
return item && trustDeclarations.some((declaration) => declaration.type === item.type)
|
||||
? [item]
|
||||
: [];
|
||||
});
|
||||
const trustPresentation = projectTrustPresentation(trustItems, trustDeclarations);
|
||||
const runtimeWorkspace: RuntimeWorkspace = {
|
||||
schemaVersion: "1.0.0",
|
||||
publication: {
|
||||
@@ -273,6 +267,7 @@ export class PublicWorkspaceController {
|
||||
publishedAt: release.createdAt.toISOString(),
|
||||
},
|
||||
brand: runtimeBrand,
|
||||
templateData,
|
||||
navigation: {
|
||||
tabs:
|
||||
templatePackageManifest?.navigation.map((tab) => ({
|
||||
|
||||
@@ -5,14 +5,61 @@ import {
|
||||
getVisualTemplate,
|
||||
getVisualTemplateManifest,
|
||||
getDefaultVisualTemplateKey,
|
||||
getTemplatePackageManifestForVisualKey,
|
||||
isVisualTemplateCompatible,
|
||||
} from "@personal-brand/config";
|
||||
import type { CreateTrustContentDto, UpdateTrustContentDto } from "./admin.dto.js";
|
||||
import type { BrandTemplateKey } from "@personal-brand/types";
|
||||
import { PrismaService } from "./prisma.service.js";
|
||||
|
||||
@Injectable()
|
||||
export class TemplateWorkspaceService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
async getTrustContentTypes(brandId: string): Promise<string[]> {
|
||||
const brand = await this.prisma.brandProfile.findUnique({
|
||||
where: { id: brandId },
|
||||
select: { templateKey: true, config: true },
|
||||
});
|
||||
const config =
|
||||
brand?.config && typeof brand.config === "object" && !Array.isArray(brand.config)
|
||||
? (brand.config as Record<string, unknown>)
|
||||
: {};
|
||||
const visualKey =
|
||||
typeof config.visualTemplateKey === "string"
|
||||
? config.visualTemplateKey
|
||||
: getDefaultVisualTemplateKey(brand?.templateKey ?? "personal");
|
||||
return (
|
||||
getTemplatePackageManifestForVisualKey(visualKey)?.trustContentTypes?.map(
|
||||
(item) => item.type,
|
||||
) ?? []
|
||||
);
|
||||
}
|
||||
async createTrustContent(brandId: string, body: CreateTrustContentDto) {
|
||||
if (!(await this.getTrustContentTypes(brandId)).includes(body.type))
|
||||
throw new BadRequestException("当前模板不支持此信任内容类型");
|
||||
const { config, ...fields } = body;
|
||||
return this.prisma.trustContent.create({
|
||||
data: {
|
||||
...fields,
|
||||
brandId,
|
||||
...(config === undefined ? {} : { config: config as Prisma.InputJsonValue }),
|
||||
},
|
||||
});
|
||||
}
|
||||
async updateTrustContent(brandId: string, id: string, body: UpdateTrustContentDto) {
|
||||
const item = await this.prisma.trustContent.findFirst({ where: { id, brandId } });
|
||||
if (!item) throw new BadRequestException("信任内容不存在");
|
||||
if (body.type !== undefined && !(await this.getTrustContentTypes(brandId)).includes(body.type))
|
||||
throw new BadRequestException("当前模板不支持此信任内容类型");
|
||||
const { config, ...fields } = body;
|
||||
return this.prisma.trustContent.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...fields,
|
||||
...(config === undefined ? {} : { config: config as Prisma.InputJsonValue }),
|
||||
},
|
||||
});
|
||||
}
|
||||
async getEffectiveTemplateKey(brandId: string): Promise<BrandTemplateKey> {
|
||||
const [installation, brand] = await Promise.all([
|
||||
this.prisma.brandTemplateInstallation.findFirst({
|
||||
|
||||
@@ -28,6 +28,211 @@ after(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
|
||||
test("food structured edits survive publication and reach the generated page slots", async () => {
|
||||
const { readFileSync } = await import("node:fs");
|
||||
const { runInNewContext } = await import("node:vm");
|
||||
const user = await prisma.adminUser.findUniqueOrThrow({ where: { username: "admin" } });
|
||||
const headers = {
|
||||
authorization: `Bearer ${signIdentity({ subject: user.id, brandId, role: "admin" })}`,
|
||||
};
|
||||
const records = await prisma.trustContent.findMany({
|
||||
where: {
|
||||
brandId,
|
||||
type: { in: ["schedule", "coverage", "process", "credential", "case", "promise"] },
|
||||
isPublished: true,
|
||||
},
|
||||
});
|
||||
const latest = await prisma.brandRelease.findFirstOrThrow({
|
||||
where: { brandId },
|
||||
orderBy: { version: "desc" },
|
||||
});
|
||||
const before = JSON.parse((await request("/public/workspace")).body);
|
||||
try {
|
||||
for (const item of records) {
|
||||
const url = `/admin/config/trust-content/${item.id}`;
|
||||
assert.equal(
|
||||
(await request(url, { method: "PATCH", payload: { config: {} } })).statusCode,
|
||||
401,
|
||||
);
|
||||
assert.equal(
|
||||
(
|
||||
await request(url, {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
payload: { config: {} },
|
||||
})
|
||||
).statusCode,
|
||||
403,
|
||||
);
|
||||
assert.equal(
|
||||
(await request(url, { method: "PATCH", headers, payload: { config: "invalid" } }))
|
||||
.statusCode,
|
||||
400,
|
||||
);
|
||||
const config = { ...item.config };
|
||||
if (item.type === "schedule") {
|
||||
config.weekdayDetail = "测试工作日地点";
|
||||
config.weekendDetail = "测试周末地点";
|
||||
}
|
||||
if (item.type === "coverage") {
|
||||
config.pickupDetail = "测试自取说明";
|
||||
config.deliveryDetail = "测试配送说明";
|
||||
}
|
||||
if (item.type === "process")
|
||||
config.steps = [{ title: "测试第一步", detail: "测试步骤说明" }, ...config.steps.slice(1)];
|
||||
if (item.type === "credential")
|
||||
config.standards = [{ title: "编辑后的卫生标准", detail: "编辑后的说明" }];
|
||||
if (item.type === "case")
|
||||
config.entries = [
|
||||
{ badge: "测", title: "编辑后的合作案例", detail: "编辑后的交付", result: "完成" },
|
||||
];
|
||||
if (item.type === "promise")
|
||||
config.commitments = [
|
||||
{ label: "测试时段", detail: "编辑后的回复说明", highlight: "30 分钟内" },
|
||||
];
|
||||
assert.equal(
|
||||
(
|
||||
await request(url, {
|
||||
method: "PATCH",
|
||||
headers,
|
||||
payload: {
|
||||
content: ["schedule", "coverage", "process"].includes(item.type) ? "" : item.content,
|
||||
config,
|
||||
},
|
||||
})
|
||||
).statusCode,
|
||||
200,
|
||||
);
|
||||
}
|
||||
assert.deepEqual(
|
||||
JSON.parse((await request("/public/workspace")).body).trustItems,
|
||||
before.trustItems,
|
||||
);
|
||||
assert.equal(
|
||||
(
|
||||
await request("/admin/releases/publish", {
|
||||
method: "POST",
|
||||
headers,
|
||||
payload: { note: "结构化页面集成测试" },
|
||||
})
|
||||
).statusCode,
|
||||
201,
|
||||
);
|
||||
const workspace = JSON.parse((await request("/public/workspace")).body);
|
||||
let page;
|
||||
runInNewContext(
|
||||
readFileSync(
|
||||
new URL(
|
||||
"../../../packages/template-acheng-campus-food/miniapp/pages/stall-service/index.js",
|
||||
import.meta.url,
|
||||
),
|
||||
"utf8",
|
||||
),
|
||||
{
|
||||
Page(value) {
|
||||
page = value;
|
||||
},
|
||||
require(name) {
|
||||
return name.includes("runtime-workspace")
|
||||
? { loadWorkspaceWithFallback: () => Promise.resolve(workspace) }
|
||||
: { openPage() {} };
|
||||
},
|
||||
},
|
||||
);
|
||||
page.setData = (data) => Object.assign(page.data, data);
|
||||
await page.load();
|
||||
assert.equal(page.data.schedule.rows.length, 2);
|
||||
assert.equal(page.data.schedule.rows[0].detail, "测试工作日地点");
|
||||
assert.equal(page.data.schedule.rows[1].detail, "测试周末地点");
|
||||
assert.equal(page.data.coverage.config.pickupDetail, "测试自取说明");
|
||||
assert.equal(page.data.coverage.config.deliveryDetail, "测试配送说明");
|
||||
assert.equal(page.data.process.steps.length, 4);
|
||||
assert.equal(page.data.process.steps[0].detail, "测试步骤说明");
|
||||
let owner;
|
||||
runInNewContext(
|
||||
readFileSync(
|
||||
new URL(
|
||||
"../../../packages/template-acheng-campus-food/miniapp/pages/bookings/index.js",
|
||||
import.meta.url,
|
||||
),
|
||||
"utf8",
|
||||
),
|
||||
{
|
||||
Page(value) {
|
||||
owner = value;
|
||||
},
|
||||
require(name) {
|
||||
return name.includes("runtime-workspace")
|
||||
? { loadWorkspaceWithFallback: () => Promise.resolve(workspace) }
|
||||
: {};
|
||||
},
|
||||
},
|
||||
);
|
||||
owner.setData = (data) => Object.assign(owner.data, data);
|
||||
owner.onLoad();
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
assert.equal(owner.data.credentials[0].config.standards[0].title, "编辑后的卫生标准");
|
||||
assert.equal(owner.data.cases[0].entries[0].result, "完成");
|
||||
assert.equal(owner.data.promises[0].config.commitments[0].highlight, "30 分钟内");
|
||||
assert.ok(workspace.trustItems.every((item) => typeof item.summary === "string"));
|
||||
assert.ok(workspace.trustItems.every((item) => typeof item.id === "string"));
|
||||
assert.equal(
|
||||
new Set(workspace.trustItems.map((item) => item.id)).size,
|
||||
workspace.trustItems.length,
|
||||
);
|
||||
const schedule = records.find((item) => item.type === "schedule");
|
||||
await request(`/admin/config/trust-content/${schedule.id}`, {
|
||||
method: "PATCH",
|
||||
headers,
|
||||
payload: { config: {} },
|
||||
});
|
||||
const blocked = await request("/admin/releases/publish", {
|
||||
method: "POST",
|
||||
headers,
|
||||
payload: {},
|
||||
});
|
||||
assert.equal(blocked.statusCode, 400);
|
||||
await prisma.trustContent.update({
|
||||
where: { id: schedule.id },
|
||||
data: { config: schedule.config },
|
||||
});
|
||||
const duplicate = await prisma.trustContent.create({
|
||||
data: {
|
||||
brandId,
|
||||
type: "schedule",
|
||||
title: "重复公开日程",
|
||||
content: "",
|
||||
config: schedule.config,
|
||||
isPublished: true,
|
||||
},
|
||||
});
|
||||
try {
|
||||
const duplicateReadiness = JSON.parse(
|
||||
(await request("/admin/releases/readiness", { headers })).body,
|
||||
);
|
||||
assert.equal(
|
||||
duplicateReadiness.checks.find((check) => check.key === "trust:schedule").passed,
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
(await request("/admin/releases/publish", { method: "POST", headers, payload: {} }))
|
||||
.statusCode,
|
||||
400,
|
||||
);
|
||||
} finally {
|
||||
await prisma.trustContent.delete({ where: { id: duplicate.id } });
|
||||
}
|
||||
} finally {
|
||||
for (const item of records)
|
||||
await prisma.trustContent.update({
|
||||
where: { id: item.id },
|
||||
data: { config: item.config, content: item.content },
|
||||
});
|
||||
await prisma.brandRelease.deleteMany({ where: { brandId, version: { gt: latest.version } } });
|
||||
await prisma.brandRelease.update({ where: { id: latest.id }, data: { status: latest.status } });
|
||||
}
|
||||
});
|
||||
|
||||
test("admin release lifecycle is authorized, brand-scoped, and versioned", async () => {
|
||||
const missing = await request("/admin/releases");
|
||||
assert.equal(missing.statusCode, 401);
|
||||
@@ -241,6 +446,7 @@ test("admin release lifecycle is authorized, brand-scoped, and versioned", async
|
||||
isPublished: scheduleTrust.isPublished,
|
||||
title: scheduleTrust.title,
|
||||
content: scheduleTrust.content,
|
||||
config: scheduleTrust.config,
|
||||
};
|
||||
try {
|
||||
await prisma.trustContent.update({
|
||||
@@ -274,7 +480,7 @@ test("admin release lifecycle is authorized, brand-scoped, and versioned", async
|
||||
);
|
||||
await prisma.trustContent.update({
|
||||
where: { id: scheduleTrust.id },
|
||||
data: { title: originalScheduleTrust.title, content: " \n " },
|
||||
data: { title: originalScheduleTrust.title, content: " \n ", config: {} },
|
||||
});
|
||||
const missingContent = JSON.parse(
|
||||
(
|
||||
@@ -920,6 +1126,7 @@ test("admin can install doors industry template through the shared runtime contr
|
||||
|
||||
test("admin can preview and import sample content idempotently", async () => {
|
||||
const originalBrand = await prisma.brandProfile.findUnique({ where: { id: brandId } });
|
||||
const originalForms = await prisma.inquiryForm.findMany({ where: { brandId } });
|
||||
const originalSampleTrust = await prisma.trustContent.findMany({
|
||||
where: { brandId, content: "示例内容,待品牌主理人完善。" },
|
||||
});
|
||||
@@ -934,6 +1141,15 @@ test("admin can preview and import sample content idempotently", async () => {
|
||||
where: { brandId, content: "示例内容,待品牌主理人完善。" },
|
||||
});
|
||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId, source: "sample" } });
|
||||
if (!originalForms.some((item) => item.isEnabled)) {
|
||||
await prisma.inquiryForm.create({
|
||||
data: {
|
||||
brandId,
|
||||
name: "现有客户表单",
|
||||
fieldsSnapshot: [{ key: "phone", label: "联系电话", type: "tel", required: true }],
|
||||
},
|
||||
});
|
||||
}
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
@@ -943,11 +1159,35 @@ test("admin can preview and import sample content idempotently", async () => {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(preview.statusCode, 200);
|
||||
assert.equal(JSON.parse(preview.body).willCreateInquiryForm, false);
|
||||
const imported = await request("/admin/workspace/sample-content/import", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(imported.statusCode, 201);
|
||||
assert.equal(JSON.parse(imported.body).counts.inquiryForms, 0);
|
||||
assert.ok(await prisma.inquiryForm.findFirst({ where: { brandId, name: "现有客户表单" } }));
|
||||
await prisma.offering.deleteMany({
|
||||
where: {
|
||||
brandId,
|
||||
name: { in: ["序章·入户门", "庭院·边界门", "室内·静谧门", "一对一门系统设计咨询"] },
|
||||
},
|
||||
});
|
||||
await prisma.trustContent.deleteMany({
|
||||
where: { brandId, content: "示例内容,待品牌主理人完善。" },
|
||||
});
|
||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId, source: "sample" } });
|
||||
await prisma.inquiryForm.deleteMany({ where: { brandId } });
|
||||
const importedWithoutForm = await request("/admin/workspace/sample-content/import", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(importedWithoutForm.statusCode, 201);
|
||||
assert.equal(JSON.parse(importedWithoutForm.body).counts.inquiryForms, 1);
|
||||
const importedForm = await prisma.inquiryForm.findFirstOrThrow({
|
||||
where: { brandId, name: "门系统咨询表单" },
|
||||
});
|
||||
assert.ok(Array.isArray(importedForm.fieldsSnapshot) && importedForm.fieldsSnapshot.length > 0);
|
||||
const duplicate = await request("/admin/workspace/sample-content/import", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -970,6 +1210,14 @@ test("admin can preview and import sample content idempotently", async () => {
|
||||
});
|
||||
}
|
||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId, source: "sample" } });
|
||||
await prisma.inquiryForm.deleteMany({ where: { brandId, name: "门系统咨询表单" } });
|
||||
if (originalForms.length) {
|
||||
await prisma.inquiryForm.createMany({
|
||||
data: originalForms.map(
|
||||
({ id: _id, createdAt: _createdAt, updatedAt: _updatedAt, ...item }) => item,
|
||||
),
|
||||
});
|
||||
}
|
||||
await prisma.capabilityAuditLog.deleteMany({ where: { brandId, capabilityKey: "doors" } });
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: brandId },
|
||||
@@ -1039,8 +1287,14 @@ test("admin can install a template and public workspace exposes enabled configur
|
||||
const templateContent = JSON.parse(workspace.body).templateContent;
|
||||
assert.equal(templateContent.displayName, "阿成校园餐");
|
||||
assert.ok(templateContent.trustContentTypes.some((item) => item.type === "schedule"));
|
||||
assert.ok(templateContent.trustContentTypes.some((item) => item.label === "出摊与营业安排"));
|
||||
assert.ok(templateContent.trustContentTypes.some((item) => item.label === "每周出摊安排"));
|
||||
assert.ok(templateContent.admin.sections.some((section) => section.title === "首页出摊信息"));
|
||||
assert.ok(
|
||||
templateContent.admin.sections
|
||||
.filter((section) => section.title === "首页出摊信息")
|
||||
.every((section) => section.page === "home"),
|
||||
);
|
||||
assert.ok(templateContent.navigation.some((item) => item.page === "home" && item.label));
|
||||
assert.ok(
|
||||
templateContent.admin.sections
|
||||
.flatMap((section) => section.fields)
|
||||
@@ -1197,7 +1451,14 @@ test("public workspace exposes declared brand and trust presentation data", asyn
|
||||
);
|
||||
const doorType = body.inquiryForms[0].fields.find((field) => field.key === "doorType");
|
||||
assert.equal(doorType.options.length, 5);
|
||||
assert.equal(doorType.options[0].value, "入户大门(防暴铸铜 / 实木)");
|
||||
assert.equal(doorType.options[0].value, "entry");
|
||||
const phone = body.inquiryForms[0].fields.find((field) => field.key === "contactPhone");
|
||||
assert.equal(phone.type, "tel");
|
||||
const foodWorkspace = await request("/public/workspace?brandSlug=default-brand");
|
||||
const foodPhone = JSON.parse(foodWorkspace.body).inquiryForms[0].fields.find(
|
||||
(field) => field.key === "phone",
|
||||
);
|
||||
assert.equal(foodPhone.type, "tel");
|
||||
} finally {
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: doorsBrand.id },
|
||||
@@ -1233,7 +1494,20 @@ test("edited template facts reach public workspace only after publication", asyn
|
||||
const changedIntro = "集成测试发布后联系说明";
|
||||
const changedHint = "集成测试咨询后处理说明";
|
||||
const changedDetailHero = "https://example.com/integration-detail.jpg";
|
||||
const changedDetailBackground = "集成测试案例详情正文";
|
||||
const changedTemplateData = "集成测试设计理念";
|
||||
const changedStats = [{ value: "42", label: "测试成果" }];
|
||||
const obsolete = await prisma.trustContent.create({
|
||||
data: {
|
||||
brandId: doorsBrand.id,
|
||||
type: "profile",
|
||||
title: "旧类型不得覆盖模板配置",
|
||||
content: "旧简介",
|
||||
config: { stats: [{ value: "旧值", label: "不得显示" }], internalOnly: "不得公开" },
|
||||
isPublished: true,
|
||||
sortOrder: -100,
|
||||
},
|
||||
});
|
||||
try {
|
||||
const brandConfig = originalBrandConfig ?? {};
|
||||
const presentation = brandConfig.visualPresentation ?? {};
|
||||
@@ -1248,6 +1522,11 @@ test("edited template facts reach public workspace only after publication", asyn
|
||||
success: { ...presentation.success, intro: changedIntro },
|
||||
detail: { ...presentation.detail, inquiryHint: changedHint },
|
||||
},
|
||||
templateData: {
|
||||
...(brandConfig.templateData ?? {}),
|
||||
designPhilosophy: changedTemplateData,
|
||||
internalOnly: "不得公开",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1266,6 +1545,10 @@ test("edited template facts reach public workspace only after publication", asyn
|
||||
...(offering.config ?? {}),
|
||||
area: changedArea,
|
||||
detailHero: changedDetailHero,
|
||||
details: {
|
||||
...((offering.config ?? {}).details ?? {}),
|
||||
background: changedDetailBackground,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1298,12 +1581,24 @@ test("edited template facts reach public workspace only after publication", asyn
|
||||
(await request("/public/workspace?brandSlug=linjing-doors")).body,
|
||||
);
|
||||
assert.equal(afterPublish.brand.homeHero.title, changedTitle);
|
||||
assert.equal(afterPublish.templateData.designPhilosophy, changedTemplateData);
|
||||
assert.equal(Object.hasOwn(afterPublish.templateData, "internalOnly"), false);
|
||||
assert.equal(afterPublish.brand.visualPresentation.success.intro, changedIntro);
|
||||
assert.equal(afterPublish.brand.visualPresentation.detail.inquiryHint, changedHint);
|
||||
assert.deepEqual(afterPublish.trustPresentation.stats, changedStats);
|
||||
assert.equal(
|
||||
afterPublish.trustItems.some((item) => item.type === "profile"),
|
||||
false,
|
||||
);
|
||||
assert.equal(Object.hasOwn(afterPublish.trustPresentation, "internalOnly"), false);
|
||||
assert.equal(afterPublish.offerings[0].presentation.area, changedArea);
|
||||
assert.equal(afterPublish.offerings[0].presentation.heroImage, changedDetailHero);
|
||||
assert.equal(
|
||||
afterPublish.offerings[0].presentation.details.background,
|
||||
changedDetailBackground,
|
||||
);
|
||||
} finally {
|
||||
await prisma.trustContent.delete({ where: { id: obsolete.id } });
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: doorsBrand.id },
|
||||
data: { config: originalBrandConfig },
|
||||
@@ -1377,6 +1672,15 @@ test("admin can create and version an inquiry form", async () => {
|
||||
label: "联系渠道",
|
||||
options: [{ label: "微信", value: "wechat" }],
|
||||
},
|
||||
{
|
||||
key: "topics",
|
||||
type: "multi-select",
|
||||
label: "关注方向",
|
||||
options: [
|
||||
{ label: "咨询", value: "consulting" },
|
||||
{ label: "设计", value: "design" },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
@@ -1425,20 +1729,25 @@ test("admin can create and version an inquiry form", async () => {
|
||||
assert.equal((await publishReleaseForTests()).statusCode, 201);
|
||||
const publicForm = await request(`/public/inquiry-forms/${id}`);
|
||||
assert.equal(publicForm.statusCode, 200);
|
||||
assert.equal(
|
||||
JSON.parse(publicForm.body).fieldsSnapshot.find((field) => field.key === "topics").type,
|
||||
"multi-select",
|
||||
);
|
||||
const publicOffering = await request(`/public/offerings/${offering.id}`);
|
||||
assert.equal(publicOffering.statusCode, 200);
|
||||
assert.equal(JSON.parse(publicOffering.body).inquiryForms[0].id, id);
|
||||
const publicWorkspace = await request("/public/workspace");
|
||||
assert.equal(publicWorkspace.statusCode, 200);
|
||||
assert.ok(JSON.parse(publicWorkspace.body).inquiryForms.some((form) => form.key === id));
|
||||
const runtimeForm = JSON.parse(publicWorkspace.body).inquiryForms.find(
|
||||
(form) => form.key === id,
|
||||
);
|
||||
assert.ok(runtimeForm);
|
||||
assert.equal(runtimeForm.fields.find((field) => field.key === "topics").type, "checkbox");
|
||||
assert.ok(
|
||||
JSON.parse(publicWorkspace.body).inquiryForms.some(
|
||||
(form) => form.key === id && form.targetId === offering.id,
|
||||
),
|
||||
);
|
||||
const runtimeForm = JSON.parse(publicWorkspace.body).inquiryForms.find(
|
||||
(form) => form.key === id,
|
||||
);
|
||||
assert.deepEqual(runtimeForm.fields[1].options, [{ label: "微信", value: "wechat" }]);
|
||||
await prisma.inquiryForm.update({
|
||||
where: { id },
|
||||
@@ -1833,6 +2142,8 @@ test("admin can read and update brand and service configuration", async () => {
|
||||
assert.equal(updatedBrand.statusCode, 200);
|
||||
assert.equal(JSON.parse(updatedBrand.body).description, "集成测试品牌简介");
|
||||
assert.equal(JSON.parse(updatedBrand.body).templateKey, "personal");
|
||||
const updatedConfig = JSON.parse(updatedBrand.body).config;
|
||||
assert.equal(updatedConfig.slogan, "集成测试品牌简介");
|
||||
|
||||
const updatedService = await request(`/admin/workspace/offerings/${serviceBefore.id}`, {
|
||||
method: "PATCH",
|
||||
@@ -1950,6 +2261,26 @@ test("admin can manage trust content", async () => {
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
assert.equal((await request("/admin/config/trust-content")).statusCode, 401);
|
||||
assert.equal(
|
||||
(
|
||||
await request("/admin/config/trust-content", {
|
||||
method: "POST",
|
||||
headers: { authorization: "Bearer invalid" },
|
||||
payload: { type: "schedule", title: "安排", content: "时间" },
|
||||
})
|
||||
).statusCode,
|
||||
401,
|
||||
);
|
||||
assert.equal(
|
||||
(
|
||||
await request("/admin/config/trust-content", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
payload: { type: "schedule", title: "安排", content: "时间" },
|
||||
})
|
||||
).statusCode,
|
||||
403,
|
||||
);
|
||||
const created = await request("/admin/config/trust-content", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -1957,6 +2288,25 @@ test("admin can manage trust content", async () => {
|
||||
});
|
||||
assert.equal(created.statusCode, 201);
|
||||
const id = JSON.parse(created.body).id;
|
||||
const schedule = await request("/admin/config/trust-content", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: {
|
||||
type: "schedule",
|
||||
title: "每周营业安排",
|
||||
summary: "周一至周五 17:00 - 22:30",
|
||||
content: "周六、周日承接团体单",
|
||||
},
|
||||
});
|
||||
assert.equal(schedule.statusCode, 201);
|
||||
assert.equal(JSON.parse(schedule.body).summary, "周一至周五 17:00 - 22:30");
|
||||
assert.equal(JSON.parse(schedule.body).content, "周六、周日承接团体单");
|
||||
const unsupported = await request("/admin/config/trust-content", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { type: "unregistered-template-type", title: "不支持", content: "不应保存" },
|
||||
});
|
||||
assert.equal(unsupported.statusCode, 400);
|
||||
const draft = await request("/admin/config/trust-content", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -1981,6 +2331,7 @@ test("admin can manage trust content", async () => {
|
||||
assert.equal(updated.statusCode, 200);
|
||||
assert.equal(JSON.parse(updated.body).content, "更新后的内容");
|
||||
} finally {
|
||||
await prisma.trustContent.delete({ where: { id: JSON.parse(schedule.body).id } });
|
||||
const deleted = await request(`/admin/config/trust-content/${id}`, {
|
||||
method: "DELETE",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const assert = require("node:assert/strict");
|
||||
const { randomBytes } = require("node:crypto");
|
||||
const { spawnSync } = require("node:child_process");
|
||||
const { PrismaClient } = require("@prisma/client");
|
||||
@@ -10,6 +11,7 @@ const testUrl = new URL(databaseUrl);
|
||||
testUrl.searchParams.set("schema", schema);
|
||||
const testEnvironment = { ...process.env, DATABASE_URL: testUrl.toString(), NODE_ENV: "test" };
|
||||
const administrator = new PrismaClient();
|
||||
const fixtureDatabase = new PrismaClient({ datasourceUrl: testUrl.toString() });
|
||||
|
||||
function run(command, args) {
|
||||
const result = spawnSync(command, args, { stdio: "inherit", env: testEnvironment });
|
||||
@@ -25,9 +27,30 @@ async function main() {
|
||||
created = true;
|
||||
if (run("pnpm", ["exec", "prisma", "migrate", "deploy"]) !== 0) return status;
|
||||
if (run("pnpm", ["db:seed"]) !== 0) return status;
|
||||
const initialTrustCount = await fixtureDatabase.trustContent.count();
|
||||
const initialFormCount = await fixtureDatabase.inquiryForm.count();
|
||||
const initialReleases = await fixtureDatabase.brandRelease.findMany({ orderBy: { id: "asc" } });
|
||||
if (run("pnpm", ["db:seed"]) !== 0) return status;
|
||||
assert.equal(
|
||||
await fixtureDatabase.trustContent.count(),
|
||||
initialTrustCount,
|
||||
"Repeated seed must not duplicate trust content",
|
||||
);
|
||||
assert.equal(
|
||||
await fixtureDatabase.inquiryForm.count(),
|
||||
initialFormCount,
|
||||
"Repeated seed must not duplicate forms",
|
||||
);
|
||||
assert.deepEqual(
|
||||
await fixtureDatabase.brandRelease.findMany({ orderBy: { id: "asc" } }),
|
||||
initialReleases,
|
||||
"Repeated seed must preserve release history and snapshots",
|
||||
);
|
||||
console.log("Seed idempotency verified: content, forms and release history preserved");
|
||||
status = run(process.execPath, ["--test", "test/http.integration.test.js"]);
|
||||
return status;
|
||||
} finally {
|
||||
await fixtureDatabase.$disconnect();
|
||||
if (created) await administrator.$executeRawUnsafe(`DROP SCHEMA "${schema}" CASCADE`);
|
||||
await administrator.$disconnect();
|
||||
process.exitCode = status;
|
||||
|
||||
@@ -5,6 +5,22 @@ Component({
|
||||
submitting: { type: Boolean, value: false },
|
||||
submitLabel: { type: String, value: "提交需求" },
|
||||
},
|
||||
observers: {
|
||||
"fields, values": function (fields, values) {
|
||||
const selectedValues = values || {};
|
||||
this.setData({
|
||||
renderFields: (fields || []).map((field) => ({
|
||||
...field,
|
||||
options: (field.options || []).map((option) => ({
|
||||
...option,
|
||||
checked:
|
||||
Array.isArray(selectedValues[field.key]) &&
|
||||
selectedValues[field.key].includes(option.value),
|
||||
})),
|
||||
})),
|
||||
});
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
input(e) {
|
||||
this.triggerEvent("input", { key: e.currentTarget.dataset.key, value: e.detail.value });
|
||||
@@ -14,6 +30,12 @@ Component({
|
||||
const option = field?.options?.[e.detail.value];
|
||||
if (option) this.triggerEvent("input", { key: field.key, value: option.value ?? option });
|
||||
},
|
||||
checkboxChange(e) {
|
||||
this.triggerEvent("input", {
|
||||
key: e.currentTarget.dataset.key,
|
||||
value: e.detail.value,
|
||||
});
|
||||
},
|
||||
dateChange(e) {
|
||||
this.triggerEvent("input", { key: e.currentTarget.dataset.key, value: e.detail.value });
|
||||
},
|
||||
|
||||
@@ -1 +1,16 @@
|
||||
<view class="form"><view wx:for="{{fields}}" wx:key="key" class="field"><text class="label">{{item.label}}{{item.required ? ' *' : ''}}</text><input wx:if="{{item.type === 'tel' || item.type === 'phone' || item.type === 'number' || item.type === 'text'}}" type="{{item.type === 'number' ? 'number' : item.type === 'tel' || item.type === 'phone' ? 'number' : 'text'}}" data-key="{{item.key}}" placeholder="{{item.placeholder || '请填写'}}" value="{{values[item.key]}}" bindinput="input"/><textarea wx:elif="{{item.type === 'textarea'}}" data-key="{{item.key}}" placeholder="{{item.placeholder || '请填写'}}" value="{{values[item.key]}}" bindinput="input" auto-height="true"/><picker wx:elif="{{item.type === 'date'}}" mode="date" data-key="{{item.key}}" value="{{values[item.key]}}" bindchange="dateChange"><view class="picker-value">{{values[item.key] || '请选择日期'}}</view></picker><picker wx:elif="{{item.type === 'select' || item.type === 'radio'}}" mode="selector" range="{{item.options}}" range-key="label" data-key="{{item.key}}" bindchange="choose"><view class="picker-value">{{values[item.key] || '请选择'}}</view></picker></view><button class="submit" loading="{{submitting}}" bindtap="submit">{{submitLabel || '提交需求'}}</button></view>
|
||||
<view class="form">
|
||||
<view wx:for="{{renderFields}}" wx:key="key" class="field">
|
||||
<text class="label">{{item.label}}{{item.required ? ' *' : ''}}</text>
|
||||
<input wx:if="{{item.type === 'tel' || item.type === 'phone' || item.type === 'number' || item.type === 'text'}}" type="{{item.type === 'number' ? 'number' : item.type === 'tel' || item.type === 'phone' ? 'number' : 'text'}}" data-key="{{item.key}}" placeholder="{{item.placeholder || '请填写'}}" value="{{values[item.key]}}" bindinput="input" />
|
||||
<textarea wx:elif="{{item.type === 'textarea'}}" data-key="{{item.key}}" placeholder="{{item.placeholder || '请填写'}}" value="{{values[item.key]}}" bindinput="input" auto-height="true" />
|
||||
<picker wx:elif="{{item.type === 'date'}}" mode="date" data-key="{{item.key}}" value="{{values[item.key]}}" bindchange="dateChange"><view class="picker-value">{{values[item.key] || '请选择日期'}}</view></picker>
|
||||
<picker wx:elif="{{item.type === 'select' || item.type === 'radio'}}" mode="selector" range="{{item.options}}" range-key="label" data-key="{{item.key}}" bindchange="choose"><view class="picker-value">{{values[item.key] || '请选择'}}</view></picker>
|
||||
<checkbox-group wx:elif="{{item.type === 'checkbox'}}" class="checkbox-group" data-key="{{item.key}}" bindchange="checkboxChange">
|
||||
<label wx:for="{{item.options}}" wx:for-item="option" wx:key="value" class="checkbox-option">
|
||||
<checkbox value="{{option.value}}" checked="{{option.checked}}" />
|
||||
<text>{{option.label}}</text>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
<button class="submit" loading="{{submitting}}" bindtap="submit">{{submitLabel || '提交需求'}}</button>
|
||||
</view>
|
||||
@@ -29,6 +29,16 @@
|
||||
.picker-value {
|
||||
color: #77736b;
|
||||
}
|
||||
.checkbox-group {
|
||||
flex: 1;
|
||||
}
|
||||
.checkbox-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 64rpx;
|
||||
color: #252827;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.submit {
|
||||
margin-top: 30rpx;
|
||||
background: #252827;
|
||||
|
||||
@@ -1 +1 @@
|
||||
<view class="detail"><view class="hero-wrap"><image class="hero" src="{{item.detailHero || item.image}}" mode="aspectFill"/><view class="hero-shade"></view><view class="hero-copy"><text>{{item.category}} · {{item.area}}</text><text>{{item.name}}</text><text>{{item.series}}</text></view></view><view class="content"><view class="price-card"><view><text>{{presentation.priceLabel}}</text><text>{{item.priceRange}}</text></view><view><text>{{presentation.spaceLabel}}</text><text>{{item.spaceType}}</text></view></view><view class="detail-section"><text class="section-title">{{presentation.backgroundTitle}}</text><text class="body">{{item.details.background || item.desc}}</text></view><view wx:if="{{item.details.designConcept}}" class="detail-section"><text class="section-title">{{presentation.conceptTitle}}</text><text class="body warm">{{item.details.designConcept}}</text></view><view wx:if="{{item.details.crafts.length}}" class="detail-section"><text class="section-title">{{presentation.craftsTitle}}</text><view wx:for="{{item.details.crafts}}" wx:key="*this" class="craft"><text>0{{index + 1}}</text><text>{{item}}</text></view></view><view wx:if="{{item.details.materialsList.length}}" class="detail-section"><text class="section-title">{{presentation.materialsTitle}}</text><view class="materials"><view wx:for="{{item.details.materialsList}}" wx:key="name"><text>{{item.name}}</text><text>{{item.spec}}</text></view></view></view><view class="chips"><text wx:for="{{item.keywords}}" wx:key="*this">{{item}}</text></view></view><view class="bar"><button bindtap="inquire">{{presentation.inquiryAction}}</button><text>{{presentation.inquiryHint}}</text></view></view>
|
||||
<view class="detail"><view class="hero-wrap"><image class="hero" src="{{item.detailHero || item.image}}" mode="aspectFill"/><view class="hero-shade"></view><view class="hero-copy"><text>{{item.presentation.categoryLabel || item.category}} · {{item.area}}</text><text>{{item.name}}</text><text>{{item.series}}</text></view></view><view class="content"><view class="price-card"><view><text>{{presentation.priceLabel}}</text><text>{{item.priceRange}}</text></view><view><text>{{presentation.spaceLabel}}</text><text>{{item.spaceType}}</text></view></view><view class="detail-section"><text class="section-title">{{presentation.backgroundTitle}}</text><text class="body">{{item.details.background || item.desc}}</text></view><view wx:if="{{item.details.designConcept}}" class="detail-section"><text class="section-title">{{presentation.conceptTitle}}</text><text class="body warm">{{item.details.designConcept}}</text></view><view wx:if="{{item.details.crafts.length}}" class="detail-section"><text class="section-title">{{presentation.craftsTitle}}</text><view wx:for="{{item.details.crafts}}" wx:key="*this" class="craft"><text>0{{index + 1}}</text><text>{{item}}</text></view></view><view wx:if="{{item.details.materialsList.length}}" class="detail-section"><text class="section-title">{{presentation.materialsTitle}}</text><view class="materials"><view wx:for="{{item.details.materialsList}}" wx:key="name"><text>{{item.name}}</text><text>{{item.spec}}</text></view></view></view><view class="chips"><text wx:for="{{item.keywords}}" wx:key="*this">{{item}}</text></view></view><view class="bar"><button bindtap="inquire">{{presentation.inquiryAction}}</button><text>{{presentation.inquiryHint}}</text></view></view>
|
||||
@@ -8,7 +8,7 @@
|
||||
"tdesign-miniprogram": "^1.16.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test:fixture": "node test/validate-fixture.cjs && node --test test/runtime-workspace.test.cjs",
|
||||
"test:fixture": "node test/validate-fixture.cjs && node --test test/*.test.cjs",
|
||||
"test:visual-fixture": "node test/validate-visual-fixture.cjs",
|
||||
"lint": "eslint src --ext .ts",
|
||||
"typecheck": "tsc -p tsconfig.json --noEmit",
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const vm = require("node:vm");
|
||||
const test = require("node:test");
|
||||
const root = path.resolve(__dirname, "../../..");
|
||||
const template = path.join(root, "packages/template-acheng-campus-food");
|
||||
const fields = JSON.parse(fs.readFileSync(path.join(template, "template.json"))).sampleContent.food
|
||||
.fields;
|
||||
async function loadPage() {
|
||||
let page;
|
||||
vm.runInNewContext(
|
||||
fs.readFileSync(path.join(template, "miniapp/pages/inquiry/index.js"), "utf8"),
|
||||
{
|
||||
Page(value) {
|
||||
page = value;
|
||||
},
|
||||
require(name) {
|
||||
if (name.includes("runtime-workspace"))
|
||||
return {
|
||||
loadWorkspaceWithFallback: () =>
|
||||
Promise.resolve({
|
||||
brand: {},
|
||||
inquiryForms: [{ id: "brand-form", target: "brand", fields }],
|
||||
}),
|
||||
};
|
||||
if (name.includes("navigation")) return { takePageQuery: () => ({}) };
|
||||
return {};
|
||||
},
|
||||
},
|
||||
);
|
||||
page.setData = (data) => {
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
if (key.startsWith("values.")) page.data.values[key.slice(7)] = value;
|
||||
else if (key.startsWith("displayValues.")) page.data.displayValues[key.slice(14)] = value;
|
||||
else page.data[key] = value;
|
||||
}
|
||||
};
|
||||
await page.onLoad({});
|
||||
return page;
|
||||
}
|
||||
test("餐饮咨询布局保留原型类型按钮和双列字段,文案与选项仍读取表单", async () => {
|
||||
const page = await loadPage();
|
||||
assert.equal(page.data.formId, "brand-form");
|
||||
assert.equal(page.data.fields.find((field) => field.key === "type").useChips, true);
|
||||
assert.equal(page.data.fields.filter((field) => field.halfWidth).length, 4);
|
||||
assert.equal(page.data.fields.find((field) => field.key === "type").options.length, 6);
|
||||
assert.equal(
|
||||
page.data.fields.find((field) => field.key === "remark").label,
|
||||
"餐品 / 口味 / 忌口备注",
|
||||
);
|
||||
});
|
||||
test("选择类型或选项保存真实值,选择器展示标签;空数组不能通过必填检查", async () => {
|
||||
const page = await loadPage();
|
||||
page.chooseChip({ currentTarget: { dataset: { key: "type", value: "日常留餐" } } });
|
||||
assert.equal(page.data.values.type, "日常留餐");
|
||||
const people = page.data.fields.find((field) => field.key === "people");
|
||||
people.options = [{ label: "人数显示标签", value: "people-value" }];
|
||||
page.choose({ currentTarget: { dataset: { key: "people" } }, detail: { value: "0" } });
|
||||
assert.equal(page.data.values.people, "people-value");
|
||||
assert.equal(page.data.displayValues.people, "人数显示标签");
|
||||
page.data.fields = [{ key: "allergy", label: "饮食要求", required: true }];
|
||||
page.data.values = { allergy: [] };
|
||||
page.submit();
|
||||
assert.equal(page.data.formError, "请填写饮食要求");
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const vm = require("node:vm");
|
||||
const test = require("node:test");
|
||||
const root = path.resolve(__dirname, "../../../packages/template-acheng-campus-food/miniapp");
|
||||
test("主理人页只呈现资质、案例和承诺,不混入出摊区块", async () => {
|
||||
let page;
|
||||
const items = ["schedule", "coverage", "process", "credential", "case", "promise"].map(
|
||||
(type) => ({ id: type, type, title: type, content: "后台编辑内容" }),
|
||||
);
|
||||
vm.runInNewContext(fs.readFileSync(path.join(root, "pages/bookings/index.js"), "utf8"), {
|
||||
Page(value) {
|
||||
page = value;
|
||||
},
|
||||
require(name) {
|
||||
return name.includes("runtime-workspace")
|
||||
? {
|
||||
loadWorkspaceWithFallback: () =>
|
||||
Promise.resolve({ brand: { description: "主理人简介" }, trustItems: items }),
|
||||
}
|
||||
: {};
|
||||
},
|
||||
});
|
||||
page.setData = (data) => Object.assign(page.data, data);
|
||||
page.onLoad();
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
assert.equal(page.data.credentials.length, 1);
|
||||
assert.equal(page.data.cases[0].content, "后台编辑内容");
|
||||
assert.equal(page.data.promises.length, 1);
|
||||
const markup = fs.readFileSync(
|
||||
path.join(root, "components/templates/acheng-profile/acheng-profile.wxml"),
|
||||
"utf8",
|
||||
);
|
||||
assert.ok(markup.includes("brand.description"));
|
||||
assert.ok(!markup.includes("brand.slogan"));
|
||||
assert.ok(!markup.includes("coverageContent"));
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const vm = require("node:vm");
|
||||
const test = require("node:test");
|
||||
const root = path.resolve(__dirname, "../../..");
|
||||
const template = path.join(root, "packages/template-acheng-campus-food");
|
||||
const sample = JSON.parse(fs.readFileSync(path.join(template, "template.json"))).sampleContent.food;
|
||||
async function loadPage(items) {
|
||||
let page;
|
||||
vm.runInNewContext(
|
||||
fs.readFileSync(path.join(template, "miniapp/pages/stall-service/index.js"), "utf8"),
|
||||
{
|
||||
Page(value) {
|
||||
page = value;
|
||||
},
|
||||
require(name) {
|
||||
return name.includes("runtime-workspace")
|
||||
? { loadWorkspaceWithFallback: () => Promise.resolve({ brand: {}, trustItems: items }) }
|
||||
: { openPage() {} };
|
||||
},
|
||||
},
|
||||
);
|
||||
page.setData = (data) => Object.assign(page.data, data);
|
||||
await page.load();
|
||||
return page.data;
|
||||
}
|
||||
test("旧记录不遮住结构化内容,每种内容只投影一个固定区域", async () => {
|
||||
const old = ["schedule", "coverage", "process"].map((type) => ({
|
||||
type,
|
||||
title: "旧记录",
|
||||
content: "旧正文",
|
||||
}));
|
||||
const data = await loadPage([...old, ...sample.trustContent, ...sample.trustContent]);
|
||||
assert.equal(data.schedule.rows.length, 2);
|
||||
assert.equal(data.schedule.rows[0].title, sample.trustContent[0].config.weekdayLabel);
|
||||
assert.equal(data.schedule.rows[1].title, sample.trustContent[0].config.weekendLabel);
|
||||
assert.equal(data.coverage.config.pickupDetail, sample.trustContent[1].config.pickupDetail);
|
||||
assert.equal(data.coverage.config.deliveryDetail, sample.trustContent[1].config.deliveryDetail);
|
||||
assert.equal(data.process.steps.length, 4);
|
||||
assert.equal(new Set(data.process.steps.map((step) => step.index)).size, 4);
|
||||
assert.ok(data.process.steps.every((step) => step.title && step.detail));
|
||||
});
|
||||
test("缺少配置时不渲染空配送卡和空流程卡", async () => {
|
||||
const data = await loadPage([
|
||||
{ type: "coverage", title: "地点", config: {} },
|
||||
{ type: "process", title: "旧流程", content: "步骤一\n步骤二" },
|
||||
]);
|
||||
assert.equal(data.coverage, null);
|
||||
assert.equal(data.process, null);
|
||||
});
|
||||
test("编辑工作日、周末、配送和步骤变量后页面数据同时更新", async () => {
|
||||
const items = JSON.parse(JSON.stringify(sample.trustContent));
|
||||
items[0].config.weekdayDetail = "工作日新地点";
|
||||
items[0].config.weekendHours = "周末新时间";
|
||||
items[1].config.deliveryDetail = "新配送规则";
|
||||
items[2].config.steps[0].detail = "新第一步";
|
||||
const data = await loadPage(items);
|
||||
assert.equal(data.schedule.rows[0].detail, "工作日新地点");
|
||||
assert.equal(data.schedule.rows[1].hours, "周末新时间");
|
||||
assert.equal(data.coverage.config.deliveryDetail, "新配送规则");
|
||||
assert.equal(data.process.steps[0].detail, "新第一步");
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const test = require("node:test");
|
||||
const vm = require("node:vm");
|
||||
|
||||
const componentDirectory = path.join(__dirname, "../components/modules/inquiry-form");
|
||||
let definition;
|
||||
vm.runInNewContext(fs.readFileSync(path.join(componentDirectory, "inquiry-form.js"), "utf8"), {
|
||||
Component: (value) => {
|
||||
definition = value;
|
||||
},
|
||||
});
|
||||
|
||||
test("多选字段根据已有值标记选项并把选中值数组传回表单", () => {
|
||||
const context = {
|
||||
data: {},
|
||||
events: [],
|
||||
setData(value) {
|
||||
this.data = { ...this.data, ...value };
|
||||
},
|
||||
triggerEvent(name, detail) {
|
||||
this.events.push({ name, detail });
|
||||
},
|
||||
};
|
||||
definition.observers["fields, values"].call(
|
||||
context,
|
||||
[
|
||||
{
|
||||
key: "topics",
|
||||
type: "checkbox",
|
||||
options: [
|
||||
{ label: "咨询", value: "consulting" },
|
||||
{ label: "设计", value: "design" },
|
||||
],
|
||||
},
|
||||
],
|
||||
{ topics: ["design"] },
|
||||
);
|
||||
|
||||
assert.equal(context.data.renderFields[0].options[0].checked, false);
|
||||
assert.equal(context.data.renderFields[0].options[1].checked, true);
|
||||
definition.methods.checkboxChange.call(context, {
|
||||
currentTarget: { dataset: { key: "topics" } },
|
||||
detail: { value: ["consulting", "design"] },
|
||||
});
|
||||
assert.equal(context.events[0].name, "input");
|
||||
assert.equal(context.events[0].detail.key, "topics");
|
||||
assert.deepEqual(context.events[0].detail.value, ["consulting", "design"]);
|
||||
});
|
||||
@@ -53,7 +53,7 @@ test("运行时保留模板业务数据,不再解释视觉模块", async () =>
|
||||
modules: [{ key: "brand-hero" }],
|
||||
visualTemplateManifest: { pages: [] },
|
||||
});
|
||||
assert.deepEqual(workspace.trustContent, { bio: "品牌介绍" });
|
||||
assert.deepEqual(workspace.trustPresentation, { bio: "品牌介绍" });
|
||||
assert.equal(workspace.fields, undefined);
|
||||
assert.equal(workspace.inquiryForm, undefined);
|
||||
assert.equal(workspace.modules[0].key, "brand-hero");
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const test = require("node:test");
|
||||
const vm = require("node:vm");
|
||||
|
||||
const source = fs.readFileSync(path.join(__dirname, "../utils/trust-content.js"), "utf8");
|
||||
const trustModule = { exports: {} };
|
||||
vm.runInNewContext(source, { module: trustModule });
|
||||
const { prepareTrustItems } = trustModule.exports;
|
||||
|
||||
test("流程信任内容按换行整理为非空步骤", () => {
|
||||
const [process] = prepareTrustItems([
|
||||
{ type: "process", title: "定制流程", content: " 沟通需求\r\n\n确认菜单\n 现场交付 " },
|
||||
]);
|
||||
assert.equal(JSON.stringify(process.lines), JSON.stringify(["沟通需求", "确认菜单", "现场交付"]));
|
||||
assert.equal(process.content, " 沟通需求\r\n\n确认菜单\n 现场交付 ");
|
||||
});
|
||||
|
||||
test("非流程信任内容不添加步骤列表", () => {
|
||||
const [schedule] = prepareTrustItems([{ type: "schedule", content: "工作日营业" }]);
|
||||
assert.equal("lines" in schedule, false);
|
||||
assert.equal(prepareTrustItems(null).length, 0);
|
||||
});
|
||||
@@ -29,7 +29,7 @@ function normalizeWorkspace(workspace) {
|
||||
const offerings = Array.isArray(workspace && workspace.offerings)
|
||||
? workspace.offerings.map(toOffering)
|
||||
: [];
|
||||
const trustContent =
|
||||
const trustPresentation =
|
||||
workspace && workspace.trustPresentation && typeof workspace.trustPresentation === "object"
|
||||
? workspace.trustPresentation
|
||||
: {};
|
||||
@@ -43,7 +43,7 @@ function normalizeWorkspace(workspace) {
|
||||
...workspace,
|
||||
brand,
|
||||
offerings,
|
||||
trustContent,
|
||||
trustPresentation,
|
||||
trustItems,
|
||||
plugins: Array.isArray(workspace.plugins) ? workspace.plugins : [],
|
||||
};
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
function prepareTrustItems(items) {
|
||||
if (!Array.isArray(items)) return [];
|
||||
return items.map((item) => ({
|
||||
...item,
|
||||
...(item.type === "process"
|
||||
? {
|
||||
lines:
|
||||
typeof item.content === "string"
|
||||
? item.content
|
||||
.split(/\r?\n/)
|
||||
.map((line) => line.trim())
|
||||
.filter(Boolean)
|
||||
: [],
|
||||
}
|
||||
: {}),
|
||||
}));
|
||||
}
|
||||
|
||||
module.exports = { prepareTrustItems };
|
||||
@@ -0,0 +1,43 @@
|
||||
# 0017 统一内容 Runtime Contract
|
||||
|
||||
## Context
|
||||
|
||||
模板字段目前同时经过 manifest、Prisma JSON、API projection 和 Mini Program 组件。历史兼容字段使同一业务语义存在多个入口,例如 Offering 的通用 `description` 与模板详情 `config.details.background`。仅检查某一层会允许“可编辑但不展示”的字段继续进入系统。
|
||||
|
||||
## Decision
|
||||
|
||||
每个公开字段必须有一个规范 binding 和一个规范 Runtime path。binding 是持久化编辑路径,Runtime path 是 `RuntimeWorkspace` / 组件 props 的稳定路径。模板 manifest 负责声明业务字段和编辑文案,平台 contract 负责校验 binding、Runtime path 和页面归属;projection 只输出规范 Runtime path。
|
||||
|
||||
规范路径:
|
||||
|
||||
| 数据 | 规范编辑路径 | 规范 Runtime 路径 |
|
||||
| -------------- | ---------------------------------------------- | -------------------------------------------------- |
|
||||
| 品牌事实 | `brand.*` | `workspace.brand.*` |
|
||||
| 模板品牌字段 | `brand.config.templateData.<key>` | `workspace.templateData.<key>` |
|
||||
| 页面表达 | `brand.config.visualPresentation.<page>.<key>` | `workspace.brand.visualPresentation.<page>.<key>` |
|
||||
| 业务详情 | `offering.config.<key>` | `workspace.offerings[].presentation.<key>` |
|
||||
| 业务详情正文 | `offering.config.details.<key>` | `workspace.offerings[].presentation.details.<key>` |
|
||||
| 信任内容标准列 | `trust.title/summary/content` | `workspace.trustItems[].title/summary/content` |
|
||||
| 信任内容扩展 | `trust.config.<key>` | `workspace.trustItems[].config.<key>` |
|
||||
| 咨询字段 | `inquiry.fieldsSnapshot` | `workspace.inquiryForms[].fields` |
|
||||
|
||||
历史别名只允许在 projection 或导入迁移处读取,不得新增 Admin binding,也不得作为组件协议。组件 props 必须直接使用 Runtime path 对应的对象,页面不能自行重新解释数据库字段。
|
||||
|
||||
## Alternatives
|
||||
|
||||
- 继续使用字段命名约定:实现快,但无法阻止别名和页面错配。
|
||||
- 为每个模板独立写 DTO:隔离性好,但会复制平台数据事实并增加升级成本。
|
||||
- 允许任意 JSON 编辑:灵活但无法做页面可见性和发布校验。
|
||||
|
||||
## Consequences
|
||||
|
||||
- 新模板必须声明字段到 Runtime 的完整路径,并通过 package-discovered contract tests。
|
||||
- 兼容字段不会立即删除,先停止新增使用,再按发布版本迁移。
|
||||
- 需要增加发布后测试,验证 Admin 修改值最终出现在 public workspace 和页面输入数据中。
|
||||
|
||||
## Migration Plan
|
||||
|
||||
1. 为现有 manifest 补齐并验证规范 Runtime path。
|
||||
2. 将 API projection 抽为共享 contract mapper,收敛别名处理。
|
||||
3. 将 Admin 和 Mini Program props 改为消费规范路径。
|
||||
4. 为每类字段增加发布后集成测试,完成后再评估删除旧 JSON 别名。
|
||||
@@ -0,0 +1,31 @@
|
||||
# 0018 模板视觉槽位与内容发布校验
|
||||
|
||||
## Context
|
||||
|
||||
餐饮原型的固定日程、配送双列和流程列表被错误地转换为任意 TrustContent 记录循环。旧正文、摘要和 config 并存,后台与小程序选择的记录不同。隔离数据库 seed 测试通过,开发数据库和发布快照仍缺字段。
|
||||
|
||||
## Decision
|
||||
|
||||
- 先确认原型区块、子卡、行和按钮,再声明浅层字段。布局只使用结构化字段,不拆分正文推断布局。
|
||||
- 餐饮三个固定区域声明 `maxPublishedItems: 1`,每个区域只能有一条公开记录;草稿和旧记录可以保留。其他模板的列表内容可以声明自己的数量限制,未声明时允许多条。发布检查阻止重复公开记录或缺少实际展示字段。
|
||||
- `hideStandardFields` 明确当前模板不使用的标准列。Admin、共享内容完整性判定和发布校验消费同一声明;隐藏正文不再作为完整性门槛。
|
||||
- 公开记录投影保留稳定 `id`,视觉步骤列表生成明确索引 key,避免编辑和重排时出现节点复用错误。
|
||||
- 可编辑状态、标签、步骤说明和页脚文案均由 manifest 声明,业务承诺不得硬编码在 renderer。
|
||||
- 咨询问题来自已发布 InquiryForm,模板样例只在显式导入或限定开发 fixture 时复制。历史提交快照不改变。
|
||||
- 完成必须覆盖当前数据库、发布 API、最终生成文件和页面数据。静态源码检查和独立 seed 测试不能代替实际数据迁移。
|
||||
|
||||
## Alternatives
|
||||
|
||||
保留正文拆分兼容会继续产生双数据源。为餐饮新建专用表会把示例行业侵入平台模型。采用浅层 TrustContent.config 与模板声明即可保持可替换模板边界。
|
||||
|
||||
## Consequences
|
||||
|
||||
旧记录可以作为草稿查看和恢复,但不能同时公开到同一必填视觉区域。后台列表展示实际 config 内容预览。发布失败明确引导用户完善对应区块。
|
||||
|
||||
## Migration Plan
|
||||
|
||||
`apps/api/scripts/migrate-food-template-content.ts` 只处理开发餐饮品牌,执行前备份,事务内迁移,保留旧记录为草稿,并创建新发布版本。命令默认 dry run,`--apply` 执行;成功标记后再次执行不写数据。生产客户必须另行制定品牌内容迁移映射,不能批量导入演示承诺。
|
||||
|
||||
## 主理人视觉约束
|
||||
|
||||
整理主理人页内容不得改为通用正文卡。以 OwnerView 原型为基准保留 208 px 写真封面、渐变身份区、三列资质图标小卡、案例简称/说明/结果标签及回复承诺圆点/强调色。新增槽位使用浅层 config 列表;不拆旧正文来猜测条目。缺少结构化数据时可显示原有正文,但不能用样例遮挡用户编辑。原型中的证书、经营年限和统计只在品牌管理员确认后填写。
|
||||
@@ -22,6 +22,11 @@
|
||||
## 模板与配置包
|
||||
|
||||
- 模板声明必须真正驱动安装和升级,不能只增加类型而保留 Controller 硬编码;
|
||||
- 每个页面上的品牌事实、信任资料、业务详情和可编辑文案都必须来自 Runtime 数据,并在同一页面声明对应 Admin editor binding;`pnpm validate:templates` 的逐页 renderer / editor 契约测试通过后才能判定模板完成;
|
||||
- 每种模板信任内容必须声明实际展示页面,逐页测试要同时验证“声明的类型有 renderer 消费”和“renderer 使用的类型已声明”;
|
||||
- 新模板必须由 package-discovered 测试自动纳入,不得只给现有模板写专用断言;
|
||||
- 信任内容类型必须在 manifest 声明 `title`、`summary`、`content` 对应的 Admin 字段标签;API 按当前品牌 manifest 校验类型,不能在 DTO 中固定模板类型枚举;
|
||||
- 模板数据存储与发布映射遵循 `docs/template-data-flow.md`,信任内容和咨询表单分别使用 `TrustContent` 与 `InquiryForm`;
|
||||
- 安装必须保存版本和配置快照;
|
||||
- 升级必须有预览、显式确认和“不覆盖用户内容”的规则;
|
||||
- 回滚必须明确是恢复配置基线还是删除新增数据,并在接口文案和测试中保持一致;
|
||||
@@ -43,3 +48,11 @@
|
||||
- 运行 Admin production build;
|
||||
- 运行 `pnpm format:check` 和 `git diff --check`;
|
||||
- 做一次变更范围 Code Review,确认没有“已实现但未测试”的 endpoint 或 UI 操作。
|
||||
|
||||
## 固定视觉区域与旧数据验收
|
||||
|
||||
- 必填视觉区域不由任意记录数量决定布局;缺少实际展示字段或重复公开记录必须阻止发布;
|
||||
- 结构化内容完整性由 manifest 声明判定,后台和发布端共用规则;隐藏字段不能仍被要求必填;
|
||||
- 对照原型检查子卡数量、内容层次和文字换行,源码匹配不视为视觉验收;
|
||||
- 使用当前数据库通过发布 API 驱动最终生成页面,验证日程、配送、流程和咨询字段;
|
||||
- 数据迁移必须备份、限定品牌、保留历史提交和旧发布快照,并验证重复执行不产生重复内容。
|
||||
@@ -0,0 +1,17 @@
|
||||
# Runtime Content Matrix
|
||||
|
||||
本表是字段审查的固定入口。任何新增模板字段必须同时补充 binding、存储、Runtime path、编辑页面和最终 renderer。
|
||||
|
||||
| 内容类别 | Admin 来源 | 数据库来源 | API Runtime | 小程序消费 | 当前状态 |
|
||||
| ------------------------------ | --------------------- | ---------------------------------------- | ------------------------------------------------------- | -------------------------- | ---------------------------------------------------------- |
|
||||
| 品牌名称、定位、简介、联系信息 | 品牌资料 | `BrandProfile` columns | `workspace.brand` | 各模板 brand component | 已收敛,旧 config 仅兼容 |
|
||||
| 模板自定义品牌字段 | 模板页面编辑器 | `BrandProfile.config.templateData` | `workspace.templateData` | 模板页面读取 | 已有 contract,需继续禁止未声明 key |
|
||||
| 页面标题和按钮文案 | 模板页面编辑器 | `BrandProfile.config.visualPresentation` | `workspace.brand.visualPresentation` | 页面 presentation props | 已有 contract |
|
||||
| 业务摘要 | 业务提供项表单 | `Offering.summary` | `workspace.offerings[].summary` | 列表和首页 | 已收敛 |
|
||||
| 业务详情正文 | 模板详情字段 | `Offering.config.details.background` | `workspace.offerings[].presentation.details.background` | 详情页 | 已收敛,禁止重复 description 入口 |
|
||||
| 业务图片、分类、关键词 | 模板详情字段 | `Offering.config` | `workspace.offerings[].presentation` | 详情/列表页 | 已有映射测试 |
|
||||
| 信任内容标题、摘要、正文 | 信任内容编辑器 | `TrustContent.title/summary/content` | `workspace.trustItems[]` | 首页、资料页及出摊区块标题 | 已修正 trustItems 传参,隐藏字段不消费 |
|
||||
| 信任内容扩展 | 模板声明 configFields | `TrustContent.config` | `workspace.trustItems[].config` | 模板组件 | 已验证编辑、发布、页面数据及必填规则 |
|
||||
| 咨询表单字段 | 工作台表单编辑器 | `InquiryForm.fieldsSnapshot` | `workspace.inquiryForms[].fields` | inquiry form | 已验证实际数据库表单与生成页面,餐饮类型网格和双列布局保留 |
|
||||
|
||||
餐饮出摊服务的日程、配送和流程正文均使用结构化 `configFields`,不再读取隐藏的摘要和正文。`maxPublishedItems: 1` 由该模板为三个固定区域声明,Admin 和发布检查同时提示重复公开记录。每周主卡内两张日程小卡、配送双列和流程标题/说明列表均由模板布局固定,不由数据库记录数量推断。
|
||||
@@ -0,0 +1,54 @@
|
||||
# Template Data Flow
|
||||
|
||||
This document records where template-controlled content is stored and how it reaches the Mini Program. Template packages define presentation and editor declarations; database rows are the source of truth for each brand's edited content.
|
||||
|
||||
## Storage And Runtime Mapping
|
||||
|
||||
| Content | Template declaration | Brand-scoped storage | Admin editor | Published runtime |
|
||||
| -------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Brand identity and contact facts | `admin.sections` bindings such as `brand.config.founder`; platform identity fields are shared | `BrandProfile` columns and `BrandProfile.config` JSON | Brand profile and page configuration | Brand data is copied into `BrandRelease.snapshot`; public workspace merges the brand config into `RuntimeWorkspace.brand` |
|
||||
| Page copy and presentation | `admin.sections` with exact page binding | `BrandProfile.config.visualPresentation` and related config objects | Template-driven page editor | Public workspace exposes the saved config; Mini Program renderers consume the matching page fields |
|
||||
| Offerings and details | Offering-target `admin.sections` | `Offering` columns and `Offering.config` JSON | Services editor | Release snapshot offerings are normalized by public workspace; disabled offerings are filtered |
|
||||
| Trust content | `trustContentTypes`, including page destinations and Admin labels for `title`, `summary`, and `content` | Brand-scoped `TrustContent` rows | Trust content editor; form labels/options come from the selected template manifest | Only published rows are copied to public runtime; template pages render declared types |
|
||||
| Inquiry forms | The template package provides an explicit sample form name and sample fields | Brand-scoped `InquiryForm.fieldsSnapshot`; submissions keep their own snapshots | Workspace form editor; explicit sample import creates a form only when no enabled form exists | Release snapshot forms are normalized into `RuntimeWorkspace.inquiryForms` |
|
||||
| Template and visual selection | Package manifest and visual template manifest | `BrandTemplateInstallation` snapshot plus `BrandProfile.templateKey/config.visualTemplateKey` | Workspace/template selection | Release snapshot pins package and visual manifest versions |
|
||||
|
||||
## Food Schedule Example
|
||||
|
||||
The food template declares the schedule type for the `home` and `service` pages. Its Admin fields map directly to existing database columns:
|
||||
|
||||
- `adminFields.title` edits `TrustContent.title`.
|
||||
- `adminFields.summary` edits the primary weekday schedule in `TrustContent.summary`.
|
||||
- `adminFields.content` edits the weekend and supplementary schedule in `TrustContent.content`.
|
||||
- The public workspace returns those values as a `RuntimeTrustItem`; the home and service page renderers read `item.summary` and `item.content`.
|
||||
|
||||
No schedule-specific Prisma migration is needed. Different templates can choose different field labels while retaining the shared trust-content storage contract.
|
||||
|
||||
The Admin editor lists the selected template's declared trust types and uses their `adminFields` labels, help, and placeholders. In the food workspace, the service page links directly to the trust-content editor, so the schedule is configured under **内容管理 → 信任内容 → 出摊安排**. Saving changes the brand's draft content; the Mini Program sees the new values after the next publication.
|
||||
|
||||
## Inquiry Field Runtime Mapping
|
||||
|
||||
- Explicit sample import copies package-declared fields into `InquiryForm.fieldsSnapshot` only when the brand has no enabled inquiry form. It does not overwrite an existing form.
|
||||
- The public workspace projects the persisted form into Runtime field types. `phone` becomes Mini Program `tel`, and `multi-select` becomes the supported `checkbox` control.
|
||||
- The Mini Program renders checkbox options and submits the selected values as an array. The stored Admin/API field type remains `multi-select`.
|
||||
|
||||
## Template-Specific Shallow Data
|
||||
|
||||
Templates may declare a small set of customer-specific `templateFields`. Their values are stored under `BrandProfile.config.templateData`, edited by the same manifest-driven Admin editor, copied into the publication snapshot, and exposed as `RuntimeWorkspace.templateData`. The contract intentionally supports shallow scalar fields and one-level lists; it is not an arbitrary JSON editor. Undeclared keys are filtered from the public Runtime response.
|
||||
|
||||
## Shared Platform Data
|
||||
|
||||
The visual template packages and their manifests are package-discovered. Brand-specific copy, trust content, offerings, and inquiry forms are persisted per brand and included in publication snapshots. The platform's `BrandTemplateDefinition` taxonomy (`personal`, `food`, and `doors`) remains a shared product-level catalog used for template selection and brand categorization; it is not the source of visual package content or sample data. Adding a visual package does not require adding its sample records to Prisma seed data.
|
||||
|
||||
## Template Completion Checks
|
||||
|
||||
- `pnpm validate:templates` discovers every `packages/template-*` package and checks same-page Admin bindings, trust type declarations, sample trust type declarations, and trust Admin field labels.
|
||||
- API integration tests cover trust authorization, writes to the persisted summary/content columns, and rejection of types absent from the brand's selected template manifest.
|
||||
- `pnpm template:check` also compiles templates and validates Mini Program fixture output.
|
||||
- Package-discovered contract tests compare each declared trust type against Mini Program page renderers and require Admin labels for the persisted `TrustContent` columns.
|
||||
|
||||
## Boundaries
|
||||
|
||||
- `template.json.sampleContent` is an import fixture, not live brand content. It is copied into brand rows only after an explicit Admin import.
|
||||
- Active customer inquiry forms are persisted separately from `BrandFieldDefinition`; the public Mini Program receives `InquiryForm.fieldsSnapshot`. Importing sample fields creates a form only when no enabled form exists and never replaces administrator-authored forms.
|
||||
- Layout, icons, and template-specific visual composition remain package code. Brand facts and business claims shown in those layouts must come from brand-scoped runtime data.
|
||||
@@ -12,6 +12,7 @@ export default tseslint.config(
|
||||
"apps/api/test/**/*.test.js",
|
||||
"apps/api/test/**/*.cjs",
|
||||
"apps/admin/test/**/*.test.mjs",
|
||||
"packages/types/test/**/*.test.mjs",
|
||||
"apps/miniapp/pages/**/*.js",
|
||||
"apps/miniapp/app.js",
|
||||
"apps/admin/vite.config.ts",
|
||||
|
||||
@@ -67,10 +67,20 @@ export type BrandPresentationUpdate = Partial<
|
||||
|
||||
export interface TemplateAdminField {
|
||||
key: string;
|
||||
page?: string;
|
||||
binding: string;
|
||||
label: string;
|
||||
help?: string;
|
||||
input: "text" | "textarea" | "phone" | "image" | "number" | "list";
|
||||
input:
|
||||
| "text"
|
||||
| "textarea"
|
||||
| "phone"
|
||||
| "image"
|
||||
| "number"
|
||||
| "boolean"
|
||||
| "select"
|
||||
| "multi-select"
|
||||
| "list";
|
||||
itemFields?: Array<{
|
||||
key: string;
|
||||
label: string;
|
||||
@@ -81,12 +91,14 @@ export interface TemplateAdminField {
|
||||
required?: boolean;
|
||||
maxLength?: number;
|
||||
placeholder?: string;
|
||||
options?: Array<{ value: string; label: string }>;
|
||||
}
|
||||
|
||||
export interface TemplateAdminSection {
|
||||
key: string;
|
||||
title: string;
|
||||
description: string;
|
||||
page: string;
|
||||
target: "brand" | "offering" | "trust" | "inquiry";
|
||||
fields: TemplateAdminField[];
|
||||
}
|
||||
@@ -94,13 +106,25 @@ export interface TemplateAdminSection {
|
||||
export interface AdminTemplateContent {
|
||||
displayName: string;
|
||||
admin: { sections: TemplateAdminSection[] };
|
||||
navigation: Array<{ key: string; label: string; page: string }>;
|
||||
templateFields?: TemplateAdminField[];
|
||||
trustContentTypes?: Array<{
|
||||
type: string;
|
||||
label: string;
|
||||
adminFields: {
|
||||
title: string;
|
||||
summary: string;
|
||||
content: string;
|
||||
summaryHelp?: string;
|
||||
summaryPlaceholder?: string;
|
||||
};
|
||||
pages?: string[];
|
||||
help?: string;
|
||||
placeholder?: string;
|
||||
required?: boolean;
|
||||
configFields?: TemplateAdminField[];
|
||||
maxPublishedItems?: number;
|
||||
hideStandardFields?: Array<"summary" | "content">;
|
||||
}>;
|
||||
assetSlots: Array<{
|
||||
key: string;
|
||||
@@ -716,6 +740,7 @@ export class ApiClient {
|
||||
templateKey: string;
|
||||
alreadyImported: boolean;
|
||||
counts: Record<string, number>;
|
||||
willCreateInquiryForm: boolean;
|
||||
}> {
|
||||
return this.request("/admin/workspace/sample-content/preview");
|
||||
}
|
||||
@@ -845,3 +870,5 @@ export class ApiClient {
|
||||
}
|
||||
|
||||
export const apiClientName = "personal-brand-api-client";
|
||||
|
||||
export { isTrustContentComplete } from "@personal-brand/types";
|
||||
@@ -141,7 +141,8 @@ export const generatedTemplatePackageRegistry = [
|
||||
{
|
||||
"key": "identity",
|
||||
"title": "摊位与主理人",
|
||||
"description": "让访客知道谁在出餐、在哪里可以找到你。",
|
||||
"description": "配置主理人姓名与身份,介绍、头像和联系方式在品牌资料中编辑。",
|
||||
"page": "profile",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -152,13 +153,6 @@ export const generatedTemplatePackageRegistry = [
|
||||
"required": true,
|
||||
"placeholder": "例如:阿成"
|
||||
},
|
||||
{
|
||||
"key": "portrait",
|
||||
"binding": "brand.config.avatarUrl",
|
||||
"label": "主理人照片",
|
||||
"help": "使用清晰、真实的照片,让顾客知道是谁在认真做餐。",
|
||||
"input": "image"
|
||||
},
|
||||
{
|
||||
"key": "title",
|
||||
"binding": "brand.config.title",
|
||||
@@ -168,29 +162,29 @@ export const generatedTemplatePackageRegistry = [
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "slogan",
|
||||
"binding": "brand.config.slogan",
|
||||
"label": "想对顾客说的一句话",
|
||||
"input": "textarea",
|
||||
"maxLength": 80
|
||||
},
|
||||
{
|
||||
"key": "studioAddress",
|
||||
"binding": "brand.config.studioAddress",
|
||||
"label": "出摊地点或服务范围",
|
||||
"key": "badge",
|
||||
"binding": "brand.config.visualPresentation.profile.badge",
|
||||
"label": "写真角标",
|
||||
"input": "text",
|
||||
"required": true
|
||||
"help": "显示在主理人写真上,可填写经验或服务定位。"
|
||||
},
|
||||
{
|
||||
"key": "phone",
|
||||
"binding": "brand.config.phone",
|
||||
"label": "公开联系电话",
|
||||
"input": "phone"
|
||||
"key": "storyLead",
|
||||
"binding": "brand.config.visualPresentation.profile.storyLead",
|
||||
"label": "故事引言",
|
||||
"input": "textarea",
|
||||
"help": "故事开头的强调段落,下面的正文使用品牌简介。"
|
||||
},
|
||||
{
|
||||
"key": "wechat",
|
||||
"binding": "brand.config.wechat",
|
||||
"label": "公开微信号",
|
||||
"key": "recordsTitle",
|
||||
"binding": "brand.config.visualPresentation.profile.recordsTitle",
|
||||
"label": "记录入口文案",
|
||||
"input": "text"
|
||||
},
|
||||
{
|
||||
"key": "recordsCountUnit",
|
||||
"binding": "brand.config.visualPresentation.profile.recordsCountUnit",
|
||||
"label": "记录数量单位",
|
||||
"input": "text"
|
||||
}
|
||||
]
|
||||
@@ -199,6 +193,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "home",
|
||||
"title": "首页出摊信息",
|
||||
"description": "说明今天在哪里、何时营业,以及餐品有什么特点。",
|
||||
"page": "home",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -223,18 +218,6 @@ export const generatedTemplatePackageRegistry = [
|
||||
"input": "text",
|
||||
"placeholder": "例如:17:00 - 22:30 · 今日营业中"
|
||||
},
|
||||
{
|
||||
"key": "coverageContent",
|
||||
"binding": "brand.config.visualPresentation.profile.coverageContent",
|
||||
"label": "取餐与配送说明",
|
||||
"input": "textarea"
|
||||
},
|
||||
{
|
||||
"key": "coverageTitle",
|
||||
"binding": "brand.config.visualPresentation.profile.coverageTitle",
|
||||
"label": "服务方式标题",
|
||||
"input": "text"
|
||||
},
|
||||
{
|
||||
"key": "worksEyebrow",
|
||||
"binding": "brand.config.visualPresentation.home.worksEyebrow",
|
||||
@@ -258,23 +241,10 @@ export const generatedTemplatePackageRegistry = [
|
||||
{
|
||||
"key": "service",
|
||||
"title": "出摊服务页说明",
|
||||
"description": "设置出摊服务页的区块标题和咨询入口文字;具体时间、范围和流程内容在信任内容中维护。",
|
||||
"description": "设置出摊服务页的咨询按钮;日程、取餐配送和流程在对应内容编辑器中维护。",
|
||||
"page": "service",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
"key": "coverageLabel",
|
||||
"binding": "brand.config.visualPresentation.service.coverageLabel",
|
||||
"label": "服务范围标签",
|
||||
"input": "text",
|
||||
"placeholder": "例如:取餐与配送"
|
||||
},
|
||||
{
|
||||
"key": "stepLabel",
|
||||
"binding": "brand.config.visualPresentation.service.stepLabel",
|
||||
"label": "流程步骤标签",
|
||||
"input": "text",
|
||||
"placeholder": "例如:第"
|
||||
},
|
||||
{
|
||||
"key": "processAction",
|
||||
"binding": "brand.config.visualPresentation.service.processAction",
|
||||
@@ -288,6 +258,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "menu",
|
||||
"title": "菜单页说明",
|
||||
"description": "帮助顾客理解日常餐品和团体定制的选择方式。",
|
||||
"page": "offerings",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -316,6 +287,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "booking",
|
||||
"title": "预订与定制",
|
||||
"description": "告诉顾客提交信息后会如何确认餐品和时间。",
|
||||
"page": "inquiry",
|
||||
"target": "inquiry",
|
||||
"fields": [
|
||||
{
|
||||
@@ -351,6 +323,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "dishDetail",
|
||||
"title": "餐品与服务详情",
|
||||
"description": "每项餐品或服务单独填写;没有内容的详情区块不会展示。",
|
||||
"page": "detail",
|
||||
"target": "offering",
|
||||
"fields": [
|
||||
{
|
||||
@@ -443,6 +416,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "detailCopy",
|
||||
"title": "详情页说明",
|
||||
"description": "解释价格、餐品内容和咨询后会怎样处理。",
|
||||
"page": "detail",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -500,6 +474,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "successCopy",
|
||||
"title": "提交成功页",
|
||||
"description": "顾客提交后看到的确认信息与后续预期。",
|
||||
"page": "success",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -539,6 +514,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "recordsCopy",
|
||||
"title": "咨询记录页",
|
||||
"description": "顾客查看预订与咨询处理进度时看到的内容。",
|
||||
"page": "records",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -578,44 +554,320 @@ export const generatedTemplatePackageRegistry = [
|
||||
"trustContentTypes": [
|
||||
{
|
||||
"type": "schedule",
|
||||
"label": "出摊与营业安排",
|
||||
"help": "说明固定出摊时间、临时营业安排或接受预订的时段。",
|
||||
"placeholder": "例如:周一至周五 17:00 - 22:30",
|
||||
"required": true
|
||||
"label": "每周出摊安排",
|
||||
"adminFields": {
|
||||
"title": "安排标题",
|
||||
"summary": "主要时段(周一至周五)",
|
||||
"content": "其他时段与补充安排(周末等)",
|
||||
"summaryHelp": "此摘要作为出摊服务页的主要时段展示。",
|
||||
"summaryPlaceholder": "周一至周五 17:00 - 22:30"
|
||||
},
|
||||
"configFields": [
|
||||
{
|
||||
"key": "status",
|
||||
"binding": "trust.config.status",
|
||||
"label": "状态标签",
|
||||
"input": "text",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"key": "weekdayLabel",
|
||||
"binding": "trust.config.weekdayLabel",
|
||||
"label": "工作日标题",
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "weekdayTag",
|
||||
"binding": "trust.config.weekdayTag",
|
||||
"label": "工作日标签",
|
||||
"input": "text",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"key": "weekdayDetail",
|
||||
"binding": "trust.config.weekdayDetail",
|
||||
"label": "工作日地点",
|
||||
"input": "textarea",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "weekdayHours",
|
||||
"binding": "trust.config.weekdayHours",
|
||||
"label": "工作日营业时间",
|
||||
"input": "text",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"key": "weekendLabel",
|
||||
"binding": "trust.config.weekendLabel",
|
||||
"label": "周末标题",
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "weekendTag",
|
||||
"binding": "trust.config.weekendTag",
|
||||
"label": "周末标签",
|
||||
"input": "text",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"key": "weekendDetail",
|
||||
"binding": "trust.config.weekendDetail",
|
||||
"label": "周末白天安排",
|
||||
"input": "textarea",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "weekendHours",
|
||||
"binding": "trust.config.weekendHours",
|
||||
"label": "周末晚间安排",
|
||||
"input": "text",
|
||||
"required": false
|
||||
}
|
||||
],
|
||||
"hideStandardFields": [
|
||||
"summary",
|
||||
"content"
|
||||
],
|
||||
"pages": [
|
||||
"service"
|
||||
],
|
||||
"help": "分别编辑工作日和周末两张日程小卡,不再使用摘要或正文拼接时间。",
|
||||
"placeholder": "例如:\n周一至周五 17:00 - 22:30\n周六、周日承接团体单与夜市流动出摊",
|
||||
"required": true,
|
||||
"maxPublishedItems": 1
|
||||
},
|
||||
{
|
||||
"type": "coverage",
|
||||
"label": "取餐与配送范围",
|
||||
"adminFields": {
|
||||
"title": "范围标题",
|
||||
"summary": "方式摘要",
|
||||
"content": "取餐与配送说明"
|
||||
},
|
||||
"configFields": [
|
||||
{
|
||||
"key": "pickupTitle",
|
||||
"binding": "trust.config.pickupTitle",
|
||||
"label": "现场自取标题",
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "pickupDetail",
|
||||
"binding": "trust.config.pickupDetail",
|
||||
"label": "现场自取说明",
|
||||
"input": "textarea",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "deliveryTitle",
|
||||
"binding": "trust.config.deliveryTitle",
|
||||
"label": "校内配送标题",
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "deliveryDetail",
|
||||
"binding": "trust.config.deliveryDetail",
|
||||
"label": "校内配送说明",
|
||||
"input": "textarea",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"hideStandardFields": [
|
||||
"summary",
|
||||
"content"
|
||||
],
|
||||
"pages": [
|
||||
"service"
|
||||
],
|
||||
"help": "说明服务地点、取餐方式和可配送范围。",
|
||||
"placeholder": "例如:支持校内宿舍楼下配送",
|
||||
"required": true
|
||||
"required": true,
|
||||
"maxPublishedItems": 1
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"label": "定制餐品流程",
|
||||
"help": "每行写一步,从提出需求到完成交付。",
|
||||
"adminFields": {
|
||||
"title": "流程标题",
|
||||
"summary": "流程摘要",
|
||||
"content": "流程步骤"
|
||||
},
|
||||
"configFields": [
|
||||
{
|
||||
"key": "steps",
|
||||
"binding": "trust.config.steps",
|
||||
"label": "流程步骤",
|
||||
"input": "list",
|
||||
"itemFields": [
|
||||
{
|
||||
"key": "title",
|
||||
"label": "步骤标题",
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "detail",
|
||||
"label": "步骤说明",
|
||||
"input": "textarea",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "intro",
|
||||
"binding": "trust.config.intro",
|
||||
"label": "流程介绍",
|
||||
"input": "text"
|
||||
},
|
||||
{
|
||||
"key": "minimumNote",
|
||||
"binding": "trust.config.minimumNote",
|
||||
"label": "起订说明",
|
||||
"input": "text"
|
||||
},
|
||||
{
|
||||
"key": "refundNote",
|
||||
"binding": "trust.config.refundNote",
|
||||
"label": "退改说明",
|
||||
"input": "text"
|
||||
}
|
||||
],
|
||||
"hideStandardFields": [
|
||||
"summary",
|
||||
"content"
|
||||
],
|
||||
"pages": [
|
||||
"service"
|
||||
],
|
||||
"help": "每个步骤分别填写标题和说明,按列表顺序展示。",
|
||||
"placeholder": "例如:提交需求\n确认菜单\n制作交付",
|
||||
"required": true
|
||||
"required": true,
|
||||
"maxPublishedItems": 1
|
||||
},
|
||||
{
|
||||
"type": "credential",
|
||||
"label": "食品安全与制作标准",
|
||||
"help": "填写让顾客放心的资质、卫生或制作标准。"
|
||||
"adminFields": {
|
||||
"title": "证明标题",
|
||||
"summary": "标准摘要",
|
||||
"content": "资质与制作说明"
|
||||
},
|
||||
"pages": [
|
||||
"profile"
|
||||
],
|
||||
"help": "填写让顾客放心的资质、卫生或制作标准。",
|
||||
"configFields": [
|
||||
{
|
||||
"key": "standards",
|
||||
"binding": "trust.config.standards",
|
||||
"label": "资质与卫生小卡",
|
||||
"input": "list",
|
||||
"itemFields": [
|
||||
{
|
||||
"key": "title",
|
||||
"label": "小卡标题",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "detail",
|
||||
"label": "小卡说明",
|
||||
"required": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "case",
|
||||
"label": "客户案例与反馈",
|
||||
"help": "填写代表性订单、活动案例或客户评价。"
|
||||
"adminFields": {
|
||||
"title": "案例标题",
|
||||
"summary": "案例摘要",
|
||||
"content": "案例与客户反馈"
|
||||
},
|
||||
"pages": [
|
||||
"home",
|
||||
"profile"
|
||||
],
|
||||
"help": "填写代表性订单、活动案例或客户评价。",
|
||||
"configFields": [
|
||||
{
|
||||
"key": "entries",
|
||||
"binding": "trust.config.entries",
|
||||
"label": "合作案例条目",
|
||||
"input": "list",
|
||||
"itemFields": [
|
||||
{
|
||||
"key": "badge",
|
||||
"label": "左侧简称",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "title",
|
||||
"label": "案例名称",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "detail",
|
||||
"label": "交付说明"
|
||||
},
|
||||
{
|
||||
"key": "result",
|
||||
"label": "右侧结果标签"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "promise",
|
||||
"label": "回复与服务承诺",
|
||||
"help": "说明回复时间、退改规则或服务承诺。"
|
||||
"adminFields": {
|
||||
"title": "承诺标题",
|
||||
"summary": "承诺摘要",
|
||||
"content": "服务承诺详情"
|
||||
},
|
||||
"pages": [
|
||||
"home",
|
||||
"profile"
|
||||
],
|
||||
"help": "说明回复时间、退改规则或服务承诺。",
|
||||
"configFields": [
|
||||
{
|
||||
"key": "commitments",
|
||||
"binding": "trust.config.commitments",
|
||||
"label": "回复承诺条目",
|
||||
"input": "list",
|
||||
"itemFields": [
|
||||
{
|
||||
"key": "label",
|
||||
"label": "情境或时段",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "detail",
|
||||
"label": "承诺说明",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "highlight",
|
||||
"label": "强调文字"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"sampleContent": {
|
||||
"food": {
|
||||
"templateKey": "food",
|
||||
"inquiryFormName": "餐品预订与定制表单",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "package",
|
||||
@@ -632,14 +884,127 @@ export const generatedTemplatePackageRegistry = [
|
||||
],
|
||||
"trustContent": [
|
||||
{
|
||||
"type": "credential",
|
||||
"title": "关于主理人",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
"type": "schedule",
|
||||
"title": "每周出摊固定日程",
|
||||
"content": "",
|
||||
"config": {
|
||||
"status": "准时出摊",
|
||||
"weekdayLabel": "周一至周五(晚餐 + 夜宵档)",
|
||||
"weekdayTag": "常规固定点",
|
||||
"weekdayDetail": "地点:二号校门外小吃商业街 #07 号铺位",
|
||||
"weekdayHours": "营业:17:00 - 22:30(下雨搭防雨防风棚正常营业)",
|
||||
"weekendLabel": "周六、周日(全天接团体单 + 夜市流动)",
|
||||
"weekendTag": "活动专车",
|
||||
"weekendDetail": "白天专供:球赛、班级春游、社团集训、答辩餐",
|
||||
"weekendHours": "晚间:18:00 - 23:00 体育馆南侧流动出摊"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "coverage",
|
||||
"title": "取餐与配送范围",
|
||||
"content": "",
|
||||
"config": {
|
||||
"pickupTitle": "摊位现场自取",
|
||||
"pickupDetail": "小程序提前留餐,报手机尾号即拿,附赠特制加厚保温袋,不用排长龙。",
|
||||
"deliveryTitle": "校内楼下配送",
|
||||
"deliveryDetail": "满 3 份即可送至宿舍楼栋或实验楼门前,阿成骑专用恒温保温箱电动车直送。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"title": "从预订到取餐",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
"title": "定制餐品 4 步流程",
|
||||
"content": "",
|
||||
"config": {
|
||||
"intro": "专为班长、社长、活动干事设计的极简排菜流程",
|
||||
"steps": [
|
||||
{
|
||||
"title": "提交基本需求",
|
||||
"detail": "选择活动类型(如生日会、社团换届、答辩加餐)、预估人数与预算。"
|
||||
},
|
||||
{
|
||||
"title": "15 分钟内核算菜单",
|
||||
"detail": "阿成微信直接联系,提供荤素搭配明细与个性化需求(免辣、清真配料等)。"
|
||||
},
|
||||
{
|
||||
"title": "当日新鲜烹饪打包",
|
||||
"detail": "提前 2 小时生鲜采买,铁锅现炒,独立封盒并标注姓名 / 楼栋。"
|
||||
},
|
||||
{
|
||||
"title": "保温直达交付",
|
||||
"detail": "约定时间准时送抵指定场地,确认菜品温度与数量无误后结算。"
|
||||
}
|
||||
],
|
||||
"minimumNote": "起订门槛:6 份起",
|
||||
"refundNote": "退改:出餐前 2 小时全退"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "credential",
|
||||
"title": "食品安全与制作标准",
|
||||
"content": "示例内容,请根据实际资质和制作标准完善。",
|
||||
"config": {
|
||||
"standards": [
|
||||
{
|
||||
"title": "当天采购",
|
||||
"detail": "按当天需求采买"
|
||||
},
|
||||
{
|
||||
"title": "现做现出餐",
|
||||
"detail": "按约定时间制作"
|
||||
},
|
||||
{
|
||||
"title": "食具清洁消毒",
|
||||
"detail": "每日清洁与消毒"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "case",
|
||||
"title": "他们都在阿成这订过餐",
|
||||
"summary": "感谢大学城各学院与社团伙伴的信任",
|
||||
"content": "校街舞社年度专场 · 52 人份\n信息学院科创竞赛 · 连签 5 天\n7 号楼庆功宴 · 8 人定制",
|
||||
"config": {
|
||||
"entries": [
|
||||
{
|
||||
"badge": "舞",
|
||||
"title": "校街舞社年度专场(52 人份)",
|
||||
"detail": "保温箱直达大礼堂后台,贴名分装",
|
||||
"result": "零延误签收"
|
||||
},
|
||||
{
|
||||
"badge": "科",
|
||||
"title": "信息学院科创竞赛封闭备赛",
|
||||
"detail": "每日荤素轮换,附赠每日滋补老汤",
|
||||
"result": "连签 5 天"
|
||||
},
|
||||
{
|
||||
"badge": "寝",
|
||||
"title": "7 号楼庆功宴(8 人定制)",
|
||||
"detail": "定制双拼厚肉饭",
|
||||
"result": "定制餐品"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "promise",
|
||||
"title": "阿成的真实回复承诺",
|
||||
"content": "备料期 15 分钟内联系,出摊高峰 1 小时内回复。",
|
||||
"config": {
|
||||
"commitments": [
|
||||
{
|
||||
"label": "非出摊备料期",
|
||||
"detail": "提交咨询后通过微信或电话沟通。",
|
||||
"highlight": "15 分钟内"
|
||||
},
|
||||
{
|
||||
"label": "出摊晚高峰",
|
||||
"detail": "正在出餐,稍有延迟,会抽空回复。",
|
||||
"highlight": "1 小时内"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"fields": [
|
||||
@@ -870,6 +1235,17 @@ export const generatedTemplatePackageRegistry = [
|
||||
"description": "访客自己的咨询记录"
|
||||
}
|
||||
],
|
||||
"templateFields": [
|
||||
{
|
||||
"key": "designPhilosophy",
|
||||
"page": "home",
|
||||
"label": "设计理念",
|
||||
"help": "用一两句话说明你的设计方法。",
|
||||
"input": "textarea",
|
||||
"maxLength": 160,
|
||||
"placeholder": "例如:克制、自然、长期主义"
|
||||
}
|
||||
],
|
||||
"assetSlots": [
|
||||
{
|
||||
"key": "brand.portrait",
|
||||
@@ -908,6 +1284,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "identity",
|
||||
"title": "主理人与联系方式",
|
||||
"description": "让业主清楚谁负责项目,以及如何联系你。",
|
||||
"page": "profile",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -917,13 +1294,6 @@ export const generatedTemplatePackageRegistry = [
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "portrait",
|
||||
"binding": "brand.config.avatarUrl",
|
||||
"label": "主理人肖像",
|
||||
"help": "建议使用正式、清晰的个人照片。",
|
||||
"input": "image"
|
||||
},
|
||||
{
|
||||
"key": "title",
|
||||
"binding": "brand.config.title",
|
||||
@@ -931,32 +1301,6 @@ export const generatedTemplatePackageRegistry = [
|
||||
"input": "text",
|
||||
"required": true,
|
||||
"placeholder": "例如:别墅门系统主理人"
|
||||
},
|
||||
{
|
||||
"key": "slogan",
|
||||
"binding": "brand.config.slogan",
|
||||
"label": "主理人主张",
|
||||
"input": "textarea",
|
||||
"maxLength": 100
|
||||
},
|
||||
{
|
||||
"key": "studioAddress",
|
||||
"binding": "brand.config.studioAddress",
|
||||
"label": "服务区域或工作室地址",
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "phone",
|
||||
"binding": "brand.config.phone",
|
||||
"label": "公开联系电话",
|
||||
"input": "phone"
|
||||
},
|
||||
{
|
||||
"key": "wechat",
|
||||
"binding": "brand.config.wechat",
|
||||
"label": "公开微信号",
|
||||
"input": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -964,6 +1308,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "home",
|
||||
"title": "首页品牌表达",
|
||||
"description": "用简洁的语言解释你的项目方法、代表作品和合作流程。",
|
||||
"page": "home",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -1065,6 +1410,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "profileDetails",
|
||||
"title": "服务区域与履约说明",
|
||||
"description": "在主理人与我页面说明可服务的地区和真实履约承诺。",
|
||||
"page": "profile",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -1164,6 +1510,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "cases",
|
||||
"title": "案例与体系",
|
||||
"description": "说明案例页展示的内容,让业主能快速找到相近项目。",
|
||||
"page": "offerings",
|
||||
"target": "offering",
|
||||
"fields": [
|
||||
{
|
||||
@@ -1203,6 +1550,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "consultation",
|
||||
"title": "咨询说明",
|
||||
"description": "明确访客提交后会得到怎样的回应,减少无效咨询。",
|
||||
"page": "inquiry",
|
||||
"target": "inquiry",
|
||||
"fields": [
|
||||
{
|
||||
@@ -1242,6 +1590,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "projectDetail",
|
||||
"title": "案例详情",
|
||||
"description": "以下内容分别填写在每个案例中,空白内容不会展示。",
|
||||
"page": "detail",
|
||||
"target": "offering",
|
||||
"fields": [
|
||||
{
|
||||
@@ -1334,6 +1683,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "detailCopy",
|
||||
"title": "详情页说明",
|
||||
"description": "说明案例内容、价格与咨询后的真实处理方式。",
|
||||
"page": "detail",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -1391,6 +1741,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "successCopy",
|
||||
"title": "提交成功页",
|
||||
"description": "访客提交后看到的确认信息与后续预期。",
|
||||
"page": "success",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -1430,6 +1781,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
"key": "recordsCopy",
|
||||
"title": "咨询记录页",
|
||||
"description": "访客查看咨询状态时看到的内容。",
|
||||
"page": "records",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -1470,16 +1822,40 @@ export const generatedTemplatePackageRegistry = [
|
||||
{
|
||||
"type": "schedule",
|
||||
"label": "服务与合作安排",
|
||||
"adminFields": {
|
||||
"title": "安排标题",
|
||||
"summary": "安排摘要",
|
||||
"content": "时间与排期详情"
|
||||
},
|
||||
"pages": [
|
||||
"profile"
|
||||
],
|
||||
"help": "说明可预约时间、服务周期或项目排期。"
|
||||
},
|
||||
{
|
||||
"type": "coverage",
|
||||
"label": "服务范围与适用对象",
|
||||
"adminFields": {
|
||||
"title": "范围标题",
|
||||
"summary": "范围摘要",
|
||||
"content": "服务范围说明"
|
||||
},
|
||||
"pages": [
|
||||
"profile"
|
||||
],
|
||||
"help": "说明服务地区、项目类型或合作边界。"
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"label": "合作流程",
|
||||
"adminFields": {
|
||||
"title": "流程标题",
|
||||
"summary": "流程摘要",
|
||||
"content": "流程步骤"
|
||||
},
|
||||
"pages": [
|
||||
"profile"
|
||||
],
|
||||
"help": "每行写一步,从初次沟通到交付完成。",
|
||||
"placeholder": "例如:需求沟通\n方案确认\n落地交付",
|
||||
"required": true
|
||||
@@ -1487,6 +1863,15 @@ export const generatedTemplatePackageRegistry = [
|
||||
{
|
||||
"type": "credential",
|
||||
"label": "专业资历与方法",
|
||||
"adminFields": {
|
||||
"title": "证明标题",
|
||||
"summary": "专业摘要",
|
||||
"content": "资历与方法说明"
|
||||
},
|
||||
"pages": [
|
||||
"home",
|
||||
"profile"
|
||||
],
|
||||
"help": "填写经验、资质、专业标准或工作方法。",
|
||||
"configFields": [
|
||||
{
|
||||
@@ -1552,17 +1937,34 @@ export const generatedTemplatePackageRegistry = [
|
||||
{
|
||||
"type": "case",
|
||||
"label": "项目案例与客户反馈",
|
||||
"adminFields": {
|
||||
"title": "案例标题",
|
||||
"summary": "案例摘要",
|
||||
"content": "项目成果与客户反馈"
|
||||
},
|
||||
"pages": [
|
||||
"profile"
|
||||
],
|
||||
"help": "填写代表性项目、成果或客户评价。"
|
||||
},
|
||||
{
|
||||
"type": "promise",
|
||||
"label": "合作预期与响应承诺",
|
||||
"adminFields": {
|
||||
"title": "承诺标题",
|
||||
"summary": "承诺摘要",
|
||||
"content": "合作与响应说明"
|
||||
},
|
||||
"pages": [
|
||||
"profile"
|
||||
],
|
||||
"help": "说明回复时间、合作边界和后续跟进方式。"
|
||||
}
|
||||
],
|
||||
"sampleContent": {
|
||||
"doors": {
|
||||
"templateKey": "doors",
|
||||
"inquiryFormName": "门系统咨询表单",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "product",
|
||||
@@ -1733,6 +2135,7 @@ export const generatedTemplatePackageRegistry = [
|
||||
},
|
||||
"personal": {
|
||||
"templateKey": "personal",
|
||||
"inquiryFormName": "合作咨询表单",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "service",
|
||||
@@ -1791,4 +2194,4 @@ export const generatedTemplatePackageRegistry = [
|
||||
}
|
||||
];
|
||||
export const generatedTemplatePackageRegistryHash =
|
||||
"4004c3102fdf693432f8309809ee91bae8f6aba32c6b01247c288308fa7ce65a";
|
||||
"17a54a9f2e4a95cfa16941d1ecf37abeb88f463046a1da0bdc8767a56d4a4cc1";
|
||||
@@ -208,6 +208,20 @@ export interface TemplatePackageManifest {
|
||||
required: boolean;
|
||||
description: string;
|
||||
}[];
|
||||
templateFields?: readonly {
|
||||
key: string;
|
||||
page?: string;
|
||||
binding?: string;
|
||||
label: string;
|
||||
help?: string;
|
||||
input: string;
|
||||
itemFields?: readonly { key: string; label: string; input?: string; required?: boolean }[];
|
||||
itemValueKey?: string;
|
||||
required?: boolean;
|
||||
maxLength?: number;
|
||||
placeholder?: string;
|
||||
options?: readonly { value: string; label: string }[];
|
||||
}[];
|
||||
assetSlots: readonly {
|
||||
key: string;
|
||||
binding: string;
|
||||
@@ -236,9 +250,18 @@ export interface TemplatePackageManifest {
|
||||
trustContentTypes?: readonly {
|
||||
type: string;
|
||||
label: string;
|
||||
adminFields: {
|
||||
title: string;
|
||||
summary: string;
|
||||
content: string;
|
||||
summaryHelp?: string;
|
||||
summaryPlaceholder?: string;
|
||||
};
|
||||
help?: string;
|
||||
placeholder?: string;
|
||||
required?: boolean;
|
||||
maxPublishedItems?: number;
|
||||
hideStandardFields?: readonly ("summary" | "content")[];
|
||||
configFields?: readonly {
|
||||
key: string;
|
||||
binding: string;
|
||||
@@ -246,6 +269,7 @@ export interface TemplatePackageManifest {
|
||||
input: string;
|
||||
itemFields?: readonly { key: string; label: string; input?: string; required?: boolean }[];
|
||||
itemValueKey?: string;
|
||||
required?: boolean;
|
||||
}[];
|
||||
}[];
|
||||
sampleContent?: Partial<Record<BrandTemplateKey, TemplateSampleContent>>;
|
||||
@@ -287,13 +311,20 @@ export function validateTemplatePackageManifest(manifest: TemplatePackageManifes
|
||||
|
||||
export interface TemplateSampleContent {
|
||||
templateKey: BrandTemplateKey;
|
||||
inquiryFormName: string;
|
||||
offerings: Array<{
|
||||
kind: "service" | "product" | "package" | "subscription";
|
||||
name: string;
|
||||
summary: string;
|
||||
categoryKey: string;
|
||||
}>;
|
||||
trustContent: Array<{ type: string; title: string; content: string; summary?: string }>;
|
||||
trustContent: Array<{
|
||||
type: string;
|
||||
title: string;
|
||||
content: string;
|
||||
summary?: string;
|
||||
config?: Record<string, unknown>;
|
||||
}>;
|
||||
fields: Array<{
|
||||
key: string;
|
||||
label: string;
|
||||
@@ -306,6 +337,7 @@ export interface TemplateSampleContent {
|
||||
|
||||
const doorsSampleContent: TemplateSampleContent = {
|
||||
templateKey: "doors",
|
||||
inquiryFormName: "门系统咨询表单",
|
||||
offerings: [
|
||||
{
|
||||
kind: "product",
|
||||
@@ -349,6 +381,7 @@ const doorsSampleContent: TemplateSampleContent = {
|
||||
|
||||
const foodSampleContent: TemplateSampleContent = {
|
||||
templateKey: "food",
|
||||
inquiryFormName: "餐品预订与定制表单",
|
||||
offerings: [
|
||||
{
|
||||
kind: "package",
|
||||
@@ -377,6 +410,7 @@ const foodSampleContent: TemplateSampleContent = {
|
||||
|
||||
const personalSampleContent: TemplateSampleContent = {
|
||||
templateKey: "personal",
|
||||
inquiryFormName: "合作咨询表单",
|
||||
offerings: [
|
||||
{
|
||||
kind: "service",
|
||||
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#d97706" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg>
|
||||
|
After Width: | Height: | Size: 238 B |
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#f97316" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6M9 15l2 2 4-4"/></svg>
|
||||
|
After Width: | Height: | Size: 287 B |
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#f97316" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m11 17 2 2a2 2 0 1 0 3-3M14 14l3 3a2 2 0 1 0 3-3l-5-5M8 17l3 3a2 2 0 0 0 3-3M2 12l3-7 5 1 4-1 7 3 1 4-3 2M5 14l-3-2M5 14l3 3M10 6 7 9a2 2 0 0 0 3 3l3-3"/></svg>
|
||||
|
After Width: | Height: | Size: 346 B |
|
After Width: | Height: | Size: 105 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#10b981" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-11V5l-8-3-8 3v6c0 7 8 11 8 11z"/><path d="m9 12 2 2 4-4"/></svg>
|
||||
|
After Width: | Height: | Size: 263 B |
|
After Width: | Height: | Size: 1.6 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#3b82f6" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m12 3 1.9 5.8L20 11l-6.1 2.2L12 19l-1.9-5.8L4 11l6.1-2.2L12 3zM20 2v4M18 4h4M3 17v4M1 19h4"/></svg>
|
||||
|
After Width: | Height: | Size: 285 B |
|
After Width: | Height: | Size: 2.4 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#3b82f6" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="5.5" cy="17.5" r="3.5"/><circle cx="18.5" cy="17.5" r="3.5"/><path d="m15 6 2 4h3M12 17.5l-5-8H4m3 0h9l-4 8 5-8M9 6h3"/></svg>
|
||||
|
After Width: | Height: | Size: 315 B |
|
After Width: | Height: | Size: 2.4 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#f97316" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="5.5" cy="17.5" r="3.5"/><circle cx="18.5" cy="17.5" r="3.5"/><path d="m15 6 2 4h3M12 17.5l-5-8H4m3 0h9l-4 8 5-8M9 6h3"/></svg>
|
||||
|
After Width: | Height: | Size: 315 B |
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#f97316" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg>
|
||||
|
After Width: | Height: | Size: 238 B |
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#f97316" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 16v-2.4a3 3 0 0 1 6 0V16a3 3 0 0 1-6 0Zm10-8V5.6a3 3 0 0 1 6 0V8a3 3 0 0 1-6 0Z"/><path d="M7 21h0M17 13h0"/></svg>
|
||||
|
After Width: | Height: | Size: 304 B |
|
After Width: | Height: | Size: 674 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#f97316" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 6h11M10 12h11M10 18h11M3 5h1v2M3 11h2l-2 2h2M3 17h2v2H3"/></svg>
|
||||
|
After Width: | Height: | Size: 254 B |
@@ -1 +1 @@
|
||||
<view class="page"><view class="brand-card"><view class="identity"><image src="{{brand.avatarUrl}}" mode="aspectFill"/><view><text class="name">{{brand.founder}}</text><text class="title">{{brand.title}}</text><text class="slogan">“{{brand.slogan}}”</text></view></view><view class="notice"><text class="notice-title">{{presentation.stallTitle || '服务地点'}}</text><text>{{brand.studioAddress || brand.address}}</text><text wx:if="{{presentation.stallTime}}" class="notice-time">{{presentation.stallTime}}</text><text wx:for="{{trustItems}}" wx:if="{{item.type === 'schedule'}}" wx:key="title" class="notice-desc">{{item.content}}</text></view><view class="actions"><button bindtap="openInquiry">咨询 / 预订</button><button class="muted" bindtap="openOfferings">查看餐品</button></view></view><view class="scene-wrap"><view class="section-head"><text class="eyebrow">{{brand.name}}</text></view><image src="{{brand.heroImage}}" mode="aspectFill" bindtap="openService"/></view><view class="section-head"><view><text class="eyebrow">{{presentation.worksEyebrow || '餐品与服务'}}</text><text class="heading">{{presentation.worksTitle || '可选餐品'}}</text></view><text class="more" bindtap="openOfferings">查看全部 ›</text></view><view class="dish-grid"><view wx:for="{{offerings}}" wx:key="id" class="dish" data-id="{{item.id}}" bindtap="openOffering"><image src="{{item.image}}" mode="aspectFill"/><view class="dish-copy"><text class="dish-name">{{item.name}}</text><text class="dish-sub">{{item.desc}}</text><text class="price">{{item.priceRange}}</text></view></view></view><view wx:for="{{trustItems}}" wx:if="{{item.type === 'promise' || item.type === 'case'}}" wx:key="title" class="promise"><text class="eyebrow light">{{item.title}}</text><text class="promise-title">{{item.summary}}</text><text class="quote">{{item.content}}</text></view></view>
|
||||
<view class="page"><view class="brand-card"><view class="identity"><image src="{{brand.avatarUrl}}" mode="aspectFill"/><view><text class="name">{{brand.founder}}</text><text class="title">{{brand.title}}</text><text class="slogan">“{{brand.slogan}}”</text></view></view><view class="notice"><text class="notice-title">{{presentation.stallTitle || '服务地点'}}</text><text>{{brand.studioAddress || brand.address}}</text><text wx:if="{{presentation.stallTime}}" class="notice-time">{{presentation.stallTime}}</text></view><view class="actions"><button bindtap="openInquiry">咨询 / 预订</button><button class="muted" bindtap="openOfferings">查看餐品</button></view></view><view class="scene-wrap"><view class="section-head"><text class="eyebrow">{{brand.name}}</text></view><image class="scene" src="{{brand.heroImage}}" mode="aspectFill" bindtap="openService"/></view><view class="section-head"><view><text class="eyebrow">{{presentation.worksEyebrow || '餐品与服务'}}</text><text class="heading">{{presentation.worksTitle || '可选餐品'}}</text></view><text class="more" bindtap="openOfferings">查看全部 ›</text></view><view class="dish-grid"><view wx:for="{{offerings}}" wx:key="id" class="dish" data-id="{{item.id}}" bindtap="openOffering"><image src="{{item.image}}" mode="aspectFill"/><view class="dish-copy"><text class="dish-name">{{item.name}}</text><text class="dish-sub">{{item.desc}}</text><text class="price">{{item.priceRange}}</text></view></view></view><view wx:for="{{trustItems}}" wx:if="{{item.type === 'promise' || item.type === 'case'}}" wx:key="title" class="promise"><text class="eyebrow light">{{item.title}}</text><text wx:if="{{item.summary}}" class="promise-title">{{item.summary}}</text><text class="quote">{{item.content}}</text></view></view>
|
||||
@@ -1,18 +1,7 @@
|
||||
Component({
|
||||
properties: {
|
||||
brand: { type: Object, value: {} },
|
||||
credentials: { type: Array, value: [] },
|
||||
presentation: { type: Object, value: {} },
|
||||
recordsCount: { type: Number, value: 0 },
|
||||
},
|
||||
methods: {
|
||||
call() {
|
||||
this.triggerEvent("call");
|
||||
},
|
||||
copy() {
|
||||
this.triggerEvent("copy");
|
||||
},
|
||||
records() {
|
||||
this.triggerEvent("records");
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1 +1,23 @@
|
||||
<view class="page"><view class="profile-card"><image src="{{brand.avatarUrl}}" mode="aspectFill"/><text class="name">{{brand.founder}}</text><text class="title">{{brand.title}}</text><text class="bio">{{brand.slogan}}</text><view class="contact"><button bindtap="call">电话联系</button><button bindtap="copy">复制微信</button></view></view><view class="card"><text class="card-title">{{presentation.coverageTitle || '服务地点与方式'}}</text><text>{{brand.studioAddress || brand.address}}</text><text wx:if="{{presentation.coverageContent}}">{{presentation.coverageContent}}</text></view><view class="card" bindtap="records"><text class="card-title">我的预约记录</text><text>{{recordsCount}} 条记录 ›</text></view></view>
|
||||
<view class="profile-card">
|
||||
<view class="portrait">
|
||||
<image wx:if="{{brand.avatarUrl}}" src="{{brand.avatarUrl}}" mode="aspectFill" />
|
||||
<view class="identity">
|
||||
<text wx:if="{{presentation.badge}}" class="badge">{{presentation.badge}}</text>
|
||||
<text class="name">{{brand.founder || brand.name}}</text>
|
||||
<text wx:if="{{brand.title}}" class="title">{{brand.title}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{brand.description || presentation.storyLead || credentials.length}}" class="story">
|
||||
<text wx:if="{{presentation.storyLead}}" class="story-lead">{{presentation.storyLead}}</text>
|
||||
<text wx:if="{{brand.description}}" class="bio">{{brand.description}}</text>
|
||||
<block wx:for="{{credentials}}" wx:key="id">
|
||||
<view wx:if="{{item.config.standards.length}}" class="standards">
|
||||
<view wx:for="{{item.config.standards}}" wx:for-item="standard" wx:for-index="standardIndex" wx:key="title" class="standard">
|
||||
<image class="standard-icon" src="/assets/owner/{{standardIndex % 3 === 0 ? 'file-check' : standardIndex % 3 === 1 ? 'shield-check' : 'sparkles'}}.png" />
|
||||
<text class="standard-title">{{standard.title}}</text><text wx:if="{{standard.detail}}" class="standard-detail">{{standard.detail}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:else class="credential-copy"><text class="credential-title">{{item.title}}</text><text wx:if="{{item.summary}}" class="bio">{{item.summary}}</text><text wx:if="{{item.content}}" class="bio">{{item.content}}</text></view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
@@ -1,72 +1,114 @@
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 28rpx;
|
||||
background: #fff8f0;
|
||||
color: #29231f;
|
||||
}
|
||||
.profile-card {
|
||||
padding: 36rpx 28rpx;
|
||||
text-align: center;
|
||||
border-radius: 28rpx;
|
||||
background: #3b2118;
|
||||
overflow: hidden;
|
||||
border: 1rpx solid #f5f5f4;
|
||||
border-radius: 48rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
.portrait {
|
||||
position: relative;
|
||||
height: 416rpx;
|
||||
background: #e7e5e4;
|
||||
}
|
||||
.portrait image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-position: top;
|
||||
}
|
||||
.identity {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
align-items: flex-start;
|
||||
padding: 32rpx;
|
||||
background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.2), transparent);
|
||||
color: #fff;
|
||||
}
|
||||
.profile-card image {
|
||||
width: 132rpx;
|
||||
height: 132rpx;
|
||||
border: 5rpx solid #ffbd8e;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.name,
|
||||
.title,
|
||||
.bio,
|
||||
.card-title,
|
||||
.card text {
|
||||
display: block;
|
||||
.badge {
|
||||
margin-bottom: 8rpx;
|
||||
padding: 4rpx 16rpx;
|
||||
border-radius: 99rpx;
|
||||
background: #f97316;
|
||||
color: #fff;
|
||||
font-size: 20rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.name {
|
||||
margin-top: 18rpx;
|
||||
font-size: 36rpx;
|
||||
display: block;
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.title {
|
||||
margin-top: 6rpx;
|
||||
color: #ffc79f;
|
||||
display: block;
|
||||
margin-top: 4rpx;
|
||||
color: #e7e5e4;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.story {
|
||||
padding: 32rpx;
|
||||
}
|
||||
.story-lead {
|
||||
display: block;
|
||||
margin-bottom: 20rpx;
|
||||
color: #1c1917;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
line-height: 1.6;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.bio {
|
||||
margin-top: 16rpx;
|
||||
color: #ffe5d2;
|
||||
font-size: 23rpx;
|
||||
line-height: 1.6;
|
||||
display: block;
|
||||
color: #44403c;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.65;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.contact {
|
||||
display: flex;
|
||||
gap: 14rpx;
|
||||
margin-top: 24rpx;
|
||||
.standards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 16rpx;
|
||||
margin-top: 32rpx;
|
||||
padding-top: 24rpx;
|
||||
border-top: 1rpx solid #f5f5f4;
|
||||
}
|
||||
.contact button {
|
||||
flex: 1;
|
||||
height: 70rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #e87532;
|
||||
color: #fff;
|
||||
.standard {
|
||||
padding: 20rpx 8rpx;
|
||||
text-align: center;
|
||||
border: 1rpx solid #f5f5f4;
|
||||
border-radius: 32rpx;
|
||||
background: #fafaf9;
|
||||
}
|
||||
.standard-icon {
|
||||
display: block;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
margin: 0 auto 8rpx;
|
||||
}
|
||||
.standard-title,
|
||||
.standard-detail {
|
||||
display: block;
|
||||
}
|
||||
.standard-title {
|
||||
color: #292524;
|
||||
font-size: 22rpx;
|
||||
line-height: 70rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.card {
|
||||
margin-top: 18rpx;
|
||||
padding: 26rpx;
|
||||
border: 1rpx solid #f2d9c6;
|
||||
border-radius: 22rpx;
|
||||
background: #fff;
|
||||
color: #7a6a60;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.7;
|
||||
.standard-detail {
|
||||
margin-top: 4rpx;
|
||||
color: #a8a29e;
|
||||
font-size: 18rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.card-title {
|
||||
margin-bottom: 10rpx;
|
||||
color: #4b2b1d;
|
||||
font-size: 27rpx;
|
||||
.credential-copy {
|
||||
margin-top: 24rpx;
|
||||
padding-top: 24rpx;
|
||||
border-top: 1rpx solid #f5f5f4;
|
||||
}
|
||||
.credential-title {
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
@@ -4,7 +4,10 @@ const { openPage } = require("../../utils/navigation");
|
||||
Page({
|
||||
data: {
|
||||
brand: {},
|
||||
trustItems: [],
|
||||
credentials: [],
|
||||
cases: [],
|
||||
promises: [],
|
||||
presentation: {},
|
||||
records: [],
|
||||
error: "",
|
||||
},
|
||||
@@ -13,7 +16,19 @@ Page({
|
||||
.then((workspace) =>
|
||||
this.setData({
|
||||
brand: workspace.brand || {},
|
||||
trustItems: workspace.trustItems || [],
|
||||
presentation: workspace.brand?.visualPresentation?.profile || {},
|
||||
credentials: (workspace.trustItems || []).filter((item) => item.type === "credential"),
|
||||
cases: (workspace.trustItems || [])
|
||||
.filter((item) => item.type === "case")
|
||||
.map((item) => ({
|
||||
...item,
|
||||
entries: (item.config?.entries || []).map((entry, index) => ({
|
||||
...entry,
|
||||
index,
|
||||
tone: index % 3,
|
||||
})),
|
||||
})),
|
||||
promises: (workspace.trustItems || []).filter((item) => item.type === "promise"),
|
||||
records: [],
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"navigationBarTitleText": "我的订单",
|
||||
"navigationBarTitleText": "主理人",
|
||||
"navigationBarBackgroundColor": "#FBF7F1",
|
||||
"navigationBarTextStyle": "black",
|
||||
"usingComponents": {
|
||||
|
||||
@@ -1 +1,35 @@
|
||||
<view class="page"><view wx:if="{{error}}" class="runtime-error">{{error}}</view><block wx:else><acheng-profile brand="{{brand}}" presentation="{{brand.visualPresentation.profile}}" records-count="{{records.length}}" bind:call="call" bind:copy="copyWechat" bind:records="recordsPage" /><block wx:for="{{trustItems}}" wx:key="title"><view wx:if="{{item.type === 'coverage' || item.type === 'credential' || item.type === 'case' || item.type === 'promise'}}" class="card"><text class="card-title">{{item.title}}</text><text wx:if="{{item.summary}}">{{item.summary}}</text><text>{{item.content}}</text></view></block></block></view>
|
||||
<view class="page">
|
||||
<view wx:if="{{error}}" class="runtime-error">{{error}}</view>
|
||||
<block wx:else>
|
||||
<acheng-profile brand="{{brand}}" credentials="{{credentials}}" presentation="{{presentation}}" />
|
||||
<view wx:for="{{cases}}" wx:key="id" class="case-card">
|
||||
<view class="section-heading"><image class="heading-icon" src="/assets/owner/handshake.png" /><text>{{item.title}}</text></view>
|
||||
<text wx:if="{{item.summary}}" class="summary">{{item.summary}}</text>
|
||||
<view wx:if="{{item.entries.length}}" class="case-list">
|
||||
<view wx:for="{{item.entries}}" wx:for-item="entry" wx:key="index" class="case-row tone-{{entry.tone}}">
|
||||
<view class="case-badge">{{entry.badge}}</view>
|
||||
<view class="case-copy"><text class="case-title">{{entry.title}}</text><text wx:if="{{entry.detail}}" class="case-detail">{{entry.detail}}</text></view>
|
||||
<text wx:if="{{entry.result}}" class="case-result">{{entry.result}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text wx:elif="{{item.content}}" class="content">{{item.content}}</text>
|
||||
</view>
|
||||
<view wx:for="{{promises}}" wx:key="id" class="promise-card">
|
||||
<view class="section-heading"><image class="promise-icon" src="/assets/owner/clock.png" /><text>{{item.title}}</text></view>
|
||||
<text wx:if="{{item.summary}}" class="summary">{{item.summary}}</text>
|
||||
<view wx:if="{{item.config.commitments.length}}" class="commitment-list">
|
||||
<view wx:for="{{item.config.commitments}}" wx:for-item="commitment" wx:key="label" class="commitment">
|
||||
<view class="dot"/><view class="commitment-copy"><text class="commitment-label">{{commitment.label}}:</text><text>{{commitment.detail}}</text><text wx:if="{{commitment.highlight}}" class="highlight">{{commitment.highlight}}</text></view>
|
||||
</view>
|
||||
</view>
|
||||
<text wx:elif="{{item.content}}" class="content">{{item.content}}</text>
|
||||
</view>
|
||||
<view class="utilities">
|
||||
<view wx:if="{{brand.contactPhone || brand.contactWechat}}" class="contact-actions">
|
||||
<button wx:if="{{brand.contactPhone}}" bindtap="call">电话联系</button>
|
||||
<button wx:if="{{brand.contactWechat}}" bindtap="copyWechat">复制微信</button>
|
||||
</view>
|
||||
<view class="records-entry" bindtap="recordsPage"><text>{{presentation.recordsTitle || '我的咨询记录'}}</text><text>{{records.length}} {{presentation.recordsCountUnit || '条记录'}} ›</text></view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
@@ -1,197 +1,195 @@
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 28rpx 32rpx 56rpx;
|
||||
background: #f7f5f1;
|
||||
color: #252525;
|
||||
box-sizing: border-box;
|
||||
padding: 32rpx 32rpx 64rpx;
|
||||
background: #fafaf9;
|
||||
color: #292524;
|
||||
}
|
||||
.runtime-error {
|
||||
margin: 48rpx 0;
|
||||
padding: 28rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 14rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #fff;
|
||||
color: #8a6846;
|
||||
font-size: 25rpx;
|
||||
color: #9a3412;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.case-card,
|
||||
.promise-card {
|
||||
margin-top: 32rpx;
|
||||
padding: 32rpx;
|
||||
border: 1rpx solid #f5f5f4;
|
||||
border-radius: 48rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
.section-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
color: #1c1917;
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.heading-icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.summary {
|
||||
display: block;
|
||||
margin: 8rpx 0 24rpx;
|
||||
color: #78716c;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.contact-card {
|
||||
padding: 34rpx 30rpx;
|
||||
background: #202221;
|
||||
color: #fff;
|
||||
border-radius: 18rpx;
|
||||
.content {
|
||||
display: block;
|
||||
margin-top: 16rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.65;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.identity {
|
||||
.case-list {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
.case-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
margin-top: 16rpx;
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #f5f5f4;
|
||||
border-radius: 32rpx;
|
||||
background: #fafaf9;
|
||||
}
|
||||
.avatar {
|
||||
width: 88rpx;
|
||||
height: 88rpx;
|
||||
border: 2rpx solid #8a6846;
|
||||
border-radius: 50%;
|
||||
.case-row:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
.case-badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #d9c8b2;
|
||||
font: 42rpx serif;
|
||||
}
|
||||
.founder {
|
||||
display: block;
|
||||
font: 34rpx serif;
|
||||
}
|
||||
.role {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
color: #d9c8b2;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.contact-line {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 22rpx;
|
||||
padding-top: 18rpx;
|
||||
border-top: 1rpx solid rgba(255, 255, 255, 0.12);
|
||||
color: #aaa;
|
||||
font-size: 23rpx;
|
||||
}
|
||||
.contact-line > view {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
color: #fff;
|
||||
}
|
||||
.contact-line button {
|
||||
margin: 0;
|
||||
padding: 0 14rpx;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: #d9c8b2;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
.records-entry,
|
||||
.info-card {
|
||||
margin-top: 20rpx;
|
||||
padding: 28rpx;
|
||||
background: #fff;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
.records-entry {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
.records-entry text:last-child {
|
||||
color: #8a6846;
|
||||
}
|
||||
.card-title {
|
||||
display: block;
|
||||
flex-shrink: 0;
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #ffedd5;
|
||||
color: #ea580c;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
font-size: 27rpx;
|
||||
}
|
||||
.proof-grid {
|
||||
display: flex;
|
||||
gap: 12rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.proof-grid view {
|
||||
.case-copy {
|
||||
flex: 1;
|
||||
padding: 18rpx 8rpx;
|
||||
text-align: center;
|
||||
border-radius: 18rpx;
|
||||
background: #fff;
|
||||
border: 1rpx solid #f2d9c6;
|
||||
min-width: 0;
|
||||
}
|
||||
.proof-grid text {
|
||||
.case-title {
|
||||
display: block;
|
||||
color: #7a6a60;
|
||||
font-size: 18rpx;
|
||||
color: #1c1917;
|
||||
font-size: 22rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.proof-grid .proof-icon {
|
||||
color: #e87532;
|
||||
font-size: 30rpx;
|
||||
.case-detail {
|
||||
display: block;
|
||||
margin-top: 4rpx;
|
||||
color: #a8a29e;
|
||||
font-size: 20rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.promise {
|
||||
margin-top: 18rpx;
|
||||
padding: 22rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #fff3d8;
|
||||
color: #8c5c39;
|
||||
font-size: 21rpx;
|
||||
.case-result {
|
||||
flex-shrink: 0;
|
||||
max-width: 110rpx;
|
||||
padding: 4rpx 16rpx;
|
||||
border-radius: 99rpx;
|
||||
background: #ecfdf5;
|
||||
color: #059669;
|
||||
font-size: 20rpx;
|
||||
line-height: 1.5;
|
||||
text-align: center;
|
||||
}
|
||||
.tone-1 .case-badge {
|
||||
background: #dbeafe;
|
||||
color: #2563eb;
|
||||
}
|
||||
.tone-1 .case-result {
|
||||
background: #eff6ff;
|
||||
color: #2563eb;
|
||||
}
|
||||
.tone-2 .case-badge {
|
||||
background: #f3e8ff;
|
||||
color: #9333ea;
|
||||
}
|
||||
.tone-2 .case-result {
|
||||
background: #faf5ff;
|
||||
color: #9333ea;
|
||||
}
|
||||
.promise-card {
|
||||
border-color: #fde68a;
|
||||
background: rgba(255, 251, 235, 0.8);
|
||||
color: #78350f;
|
||||
box-shadow: none;
|
||||
}
|
||||
.promise-card .section-heading {
|
||||
gap: 12rpx;
|
||||
color: #78350f;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.promise-icon {
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.commitment-list {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
.commitment {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 16rpx;
|
||||
margin-top: 12rpx;
|
||||
color: #78350f;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.note,
|
||||
.bullet {
|
||||
display: block;
|
||||
margin-top: 16rpx;
|
||||
color: #77736b;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.75;
|
||||
.dot {
|
||||
flex-shrink: 0;
|
||||
width: 12rpx;
|
||||
height: 12rpx;
|
||||
margin-top: 12rpx;
|
||||
border-radius: 50%;
|
||||
background: #f59e0b;
|
||||
}
|
||||
.entry-icon {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
border-radius: 12rpx;
|
||||
background: rgba(138, 104, 70, 0.1);
|
||||
color: #8a6846;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.records-entry {
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
}
|
||||
.entry-copy {
|
||||
.commitment-copy {
|
||||
flex: 1;
|
||||
}
|
||||
.entry-copy text {
|
||||
display: block;
|
||||
}
|
||||
.entry-copy text:last-child {
|
||||
margin-top: 8rpx;
|
||||
color: #77736b;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
.count {
|
||||
color: #8a6846;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.card-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
color: #202221;
|
||||
}
|
||||
.note {
|
||||
padding: 20rpx;
|
||||
background: #f7f5f1;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
.note-title {
|
||||
display: block;
|
||||
margin-bottom: 6rpx;
|
||||
color: #202221;
|
||||
.commitment-label {
|
||||
font-weight: 700;
|
||||
}
|
||||
.bullet {
|
||||
padding-left: 8rpx;
|
||||
.highlight {
|
||||
margin-left: 8rpx;
|
||||
color: #ea580c;
|
||||
font-weight: 700;
|
||||
}
|
||||
.contact-line button {
|
||||
.utilities {
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
.contact-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6rpx;
|
||||
height: 44rpx;
|
||||
line-height: 44rpx;
|
||||
white-space: nowrap;
|
||||
gap: 16rpx;
|
||||
}
|
||||
.contact-line button t-icon {
|
||||
display: inline-flex;
|
||||
vertical-align: middle;
|
||||
.contact-actions button {
|
||||
flex: 1;
|
||||
margin: 0;
|
||||
border-radius: 24rpx;
|
||||
background: #fff7ed;
|
||||
color: #c2410c;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 150rpx;
|
||||
.records-entry {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 28rpx 4rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.records-entry text:last-child {
|
||||
color: #78716c;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<view class="page">
|
||||
<view wx:if="{{error}}" class="runtime-error">{{error}}</view>
|
||||
<acheng-home wx:else brand="{{brand}}" presentation="{{presentation}}" trust-content="{{trustContent}}" offerings="{{offerings}}" bind:select="selectOffering" bind:inquiry="goInquiry" bind:offerings="goWorks" bind:service="goService" />
|
||||
<acheng-home wx:else brand="{{brand}}" presentation="{{presentation}}" trust-items="{{trustItems}}" offerings="{{offerings}}" bind:select="selectOffering" bind:inquiry="goInquiry" bind:offerings="goWorks" bind:service="goService" />
|
||||
</view>
|
||||
@@ -31,14 +31,15 @@ Page({
|
||||
// 字段全部来自后台已发布的咨询表单,模板只负责呈现。
|
||||
fields: [],
|
||||
values: {},
|
||||
displayValues: {},
|
||||
formId: "",
|
||||
submitting: false,
|
||||
formError: "",
|
||||
presentation: {},
|
||||
},
|
||||
onLoad(options) {
|
||||
this.offeringId = options.offeringId || "";
|
||||
loadWorkspaceWithFallback()
|
||||
this.offeringId = options?.offeringId || "";
|
||||
return loadWorkspaceWithFallback()
|
||||
.then((workspace) => {
|
||||
this.forms = workspace.inquiryForms || [];
|
||||
this.setData({ presentation: workspace.brand?.visualPresentation?.inquiry || {} });
|
||||
@@ -54,8 +55,15 @@ Page({
|
||||
forms.find((item) => item.target === "brand") ||
|
||||
forms[0];
|
||||
const formId = form?.key || form?.id || "";
|
||||
if (formId !== this.data.formId)
|
||||
this.setData({ formId, fields: form?.fields || [], values: {} });
|
||||
if (formId !== this.data.formId) {
|
||||
// 原型中的类型选项为按钮网格,人数/日期和预算/配送各占半行;数据与文案仍来自已发布表单。
|
||||
const fields = (form?.fields || []).map((field) => ({
|
||||
...field,
|
||||
useChips: field.key === "type" && (field.type === "select" || field.type === "radio"),
|
||||
halfWidth: ["people", "date", "budget", "delivery"].includes(field.key),
|
||||
}));
|
||||
this.setData({ formId, fields, values: {}, displayValues: {} });
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
// 本页是 tabBar 页,从详情页进入时参数经 openPage 暂存,而不是通过 onLoad 传入。
|
||||
@@ -90,10 +98,21 @@ Page({
|
||||
switchToForm() {
|
||||
this.setData({ subView: "form" });
|
||||
},
|
||||
chooseChip(e) {
|
||||
const { key, value } = e.currentTarget.dataset;
|
||||
this.setData({ ["values." + key]: value });
|
||||
},
|
||||
choose(e) {
|
||||
const field = this.data.fields.find((item) => item.key === e.currentTarget.dataset.key);
|
||||
const option = field?.options?.[Number(e.detail.value)];
|
||||
if (option) this.setData({ ["values." + field.key]: option.value });
|
||||
if (option)
|
||||
this.setData({
|
||||
["values." + field.key]: option.value,
|
||||
["displayValues." + field.key]: option.label,
|
||||
});
|
||||
},
|
||||
checkboxChange(e) {
|
||||
this.setData({ ["values." + e.currentTarget.dataset.key]: e.detail.value });
|
||||
},
|
||||
input(e) {
|
||||
this.setData({ ["values." + e.currentTarget.dataset.key]: e.detail.value });
|
||||
@@ -101,7 +120,11 @@ Page({
|
||||
submit() {
|
||||
const { values, formId, fields } = this.data;
|
||||
const missing = fields.find(
|
||||
(field) => field.required && (values[field.key] === undefined || values[field.key] === ""),
|
||||
(field) =>
|
||||
field.required &&
|
||||
(values[field.key] === undefined ||
|
||||
values[field.key] === "" ||
|
||||
(Array.isArray(values[field.key]) && !values[field.key].length)),
|
||||
);
|
||||
if (missing) return this.setData({ formError: "请填写" + missing.label });
|
||||
if (!formId) return this.setData({ formError: "咨询表单暂不可用,请稍后重试" });
|
||||
|
||||
@@ -4,12 +4,16 @@
|
||||
<view class="form-card">
|
||||
<text class="form-title">{{presentation.title || '咨询 / 预订'}}</text>
|
||||
<text wx:if="{{presentation.subtitle}}" class="form-desc">{{presentation.subtitle}}</text>
|
||||
<view wx:for="{{fields}}" wx:key="key" class="field">
|
||||
<text class="label">{{item.label}} <b wx:if="{{item.required}}">*</b></text>
|
||||
<picker wx:if="{{item.type === 'select' || item.type === 'radio'}}" range="{{item.options}}" range-key="label" data-key="{{item.key}}" bindchange="choose"><view class="picker">{{values[item.key] || '请选择' + item.label}}</view></picker>
|
||||
<view class="form-fields">
|
||||
<view wx:for="{{fields}}" wx:key="key" class="field {{item.halfWidth ? 'field-half' : ''}}">
|
||||
<text class="label">{{item.label}} <text wx:if="{{item.required}}" class="required">*</text></text>
|
||||
<view wx:if="{{item.useChips}}" class="type-grid"><view wx:for="{{item.options}}" wx:for-item="option" wx:key="value" class="type-option {{values[item.key] === option.value ? 'selected' : ''}}" data-key="{{item.key}}" data-value="{{option.value}}" bindtap="chooseChip">{{option.label}}</view></view>
|
||||
<picker wx:elif="{{item.type === 'select' || item.type === 'radio'}}" range="{{item.options}}" range-key="label" data-key="{{item.key}}" bindchange="choose"><view class="picker">{{displayValues[item.key] || '请选择' + item.label}}</view></picker>
|
||||
<picker wx:elif="{{item.type === 'date'}}" mode="date" value="{{values[item.key]}}" data-key="{{item.key}}" bindchange="input"><view class="picker">{{values[item.key] || '请选择日期'}}</view></picker>
|
||||
<textarea wx:elif="{{item.type === 'textarea'}}" value="{{values[item.key]}}" data-key="{{item.key}}" bindinput="input" placeholder="{{item.placeholder || '请填写' + item.label}}" />
|
||||
<input wx:else type="{{item.type === 'number' ? 'number' : 'text'}}" value="{{values[item.key]}}" data-key="{{item.key}}" bindinput="input" placeholder="{{item.placeholder || '请填写' + item.label}}" />
|
||||
<checkbox-group wx:elif="{{item.type === 'multi-select' || item.type === 'checkbox'}}" data-key="{{item.key}}" bindchange="checkboxChange"><label wx:for="{{item.options}}" wx:for-item="option" wx:key="value"><checkbox value="{{option.value}}" />{{option.label}}</label></checkbox-group>
|
||||
<input wx:else type="{{item.type === 'number' || item.type === 'phone' || item.type === 'tel' ? 'number' : 'text'}}" value="{{values[item.key]}}" data-key="{{item.key}}" bindinput="input" placeholder="{{item.placeholder || '请填写' + item.label}}" />
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{formError}}" class="error">! {{formError}}</view>
|
||||
<view wx:if="{{presentation.promise}}" class="promise"><text>{{presentation.promise}}</text></view>
|
||||
@@ -23,7 +27,7 @@
|
||||
<view class="history-head"><text class="record-id">单号 #{{item.id}}</text><text class="record-status">{{item.status}}</text></view>
|
||||
<text class="history-title">{{item.title}}</text>
|
||||
<text wx:for="{{item.summary}}" wx:for-item="line" wx:key="key">{{line.label}}:{{line.value}}</text>
|
||||
<view wx:if="{{item.replyNote}}" class="reply"><b>处理回复:</b>{{item.replyNote}}</view>
|
||||
<view wx:if="{{item.replyNote}}" class="reply"><text class="reply-label">处理回复:</text>{{item.replyNote}}</view>
|
||||
<view class="history-foot">提交时间:{{item.createdAt}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 28rpx 32rpx 150rpx;
|
||||
padding: 32rpx 32rpx 64rpx;
|
||||
background: #f7f5f1;
|
||||
color: #292725;
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
.sub-tab {
|
||||
flex: 1;
|
||||
padding: 18rpx 4rpx;
|
||||
border-radius: 14rpx;
|
||||
border-radius: 24rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.sub-tab.active {
|
||||
@@ -27,35 +27,45 @@
|
||||
box-shadow: 0 4rpx 10rpx rgba(60, 45, 30, 0.08);
|
||||
}
|
||||
.form-card {
|
||||
padding: 30rpx 28rpx;
|
||||
padding: 32rpx;
|
||||
border: 1rpx solid #eee9e3;
|
||||
border-radius: 28rpx;
|
||||
border-radius: 48rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 8rpx 20rpx rgba(60, 45, 30, 0.035);
|
||||
}
|
||||
.form-title {
|
||||
display: block;
|
||||
color: #282522;
|
||||
font-size: 30rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.form-desc {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
color: #8e877f;
|
||||
font-size: 19rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.form-fields {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
gap: 28rpx 16rpx;
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
.field {
|
||||
margin-top: 26rpx;
|
||||
grid-column: span 2;
|
||||
min-width: 0;
|
||||
}
|
||||
.field-half {
|
||||
grid-column: span 1;
|
||||
}
|
||||
.label {
|
||||
display: block;
|
||||
margin-bottom: 12rpx;
|
||||
color: #4b4640;
|
||||
font-size: 21rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.label b {
|
||||
.required {
|
||||
color: #e35237;
|
||||
}
|
||||
.type-grid {
|
||||
@@ -66,10 +76,10 @@
|
||||
.type-option {
|
||||
padding: 17rpx 6rpx;
|
||||
border: 1rpx solid #e5e0da;
|
||||
border-radius: 14rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #fbfaf8;
|
||||
color: #686159;
|
||||
font-size: 18rpx;
|
||||
font-size: 22rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.type-option.selected {
|
||||
@@ -92,26 +102,28 @@ textarea,
|
||||
min-height: 76rpx;
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #e6e0d9;
|
||||
border-radius: 14rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #fbfaf8;
|
||||
color: #59534c;
|
||||
font-size: 19rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
textarea {
|
||||
min-height: 120rpx;
|
||||
}
|
||||
.picker {
|
||||
white-space: normal;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.error {
|
||||
margin-top: 22rpx;
|
||||
padding: 16rpx;
|
||||
border: 1rpx solid #f4c5bc;
|
||||
border-radius: 14rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #fff2f0;
|
||||
color: #c34131;
|
||||
font-size: 19rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.promise {
|
||||
display: flex;
|
||||
@@ -123,7 +135,7 @@ textarea {
|
||||
border-radius: 16rpx;
|
||||
background: #faf9f7;
|
||||
color: #7b746c;
|
||||
font-size: 18rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.promise:first-letter {
|
||||
@@ -165,7 +177,7 @@ textarea {
|
||||
border-radius: 16rpx;
|
||||
background: #f18029;
|
||||
color: #fff;
|
||||
font-size: 21rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 70rpx;
|
||||
}
|
||||
.history-card {
|
||||
@@ -178,7 +190,7 @@ textarea {
|
||||
border-radius: 24rpx;
|
||||
background: #fff;
|
||||
color: #716a62;
|
||||
font-size: 19rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.history-head {
|
||||
@@ -190,7 +202,7 @@ textarea {
|
||||
.record-id {
|
||||
color: #a39c94;
|
||||
font-family: monospace;
|
||||
font-size: 18rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.record-status {
|
||||
padding: 5rpx 12rpx;
|
||||
@@ -207,11 +219,11 @@ textarea {
|
||||
.reply {
|
||||
padding: 16rpx;
|
||||
border: 1rpx solid #f5d8bc;
|
||||
border-radius: 14rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #fff8ef;
|
||||
color: #6f5744;
|
||||
}
|
||||
.reply b {
|
||||
.reply-label {
|
||||
color: #e2762c;
|
||||
}
|
||||
.history-foot {
|
||||
|
||||
@@ -1,18 +1,71 @@
|
||||
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
const { openPage } = require("../../utils/navigation");
|
||||
// 每种内容对应一个固定视觉区域,按已配置记录优先选择,避免旧记录遮住编辑结果。
|
||||
function selectSlot(items, type) {
|
||||
return (
|
||||
items
|
||||
.filter((item) => item.type === type)
|
||||
.sort(
|
||||
(a, b) =>
|
||||
Number(Object.keys(b.config || {}).length > 0) -
|
||||
Number(Object.keys(a.config || {}).length > 0),
|
||||
)[0] || null
|
||||
);
|
||||
}
|
||||
Page({
|
||||
data: { brand: {}, presentation: {}, trustItems: [], loading: true },
|
||||
data: {
|
||||
brand: {},
|
||||
presentation: {},
|
||||
schedule: null,
|
||||
coverage: null,
|
||||
process: null,
|
||||
loading: true,
|
||||
error: false,
|
||||
},
|
||||
onLoad() {
|
||||
loadWorkspaceWithFallback()
|
||||
.then((workspace) =>
|
||||
this.load();
|
||||
},
|
||||
load() {
|
||||
this.setData({ loading: true, error: false });
|
||||
return loadWorkspaceWithFallback()
|
||||
.then((workspace) => {
|
||||
const items = workspace.trustItems || [];
|
||||
const schedule = selectSlot(items, "schedule");
|
||||
const coverage = selectSlot(items, "coverage");
|
||||
const process = selectSlot(items, "process");
|
||||
const config = schedule?.config || {};
|
||||
const rows = [
|
||||
{
|
||||
title: config.weekdayLabel,
|
||||
detail: config.weekdayDetail,
|
||||
hours: config.weekdayHours,
|
||||
tag: config.weekdayTag,
|
||||
tone: "orange",
|
||||
},
|
||||
{
|
||||
title: config.weekendLabel,
|
||||
detail: config.weekendDetail,
|
||||
hours: config.weekendHours,
|
||||
tag: config.weekendTag,
|
||||
tone: "blue",
|
||||
},
|
||||
].filter((row) => row.title && row.detail);
|
||||
const steps = Array.isArray(process?.config?.steps)
|
||||
? process.config.steps
|
||||
.filter((step) => step.title && step.detail)
|
||||
.map((step, index) => ({ ...step, index }))
|
||||
: [];
|
||||
this.setData({
|
||||
brand: workspace.brand || {},
|
||||
presentation: workspace.brand?.visualPresentation?.service || {},
|
||||
trustItems: workspace.trustItems || [],
|
||||
schedule: rows.length ? { ...schedule, rows } : null,
|
||||
coverage:
|
||||
coverage?.config?.pickupDetail && coverage?.config?.deliveryDetail ? coverage : null,
|
||||
process: steps.length ? { ...process, steps } : null,
|
||||
loading: false,
|
||||
}),
|
||||
)
|
||||
.catch(() => this.setData({ loading: false }));
|
||||
});
|
||||
})
|
||||
.catch(() => this.setData({ loading: false, error: true }));
|
||||
},
|
||||
inquire() {
|
||||
openPage("/pages/inquiry/index");
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
<view class="page service-page">
|
||||
<block wx:for="{{trustItems}}" wx:key="title">
|
||||
<view wx:if="{{item.type === 'schedule'}}" class="service-card"><view class="card-head"><view class="head-title"><text class="icon">◷</text><text>{{item.title}}</text></view></view><view class="schedule schedule-primary"><view class="schedule-main"><view class="schedule-title"><text class="dot orange"></text><text>{{item.summary || item.title}}</text></view><text class="schedule-line">{{item.content}}</text></view></view></view>
|
||||
<view wx:if="{{item.type === 'coverage'}}" class="service-card"><view class="card-title"><text class="icon">⌁</text><text>{{item.title}}</text></view><view class="delivery-grid"><view class="delivery-item"><text class="delivery-title orange-text">{{presentation.coverageLabel || '服务范围'}}</text><text>{{item.content}}</text></view></view></view>
|
||||
<view wx:if="{{item.type === 'process'}}" class="service-card process-card"><view class="card-title"><text class="icon">☷</text><text>{{item.title}}</text></view><text wx:if="{{item.summary}}" class="card-sub">{{item.summary}}</text><view class="steps"><view wx:for="{{item.lines}}" wx:for-item="step" wx:key="*this" class="step"><text class="step-no">{{index + 1}}</text><view><text class="step-title">{{presentation.stepLabel || '步骤'}} {{index + 1}}</text><text>{{step}}</text></view></view></view><view class="process-foot"><text>{{item.content}}</text><button bindtap="inquire">{{presentation.processAction || '立即咨询'}} <text>→</text></button></view></view>
|
||||
<view wx:if="{{loading}}" class="empty-state">正在加载出摊服务…</view>
|
||||
<view wx:elif="{{error}}" class="empty-state">服务信息加载失败<button bindtap="load">重试</button></view>
|
||||
<block wx:else>
|
||||
<view wx:if="{{schedule}}" class="service-card schedule-card">
|
||||
<view class="card-head"><view class="head-title"><image class="icon" src="../../assets/service/clock.png" /><text>{{schedule.title}}</text></view><text wx:if="{{schedule.config.status}}" class="status-pill">{{schedule.config.status}}</text></view>
|
||||
<view wx:for="{{schedule.rows}}" wx:for-item="row" wx:key="tone" class="schedule {{row.tone === 'blue' ? 'schedule-weekend' : 'schedule-primary'}}">
|
||||
<view class="schedule-row-head"><view class="schedule-title"><text class="dot {{row.tone}}"></text><text>{{row.title}}</text></view><text wx:if="{{row.tag}}" class="schedule-tag {{row.tone === 'blue' ? 'blue-tag' : 'orange-tag'}}">{{row.tag}}</text></view>
|
||||
<text class="schedule-line">{{row.detail}}</text><text wx:if="{{row.hours}}" class="schedule-muted">{{row.hours}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{coverage}}" class="service-card coverage-card"><view class="simple-title"><image class="icon" src="../../assets/service/bike.png" /><text>{{coverage.title}}</text></view><view class="delivery-grid"><view class="delivery-item"><view class="delivery-title"><image class="small-icon" src="../../assets/service/footprints.png" /><text>{{coverage.config.pickupTitle}}</text></view><text>{{coverage.config.pickupDetail}}</text></view><view class="delivery-item"><view class="delivery-title"><image class="small-icon" src="../../assets/service/bike-blue.png" /><text>{{coverage.config.deliveryTitle}}</text></view><text>{{coverage.config.deliveryDetail}}</text></view></view></view>
|
||||
<view wx:if="{{process}}" class="service-card process-card"><view class="simple-title"><image class="icon" src="../../assets/service/list.png" /><text>{{process.title}}</text></view><text wx:if="{{process.config.intro}}" class="card-sub">{{process.config.intro}}</text><view class="steps"><view wx:for="{{process.steps}}" wx:for-item="step" wx:key="index" class="step"><text class="step-no">{{index + 1}}</text><view><text class="step-title">{{step.title}}</text><text>{{step.detail}}</text></view></view></view><view class="process-foot"><view><text wx:if="{{process.config.minimumNote}}">{{process.config.minimumNote}}</text><text wx:if="{{process.config.minimumNote && process.config.refundNote}}" class="divider">|</text><text wx:if="{{process.config.refundNote}}">{{process.config.refundNote}}</text></view><button bindtap="inquire">{{presentation.processAction || '立即咨询'}} <text>→</text></button></view></view>
|
||||
<view wx:if="{{!schedule && !coverage && !process}}" class="empty-state">出摊服务信息正在完善中</view>
|
||||
</block>
|
||||
</view>
|
||||
@@ -1,14 +1,14 @@
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 28rpx 32rpx 150rpx;
|
||||
padding: 32rpx 32rpx 64rpx;
|
||||
background: #f7f5f1;
|
||||
color: #292725;
|
||||
}
|
||||
.service-card {
|
||||
margin-bottom: 24rpx;
|
||||
padding: 30rpx 28rpx;
|
||||
margin-bottom: 28rpx;
|
||||
padding: 32rpx;
|
||||
border: 1rpx solid #eee9e3;
|
||||
border-radius: 28rpx;
|
||||
border-radius: 48rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 8rpx 20rpx rgba(60, 45, 30, 0.035);
|
||||
}
|
||||
@@ -20,9 +20,17 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.simple-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
color: #302d29;
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.card-head {
|
||||
justify-content: space-between;
|
||||
padding-bottom: 22rpx;
|
||||
padding-bottom: 24rpx;
|
||||
border-bottom: 1rpx solid #eeeae5;
|
||||
}
|
||||
.head-title,
|
||||
@@ -46,13 +54,10 @@
|
||||
font-size: 20rpx;
|
||||
}
|
||||
.schedule {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12rpx;
|
||||
margin-top: 22rpx;
|
||||
padding: 22rpx 18rpx;
|
||||
margin-top: 20rpx;
|
||||
padding: 24rpx;
|
||||
border: 1rpx solid #f1ddd0;
|
||||
border-radius: 20rpx;
|
||||
border-radius: 32rpx;
|
||||
}
|
||||
.schedule-primary {
|
||||
background: #fffaf6;
|
||||
@@ -67,7 +72,7 @@
|
||||
.schedule-title {
|
||||
gap: 12rpx;
|
||||
color: #272522;
|
||||
font-size: 22rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.dot {
|
||||
@@ -88,13 +93,13 @@
|
||||
margin-top: 12rpx;
|
||||
margin-left: 26rpx;
|
||||
color: #655e56;
|
||||
font-size: 20rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.schedule-muted {
|
||||
margin-top: 5rpx;
|
||||
color: #9a948c;
|
||||
font-size: 18rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.schedule-tag {
|
||||
height: max-content;
|
||||
@@ -114,22 +119,22 @@
|
||||
.delivery-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 18rpx;
|
||||
margin-top: 22rpx;
|
||||
gap: 20rpx;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
.delivery-item {
|
||||
padding: 20rpx;
|
||||
padding: 24rpx;
|
||||
border: 1rpx solid #eeeae5;
|
||||
border-radius: 20rpx;
|
||||
border-radius: 32rpx;
|
||||
background: #fbfaf8;
|
||||
color: #777169;
|
||||
font-size: 19rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.delivery-title {
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
font-size: 22rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.orange-text {
|
||||
@@ -142,10 +147,10 @@
|
||||
display: block;
|
||||
margin-top: 12rpx;
|
||||
color: #8b857e;
|
||||
font-size: 19rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.steps {
|
||||
margin: 24rpx 0 0 14rpx;
|
||||
margin: 28rpx 0 0 16rpx;
|
||||
padding-left: 26rpx;
|
||||
border-left: 3rpx solid #f7cda9;
|
||||
}
|
||||
@@ -155,7 +160,7 @@
|
||||
gap: 18rpx;
|
||||
margin-bottom: 26rpx;
|
||||
color: #79736c;
|
||||
font-size: 19rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.55;
|
||||
}
|
||||
.step:last-child {
|
||||
@@ -173,24 +178,24 @@
|
||||
border-radius: 50%;
|
||||
background: #ef7c26;
|
||||
color: #fff;
|
||||
font-size: 18rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.step-title {
|
||||
display: block;
|
||||
margin-bottom: 5rpx;
|
||||
color: #3d3934;
|
||||
font-size: 22rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.process-foot {
|
||||
justify-content: space-between;
|
||||
gap: 12rpx;
|
||||
margin-top: 28rpx;
|
||||
padding-top: 22rpx;
|
||||
margin-top: 32rpx;
|
||||
padding-top: 24rpx;
|
||||
border-top: 1rpx solid #eeeae5;
|
||||
color: #777169;
|
||||
font-size: 18rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.strong {
|
||||
@@ -215,3 +220,31 @@
|
||||
margin-left: 8rpx;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.schedule-row-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8rpx;
|
||||
}
|
||||
.icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
flex: none;
|
||||
}
|
||||
.small-icon {
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
margin-right: 12rpx;
|
||||
flex: none;
|
||||
}
|
||||
.delivery-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #1c1917;
|
||||
}
|
||||
.empty-state {
|
||||
padding: 64rpx 0;
|
||||
text-align: center;
|
||||
color: #78716c;
|
||||
}
|
||||
@@ -134,7 +134,8 @@
|
||||
{
|
||||
"key": "identity",
|
||||
"title": "摊位与主理人",
|
||||
"description": "让访客知道谁在出餐、在哪里可以找到你。",
|
||||
"description": "配置主理人姓名与身份,介绍、头像和联系方式在品牌资料中编辑。",
|
||||
"page": "profile",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -145,13 +146,6 @@
|
||||
"required": true,
|
||||
"placeholder": "例如:阿成"
|
||||
},
|
||||
{
|
||||
"key": "portrait",
|
||||
"binding": "brand.config.avatarUrl",
|
||||
"label": "主理人照片",
|
||||
"help": "使用清晰、真实的照片,让顾客知道是谁在认真做餐。",
|
||||
"input": "image"
|
||||
},
|
||||
{
|
||||
"key": "title",
|
||||
"binding": "brand.config.title",
|
||||
@@ -161,29 +155,29 @@
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "slogan",
|
||||
"binding": "brand.config.slogan",
|
||||
"label": "想对顾客说的一句话",
|
||||
"input": "textarea",
|
||||
"maxLength": 80
|
||||
},
|
||||
{
|
||||
"key": "studioAddress",
|
||||
"binding": "brand.config.studioAddress",
|
||||
"label": "出摊地点或服务范围",
|
||||
"key": "badge",
|
||||
"binding": "brand.config.visualPresentation.profile.badge",
|
||||
"label": "写真角标",
|
||||
"input": "text",
|
||||
"required": true
|
||||
"help": "显示在主理人写真上,可填写经验或服务定位。"
|
||||
},
|
||||
{
|
||||
"key": "phone",
|
||||
"binding": "brand.config.phone",
|
||||
"label": "公开联系电话",
|
||||
"input": "phone"
|
||||
"key": "storyLead",
|
||||
"binding": "brand.config.visualPresentation.profile.storyLead",
|
||||
"label": "故事引言",
|
||||
"input": "textarea",
|
||||
"help": "故事开头的强调段落,下面的正文使用品牌简介。"
|
||||
},
|
||||
{
|
||||
"key": "wechat",
|
||||
"binding": "brand.config.wechat",
|
||||
"label": "公开微信号",
|
||||
"key": "recordsTitle",
|
||||
"binding": "brand.config.visualPresentation.profile.recordsTitle",
|
||||
"label": "记录入口文案",
|
||||
"input": "text"
|
||||
},
|
||||
{
|
||||
"key": "recordsCountUnit",
|
||||
"binding": "brand.config.visualPresentation.profile.recordsCountUnit",
|
||||
"label": "记录数量单位",
|
||||
"input": "text"
|
||||
}
|
||||
]
|
||||
@@ -192,6 +186,7 @@
|
||||
"key": "home",
|
||||
"title": "首页出摊信息",
|
||||
"description": "说明今天在哪里、何时营业,以及餐品有什么特点。",
|
||||
"page": "home",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -216,18 +211,6 @@
|
||||
"input": "text",
|
||||
"placeholder": "例如:17:00 - 22:30 · 今日营业中"
|
||||
},
|
||||
{
|
||||
"key": "coverageContent",
|
||||
"binding": "brand.config.visualPresentation.profile.coverageContent",
|
||||
"label": "取餐与配送说明",
|
||||
"input": "textarea"
|
||||
},
|
||||
{
|
||||
"key": "coverageTitle",
|
||||
"binding": "brand.config.visualPresentation.profile.coverageTitle",
|
||||
"label": "服务方式标题",
|
||||
"input": "text"
|
||||
},
|
||||
{
|
||||
"key": "worksEyebrow",
|
||||
"binding": "brand.config.visualPresentation.home.worksEyebrow",
|
||||
@@ -251,23 +234,10 @@
|
||||
{
|
||||
"key": "service",
|
||||
"title": "出摊服务页说明",
|
||||
"description": "设置出摊服务页的区块标题和咨询入口文字;具体时间、范围和流程内容在信任内容中维护。",
|
||||
"description": "设置出摊服务页的咨询按钮;日程、取餐配送和流程在对应内容编辑器中维护。",
|
||||
"page": "service",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
"key": "coverageLabel",
|
||||
"binding": "brand.config.visualPresentation.service.coverageLabel",
|
||||
"label": "服务范围标签",
|
||||
"input": "text",
|
||||
"placeholder": "例如:取餐与配送"
|
||||
},
|
||||
{
|
||||
"key": "stepLabel",
|
||||
"binding": "brand.config.visualPresentation.service.stepLabel",
|
||||
"label": "流程步骤标签",
|
||||
"input": "text",
|
||||
"placeholder": "例如:第"
|
||||
},
|
||||
{
|
||||
"key": "processAction",
|
||||
"binding": "brand.config.visualPresentation.service.processAction",
|
||||
@@ -281,6 +251,7 @@
|
||||
"key": "menu",
|
||||
"title": "菜单页说明",
|
||||
"description": "帮助顾客理解日常餐品和团体定制的选择方式。",
|
||||
"page": "offerings",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -309,6 +280,7 @@
|
||||
"key": "booking",
|
||||
"title": "预订与定制",
|
||||
"description": "告诉顾客提交信息后会如何确认餐品和时间。",
|
||||
"page": "inquiry",
|
||||
"target": "inquiry",
|
||||
"fields": [
|
||||
{
|
||||
@@ -344,6 +316,7 @@
|
||||
"key": "dishDetail",
|
||||
"title": "餐品与服务详情",
|
||||
"description": "每项餐品或服务单独填写;没有内容的详情区块不会展示。",
|
||||
"page": "detail",
|
||||
"target": "offering",
|
||||
"fields": [
|
||||
{
|
||||
@@ -394,7 +367,12 @@
|
||||
"label": "餐品特色",
|
||||
"input": "list",
|
||||
"itemValueKey": "value",
|
||||
"itemFields": [{ "key": "value", "label": "特色" }]
|
||||
"itemFields": [
|
||||
{
|
||||
"key": "value",
|
||||
"label": "特色"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "crafts",
|
||||
@@ -402,7 +380,12 @@
|
||||
"label": "制作方式",
|
||||
"input": "list",
|
||||
"itemValueKey": "value",
|
||||
"itemFields": [{ "key": "value", "label": "制作说明" }]
|
||||
"itemFields": [
|
||||
{
|
||||
"key": "value",
|
||||
"label": "制作说明"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "materialsList",
|
||||
@@ -410,8 +393,14 @@
|
||||
"label": "食材与搭配",
|
||||
"input": "list",
|
||||
"itemFields": [
|
||||
{ "key": "name", "label": "食材或搭配" },
|
||||
{ "key": "spec", "label": "说明" }
|
||||
{
|
||||
"key": "name",
|
||||
"label": "食材或搭配"
|
||||
},
|
||||
{
|
||||
"key": "spec",
|
||||
"label": "说明"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -420,6 +409,7 @@
|
||||
"key": "detailCopy",
|
||||
"title": "详情页说明",
|
||||
"description": "解释价格、餐品内容和咨询后会怎样处理。",
|
||||
"page": "detail",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -477,6 +467,7 @@
|
||||
"key": "successCopy",
|
||||
"title": "提交成功页",
|
||||
"description": "顾客提交后看到的确认信息与后续预期。",
|
||||
"page": "success",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -516,6 +507,7 @@
|
||||
"key": "recordsCopy",
|
||||
"title": "咨询记录页",
|
||||
"description": "顾客查看预订与咨询处理进度时看到的内容。",
|
||||
"page": "records",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -555,36 +547,297 @@
|
||||
"trustContentTypes": [
|
||||
{
|
||||
"type": "schedule",
|
||||
"label": "出摊与营业安排",
|
||||
"help": "说明固定出摊时间、临时营业安排或接受预订的时段。",
|
||||
"placeholder": "例如:周一至周五 17:00 - 22:30",
|
||||
"required": true
|
||||
"label": "每周出摊安排",
|
||||
"adminFields": {
|
||||
"title": "安排标题",
|
||||
"summary": "主要时段(周一至周五)",
|
||||
"content": "其他时段与补充安排(周末等)",
|
||||
"summaryHelp": "此摘要作为出摊服务页的主要时段展示。",
|
||||
"summaryPlaceholder": "周一至周五 17:00 - 22:30"
|
||||
},
|
||||
"configFields": [
|
||||
{
|
||||
"key": "status",
|
||||
"binding": "trust.config.status",
|
||||
"label": "状态标签",
|
||||
"input": "text",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"key": "weekdayLabel",
|
||||
"binding": "trust.config.weekdayLabel",
|
||||
"label": "工作日标题",
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "weekdayTag",
|
||||
"binding": "trust.config.weekdayTag",
|
||||
"label": "工作日标签",
|
||||
"input": "text",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"key": "weekdayDetail",
|
||||
"binding": "trust.config.weekdayDetail",
|
||||
"label": "工作日地点",
|
||||
"input": "textarea",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "weekdayHours",
|
||||
"binding": "trust.config.weekdayHours",
|
||||
"label": "工作日营业时间",
|
||||
"input": "text",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"key": "weekendLabel",
|
||||
"binding": "trust.config.weekendLabel",
|
||||
"label": "周末标题",
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "weekendTag",
|
||||
"binding": "trust.config.weekendTag",
|
||||
"label": "周末标签",
|
||||
"input": "text",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"key": "weekendDetail",
|
||||
"binding": "trust.config.weekendDetail",
|
||||
"label": "周末白天安排",
|
||||
"input": "textarea",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "weekendHours",
|
||||
"binding": "trust.config.weekendHours",
|
||||
"label": "周末晚间安排",
|
||||
"input": "text",
|
||||
"required": false
|
||||
}
|
||||
],
|
||||
"hideStandardFields": ["summary", "content"],
|
||||
"pages": ["service"],
|
||||
"help": "分别编辑工作日和周末两张日程小卡,不再使用摘要或正文拼接时间。",
|
||||
"placeholder": "例如:\n周一至周五 17:00 - 22:30\n周六、周日承接团体单与夜市流动出摊",
|
||||
"required": true,
|
||||
"maxPublishedItems": 1
|
||||
},
|
||||
{
|
||||
"type": "coverage",
|
||||
"label": "取餐与配送范围",
|
||||
"adminFields": {
|
||||
"title": "范围标题",
|
||||
"summary": "方式摘要",
|
||||
"content": "取餐与配送说明"
|
||||
},
|
||||
"configFields": [
|
||||
{
|
||||
"key": "pickupTitle",
|
||||
"binding": "trust.config.pickupTitle",
|
||||
"label": "现场自取标题",
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "pickupDetail",
|
||||
"binding": "trust.config.pickupDetail",
|
||||
"label": "现场自取说明",
|
||||
"input": "textarea",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "deliveryTitle",
|
||||
"binding": "trust.config.deliveryTitle",
|
||||
"label": "校内配送标题",
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "deliveryDetail",
|
||||
"binding": "trust.config.deliveryDetail",
|
||||
"label": "校内配送说明",
|
||||
"input": "textarea",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"hideStandardFields": ["summary", "content"],
|
||||
"pages": ["service"],
|
||||
"help": "说明服务地点、取餐方式和可配送范围。",
|
||||
"placeholder": "例如:支持校内宿舍楼下配送",
|
||||
"required": true
|
||||
"required": true,
|
||||
"maxPublishedItems": 1
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"label": "定制餐品流程",
|
||||
"help": "每行写一步,从提出需求到完成交付。",
|
||||
"adminFields": {
|
||||
"title": "流程标题",
|
||||
"summary": "流程摘要",
|
||||
"content": "流程步骤"
|
||||
},
|
||||
"configFields": [
|
||||
{
|
||||
"key": "steps",
|
||||
"binding": "trust.config.steps",
|
||||
"label": "流程步骤",
|
||||
"input": "list",
|
||||
"itemFields": [
|
||||
{
|
||||
"key": "title",
|
||||
"label": "步骤标题",
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "detail",
|
||||
"label": "步骤说明",
|
||||
"input": "textarea",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "intro",
|
||||
"binding": "trust.config.intro",
|
||||
"label": "流程介绍",
|
||||
"input": "text"
|
||||
},
|
||||
{
|
||||
"key": "minimumNote",
|
||||
"binding": "trust.config.minimumNote",
|
||||
"label": "起订说明",
|
||||
"input": "text"
|
||||
},
|
||||
{
|
||||
"key": "refundNote",
|
||||
"binding": "trust.config.refundNote",
|
||||
"label": "退改说明",
|
||||
"input": "text"
|
||||
}
|
||||
],
|
||||
"hideStandardFields": ["summary", "content"],
|
||||
"pages": ["service"],
|
||||
"help": "每个步骤分别填写标题和说明,按列表顺序展示。",
|
||||
"placeholder": "例如:提交需求\n确认菜单\n制作交付",
|
||||
"required": true
|
||||
"required": true,
|
||||
"maxPublishedItems": 1
|
||||
},
|
||||
{
|
||||
"type": "credential",
|
||||
"label": "食品安全与制作标准",
|
||||
"help": "填写让顾客放心的资质、卫生或制作标准。"
|
||||
"adminFields": {
|
||||
"title": "证明标题",
|
||||
"summary": "标准摘要",
|
||||
"content": "资质与制作说明"
|
||||
},
|
||||
"pages": ["profile"],
|
||||
"help": "填写让顾客放心的资质、卫生或制作标准。",
|
||||
"configFields": [
|
||||
{
|
||||
"key": "standards",
|
||||
"binding": "trust.config.standards",
|
||||
"label": "资质与卫生小卡",
|
||||
"input": "list",
|
||||
"itemFields": [
|
||||
{
|
||||
"key": "title",
|
||||
"label": "小卡标题",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "detail",
|
||||
"label": "小卡说明",
|
||||
"required": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "type": "case", "label": "客户案例与反馈", "help": "填写代表性订单、活动案例或客户评价。" },
|
||||
{ "type": "promise", "label": "回复与服务承诺", "help": "说明回复时间、退改规则或服务承诺。" }
|
||||
{
|
||||
"type": "case",
|
||||
"label": "客户案例与反馈",
|
||||
"adminFields": {
|
||||
"title": "案例标题",
|
||||
"summary": "案例摘要",
|
||||
"content": "案例与客户反馈"
|
||||
},
|
||||
"pages": ["home", "profile"],
|
||||
"help": "填写代表性订单、活动案例或客户评价。",
|
||||
"configFields": [
|
||||
{
|
||||
"key": "entries",
|
||||
"binding": "trust.config.entries",
|
||||
"label": "合作案例条目",
|
||||
"input": "list",
|
||||
"itemFields": [
|
||||
{
|
||||
"key": "badge",
|
||||
"label": "左侧简称",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "title",
|
||||
"label": "案例名称",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "detail",
|
||||
"label": "交付说明"
|
||||
},
|
||||
{
|
||||
"key": "result",
|
||||
"label": "右侧结果标签"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "promise",
|
||||
"label": "回复与服务承诺",
|
||||
"adminFields": {
|
||||
"title": "承诺标题",
|
||||
"summary": "承诺摘要",
|
||||
"content": "服务承诺详情"
|
||||
},
|
||||
"pages": ["home", "profile"],
|
||||
"help": "说明回复时间、退改规则或服务承诺。",
|
||||
"configFields": [
|
||||
{
|
||||
"key": "commitments",
|
||||
"binding": "trust.config.commitments",
|
||||
"label": "回复承诺条目",
|
||||
"input": "list",
|
||||
"itemFields": [
|
||||
{
|
||||
"key": "label",
|
||||
"label": "情境或时段",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "detail",
|
||||
"label": "承诺说明",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "highlight",
|
||||
"label": "强调文字"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"sampleContent": {
|
||||
"food": {
|
||||
"templateKey": "food",
|
||||
"inquiryFormName": "餐品预订与定制表单",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "package",
|
||||
@@ -600,8 +853,129 @@
|
||||
}
|
||||
],
|
||||
"trustContent": [
|
||||
{ "type": "credential", "title": "关于主理人", "content": "示例内容,待品牌主理人完善。" },
|
||||
{ "type": "process", "title": "从预订到取餐", "content": "示例内容,待品牌主理人完善。" }
|
||||
{
|
||||
"type": "schedule",
|
||||
"title": "每周出摊固定日程",
|
||||
"content": "",
|
||||
"config": {
|
||||
"status": "准时出摊",
|
||||
"weekdayLabel": "周一至周五(晚餐 + 夜宵档)",
|
||||
"weekdayTag": "常规固定点",
|
||||
"weekdayDetail": "地点:二号校门外小吃商业街 #07 号铺位",
|
||||
"weekdayHours": "营业:17:00 - 22:30(下雨搭防雨防风棚正常营业)",
|
||||
"weekendLabel": "周六、周日(全天接团体单 + 夜市流动)",
|
||||
"weekendTag": "活动专车",
|
||||
"weekendDetail": "白天专供:球赛、班级春游、社团集训、答辩餐",
|
||||
"weekendHours": "晚间:18:00 - 23:00 体育馆南侧流动出摊"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "coverage",
|
||||
"title": "取餐与配送范围",
|
||||
"content": "",
|
||||
"config": {
|
||||
"pickupTitle": "摊位现场自取",
|
||||
"pickupDetail": "小程序提前留餐,报手机尾号即拿,附赠特制加厚保温袋,不用排长龙。",
|
||||
"deliveryTitle": "校内楼下配送",
|
||||
"deliveryDetail": "满 3 份即可送至宿舍楼栋或实验楼门前,阿成骑专用恒温保温箱电动车直送。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"title": "定制餐品 4 步流程",
|
||||
"content": "",
|
||||
"config": {
|
||||
"intro": "专为班长、社长、活动干事设计的极简排菜流程",
|
||||
"steps": [
|
||||
{
|
||||
"title": "提交基本需求",
|
||||
"detail": "选择活动类型(如生日会、社团换届、答辩加餐)、预估人数与预算。"
|
||||
},
|
||||
{
|
||||
"title": "15 分钟内核算菜单",
|
||||
"detail": "阿成微信直接联系,提供荤素搭配明细与个性化需求(免辣、清真配料等)。"
|
||||
},
|
||||
{
|
||||
"title": "当日新鲜烹饪打包",
|
||||
"detail": "提前 2 小时生鲜采买,铁锅现炒,独立封盒并标注姓名 / 楼栋。"
|
||||
},
|
||||
{
|
||||
"title": "保温直达交付",
|
||||
"detail": "约定时间准时送抵指定场地,确认菜品温度与数量无误后结算。"
|
||||
}
|
||||
],
|
||||
"minimumNote": "起订门槛:6 份起",
|
||||
"refundNote": "退改:出餐前 2 小时全退"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "credential",
|
||||
"title": "食品安全与制作标准",
|
||||
"content": "示例内容,请根据实际资质和制作标准完善。",
|
||||
"config": {
|
||||
"standards": [
|
||||
{
|
||||
"title": "当天采购",
|
||||
"detail": "按当天需求采买"
|
||||
},
|
||||
{
|
||||
"title": "现做现出餐",
|
||||
"detail": "按约定时间制作"
|
||||
},
|
||||
{
|
||||
"title": "食具清洁消毒",
|
||||
"detail": "每日清洁与消毒"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "case",
|
||||
"title": "他们都在阿成这订过餐",
|
||||
"summary": "感谢大学城各学院与社团伙伴的信任",
|
||||
"content": "校街舞社年度专场 · 52 人份\n信息学院科创竞赛 · 连签 5 天\n7 号楼庆功宴 · 8 人定制",
|
||||
"config": {
|
||||
"entries": [
|
||||
{
|
||||
"badge": "舞",
|
||||
"title": "校街舞社年度专场(52 人份)",
|
||||
"detail": "保温箱直达大礼堂后台,贴名分装",
|
||||
"result": "零延误签收"
|
||||
},
|
||||
{
|
||||
"badge": "科",
|
||||
"title": "信息学院科创竞赛封闭备赛",
|
||||
"detail": "每日荤素轮换,附赠每日滋补老汤",
|
||||
"result": "连签 5 天"
|
||||
},
|
||||
{
|
||||
"badge": "寝",
|
||||
"title": "7 号楼庆功宴(8 人定制)",
|
||||
"detail": "定制双拼厚肉饭",
|
||||
"result": "定制餐品"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "promise",
|
||||
"title": "阿成的真实回复承诺",
|
||||
"content": "备料期 15 分钟内联系,出摊高峰 1 小时内回复。",
|
||||
"config": {
|
||||
"commitments": [
|
||||
{
|
||||
"label": "非出摊备料期",
|
||||
"detail": "提交咨询后通过微信或电话沟通。",
|
||||
"highlight": "15 分钟内"
|
||||
},
|
||||
{
|
||||
"label": "出摊晚高峰",
|
||||
"detail": "正在出餐,稍有延迟,会抽空回复。",
|
||||
"highlight": "1 小时内"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -610,12 +984,30 @@
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"options": [
|
||||
{ "label": "日常留餐", "value": "日常留餐" },
|
||||
{ "label": "宿舍开黑餐", "value": "宿舍开黑餐" },
|
||||
{ "label": "社团 / 班级活动", "value": "社团 / 班级活动" },
|
||||
{ "label": "生日聚会", "value": "生日聚会" },
|
||||
{ "label": "考试周加餐", "value": "考试周加餐" },
|
||||
{ "label": "其他需求", "value": "其他需求" }
|
||||
{
|
||||
"label": "日常留餐",
|
||||
"value": "日常留餐"
|
||||
},
|
||||
{
|
||||
"label": "宿舍开黑餐",
|
||||
"value": "宿舍开黑餐"
|
||||
},
|
||||
{
|
||||
"label": "社团 / 班级活动",
|
||||
"value": "社团 / 班级活动"
|
||||
},
|
||||
{
|
||||
"label": "生日聚会",
|
||||
"value": "生日聚会"
|
||||
},
|
||||
{
|
||||
"label": "考试周加餐",
|
||||
"value": "考试周加餐"
|
||||
},
|
||||
{
|
||||
"label": "其他需求",
|
||||
"value": "其他需求"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -624,23 +1016,52 @@
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"options": [
|
||||
{ "label": "1 人(单点)", "value": "1 人(单点)" },
|
||||
{ "label": "2-4 人(寝室小聚)", "value": "2-4 人(寝室小聚)" },
|
||||
{ "label": "5-10 人(部门小聚)", "value": "5-10 人(部门小聚)" },
|
||||
{ "label": "10-30 人(社团活动)", "value": "10-30 人(社团活动)" },
|
||||
{ "label": "30 人以上(大型活动)", "value": "30 人以上(大型活动)" }
|
||||
{
|
||||
"label": "1 人(单点)",
|
||||
"value": "1 人(单点)"
|
||||
},
|
||||
{
|
||||
"label": "2-4 人(寝室小聚)",
|
||||
"value": "2-4 人(寝室小聚)"
|
||||
},
|
||||
{
|
||||
"label": "5-10 人(部门小聚)",
|
||||
"value": "5-10 人(部门小聚)"
|
||||
},
|
||||
{
|
||||
"label": "10-30 人(社团活动)",
|
||||
"value": "10-30 人(社团活动)"
|
||||
},
|
||||
{
|
||||
"label": "30 人以上(大型活动)",
|
||||
"value": "30 人以上(大型活动)"
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "key": "date", "label": "用餐日期", "type": "date", "required": true },
|
||||
{
|
||||
"key": "date",
|
||||
"label": "用餐日期",
|
||||
"type": "date",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "budget",
|
||||
"label": "人均预算",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"options": [
|
||||
{ "label": "15 元左右 / 人(实惠)", "value": "15 元左右 / 人(实惠)" },
|
||||
{ "label": "18-22 元 / 人(荤素双拼)", "value": "18-22 元 / 人(荤素双拼)" },
|
||||
{ "label": "25 元以上 / 人(高规格定制)", "value": "25 元以上 / 人(高规格定制)" }
|
||||
{
|
||||
"label": "15 元左右 / 人(实惠)",
|
||||
"value": "15 元左右 / 人(实惠)"
|
||||
},
|
||||
{
|
||||
"label": "18-22 元 / 人(荤素双拼)",
|
||||
"value": "18-22 元 / 人(荤素双拼)"
|
||||
},
|
||||
{
|
||||
"label": "25 元以上 / 人(高规格定制)",
|
||||
"value": "25 元以上 / 人(高规格定制)"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -649,9 +1070,18 @@
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"options": [
|
||||
{ "label": "摊位自取(报手机尾号即拿)", "value": "摊位自取(报手机尾号即拿)" },
|
||||
{ "label": "送至宿舍楼下(满 3 份)", "value": "送至宿舍楼下(满 3 份)" },
|
||||
{ "label": "送至指定教室 / 场地", "value": "送至指定教室 / 场地" }
|
||||
{
|
||||
"label": "摊位自取(报手机尾号即拿)",
|
||||
"value": "摊位自取(报手机尾号即拿)"
|
||||
},
|
||||
{
|
||||
"label": "送至宿舍楼下(满 3 份)",
|
||||
"value": "送至宿舍楼下(满 3 份)"
|
||||
},
|
||||
{
|
||||
"label": "送至指定教室 / 场地",
|
||||
"value": "送至指定教室 / 场地"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -661,7 +1091,12 @@
|
||||
"required": false,
|
||||
"placeholder": "例:现炒牛肉饭 1 份,微辣多浇卤汁,不要香菜"
|
||||
},
|
||||
{ "key": "phone", "label": "联系手机", "type": "phone", "required": true }
|
||||
{
|
||||
"key": "phone",
|
||||
"label": "联系手机",
|
||||
"type": "phone",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"capabilityKey": "booking"
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"key": "identity",
|
||||
"title": "顾问介绍",
|
||||
"description": "客户在首页看到的姓名和定位",
|
||||
"target": "brand",
|
||||
"page": "home",
|
||||
"fields": [
|
||||
{
|
||||
"key": "name",
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
4. 如果需要替换运行时或能力包页面,必须在 `overrides` 中声明目录;未声明的同路径文件会被 compiler 拒绝。
|
||||
5. 执行 `pnpm generate:template-catalog --write` 和 `pnpm template:check`。
|
||||
|
||||
## 模板完成门槛
|
||||
|
||||
- 每个 `entrypoints` 页面里由品牌编辑者提供的标题、说明、信任资料、业务详情和视觉文案,都必须由 Runtime 数据驱动,不能只在 WXML 中写成固定业务事实。
|
||||
- 每个可编辑字段必须在 `admin.sections` 声明,并把 `page` 指向实际显示它的页面;测试会按页面检查 `presentation`、hero、profile、trust 和 offering 绑定,不能只在其他页面存在同名绑定。
|
||||
- 每个 `trustContentTypes` 都必须声明至少一个实际展示页面;模板测试会检查 renderer 是否消费该类型,也会检查 renderer 使用的类型是否已声明在对应页面。
|
||||
- `pnpm validate:templates` 会自动发现所有 `packages/template-*` 并运行上述绑定回归。模板不能在未通过该检查时标记完成。
|
||||
- 通过自动检查后,还要用 `pnpm template:dev <key> --brand <slug>` 生成产物,检查真实内容、空状态和窄屏视觉;自动绑定测试不能替代微信开发者工具中的视觉验收。
|
||||
|
||||
最小可编译模板可参考 `packages/template-compiler/test/fixtures/template-drill-consultant`。
|
||||
|
||||
使用 `pnpm template:dev <key> --brand <slug>` 生成微信开发者工具项目。生产构建还必须提供 `--appid` 和 HTTPS `--api`。模板在构建时选择,运行时不会下载或解释模板代码。
|
||||
@@ -45,7 +45,16 @@ export type TemplateAdminField = {
|
||||
binding: string;
|
||||
label: string;
|
||||
help?: string;
|
||||
input: "text" | "textarea" | "phone" | "image" | "number" | "list";
|
||||
input:
|
||||
| "text"
|
||||
| "textarea"
|
||||
| "phone"
|
||||
| "image"
|
||||
| "number"
|
||||
| "boolean"
|
||||
| "select"
|
||||
| "multi-select"
|
||||
| "list";
|
||||
itemFields?: Array<{
|
||||
key: string;
|
||||
label: string;
|
||||
@@ -56,6 +65,14 @@ export type TemplateAdminField = {
|
||||
required?: boolean;
|
||||
maxLength?: number;
|
||||
placeholder?: string;
|
||||
options?: Array<{ value: string; label: string }>;
|
||||
};
|
||||
|
||||
/** 模板自己的浅层品牌字段,值存于 BrandProfile.config.templateData。 */
|
||||
export type TemplateField = Omit<TemplateAdminField, "binding"> & {
|
||||
key: string;
|
||||
page?: TemplatePageKey;
|
||||
binding?: `brand.config.templateData.${string}`;
|
||||
};
|
||||
|
||||
/** 一个面向业务用户的编辑分组,而不是技术 schema 或 JSON 编辑器。 */
|
||||
@@ -63,6 +80,8 @@ export type TemplateAdminSection = {
|
||||
key: string;
|
||||
title: string;
|
||||
description: string;
|
||||
/** Exact Mini Program page that displays this section's content. */
|
||||
page: TemplatePageKey;
|
||||
target: "brand" | "offering" | "trust" | "inquiry";
|
||||
fields: TemplateAdminField[];
|
||||
};
|
||||
@@ -74,14 +93,26 @@ export type TemplateAdminManifest = {
|
||||
export type TemplateTrustContentType = {
|
||||
type: "schedule" | "coverage" | "process" | "credential" | "case" | "promise" | (string & {});
|
||||
label: string;
|
||||
/** Labels for the persisted TrustContent columns edited in Admin. */
|
||||
adminFields: {
|
||||
title: string;
|
||||
summary: string;
|
||||
content: string;
|
||||
summaryHelp?: string;
|
||||
summaryPlaceholder?: string;
|
||||
};
|
||||
pages?: TemplatePageKey[];
|
||||
help?: string;
|
||||
placeholder?: string;
|
||||
required?: boolean;
|
||||
configFields?: TemplateAdminField[];
|
||||
maxPublishedItems?: number;
|
||||
hideStandardFields?: Array<"summary" | "content">;
|
||||
};
|
||||
|
||||
export type TemplateSampleContent = {
|
||||
templateKey: string;
|
||||
inquiryFormName: string;
|
||||
offerings: Array<Record<string, unknown>>;
|
||||
trustContent: Array<Record<string, unknown>>;
|
||||
fields: Array<Record<string, unknown>>;
|
||||
@@ -110,6 +141,7 @@ export type TemplatePackageManifest = {
|
||||
/** 开发时的默认品牌;构建参数 `--brand` 优先。 */
|
||||
defaultBrandSlug?: string;
|
||||
dataSlots: TemplateDataSlot[];
|
||||
templateFields?: TemplateField[];
|
||||
assetSlots: TemplateAssetSlot[];
|
||||
admin: TemplateAdminManifest;
|
||||
trustContentTypes?: TemplateTrustContentType[];
|
||||
@@ -142,6 +174,14 @@ export function validateTemplatePackageManifest(value: unknown): string[] {
|
||||
errors.push("data slot source is invalid");
|
||||
}
|
||||
}
|
||||
for (const [index, field] of (manifest.templateFields ?? []).entries()) {
|
||||
if (!field?.key?.trim() || !field?.label?.trim())
|
||||
errors.push(`templateFields.${index} requires key and label`);
|
||||
if (field.binding && !field.binding.startsWith("brand.config.templateData."))
|
||||
errors.push(`templateFields.${index}.binding must target templateData`);
|
||||
if (field.input === "list" && !field.itemFields?.length)
|
||||
errors.push(`templateFields.${index}.list requires itemFields`);
|
||||
}
|
||||
if (manifest.trustContentTypes !== undefined) {
|
||||
if (!Array.isArray(manifest.trustContentTypes))
|
||||
errors.push("trustContentTypes must be an array");
|
||||
@@ -155,6 +195,19 @@ export function validateTemplatePackageManifest(value: unknown): string[] {
|
||||
errors.push(`trustContentTypes.${index}.type is required`);
|
||||
if (typeof item.label !== "string" || !item.label.trim())
|
||||
errors.push(`trustContentTypes.${index}.label is required`);
|
||||
for (const key of ["title", "summary", "content"] as const) {
|
||||
if (typeof item.adminFields?.[key] !== "string" || !item.adminFields[key].trim())
|
||||
errors.push(`trustContentTypes.${index}.adminFields.${key} is required`);
|
||||
}
|
||||
for (const page of item.pages ?? []) {
|
||||
if (!manifest.entrypoints?.[page])
|
||||
errors.push(`trustContentTypes.${index}.pages contains an undeclared entrypoint`);
|
||||
}
|
||||
if (
|
||||
item.maxPublishedItems !== undefined &&
|
||||
(!Number.isInteger(item.maxPublishedItems) || item.maxPublishedItems < 1)
|
||||
)
|
||||
errors.push(`trustContentTypes.${index}.maxPublishedItems must be a positive integer`);
|
||||
for (const field of item.configFields ?? []) {
|
||||
if (!field.key?.trim() || !field.binding?.startsWith("trust.config."))
|
||||
errors.push(`trustContentTypes.${index}.configFields binding is invalid`);
|
||||
@@ -164,6 +217,41 @@ export function validateTemplatePackageManifest(value: unknown): string[] {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (manifest.sampleContent && typeof manifest.sampleContent === "object") {
|
||||
for (const [industry, sample] of Object.entries(manifest.sampleContent)) {
|
||||
if (!sample.inquiryFormName?.trim())
|
||||
errors.push(`sampleContent.${industry}.inquiryFormName is required`);
|
||||
for (const [index, item] of (sample.trustContent ?? []).entries()) {
|
||||
if (!manifest.trustContentTypes?.some((type) => type.type === item.type))
|
||||
errors.push(
|
||||
`sampleContent.${industry}.trustContent.${index} uses an undeclared trust content type`,
|
||||
);
|
||||
}
|
||||
for (const [index, field] of (sample.fields ?? []).entries()) {
|
||||
if (
|
||||
typeof field.key !== "string" ||
|
||||
!field.key.trim() ||
|
||||
typeof field.label !== "string" ||
|
||||
!field.label.trim()
|
||||
)
|
||||
errors.push(`sampleContent.${industry}.fields.${index} requires key and label`);
|
||||
if (
|
||||
![
|
||||
"text",
|
||||
"tel",
|
||||
"phone",
|
||||
"number",
|
||||
"select",
|
||||
"radio",
|
||||
"multi-select",
|
||||
"textarea",
|
||||
"date",
|
||||
].includes(String(field.type))
|
||||
)
|
||||
errors.push(`sampleContent.${industry}.fields.${index} has an unsupported Runtime type`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Array.isArray(manifest.assetSlots)) errors.push("assetSlots must be an array");
|
||||
else {
|
||||
for (const slot of manifest.assetSlots) {
|
||||
@@ -177,6 +265,10 @@ export function validateTemplatePackageManifest(value: unknown): string[] {
|
||||
for (const section of manifest.admin.sections) {
|
||||
if (!section?.key?.trim() || !section.title?.trim() || !section.description?.trim())
|
||||
errors.push("every admin section requires key, title and description");
|
||||
if (!section?.page?.trim() || !manifest.entrypoints?.[section.page])
|
||||
errors.push(
|
||||
`admin section ${section?.key ?? "<unknown>"} must target a declared entrypoint`,
|
||||
);
|
||||
if (!Array.isArray(section.fields) || !section.fields.length)
|
||||
errors.push("every admin section must contain fields");
|
||||
for (const field of section.fields ?? []) {
|
||||
|
||||
@@ -6,6 +6,17 @@ import test from "node:test";
|
||||
|
||||
const packagesRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
||||
const runtimeRoot = path.resolve(packagesRoot, "../apps/miniapp");
|
||||
const adminTrustEditor = fs.readFileSync(
|
||||
path.resolve(packagesRoot, "../apps/admin/src/features/trust-content/TrustContentPage.tsx"),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
for (const field of ["title", "summary", "content"]) {
|
||||
assert.ok(
|
||||
adminTrustEditor.includes(`selectedTypeMeta?.adminFields.${field}`),
|
||||
`Admin trust editor must render the manifest label for ${field}`,
|
||||
);
|
||||
}
|
||||
|
||||
function sourceFile(templateRoot, relativePath, extension) {
|
||||
const local = path.join(templateRoot, "miniapp", `${relativePath}.${extension}`);
|
||||
@@ -19,6 +30,9 @@ function renderedFields(templateRoot, entrypoint) {
|
||||
const heroFields = new Set();
|
||||
const profileFields = new Set();
|
||||
const trustFields = new Set();
|
||||
const trustItemTypes = new Set();
|
||||
const brandFields = new Set();
|
||||
let rendersAllTrustItems = false;
|
||||
function visit(relativePath) {
|
||||
if (seen.has(relativePath)) return;
|
||||
seen.add(relativePath);
|
||||
@@ -29,6 +43,9 @@ function renderedFields(templateRoot, entrypoint) {
|
||||
for (const match of content.matchAll(/(?<![.\w])presentation\.([A-Za-z][A-Za-z0-9]*)/g)) {
|
||||
fields.add(match[1]);
|
||||
}
|
||||
for (const match of content.matchAll(/(?<![.\w])brand\.([A-Za-z][A-Za-z0-9]*)/g)) {
|
||||
brandFields.add(match[1]);
|
||||
}
|
||||
for (const match of content.matchAll(/(?<![.\w])hero\.([A-Za-z][A-Za-z0-9]*)/g)) {
|
||||
heroFields.add(match[1]);
|
||||
}
|
||||
@@ -38,6 +55,21 @@ function renderedFields(templateRoot, entrypoint) {
|
||||
for (const match of content.matchAll(/trustContent\.([A-Za-z][A-Za-z0-9]*)/g)) {
|
||||
trustFields.add(match[1]);
|
||||
}
|
||||
for (const match of content.matchAll(
|
||||
/selectSlot\(items,\s*["']([A-Za-z][A-Za-z0-9_-]*)["']\)/g,
|
||||
)) {
|
||||
trustItemTypes.add(match[1]);
|
||||
}
|
||||
if (/trustItems/.test(content)) {
|
||||
for (const match of content.matchAll(
|
||||
/item\.type\s*===\s*["']([A-Za-z][A-Za-z0-9_-]*)["']/g,
|
||||
)) {
|
||||
trustItemTypes.add(match[1]);
|
||||
}
|
||||
if (/wx:for="{{trustItems}}"/.test(content) && !/item\.type\s*===/.test(content)) {
|
||||
rendersAllTrustItems = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
const componentConfig = sourceFile(templateRoot, relativePath, "json");
|
||||
if (!componentConfig) return;
|
||||
@@ -49,7 +81,16 @@ function renderedFields(templateRoot, entrypoint) {
|
||||
}
|
||||
}
|
||||
visit(entrypoint);
|
||||
return { fields, heroFields, profileFields, trustFields, seen };
|
||||
return {
|
||||
fields,
|
||||
heroFields,
|
||||
profileFields,
|
||||
trustFields,
|
||||
trustItemTypes,
|
||||
brandFields,
|
||||
rendersAllTrustItems,
|
||||
seen,
|
||||
};
|
||||
}
|
||||
|
||||
const sharedOfferingBindings = [
|
||||
@@ -64,6 +105,18 @@ const sharedOfferingBindings = [
|
||||
"offering.config.details.crafts",
|
||||
"offering.config.details.materialsList",
|
||||
];
|
||||
const offeringRuntimeBindings = {
|
||||
"offering.config.categoryLabel": "item.presentation.categoryLabel",
|
||||
"offering.config.detailHero": "item.detailHero",
|
||||
"offering.config.area": "item.area",
|
||||
"offering.config.series": "item.series",
|
||||
"offering.config.spaceType": "item.spaceType",
|
||||
"offering.config.keywords": "item.keywords",
|
||||
"offering.config.details.background": "item.details.background",
|
||||
"offering.config.details.designConcept": "item.details.designConcept",
|
||||
"offering.config.details.crafts": "item.details.crafts",
|
||||
"offering.config.details.materialsList": "item.details.materialsList",
|
||||
};
|
||||
|
||||
for (const directory of fs
|
||||
.readdirSync(packagesRoot)
|
||||
@@ -73,31 +126,99 @@ for (const directory of fs
|
||||
if (!fs.existsSync(manifestPath)) continue;
|
||||
test(`${directory} exposes rendered content through Admin bindings`, () => {
|
||||
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
||||
for (const declaration of manifest.trustContentTypes ?? []) {
|
||||
for (const field of ["title", "summary", "content"]) {
|
||||
assert.ok(
|
||||
declaration.adminFields?.[field]?.trim(),
|
||||
`${manifest.packageKey}: trust type ${declaration.type} has no Admin label for ${field}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
for (const sample of Object.values(manifest.sampleContent ?? {})) {
|
||||
for (const item of sample.trustContent ?? []) {
|
||||
assert.ok(
|
||||
manifest.trustContentTypes?.some((type) => type.type === item.type),
|
||||
`${manifest.packageKey}: sample trust type ${item.type} has no declared editor or renderer`,
|
||||
);
|
||||
}
|
||||
}
|
||||
for (const section of manifest.admin.sections) {
|
||||
assert.ok(
|
||||
manifest.entrypoints[section.page],
|
||||
`${manifest.packageKey}: ${section.key} points to an unknown Mini Program page`,
|
||||
);
|
||||
}
|
||||
const bindings = new Set(
|
||||
manifest.admin.sections.flatMap((section) => section.fields.map((field) => field.binding)),
|
||||
);
|
||||
for (const [pageKey, entrypoint] of Object.entries(manifest.entrypoints)) {
|
||||
const { fields, heroFields, profileFields, trustFields, seen } = renderedFields(
|
||||
templateRoot,
|
||||
entrypoint,
|
||||
const {
|
||||
fields,
|
||||
heroFields,
|
||||
profileFields,
|
||||
trustFields,
|
||||
trustItemTypes,
|
||||
brandFields,
|
||||
rendersAllTrustItems,
|
||||
seen,
|
||||
} = renderedFields(templateRoot, entrypoint);
|
||||
const pageBindings = new Set(
|
||||
manifest.admin.sections
|
||||
.filter((section) => section.page === pageKey)
|
||||
.flatMap((section) => section.fields.map((field) => field.binding)),
|
||||
);
|
||||
for (const field of fields) {
|
||||
const binding = `brand.config.visualPresentation.${pageKey}.${field}`;
|
||||
assert.ok(
|
||||
bindings.has(`brand.config.visualPresentation.${pageKey}.${field}`),
|
||||
`${manifest.packageKey}: ${pageKey}.${field} is rendered but has no Admin field`,
|
||||
bindings.has(binding),
|
||||
`${manifest.packageKey}: ${pageKey}.${field} has no Admin field`,
|
||||
);
|
||||
assert.ok(
|
||||
pageBindings.has(binding),
|
||||
`${manifest.packageKey}: ${pageKey}.${field} Admin field is assigned to another page`,
|
||||
);
|
||||
}
|
||||
for (const field of heroFields) {
|
||||
const binding =
|
||||
field === "image" ? "brand.config.heroImage" : `brand.config.homeHero.${field}`;
|
||||
assert.ok(
|
||||
bindings.has(binding),
|
||||
pageBindings.has(binding),
|
||||
`${manifest.packageKey}: ${pageKey} hero.${field} has no Admin field`,
|
||||
);
|
||||
}
|
||||
for (const declaration of manifest.admin.sections.filter((item) => item.page === pageKey)) {
|
||||
for (const field of declaration.fields) {
|
||||
const binding = field.binding;
|
||||
if (binding === "brand.avatarUrl")
|
||||
assert.ok(
|
||||
brandFields.has("avatarUrl"),
|
||||
`${manifest.packageKey}: avatar has no renderer`,
|
||||
);
|
||||
if (binding === "brand.description")
|
||||
assert.ok(
|
||||
brandFields.has("slogan") || brandFields.has("description"),
|
||||
`${manifest.packageKey}: description has no renderer`,
|
||||
);
|
||||
if (binding === "brand.contactPhone")
|
||||
assert.ok(
|
||||
brandFields.has("phone") || brandFields.has("contactPhone"),
|
||||
`${manifest.packageKey}: phone has no renderer`,
|
||||
);
|
||||
if (binding === "brand.contactWechat")
|
||||
assert.ok(
|
||||
brandFields.has("wechat") || brandFields.has("contactWechat"),
|
||||
`${manifest.packageKey}: WeChat has no renderer`,
|
||||
);
|
||||
if (binding === "brand.address")
|
||||
assert.ok(
|
||||
brandFields.has("studioAddress") || brandFields.has("address"),
|
||||
`${manifest.packageKey}: address has no renderer`,
|
||||
);
|
||||
}
|
||||
}
|
||||
for (const field of profileFields) {
|
||||
assert.ok(
|
||||
bindings.has(`brand.config.profilePresentation.${field}`),
|
||||
pageBindings.has(`brand.config.profilePresentation.${field}`),
|
||||
`${manifest.packageKey}: profilePresentation.${field} has no Admin field`,
|
||||
);
|
||||
}
|
||||
@@ -110,17 +231,107 @@ for (const directory of fs
|
||||
continue;
|
||||
}
|
||||
assert.ok(
|
||||
manifest.trustContentTypes?.some((type) =>
|
||||
type.configFields?.some(
|
||||
(configField) => configField.binding === `trust.config.${field}`,
|
||||
),
|
||||
manifest.trustContentTypes?.some(
|
||||
(type) =>
|
||||
type.pages?.includes(pageKey) &&
|
||||
type.configFields?.some(
|
||||
(configField) => configField.binding === `trust.config.${field}`,
|
||||
),
|
||||
),
|
||||
`${manifest.packageKey}: trustContent.${field} has no Admin field`,
|
||||
);
|
||||
}
|
||||
for (const type of trustItemTypes) {
|
||||
const declaration = manifest.trustContentTypes?.find((item) => item.type === type);
|
||||
assert.ok(
|
||||
declaration,
|
||||
`${manifest.packageKey}: renderer uses undeclared trust type ${type}`,
|
||||
);
|
||||
assert.ok(
|
||||
declaration.pages?.includes(pageKey),
|
||||
`${manifest.packageKey}: renderer uses trust type ${type} on ${pageKey} but the page is not declared`,
|
||||
);
|
||||
}
|
||||
for (const declaration of manifest.trustContentTypes ?? []) {
|
||||
if (!declaration.pages?.includes(pageKey)) continue;
|
||||
assert.ok(
|
||||
rendersAllTrustItems || trustItemTypes.has(declaration.type),
|
||||
`${manifest.packageKey}: trust type ${declaration.type} claims ${pageKey}, but that renderer does not display it`,
|
||||
);
|
||||
}
|
||||
const pageSource = [...seen]
|
||||
.flatMap((relativePath) =>
|
||||
["js", "wxml"]
|
||||
.map((extension) => sourceFile(templateRoot, relativePath, extension))
|
||||
.filter(Boolean)
|
||||
.map((file) => fs.readFileSync(file, "utf8")),
|
||||
)
|
||||
.join("\n");
|
||||
for (const declaration of manifest.trustContentTypes ?? []) {
|
||||
if (!declaration.pages?.includes(pageKey)) continue;
|
||||
for (const field of declaration.configFields ?? []) {
|
||||
assert.ok(
|
||||
pageSource.includes(`.${field.key}`) ||
|
||||
declaration.pages.some((destination) => {
|
||||
const destinationFiles = renderedFields(
|
||||
templateRoot,
|
||||
manifest.entrypoints[destination],
|
||||
).seen;
|
||||
return [...destinationFiles].some((file) =>
|
||||
["js", "wxml"].some((extension) => {
|
||||
const source = sourceFile(templateRoot, file, extension);
|
||||
return source && fs.readFileSync(source, "utf8").includes(`.${field.key}`);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
`${manifest.packageKey}: ${declaration.type}.${field.key} is editable but is not consumed on ${pageKey}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (pageKey === Object.keys(manifest.entrypoints)[0]) {
|
||||
for (const declaration of manifest.trustContentTypes ?? []) {
|
||||
assert.ok(
|
||||
declaration.pages?.length,
|
||||
`${manifest.packageKey}: trust type ${declaration.type} must declare its Mini Program destination`,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (pageKey === "home") {
|
||||
for (const field of manifest.templateFields ?? []) {
|
||||
const source = `templateData.${field.key}`;
|
||||
const entryFiles = [...seen].flatMap((relativePath) =>
|
||||
["js", "wxml"]
|
||||
.map((extension) => sourceFile(templateRoot, relativePath, extension))
|
||||
.filter(Boolean),
|
||||
);
|
||||
assert.ok(
|
||||
entryFiles.some((file) =>
|
||||
new RegExp(`templateData(?:\\?\\.)?${field.key}`).test(fs.readFileSync(file, "utf8")),
|
||||
),
|
||||
`${manifest.packageKey}: template field ${field.key} is declared but never rendered`,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (seen.has("components/modules/offering-detail/offering-detail")) {
|
||||
for (const binding of sharedOfferingBindings) {
|
||||
assert.ok(bindings.has(binding), `${manifest.packageKey}: missing ${binding}`);
|
||||
assert.ok(
|
||||
pageBindings.has(binding),
|
||||
`${manifest.packageKey}: missing ${binding} on detail page`,
|
||||
);
|
||||
}
|
||||
const detailSources = [...seen].flatMap((relativePath) =>
|
||||
["wxml", "js"]
|
||||
.map((extension) => sourceFile(templateRoot, relativePath, extension))
|
||||
.filter(Boolean)
|
||||
.map((file) => fs.readFileSync(file, "utf8")),
|
||||
);
|
||||
const detailSource = detailSources.join("\n");
|
||||
for (const [binding, runtimePath] of Object.entries(offeringRuntimeBindings)) {
|
||||
if (!pageBindings.has(binding)) continue;
|
||||
assert.ok(
|
||||
detailSource.includes(runtimePath),
|
||||
`${manifest.packageKey}: ${binding} is editable but ${runtimePath} is not rendered on ${pageKey}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import test from "node:test";
|
||||
import { validateTemplatePackageManifest } from "../src/index.ts";
|
||||
import { runtimeContractForBinding } from "../../types/src/runtime-content-contract.ts";
|
||||
|
||||
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
||||
|
||||
@@ -26,6 +27,61 @@ test("template contract rejects technical or incomplete admin declarations", ()
|
||||
]);
|
||||
});
|
||||
|
||||
test("template admin sections must point to a declared Mini Program page", () => {
|
||||
const manifestPath = path.join(packageRoot, "template-acheng-campus-food/template.json");
|
||||
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
||||
manifest.admin.sections[0].page = "missing-page";
|
||||
assert.deepEqual(validateTemplatePackageManifest(manifest), [
|
||||
"admin section identity must target a declared entrypoint",
|
||||
]);
|
||||
});
|
||||
|
||||
test("template trust content pages must point to declared Mini Program pages", () => {
|
||||
const manifestPath = path.join(packageRoot, "template-acheng-campus-food/template.json");
|
||||
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
||||
manifest.trustContentTypes[0].pages = ["missing-page"];
|
||||
assert.deepEqual(validateTemplatePackageManifest(manifest), [
|
||||
"trustContentTypes.0.pages contains an undeclared entrypoint",
|
||||
]);
|
||||
});
|
||||
|
||||
test("template trust editor fields map to persisted TrustContent columns", () => {
|
||||
const manifestPath = path.join(packageRoot, "template-acheng-campus-food/template.json");
|
||||
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
||||
manifest.trustContentTypes[0].adminFields.summary = "";
|
||||
assert.ok(
|
||||
validateTemplatePackageManifest(manifest).includes(
|
||||
"trustContentTypes.0.adminFields.summary is required",
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test("template samples cannot import trust types without an Admin declaration", () => {
|
||||
const manifestPath = path.join(packageRoot, "template-acheng-campus-food/template.json");
|
||||
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
||||
manifest.sampleContent.food.trustContent.push({
|
||||
type: "not-declared",
|
||||
title: "未知",
|
||||
content: "未知",
|
||||
});
|
||||
assert.ok(
|
||||
validateTemplatePackageManifest(manifest).includes(
|
||||
`sampleContent.food.trustContent.${manifest.sampleContent.food.trustContent.length - 1} uses an undeclared trust content type`,
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test("template sample inquiry fields use Runtime-supported input types", () => {
|
||||
const manifestPath = path.join(packageRoot, "template-acheng-campus-food/template.json");
|
||||
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
||||
manifest.sampleContent.food.fields[0].type = "image";
|
||||
assert.ok(
|
||||
validateTemplatePackageManifest(manifest).includes(
|
||||
"sampleContent.food.fields.0 has an unsupported Runtime type",
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test("template manifests declare editable material content", () => {
|
||||
const linjing = JSON.parse(
|
||||
fs.readFileSync(path.join(packageRoot, "template-linjing-editorial/template.json"), "utf8"),
|
||||
@@ -47,7 +103,6 @@ test("template manifests declare editable material content", () => {
|
||||
])
|
||||
assert.ok(bindings(linjing).has(binding), binding);
|
||||
for (const binding of [
|
||||
"brand.config.visualPresentation.profile.coverageContent",
|
||||
"brand.config.visualPresentation.offerings.menuTip",
|
||||
"brand.config.visualPresentation.inquiry.promise",
|
||||
])
|
||||
@@ -59,3 +114,135 @@ test("template manifests declare editable material content", () => {
|
||||
["stats", "pillars", "serviceFlow"],
|
||||
);
|
||||
});
|
||||
|
||||
test("template fields use the shallow templateData namespace", () => {
|
||||
for (const key of ["acheng-campus-food", "linjing-editorial"]) {
|
||||
const manifest = JSON.parse(
|
||||
fs.readFileSync(path.join(packageRoot, `template-${key}/template.json`), "utf8"),
|
||||
);
|
||||
for (const field of manifest.templateFields ?? []) {
|
||||
assert.equal(typeof field.key, "string");
|
||||
assert.ok(!field.key.includes("."), `${key}: template field keys stay shallow`);
|
||||
assert.ok(
|
||||
[
|
||||
"text",
|
||||
"textarea",
|
||||
"number",
|
||||
"boolean",
|
||||
"image",
|
||||
"select",
|
||||
"multi-select",
|
||||
"list",
|
||||
].includes(field.input),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("every declared Admin binding has one Runtime contract", () => {
|
||||
for (const key of ["acheng-campus-food", "linjing-editorial"]) {
|
||||
const manifest = JSON.parse(
|
||||
fs.readFileSync(path.join(packageRoot, `template-${key}/template.json`), "utf8"),
|
||||
);
|
||||
for (const field of manifest.admin.sections.flatMap((section) => section.fields)) {
|
||||
assert.ok(runtimeContractForBinding(field.binding), `${key}: ${field.binding}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("shared brand facts have one editor and template-specific offering detail binds to Runtime", () => {
|
||||
const sharedBrandBindings = new Set([
|
||||
"brand.name",
|
||||
"brand.tagline",
|
||||
"brand.description",
|
||||
"brand.avatarUrl",
|
||||
"brand.coverUrl",
|
||||
"brand.hours",
|
||||
"brand.address",
|
||||
"brand.contactPhone",
|
||||
"brand.contactWechat",
|
||||
"brand.deliveryNote",
|
||||
]);
|
||||
for (const key of ["acheng-campus-food", "linjing-editorial"]) {
|
||||
const root = path.join(packageRoot, `template-${key}`);
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(root, "template.json"), "utf8"));
|
||||
const bindings = manifest.admin.sections.flatMap((section) =>
|
||||
section.fields.map((field) => field.binding),
|
||||
);
|
||||
assert.ok(!bindings.some((binding) => sharedBrandBindings.has(binding)), key);
|
||||
}
|
||||
const foodRoot = path.join(packageRoot, "template-acheng-campus-food");
|
||||
const food = JSON.parse(fs.readFileSync(path.join(foodRoot, "template.json"), "utf8"));
|
||||
const background = food.admin.sections
|
||||
.flatMap((section) => section.fields)
|
||||
.find((field) => field.binding === "offering.config.details.background");
|
||||
assert.equal(background.label, "餐品介绍");
|
||||
const runtimeRenderer = fs.readFileSync(
|
||||
path.resolve(
|
||||
packageRoot,
|
||||
"../apps/miniapp/components/modules/offering-detail/offering-detail.wxml",
|
||||
),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(runtimeRenderer, /item\.details\.background\s*\|\|\s*item\.desc/);
|
||||
const runtimeProjection = fs.readFileSync(
|
||||
path.resolve(packageRoot, "../apps/api/src/modules/public/public-workspace.controller.ts"),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(runtimeProjection, /projectOfferingDetails\(config\)/);
|
||||
});
|
||||
|
||||
test("food service slots declare the structured fields consumed by their visual layout", () => {
|
||||
const manifest = JSON.parse(
|
||||
fs.readFileSync(path.join(packageRoot, "template-acheng-campus-food/template.json"), "utf8"),
|
||||
);
|
||||
const schedule = manifest.trustContentTypes.find((item) => item.type === "schedule");
|
||||
assert.deepEqual(schedule.pages, ["service"]);
|
||||
assert.deepEqual(schedule.hideStandardFields, ["summary", "content"]);
|
||||
for (const key of ["weekdayLabel", "weekdayDetail", "weekendLabel", "weekendDetail"]) {
|
||||
assert.ok(schedule.configFields.some((field) => field.key === key && field.required));
|
||||
}
|
||||
const page = fs.readFileSync(
|
||||
path.join(packageRoot, "template-acheng-campus-food/miniapp/pages/stall-service/index.wxml"),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(page, /wx:for="\{\{schedule\.rows\}\}"/);
|
||||
assert.doesNotMatch(page, /wx:for="\{\{trustItems\}\}"|item\.summary|item\.content/);
|
||||
});
|
||||
|
||||
test("food home passes projected trust items to the renderer", () => {
|
||||
const page = fs.readFileSync(
|
||||
path.join(packageRoot, "template-acheng-campus-food/miniapp/pages/index/index.wxml"),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(page, /<acheng-home[\s\S]*trust-items="\{\{trustItems\}\}"/);
|
||||
assert.doesNotMatch(page, /trust-content=/);
|
||||
});
|
||||
|
||||
test("food profile renders only profile trust types once", () => {
|
||||
const manifest = JSON.parse(
|
||||
fs.readFileSync(path.join(packageRoot, "template-acheng-campus-food/template.json"), "utf8"),
|
||||
);
|
||||
const page = fs.readFileSync(
|
||||
path.join(packageRoot, "template-acheng-campus-food/miniapp/pages/bookings/index.wxml"),
|
||||
"utf8",
|
||||
);
|
||||
assert.equal(
|
||||
manifest.trustContentTypes.find((item) => item.type === "credential").pages.includes("profile"),
|
||||
true,
|
||||
);
|
||||
for (const type of ["coverage", "process"]) {
|
||||
assert.equal(
|
||||
manifest.trustContentTypes.find((item) => item.type === type).pages.includes("profile"),
|
||||
false,
|
||||
`${type} must be rendered on its dedicated page`,
|
||||
);
|
||||
}
|
||||
assert.equal((page.match(/credentials="{{credentials}}"/g) ?? []).length, 1);
|
||||
assert.doesNotMatch(page, /item\.type === '(coverage|process)'/);
|
||||
for (const type of ["case", "promise"]) {
|
||||
assert.ok(
|
||||
manifest.trustContentTypes.find((item) => item.type === type).pages.includes("profile"),
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -3,7 +3,7 @@ Component({
|
||||
brand: { type: Object, value: {} },
|
||||
presentation: { type: Object, value: {} },
|
||||
hero: { type: Object, value: {} },
|
||||
trustContent: { type: Object, value: {} },
|
||||
trustPresentation: { type: Object, value: {} },
|
||||
offerings: { type: Array, value: [] },
|
||||
},
|
||||
data: { resolvedHeroImage: "" },
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<view class="page">
|
||||
<view class="founder-card"><image class="avatar" src="{{brand.avatarUrl}}" mode="aspectFill"/><view class="founder-copy"><text class="founder-name">{{brand.founder}}</text><text class="founder-title">{{brand.title}}</text><text class="quote">“{{brand.slogan}}”</text></view><text class="badge">{{presentation.founderBadge}}</text></view>
|
||||
<view class="hero" bindtap="goWorks"><image class="hero-image" src="{{resolvedHeroImage}}" mode="aspectFill"/><view class="hero-shade"/><view class="hero-copy"><text class="eyebrow">{{hero.eyebrow}}</text><text class="hero-title">{{hero.title}}</text><text class="hero-slogan">{{hero.slogan}}</text><text class="hero-button">{{hero.cta}}</text></view></view>
|
||||
<view class="intro"><text class="eyebrow dark">{{presentation.proofEyebrow}}</text><text class="section-title">{{presentation.proofTitle}}</text><text class="body">{{trustContent.bio}}</text><view class="stats"><view wx:for="{{trustContent.stats}}" wx:key="value"><text class="stat-value">{{item.value}}</text><text class="stat-label">{{item.label}}</text><text class="stat-sub">{{item.sub}}</text></view></view></view>
|
||||
<view class="trust"><text class="eyebrow">{{presentation.manifestoEyebrow}}</text><text class="section-title light">{{presentation.manifestoTitle}}</text><view wx:for="{{trustContent.pillars}}" wx:key="title" class="pillar"><text class="pillar-title">{{item.title}}</text><text class="pillar-desc">{{item.desc}}</text></view></view>
|
||||
<view class="intro"><text class="eyebrow dark">{{presentation.proofEyebrow}}</text><text class="section-title">{{presentation.proofTitle}}</text><text class="body">{{trustPresentation.bio}}</text><view class="stats"><view wx:for="{{trustPresentation.stats}}" wx:key="value"><text class="stat-value">{{item.value}}</text><text class="stat-label">{{item.label}}</text><text class="stat-sub">{{item.sub}}</text></view></view></view>
|
||||
<view class="trust"><text class="eyebrow">{{presentation.manifestoEyebrow}}</text><text class="section-title light">{{presentation.manifestoTitle}}</text><view wx:for="{{trustPresentation.pillars}}" wx:key="title" class="pillar"><text class="pillar-title">{{item.title}}</text><text class="pillar-desc">{{item.desc}}</text></view></view>
|
||||
<view class="section"><view class="section-head"><view><text class="eyebrow dark">{{presentation.worksEyebrow}}</text><text class="section-title">{{presentation.worksTitle}}</text></view><text class="more" bindtap="goWorks">{{presentation.worksAction}}</text></view><view wx:for="{{offerings}}" wx:key="id" class="work-card" data-id="{{item.id}}" bindtap="selectOffering"><image src="{{item.image}}" mode="aspectFill"/><view class="work-info"><text class="work-category">{{item.category}} · {{item.area}}</text><text class="work-name">{{item.name}}</text><text class="work-desc">{{item.series}} · {{item.keywords[0]}} · {{item.keywords[1]}}</text></view></view></view>
|
||||
<view class="flow"><text class="flow-eyebrow">{{presentation.flowEyebrow}}</text><text class="flow-title">{{presentation.flowTitle}}</text><view class="flow-grid"><view wx:for="{{trustContent.serviceFlow}}" wx:key="step" class="flow-item"><text class="flow-step">{{item.step}}</text><text class="flow-name">{{item.name}}</text><text class="flow-desc">{{item.desc}}</text></view></view></view>
|
||||
<view class="flow"><text class="flow-eyebrow">{{presentation.flowEyebrow}}</text><text class="flow-title">{{presentation.flowTitle}}</text><view class="flow-grid"><view wx:for="{{trustPresentation.serviceFlow}}" wx:key="step" class="flow-item"><text class="flow-step">{{item.step}}</text><text class="flow-name">{{item.name}}</text><text class="flow-desc">{{item.desc}}</text></view></view></view>
|
||||
</view>
|
||||
@@ -1,6 +1,7 @@
|
||||
Component({
|
||||
properties: {
|
||||
brand: { type: Object, value: {} },
|
||||
trustItems: { type: Array, value: [] },
|
||||
presentation: { type: Object, value: {} },
|
||||
recordsCount: { type: Number, value: 0 },
|
||||
},
|
||||
|
||||
@@ -23,4 +23,9 @@
|
||||
<view class="card-title"><t-icon name="secured" size="32rpx" /><text>{{presentation.warrantyTitle}}</text></view>
|
||||
<view wx:for="{{brand.profilePresentation.warranty}}" wx:key="*this" class="warranty"><text class="dot">•</text><text>{{item}}</text></view>
|
||||
</view>
|
||||
<view wx:for="{{trustItems}}" wx:key="title" class="info-card trust-card">
|
||||
<view class="card-title"><text>{{item.title}}</text></view>
|
||||
<text wx:if="{{item.summary}}" class="trust-summary">{{item.summary}}</text>
|
||||
<text>{{item.content}}</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -189,6 +189,17 @@
|
||||
font-size: 23rpx;
|
||||
line-height: 1.65;
|
||||
}
|
||||
.trust-card > text {
|
||||
display: block;
|
||||
color: #57534e;
|
||||
font-size: 23rpx;
|
||||
line-height: 1.65;
|
||||
}
|
||||
.trust-card .trust-summary {
|
||||
margin-bottom: 8rpx;
|
||||
color: #202221;
|
||||
font-weight: 600;
|
||||
}
|
||||
.dot {
|
||||
flex: 0 0 auto;
|
||||
color: #8a6846;
|
||||
|
||||
@@ -5,7 +5,12 @@ Page({
|
||||
data: { brand: {}, records: [], error: "" },
|
||||
onLoad() {
|
||||
loadWorkspaceWithFallback()
|
||||
.then((workspace) => this.setData({ brand: workspace.brand || {} }))
|
||||
.then((workspace) =>
|
||||
this.setData({
|
||||
brand: workspace.brand || {},
|
||||
trustItems: workspace.trustItems || [],
|
||||
}),
|
||||
)
|
||||
.catch((error) => this.setData({ error: error.message }));
|
||||
},
|
||||
onShow() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<view class="page">
|
||||
<view wx:if="{{error}}" class="runtime-error">{{error}}</view>
|
||||
<linjing-profile wx:else brand="{{brand}}" presentation="{{brand.visualPresentation.profile}}" records-count="{{records.length}}" bind:call="call" bind:copy="copyWechat" bind:records="recordsPage" />
|
||||
<linjing-profile wx:else brand="{{brand}}" trust-items="{{trustItems}}" presentation="{{brand.visualPresentation.profile}}" records-count="{{records.length}}" bind:call="call" bind:copy="copyWechat" bind:records="recordsPage" />
|
||||
</view>
|
||||
@@ -3,7 +3,7 @@ const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
Page({
|
||||
data: {
|
||||
brand: {},
|
||||
trustContent: {},
|
||||
trustPresentation: {},
|
||||
offerings: [],
|
||||
hero: { image: "", eyebrow: "", title: "", slogan: "", cta: "" },
|
||||
error: "",
|
||||
@@ -13,16 +13,18 @@ Page({
|
||||
.then((workspace) => {
|
||||
const brand = workspace.brand || {};
|
||||
const offerings = workspace.offerings || [];
|
||||
const credentials = (workspace.trustItems || []).filter(
|
||||
(item) => item.type === "credential",
|
||||
);
|
||||
const credential =
|
||||
credentials.find((item) => Object.keys(item.config || {}).length > 0) || credentials[0];
|
||||
const configuredHero =
|
||||
brand.homeHero && typeof brand.homeHero === "object" ? brand.homeHero : {};
|
||||
this.setData({
|
||||
brand,
|
||||
trustContent: {
|
||||
trustPresentation: {
|
||||
...(workspace.trustPresentation || {}),
|
||||
bio:
|
||||
workspace.trustPresentation?.bio ||
|
||||
(workspace.trustItems || []).find((item) => item.type === "credential")?.content ||
|
||||
"",
|
||||
bio: credential?.content || "",
|
||||
},
|
||||
offerings,
|
||||
hero: {
|
||||
@@ -30,7 +32,7 @@ Page({
|
||||
image: brand.heroImage || "",
|
||||
eyebrow: brand.tagline || brand.name,
|
||||
title: (offerings[0] && offerings[0].name) || brand.name,
|
||||
slogan: brand.description || "",
|
||||
slogan: workspace.templateData?.designPhilosophy || brand.description || "",
|
||||
...configuredHero,
|
||||
image: brand.heroImage || "",
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<view class="page">
|
||||
<view wx:if="{{error}}" class="runtime-error">{{error}}</view>
|
||||
<linjing-home wx:else brand="{{brand}}" presentation="{{brand.visualPresentation.home}}" hero="{{hero}}" trust-content="{{trustContent}}" offerings="{{offerings}}" bind:select="selectOffering" bind:works="goWorks" />
|
||||
<linjing-home wx:else brand="{{brand}}" presentation="{{brand.visualPresentation.home}}" hero="{{hero}}" trust-presentation="{{trustPresentation}}" offerings="{{offerings}}" bind:select="selectOffering" bind:works="goWorks" />
|
||||
</view>
|
||||
@@ -82,6 +82,17 @@
|
||||
"description": "访客自己的咨询记录"
|
||||
}
|
||||
],
|
||||
"templateFields": [
|
||||
{
|
||||
"key": "designPhilosophy",
|
||||
"page": "home",
|
||||
"label": "设计理念",
|
||||
"help": "用一两句话说明你的设计方法。",
|
||||
"input": "textarea",
|
||||
"maxLength": 160,
|
||||
"placeholder": "例如:克制、自然、长期主义"
|
||||
}
|
||||
],
|
||||
"assetSlots": [
|
||||
{
|
||||
"key": "brand.portrait",
|
||||
@@ -120,6 +131,7 @@
|
||||
"key": "identity",
|
||||
"title": "主理人与联系方式",
|
||||
"description": "让业主清楚谁负责项目,以及如何联系你。",
|
||||
"page": "profile",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -129,13 +141,6 @@
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "portrait",
|
||||
"binding": "brand.config.avatarUrl",
|
||||
"label": "主理人肖像",
|
||||
"help": "建议使用正式、清晰的个人照片。",
|
||||
"input": "image"
|
||||
},
|
||||
{
|
||||
"key": "title",
|
||||
"binding": "brand.config.title",
|
||||
@@ -143,32 +148,6 @@
|
||||
"input": "text",
|
||||
"required": true,
|
||||
"placeholder": "例如:别墅门系统主理人"
|
||||
},
|
||||
{
|
||||
"key": "slogan",
|
||||
"binding": "brand.config.slogan",
|
||||
"label": "主理人主张",
|
||||
"input": "textarea",
|
||||
"maxLength": 100
|
||||
},
|
||||
{
|
||||
"key": "studioAddress",
|
||||
"binding": "brand.config.studioAddress",
|
||||
"label": "服务区域或工作室地址",
|
||||
"input": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "phone",
|
||||
"binding": "brand.config.phone",
|
||||
"label": "公开联系电话",
|
||||
"input": "phone"
|
||||
},
|
||||
{
|
||||
"key": "wechat",
|
||||
"binding": "brand.config.wechat",
|
||||
"label": "公开微信号",
|
||||
"input": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -176,6 +155,7 @@
|
||||
"key": "home",
|
||||
"title": "首页品牌表达",
|
||||
"description": "用简洁的语言解释你的项目方法、代表作品和合作流程。",
|
||||
"page": "home",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -277,6 +257,7 @@
|
||||
"key": "profileDetails",
|
||||
"title": "服务区域与履约说明",
|
||||
"description": "在主理人与我页面说明可服务的地区和真实履约承诺。",
|
||||
"page": "profile",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -363,6 +344,7 @@
|
||||
"key": "cases",
|
||||
"title": "案例与体系",
|
||||
"description": "说明案例页展示的内容,让业主能快速找到相近项目。",
|
||||
"page": "offerings",
|
||||
"target": "offering",
|
||||
"fields": [
|
||||
{
|
||||
@@ -402,6 +384,7 @@
|
||||
"key": "consultation",
|
||||
"title": "咨询说明",
|
||||
"description": "明确访客提交后会得到怎样的回应,减少无效咨询。",
|
||||
"page": "inquiry",
|
||||
"target": "inquiry",
|
||||
"fields": [
|
||||
{
|
||||
@@ -441,6 +424,7 @@
|
||||
"key": "projectDetail",
|
||||
"title": "案例详情",
|
||||
"description": "以下内容分别填写在每个案例中,空白内容不会展示。",
|
||||
"page": "detail",
|
||||
"target": "offering",
|
||||
"fields": [
|
||||
{
|
||||
@@ -517,6 +501,7 @@
|
||||
"key": "detailCopy",
|
||||
"title": "详情页说明",
|
||||
"description": "说明案例内容、价格与咨询后的真实处理方式。",
|
||||
"page": "detail",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -574,6 +559,7 @@
|
||||
"key": "successCopy",
|
||||
"title": "提交成功页",
|
||||
"description": "访客提交后看到的确认信息与后续预期。",
|
||||
"page": "success",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -613,6 +599,7 @@
|
||||
"key": "recordsCopy",
|
||||
"title": "咨询记录页",
|
||||
"description": "访客查看咨询状态时看到的内容。",
|
||||
"page": "records",
|
||||
"target": "brand",
|
||||
"fields": [
|
||||
{
|
||||
@@ -653,16 +640,22 @@
|
||||
{
|
||||
"type": "schedule",
|
||||
"label": "服务与合作安排",
|
||||
"adminFields": { "title": "安排标题", "summary": "安排摘要", "content": "时间与排期详情" },
|
||||
"pages": ["profile"],
|
||||
"help": "说明可预约时间、服务周期或项目排期。"
|
||||
},
|
||||
{
|
||||
"type": "coverage",
|
||||
"label": "服务范围与适用对象",
|
||||
"adminFields": { "title": "范围标题", "summary": "范围摘要", "content": "服务范围说明" },
|
||||
"pages": ["profile"],
|
||||
"help": "说明服务地区、项目类型或合作边界。"
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"label": "合作流程",
|
||||
"adminFields": { "title": "流程标题", "summary": "流程摘要", "content": "流程步骤" },
|
||||
"pages": ["profile"],
|
||||
"help": "每行写一步,从初次沟通到交付完成。",
|
||||
"placeholder": "例如:需求沟通\n方案确认\n落地交付",
|
||||
"required": true
|
||||
@@ -670,6 +663,8 @@
|
||||
{
|
||||
"type": "credential",
|
||||
"label": "专业资历与方法",
|
||||
"adminFields": { "title": "证明标题", "summary": "专业摘要", "content": "资历与方法说明" },
|
||||
"pages": ["home", "profile"],
|
||||
"help": "填写经验、资质、专业标准或工作方法。",
|
||||
"configFields": [
|
||||
{
|
||||
@@ -707,16 +702,29 @@
|
||||
],
|
||||
"required": true
|
||||
},
|
||||
{ "type": "case", "label": "项目案例与客户反馈", "help": "填写代表性项目、成果或客户评价。" },
|
||||
{
|
||||
"type": "case",
|
||||
"label": "项目案例与客户反馈",
|
||||
"adminFields": {
|
||||
"title": "案例标题",
|
||||
"summary": "案例摘要",
|
||||
"content": "项目成果与客户反馈"
|
||||
},
|
||||
"pages": ["profile"],
|
||||
"help": "填写代表性项目、成果或客户评价。"
|
||||
},
|
||||
{
|
||||
"type": "promise",
|
||||
"label": "合作预期与响应承诺",
|
||||
"adminFields": { "title": "承诺标题", "summary": "承诺摘要", "content": "合作与响应说明" },
|
||||
"pages": ["profile"],
|
||||
"help": "说明回复时间、合作边界和后续跟进方式。"
|
||||
}
|
||||
],
|
||||
"sampleContent": {
|
||||
"doors": {
|
||||
"templateKey": "doors",
|
||||
"inquiryFormName": "门系统咨询表单",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "product",
|
||||
@@ -836,6 +844,7 @@
|
||||
},
|
||||
"personal": {
|
||||
"templateKey": "personal",
|
||||
"inquiryFormName": "合作咨询表单",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "service",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"test": "node --experimental-strip-types --test test/**/*.test.mjs",
|
||||
"lint": "eslint .",
|
||||
"typecheck": "tsc -p tsconfig.json --noEmit",
|
||||
"clean": "rimraf dist"
|
||||
|
||||
@@ -41,3 +41,4 @@ export interface PublicOffering {
|
||||
}
|
||||
|
||||
export * from "./runtime-workspace.js";
|
||||
export * from "./runtime-content-contract.js";
|
||||
@@ -0,0 +1,233 @@
|
||||
/**
|
||||
* 平台字段的规范 Runtime 路径。
|
||||
* 这里不保存模板样例数据,只定义跨模板稳定的数据边界。
|
||||
*/
|
||||
export const RUNTIME_CONTENT_PATHS = {
|
||||
brand: "workspace.brand",
|
||||
templateData: "workspace.templateData",
|
||||
pagePresentation: "workspace.brand.visualPresentation",
|
||||
offering: "workspace.offerings[].presentation",
|
||||
offeringDetails: "workspace.offerings[].presentation.details",
|
||||
trust: "workspace.trustItems[]",
|
||||
inquiry: "workspace.inquiryForms[]",
|
||||
} as const;
|
||||
|
||||
export type RuntimeContentKind = keyof typeof RUNTIME_CONTENT_PATHS;
|
||||
|
||||
export type RuntimeBindingContract = {
|
||||
binding: string;
|
||||
runtimePath: string;
|
||||
kind: RuntimeContentKind;
|
||||
legacyBindings?: readonly string[];
|
||||
};
|
||||
|
||||
/** 将模板 binding 映射到唯一 Runtime 对象;未知 binding 必须由模板显式扩展。 */
|
||||
export function runtimeContractForBinding(binding: string): RuntimeBindingContract | null {
|
||||
if (binding.startsWith("brand.config.templateData.")) {
|
||||
return {
|
||||
binding,
|
||||
runtimePath: `${RUNTIME_CONTENT_PATHS.templateData}.${binding.slice("brand.config.templateData.".length)}`,
|
||||
kind: "templateData",
|
||||
};
|
||||
}
|
||||
if (
|
||||
binding.startsWith("brand.config.") &&
|
||||
!binding.startsWith("brand.config.visualPresentation.")
|
||||
) {
|
||||
return {
|
||||
binding,
|
||||
runtimePath: `${RUNTIME_CONTENT_PATHS.brand}.${binding.slice("brand.config.".length)}`,
|
||||
kind: "brand",
|
||||
legacyBindings: [binding],
|
||||
};
|
||||
}
|
||||
if (binding.startsWith("brand.config.visualPresentation.")) {
|
||||
return {
|
||||
binding,
|
||||
runtimePath: `${RUNTIME_CONTENT_PATHS.pagePresentation}.${binding.slice("brand.config.visualPresentation.".length)}`,
|
||||
kind: "pagePresentation",
|
||||
};
|
||||
}
|
||||
if (binding.startsWith("offering.config.details.")) {
|
||||
return {
|
||||
binding,
|
||||
runtimePath: `${RUNTIME_CONTENT_PATHS.offeringDetails}.${binding.slice("offering.config.details.".length)}`,
|
||||
kind: "offeringDetails",
|
||||
};
|
||||
}
|
||||
if (binding.startsWith("offering.config.")) {
|
||||
return {
|
||||
binding,
|
||||
runtimePath: `${RUNTIME_CONTENT_PATHS.offering}.${binding.slice("offering.config.".length)}`,
|
||||
kind: "offering",
|
||||
};
|
||||
}
|
||||
if (binding === "trust.title" || binding === "trust.summary" || binding === "trust.content") {
|
||||
return {
|
||||
binding,
|
||||
runtimePath: `${RUNTIME_CONTENT_PATHS.trust}.${binding.slice("trust.".length)}`,
|
||||
kind: "trust",
|
||||
};
|
||||
}
|
||||
if (binding.startsWith("trust.config.")) {
|
||||
return {
|
||||
binding,
|
||||
runtimePath: `${RUNTIME_CONTENT_PATHS.trust}.config.${binding.slice("trust.config.".length)}`,
|
||||
kind: "trust",
|
||||
};
|
||||
}
|
||||
if (binding === "inquiry.fieldsSnapshot") {
|
||||
return { binding, runtimePath: `${RUNTIME_CONTENT_PATHS.inquiry}.fields`, kind: "inquiry" };
|
||||
}
|
||||
if (binding.startsWith("brand.")) {
|
||||
return {
|
||||
binding,
|
||||
runtimePath: `${RUNTIME_CONTENT_PATHS.brand}.${binding.slice("brand.".length)}`,
|
||||
kind: "brand",
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function projectBrandAliases(
|
||||
brand: Record<string, unknown>,
|
||||
config: Record<string, unknown>,
|
||||
): Record<string, unknown> {
|
||||
return {
|
||||
...brand,
|
||||
...config,
|
||||
...(typeof brand.tagline === "string" ? { tagline: brand.tagline } : {}),
|
||||
...(typeof brand.description === "string" ? { slogan: brand.description } : {}),
|
||||
...(typeof brand.contactPhone === "string" ? { phone: brand.contactPhone } : {}),
|
||||
...(typeof brand.contactWechat === "string" ? { wechat: brand.contactWechat } : {}),
|
||||
...(typeof brand.address === "string" ? { studioAddress: brand.address } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
export function projectOfferingDetails(config: Record<string, unknown>): {
|
||||
background: string;
|
||||
designConcept: string;
|
||||
crafts: string[];
|
||||
materialsList: Array<{ name: string; spec: string }>;
|
||||
} {
|
||||
const details = config.details;
|
||||
const source =
|
||||
details && typeof details === "object" && !Array.isArray(details)
|
||||
? (details as Record<string, unknown>)
|
||||
: {};
|
||||
const materialsList = Array.isArray(source.materialsList)
|
||||
? source.materialsList.flatMap((entry) => {
|
||||
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return [];
|
||||
const value = entry as Record<string, unknown>;
|
||||
return typeof value.name === "string" && typeof value.spec === "string"
|
||||
? [{ name: value.name, spec: value.spec }]
|
||||
: [];
|
||||
})
|
||||
: [];
|
||||
return {
|
||||
background: typeof source.background === "string" ? source.background : "",
|
||||
designConcept: typeof source.designConcept === "string" ? source.designConcept : "",
|
||||
crafts: Array.isArray(source.crafts)
|
||||
? source.crafts.filter((craft): craft is string => typeof craft === "string")
|
||||
: [],
|
||||
materialsList,
|
||||
};
|
||||
}
|
||||
|
||||
export function projectTemplateData(
|
||||
config: Record<string, unknown>,
|
||||
declaredKeys: readonly string[],
|
||||
): Record<string, unknown> {
|
||||
const source = config.templateData;
|
||||
if (!source || typeof source !== "object" || Array.isArray(source)) return {};
|
||||
const values = source as Record<string, unknown>;
|
||||
return Object.fromEntries(
|
||||
declaredKeys
|
||||
.map((key) => [key, values[key]] as const)
|
||||
.filter(([, value]) => value !== undefined),
|
||||
);
|
||||
}
|
||||
|
||||
export function projectTrustItem(item: Record<string, unknown>): {
|
||||
id?: string;
|
||||
type: string;
|
||||
title: string;
|
||||
summary: string;
|
||||
content: string;
|
||||
config: Record<string, unknown>;
|
||||
} | null {
|
||||
if (typeof item.type !== "string" || typeof item.title !== "string") return null;
|
||||
return {
|
||||
...(typeof item.id === "string" ? { id: item.id } : {}),
|
||||
type: item.type,
|
||||
title: item.title,
|
||||
summary: typeof item.summary === "string" ? item.summary : "",
|
||||
content: typeof item.content === "string" ? item.content : "",
|
||||
config:
|
||||
item.config && typeof item.config === "object" && !Array.isArray(item.config)
|
||||
? (item.config as Record<string, unknown>)
|
||||
: {},
|
||||
};
|
||||
}
|
||||
|
||||
/** 按模板声明校验实际使用的内容,隐藏正文的结构化区块不再依赖旧正文。 */
|
||||
export function isTrustContentComplete(
|
||||
item: { title: string; content: string; config?: unknown },
|
||||
declaration?: {
|
||||
hideStandardFields?: readonly string[];
|
||||
configFields?: readonly {
|
||||
key: string;
|
||||
required?: boolean;
|
||||
input: string;
|
||||
itemFields?: readonly { key: string; required?: boolean }[];
|
||||
}[];
|
||||
},
|
||||
): boolean {
|
||||
if (!item.title.trim()) return false;
|
||||
if (!declaration?.hideStandardFields?.includes("content") && !item.content.trim()) return false;
|
||||
const config =
|
||||
item.config && typeof item.config === "object" && !Array.isArray(item.config)
|
||||
? (item.config as Record<string, unknown>)
|
||||
: {};
|
||||
return (declaration?.configFields ?? []).every((field) => {
|
||||
const value = config[field.key];
|
||||
if (
|
||||
value === undefined ||
|
||||
value === null ||
|
||||
value === "" ||
|
||||
(Array.isArray(value) && value.length === 0)
|
||||
)
|
||||
return !field.required;
|
||||
if (field.input !== "list")
|
||||
return typeof value === "string" && (!field.required || value.trim().length > 0);
|
||||
return (
|
||||
Array.isArray(value) &&
|
||||
value.every((raw: unknown) => {
|
||||
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return false;
|
||||
const row = raw as Record<string, unknown>;
|
||||
return (field.itemFields ?? []).every((child) => {
|
||||
const cell = row[child.key];
|
||||
return !child.required || (typeof cell === "string" && cell.trim().length > 0);
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/** 每种结构化展示只读取该模板声明的来源,旧类型或其他记录不能覆盖编辑值。 */
|
||||
export function projectTrustPresentation(
|
||||
items: readonly { type: string; config: Record<string, unknown> }[],
|
||||
declarations: readonly { type: string; configFields?: readonly { key: string }[] }[],
|
||||
): Record<string, unknown> {
|
||||
const result: Record<string, unknown> = {};
|
||||
for (const declaration of declarations) {
|
||||
const records = items.filter((item) => item.type === declaration.type);
|
||||
const primary = records.find((item) => Object.keys(item.config).length > 0) ?? records[0];
|
||||
if (!primary) continue;
|
||||
for (const field of declaration.configFields ?? []) {
|
||||
const value = primary.config[field.key];
|
||||
if (value !== undefined) result[field.key] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||