fix: 收敛模板编辑发布契约并还原餐饮页面视觉

This commit is contained in:
que01 committed 2026-10-08 13:36:59 +08:00
1 parent 20bcb43534
commit f4061a24bd
102 files changed
+4510 -870

No files matched your search

+28 -1
View File
@@ -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";
+505 -102
View File
@@ -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";
+35 -1
View File
@@ -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",
Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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",
+8
View File
@@ -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`。模板在构建时选择,运行时不会下载或解释模板代码。
+93 -1
View File
@@ -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",
+1
View File
@@ -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"
+1
View File
@@ -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;
}
+3 -1
View File
@@ -78,9 +78,10 @@ export interface TrustPresentation {
}
export interface RuntimeTrustItem {
id?: string;
type: string;
title: string;
summary: string | null;
summary: string;
content: string;
config: Record<string, unknown>;
}
@@ -103,6 +104,7 @@ export interface RuntimeWorkspace {
publishedAt?: string;
};
brand: Record<string, unknown>;
templateData: Record<string, unknown>;
navigation: {
tabs: Array<{ key: string; label: string; page: string }>;
};
@@ -0,0 +1,110 @@
import assert from "node:assert/strict";
import test from "node:test";
import {
isTrustContentComplete,
projectBrandAliases,
projectOfferingDetails,
projectTemplateData,
projectTrustItem,
projectTrustPresentation,
runtimeContractForBinding,
} from "../src/runtime-content-contract.ts";
test("runtime contract resolves canonical paths", () => {
assert.equal(
runtimeContractForBinding("offering.config.details.background").runtimePath,
"workspace.offerings[].presentation.details.background",
);
assert.equal(
runtimeContractForBinding("brand.config.templateData.designPhilosophy").runtimePath,
"workspace.templateData.designPhilosophy",
);
});
test("brand projection gives standard columns precedence over legacy aliases", () => {
const result = projectBrandAliases(
{ description: "标准简介", contactPhone: "13800000000" },
{ slogan: "旧简介", phone: "旧电话" },
);
assert.equal(result.slogan, "标准简介");
assert.equal(result.phone, "13800000000");
});
test("template data projection filters undeclared values", () => {
assert.deepEqual(
projectTemplateData({ templateData: { designPhilosophy: "克制", internalOnly: "secret" } }, [
"designPhilosophy",
]),
{ designPhilosophy: "克制" },
);
});
test("offering and trust projections normalize malformed JSON", () => {
assert.deepEqual(
projectOfferingDetails({ details: { background: "餐品说明", crafts: ["手作", 1] } }),
{
background: "餐品说明",
designConcept: "",
crafts: ["手作"],
materialsList: [],
},
);
assert.equal(
projectTrustItem({ type: "schedule", title: "出摊安排", content: "周末" }).summary,
"",
);
assert.equal(projectTrustItem({ type: "schedule" }), null);
assert.equal(
projectTrustItem({ id: "stable-record", type: "credential", title: "资质" }).id,
"stable-record",
);
});
test("structured content validates visible fields and step details instead of hidden prose", () => {
const declaration = {
hideStandardFields: ["content"],
configFields: [
{
key: "steps",
input: "list",
required: true,
itemFields: [
{ key: "title", required: true },
{ key: "detail", required: true },
],
},
],
};
assert.equal(
isTrustContentComplete({ title: "流程", content: "旧正文", config: {} }, declaration),
false,
);
assert.equal(
isTrustContentComplete(
{ title: "流程", content: "", config: { steps: [{ title: "提交", detail: "填写需求" }] } },
declaration,
),
true,
);
assert.equal(
isTrustContentComplete(
{ title: "流程", content: "", config: { steps: [{ title: "提交", detail: " " }] } },
declaration,
),
false,
);
assert.equal(isTrustContentComplete({ title: "证明", content: " " }), false);
});
test("legacy profile configuration cannot shadow the declared credential editor", () => {
const stats = [{ value: "42", label: "编辑后的成果" }];
const result = projectTrustPresentation(
[
{ type: "profile", config: { stats: [{ value: "旧值" }], internalOnly: "未声明" } },
{ type: "credential", config: {} },
{ type: "credential", config: { stats, internalOnly: "未声明" } },
],
[{ type: "credential", configFields: [{ key: "stats" }] }],
);
assert.deepEqual(result, { stats });
});