feat: 收口多品牌与模板构建基础
This commit is contained in:
1 parent
0425a1c672
commit
77224ea51f
317 files changed
+11290
-1158
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { Image, Input, Space, Typography } from "antd";
|
||||
|
||||
interface ImageUrlFieldProps {
|
||||
value?: string;
|
||||
onChange?: (value: string) => void;
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export function ImageUrlField({ value, onChange, placeholder }: ImageUrlFieldProps) {
|
||||
const imageUrl = typeof value === "string" ? value.trim() : "";
|
||||
return (
|
||||
<Space direction="vertical" size={8} style={{ width: "100%" }}>
|
||||
<Input
|
||||
value={value}
|
||||
onChange={(event) => onChange?.(event.target.value)}
|
||||
placeholder={placeholder ?? "粘贴图片地址"}
|
||||
/>
|
||||
{imageUrl ? (
|
||||
<Space align="start">
|
||||
<Image
|
||||
src={imageUrl}
|
||||
width={96}
|
||||
height={64}
|
||||
preview
|
||||
fallback="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="
|
||||
style={{ objectFit: "cover", borderRadius: 8, background: "#f5f5f5" }}
|
||||
/>
|
||||
<Typography.Text type="secondary">预览图</Typography.Text>
|
||||
</Space>
|
||||
) : null}
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
@@ -3,7 +3,13 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { BrandProfile } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { ImageUrlField } from "../../components/ImageUrlField.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
import { PresentationEditor } from "./PresentationEditor.js";
|
||||
|
||||
function textValue(value: unknown): string {
|
||||
return typeof value === "string" ? value : "";
|
||||
}
|
||||
|
||||
export function BrandPage() {
|
||||
const client = createApiClient();
|
||||
@@ -15,6 +21,10 @@ export function BrandPage() {
|
||||
queryFn: () => client.getPublicTemplate(brand.data!.templateKey),
|
||||
enabled: Boolean(brand.data?.templateKey),
|
||||
});
|
||||
const runtime = useQuery({
|
||||
queryKey: ["public-runtime-workspace"],
|
||||
queryFn: () => client.getPublicWorkspace(),
|
||||
});
|
||||
const save = useMutation({
|
||||
mutationFn: (values: Partial<BrandProfile>) => client.updateAdminBrand(values),
|
||||
onSuccess: () => {
|
||||
@@ -115,13 +125,17 @@ export function BrandPage() {
|
||||
</Form.Item>
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name="avatarUrl" label="头像 URL">
|
||||
<Input />
|
||||
<Form.Item
|
||||
name="avatarUrl"
|
||||
label="头像图片地址"
|
||||
help="粘贴一张可公开访问的图片地址。"
|
||||
>
|
||||
<ImageUrlField />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name="coverUrl" label="品牌封面 URL">
|
||||
<Input />
|
||||
<Form.Item name="coverUrl" label="品牌封面图片地址" help="建议使用横向图片。">
|
||||
<ImageUrlField />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
@@ -133,6 +147,45 @@ export function BrandPage() {
|
||||
</Button>
|
||||
</Space>
|
||||
</Form>
|
||||
<PresentationEditor
|
||||
initialValue={{
|
||||
identity: {
|
||||
founder: textValue(brand.data.config?.founder),
|
||||
title: textValue(brand.data.config?.title),
|
||||
slogan: textValue(brand.data.config?.slogan),
|
||||
phone: textValue(brand.data.config?.phone),
|
||||
wechat: textValue(brand.data.config?.wechat),
|
||||
studioAddress: textValue(brand.data.config?.studioAddress),
|
||||
},
|
||||
...((brand.data.config?.visualPresentation as {
|
||||
home?: Record<string, string>;
|
||||
offerings?: Record<string, string>;
|
||||
detail?: Record<string, string>;
|
||||
profile?: Record<string, string>;
|
||||
inquiry?: Record<string, string>;
|
||||
success?: Record<string, string>;
|
||||
records?: Record<string, string>;
|
||||
}) ?? {}),
|
||||
}}
|
||||
runtimeValue={
|
||||
runtime.data?.brand
|
||||
? {
|
||||
identity: {
|
||||
founder: textValue(runtime.data.brand.config?.founder),
|
||||
title: textValue(runtime.data.brand.config?.title),
|
||||
slogan: textValue(runtime.data.brand.config?.slogan),
|
||||
},
|
||||
...((runtime.data.brand.config?.visualPresentation as {
|
||||
home?: Record<string, string>;
|
||||
inquiry?: Record<string, string>;
|
||||
profile?: Record<string, string>;
|
||||
}) ?? {}),
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
runtimeLoading={runtime.isLoading}
|
||||
runtimeError={runtime.error}
|
||||
/>
|
||||
</Col>
|
||||
<Col xs={24} xl={9}>
|
||||
<Card title="公开表达预览" style={{ position: "sticky", top: 24 }}>
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
import { Alert, Button, Card, Col, Form, Input, Row, Space, Typography, message } from "antd";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useEffect } from "react";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { MutationError } from "../../components/QueryState.js";
|
||||
|
||||
interface PresentationEditorProps {
|
||||
initialValue: PresentationFormValues;
|
||||
runtimeValue?: PresentationFormValues | undefined;
|
||||
runtimeLoading?: boolean | undefined;
|
||||
runtimeError?: unknown;
|
||||
}
|
||||
|
||||
type PresentationFormValues = {
|
||||
identity?: Record<string, string>;
|
||||
home?: Record<string, string>;
|
||||
offerings?: Record<string, string>;
|
||||
detail?: Record<string, string>;
|
||||
profile?: Record<string, string>;
|
||||
inquiry?: Record<string, string>;
|
||||
success?: Record<string, string>;
|
||||
records?: Record<string, string>;
|
||||
};
|
||||
|
||||
export function PresentationEditor({
|
||||
initialValue,
|
||||
runtimeValue,
|
||||
runtimeLoading,
|
||||
runtimeError,
|
||||
}: PresentationEditorProps) {
|
||||
const [form] = Form.useForm<PresentationFormValues>();
|
||||
const queryClient = useQueryClient();
|
||||
const save = useMutation({
|
||||
mutationFn: (values: PresentationFormValues) =>
|
||||
createApiClient().updateAdminBrandPresentation(values),
|
||||
onSuccess: () => {
|
||||
message.success("页面表达已保存,小程序将使用最新内容");
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-brand"] });
|
||||
void queryClient.invalidateQueries({ queryKey: ["public-runtime-workspace"] });
|
||||
},
|
||||
});
|
||||
useEffect(() => {
|
||||
form.setFieldsValue(initialValue);
|
||||
}, [form, initialValue]);
|
||||
|
||||
return (
|
||||
<Card
|
||||
title="小程序页面表达"
|
||||
style={{ marginTop: 24 }}
|
||||
extra={<Typography.Text type="secondary">普通用户配置</Typography.Text>}
|
||||
>
|
||||
<Typography.Paragraph type="secondary">
|
||||
这里的内容会显示在小程序中。只填写你希望访客看到的话,不需要理解模板或技术配置。
|
||||
</Typography.Paragraph>
|
||||
{runtimeLoading ? <Alert type="info" showIcon message="正在读取小程序当前内容" /> : null}
|
||||
{runtimeError ? (
|
||||
<Alert type="warning" showIcon message="小程序当前内容暂时无法读取,保存后可重新加载。" />
|
||||
) : runtimeValue ? (
|
||||
<Card size="small" title="小程序当前已生效内容" style={{ marginBottom: 16 }}>
|
||||
<Typography.Text strong>
|
||||
{runtimeValue.identity?.founder || "尚未设置主理人 / 老板姓名"}
|
||||
</Typography.Text>
|
||||
{runtimeValue.identity?.title ? (
|
||||
<Typography.Text type="secondary"> · {runtimeValue.identity.title}</Typography.Text>
|
||||
) : null}
|
||||
<Typography.Paragraph strong>
|
||||
{runtimeValue.home?.proofTitle || "尚未设置信任介绍标题"}
|
||||
</Typography.Paragraph>
|
||||
<Typography.Paragraph type="secondary">
|
||||
{runtimeValue.inquiry?.subtitle || "尚未设置咨询说明"}
|
||||
</Typography.Paragraph>
|
||||
<Typography.Text type="secondary">
|
||||
咨询按钮:{runtimeValue.inquiry?.submitLabel || "未设置"} · 记录入口:
|
||||
{runtimeValue.profile?.recordsTitle || "未设置"}
|
||||
</Typography.Text>
|
||||
</Card>
|
||||
) : null}
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
initialValues={initialValue}
|
||||
onFinish={(values) => save.mutate(values)}
|
||||
>
|
||||
<Card size="small" title="主理人信息" style={{ marginBottom: 16 }}>
|
||||
<Typography.Paragraph type="secondary">
|
||||
访客需要先知道是谁在提供服务。这里填写主理人或老板的公开信息。
|
||||
</Typography.Paragraph>
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name={["identity", "founder"]} label="主理人 / 老板姓名">
|
||||
<Input placeholder="例如:林然" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name={["identity", "title"]} label="身份或职位">
|
||||
<Input placeholder="例如:品牌顾问 / 工作室主理人" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24}>
|
||||
<Form.Item name={["identity", "slogan"]} label="主理人希望传达的一句话">
|
||||
<Input placeholder="例如:认真做好每一次定制" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name={["identity", "phone"]} label="公开联系电话">
|
||||
<Input placeholder="选填" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name={["identity", "wechat"]} label="公开微信号">
|
||||
<Input placeholder="选填" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24}>
|
||||
<Form.Item name={["identity", "studioAddress"]} label="工作地点或服务范围">
|
||||
<Input placeholder="例如:杭州及周边地区 / 某某工作室" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
<Card size="small" title="首页" style={{ marginBottom: 16 }}>
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name={["home", "founderBadge"]} label="主理人标签">
|
||||
<Input placeholder="例如:亲自主理 / 10 年经验" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name={["home", "proofTitle"]} label="信任介绍标题">
|
||||
<Input placeholder="例如:用经历和作品建立信任" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name={["home", "worksTitle"]} label="作品区域标题">
|
||||
<Input placeholder="例如:精选作品" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name={["home", "flowTitle"]} label="合作流程标题">
|
||||
<Input placeholder="例如:从沟通到交付" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
<Card size="small" title="咨询页面" style={{ marginBottom: 16 }}>
|
||||
<Form.Item name={["inquiry", "title"]} label="页面标题">
|
||||
<Input placeholder="例如:告诉我你的需求" />
|
||||
</Form.Item>
|
||||
<Form.Item name={["inquiry", "subtitle"]} label="说明文字">
|
||||
<Input.TextArea
|
||||
rows={2}
|
||||
showCount
|
||||
maxLength={120}
|
||||
placeholder="告诉访客提交后会发生什么。"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name={["inquiry", "submitLabel"]} label="提交按钮文字">
|
||||
<Input placeholder="例如:提交咨询" />
|
||||
</Form.Item>
|
||||
</Card>
|
||||
<Card size="small" title="主理人与我" style={{ marginBottom: 16 }}>
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name={["profile", "recordsTitle"]} label="咨询记录入口标题">
|
||||
<Input placeholder="例如:我的咨询记录" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name={["profile", "coverageTitle"]} label="服务范围标题">
|
||||
<Input placeholder="例如:服务范围与合作方式" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name={["profile", "warrantyTitle"]} label="承诺标题">
|
||||
<Input placeholder="例如:我的服务承诺" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<MutationError error={save.error} />
|
||||
<Button type="primary" htmlType="submit" loading={save.isPending}>
|
||||
保存页面表达
|
||||
</Button>
|
||||
</Space>
|
||||
</Form>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,382 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Divider,
|
||||
Empty,
|
||||
Input,
|
||||
Modal,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
Tag,
|
||||
Typography,
|
||||
message,
|
||||
} from "antd";
|
||||
import type { BrandTemplateKey } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
const destinations: Record<string, string> = {
|
||||
brand: "/admin/brand",
|
||||
positioning: "/admin/brand",
|
||||
template: "/admin/publication",
|
||||
visual: "/admin/publication",
|
||||
offerings: "/admin/services",
|
||||
forms: "/admin/workspace",
|
||||
trust: "/admin/trust",
|
||||
};
|
||||
|
||||
export function PublicationPage({ canManageTemplate }: { canManageTemplate: boolean }) {
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
const [industryTarget, setIndustryTarget] = useState<BrandTemplateKey | null>(null);
|
||||
const [confirmAction, setConfirmAction] = useState<"publish" | "revoke" | null>(null);
|
||||
const [rollbackVersion, setRollbackVersion] = useState<number | null>(null);
|
||||
const [note, setNote] = useState("");
|
||||
const brand = useQuery({
|
||||
queryKey: ["publication-brand"],
|
||||
queryFn: () => client.getAdminBrand(),
|
||||
});
|
||||
const workspace = useQuery({
|
||||
queryKey: ["publication-workspace"],
|
||||
queryFn: () => client.getAdminWorkspace(),
|
||||
});
|
||||
const catalog = useQuery({
|
||||
queryKey: ["publication-catalog"],
|
||||
queryFn: () => client.listPublicTemplates(),
|
||||
});
|
||||
const sample = useQuery({
|
||||
queryKey: ["publication-sample"],
|
||||
queryFn: () => client.previewAdminSampleContent(),
|
||||
enabled: Boolean(workspace.data),
|
||||
});
|
||||
const readiness = useQuery({
|
||||
queryKey: ["publication-readiness"],
|
||||
queryFn: () => client.getAdminReleaseReadiness(),
|
||||
});
|
||||
const releases = useQuery({
|
||||
queryKey: ["publication-releases"],
|
||||
queryFn: () => client.listAdminReleases(),
|
||||
});
|
||||
const refresh = () => {
|
||||
for (const key of [
|
||||
"publication-brand",
|
||||
"publication-workspace",
|
||||
"publication-sample",
|
||||
"publication-readiness",
|
||||
"publication-releases",
|
||||
"admin-shell-brand",
|
||||
"admin-workspace",
|
||||
"public-runtime-workspace",
|
||||
]) {
|
||||
void queryClient.invalidateQueries({ queryKey: [key] });
|
||||
}
|
||||
};
|
||||
const install = useMutation({
|
||||
mutationFn: (key: BrandTemplateKey) => client.installAdminTemplate(key),
|
||||
onSuccess: () => {
|
||||
setIndustryTarget(null);
|
||||
message.success("行业模板已安装");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const selectVisual = useMutation({
|
||||
mutationFn: (key: string) =>
|
||||
client.updateAdminBrand({
|
||||
config: { ...(brand.data?.config ?? {}), visualTemplateKey: key },
|
||||
}),
|
||||
onSuccess: () => {
|
||||
message.success("视觉模板已保存到草稿");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const importSample = useMutation({
|
||||
mutationFn: () => client.importAdminSampleContent(),
|
||||
onSuccess: () => {
|
||||
message.success("示例内容已导入草稿");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const publish = useMutation({
|
||||
mutationFn: () => client.publishAdminRelease(note.trim() || undefined),
|
||||
onSuccess: () => {
|
||||
setConfirmAction(null);
|
||||
setNote("");
|
||||
message.success("品牌已发布");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const revoke = useMutation({
|
||||
mutationFn: () => client.revokeAdminRelease(),
|
||||
onSuccess: () => {
|
||||
setConfirmAction(null);
|
||||
message.success("品牌已撤回,小程序将显示未发布状态");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const rollback = useMutation({
|
||||
mutationFn: (version: number) => client.rollbackAdminRelease(version),
|
||||
onSuccess: () => {
|
||||
setRollbackVersion(null);
|
||||
message.success("历史版本已重新发布");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const loading = [brand, workspace, catalog, readiness, releases].some((query) => query.isLoading);
|
||||
const error = [brand, workspace, catalog, readiness, releases].find(
|
||||
(query) => query.isError,
|
||||
)?.error;
|
||||
const retry = () => {
|
||||
void brand.refetch();
|
||||
void workspace.refetch();
|
||||
void catalog.refetch();
|
||||
void readiness.refetch();
|
||||
void releases.refetch();
|
||||
};
|
||||
const industryKey =
|
||||
workspace.data?.installations[0]?.templateKey ??
|
||||
workspace.data?.brand?.templateKey ??
|
||||
brand.data?.templateKey ??
|
||||
"personal";
|
||||
const visuals = (catalog.data?.visuals ?? []).filter((item) =>
|
||||
item.supportedIndustryTemplates.includes(industryKey),
|
||||
);
|
||||
const visualKey =
|
||||
typeof brand.data?.config?.visualTemplateKey === "string"
|
||||
? brand.data.config.visualTemplateKey
|
||||
: "linjing-editorial";
|
||||
const currentRelease = releases.data?.find((item) => item.status === "published");
|
||||
const publishedHistory = (releases.data ?? []).filter(
|
||||
(item) => item.status === "published" || item.status === "superseded",
|
||||
);
|
||||
const draftOfferings = workspace.data?.offerings.filter((item) => item.isEnabled) ?? [];
|
||||
const draftForms = (workspace.data?.forms ?? []) as Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
isEnabled: boolean;
|
||||
}>;
|
||||
|
||||
return (
|
||||
<QueryState loading={loading} error={error} onRetry={retry}>
|
||||
<AdminPageHeader
|
||||
title="配置与发布"
|
||||
description="编辑内容不会立即影响小程序;确认后统一发布当前品牌。"
|
||||
/>
|
||||
<Space direction="vertical" size={24} style={{ width: "100%" }}>
|
||||
<section>
|
||||
<Typography.Title level={4}>1. 选择表达方式</Typography.Title>
|
||||
<Space wrap>
|
||||
<Select
|
||||
aria-label="行业模板"
|
||||
style={{ width: 220 }}
|
||||
value={industryKey}
|
||||
disabled={!canManageTemplate || Boolean(workspace.data?.installations.length)}
|
||||
options={(catalog.data?.industries ?? []).map((item) => ({
|
||||
value: item.key,
|
||||
label: item.name,
|
||||
}))}
|
||||
onChange={(key: BrandTemplateKey) => setIndustryTarget(key)}
|
||||
/>
|
||||
<Select
|
||||
aria-label="视觉模板"
|
||||
style={{ width: 220 }}
|
||||
value={visualKey}
|
||||
disabled={!canManageTemplate}
|
||||
loading={selectVisual.isPending}
|
||||
options={visuals.map((item) => ({ value: item.key, label: item.name }))}
|
||||
onChange={(key) => selectVisual.mutate(key)}
|
||||
/>
|
||||
{canManageTemplate && (
|
||||
<Button onClick={() => navigate("/admin/workspace")}>高级模板设置</Button>
|
||||
)}
|
||||
</Space>
|
||||
{workspace.data?.installations.length ? (
|
||||
<Typography.Paragraph type="secondary" style={{ marginTop: 8 }}>
|
||||
当前品牌已安装主模板。模板版本与升级在高级设置中管理。
|
||||
</Typography.Paragraph>
|
||||
) : null}
|
||||
<MutationError error={install.error || selectVisual.error} />
|
||||
<Divider />
|
||||
<Space wrap>
|
||||
<Typography.Text>示例内容</Typography.Text>
|
||||
{sample.isLoading && <Spin size="small" />}
|
||||
{sample.data && (
|
||||
<Tag color={sample.data.alreadyImported ? "green" : "blue"}>
|
||||
{sample.data.alreadyImported ? "已导入" : "可导入"}
|
||||
</Tag>
|
||||
)}
|
||||
<Button
|
||||
disabled={!canManageTemplate || !sample.data || sample.data.alreadyImported}
|
||||
loading={importSample.isPending}
|
||||
onClick={() => importSample.mutate()}
|
||||
>
|
||||
导入示例内容
|
||||
</Button>
|
||||
{sample.isError && <Button onClick={() => void sample.refetch()}>重试</Button>}
|
||||
</Space>
|
||||
{sample.isError && (
|
||||
<Alert
|
||||
type="error"
|
||||
message={sample.error instanceof Error ? sample.error.message : "示例内容加载失败"}
|
||||
showIcon
|
||||
style={{ marginTop: 8 }}
|
||||
/>
|
||||
)}
|
||||
{sample.data && !sample.data.alreadyImported && (
|
||||
<Typography.Paragraph type="secondary" style={{ marginTop: 8 }}>
|
||||
将向草稿添加{" "}
|
||||
{Object.entries(sample.data.counts)
|
||||
.map(([key, count]) => `${key} ${count} 项`)
|
||||
.join("、")}
|
||||
;发布前请替换示例文案和图片。
|
||||
</Typography.Paragraph>
|
||||
)}
|
||||
<MutationError error={importSample.error} />
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<Typography.Title level={4}>2. 核对草稿内容</Typography.Title>
|
||||
<Typography.Paragraph type="secondary">
|
||||
此处核对的是待发布内容,不是小程序视觉预览。
|
||||
</Typography.Paragraph>
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<Typography.Text strong>{brand.data?.name || "未命名品牌"}</Typography.Text>
|
||||
<Typography.Text>{brand.data?.tagline || "尚未填写品牌定位"}</Typography.Text>
|
||||
<Typography.Text>
|
||||
已启用业务项:{draftOfferings.map((item) => item.name).join("、") || "无"}
|
||||
</Typography.Text>
|
||||
<Typography.Text>
|
||||
已启用咨询表单:
|
||||
{draftForms
|
||||
.filter((item) => item.isEnabled)
|
||||
.map((item) => item.name)
|
||||
.join("、") || "无"}
|
||||
</Typography.Text>
|
||||
<Space wrap>
|
||||
<Button onClick={() => navigate("/admin/brand")}>编辑品牌</Button>
|
||||
<Button onClick={() => navigate("/admin/services")}>编辑业务项</Button>
|
||||
<Button onClick={() => navigate("/admin/trust")}>编辑信任内容</Button>
|
||||
</Space>
|
||||
</Space>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<Typography.Title level={4}>3. 检查并发布</Typography.Title>
|
||||
<Space wrap style={{ marginBottom: 12 }}>
|
||||
<Tag color={currentRelease ? "green" : "default"}>
|
||||
{currentRelease ? `已发布 v${currentRelease.version}` : "尚未发布"}
|
||||
</Tag>
|
||||
<Button onClick={() => void readiness.refetch()}>重新检查</Button>
|
||||
</Space>
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
{(readiness.data?.checks ?? []).map((check) => (
|
||||
<Space key={check.key}>
|
||||
<Tag color={check.passed ? "success" : "warning"}>
|
||||
{check.passed ? "已完成" : "待完善"}
|
||||
</Tag>
|
||||
<Typography.Text>{check.label}</Typography.Text>
|
||||
{!check.passed && (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => navigate(destinations[check.key] ?? "/admin/overview")}
|
||||
>
|
||||
去处理
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
))}
|
||||
</Space>
|
||||
<Space wrap style={{ marginTop: 16 }}>
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={!readiness.data?.ready}
|
||||
onClick={() => setConfirmAction("publish")}
|
||||
>
|
||||
发布当前草稿
|
||||
</Button>
|
||||
{currentRelease && (
|
||||
<Button danger onClick={() => setConfirmAction("revoke")}>
|
||||
撤回当前版本
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
<MutationError error={publish.error || revoke.error} />
|
||||
<Divider />
|
||||
<Typography.Title level={5}>发布记录</Typography.Title>
|
||||
{releases.data?.length ? (
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
{releases.data.map((item) => (
|
||||
<Space key={item.id} wrap>
|
||||
<Typography.Text>v{item.version}</Typography.Text>
|
||||
<Tag color={item.status === "published" ? "green" : "default"}>{item.status}</Tag>
|
||||
<Typography.Text type="secondary">
|
||||
{new Date(item.createdAt).toLocaleString("zh-CN")}
|
||||
</Typography.Text>
|
||||
{item.note && <Typography.Text>{item.note}</Typography.Text>}
|
||||
{item.status === "superseded" && publishedHistory.length > 1 && (
|
||||
<Button size="small" onClick={() => setRollbackVersion(item.version)}>
|
||||
恢复此版本
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
))}
|
||||
</Space>
|
||||
) : (
|
||||
<Empty description="暂无发布记录" />
|
||||
)}
|
||||
<MutationError error={rollback.error} />
|
||||
</section>
|
||||
</Space>
|
||||
<Modal
|
||||
title={confirmAction === "revoke" ? "确认撤回品牌" : "确认发布品牌"}
|
||||
open={confirmAction !== null}
|
||||
onCancel={() => setConfirmAction(null)}
|
||||
onOk={() => (confirmAction === "revoke" ? revoke.mutate() : publish.mutate())}
|
||||
confirmLoading={publish.isPending || revoke.isPending}
|
||||
okText={confirmAction === "revoke" ? "确认撤回" : "确认发布"}
|
||||
okButtonProps={{ danger: confirmAction === "revoke" }}
|
||||
>
|
||||
{confirmAction === "revoke" ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
message="撤回后,小程序将显示品牌尚未发布,新的咨询和预约会停止受理。"
|
||||
/>
|
||||
) : (
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<Typography.Text>当前草稿将成为品牌新的公开版本。</Typography.Text>
|
||||
<Input
|
||||
value={note}
|
||||
onChange={(event) => setNote(event.target.value)}
|
||||
placeholder="发布备注(可选)"
|
||||
maxLength={200}
|
||||
/>
|
||||
</Space>
|
||||
)}
|
||||
</Modal>
|
||||
<Modal
|
||||
title="确认恢复历史版本"
|
||||
open={rollbackVersion !== null}
|
||||
onCancel={() => setRollbackVersion(null)}
|
||||
onOk={() => rollbackVersion !== null && rollback.mutate(rollbackVersion)}
|
||||
confirmLoading={rollback.isPending}
|
||||
>
|
||||
将 v{rollbackVersion} 重新发布为新版本;当前草稿不会被覆盖。
|
||||
</Modal>
|
||||
<Modal
|
||||
title="确认安装行业模板"
|
||||
open={industryTarget !== null}
|
||||
onCancel={() => setIndustryTarget(null)}
|
||||
onOk={() => industryTarget && install.mutate(industryTarget)}
|
||||
confirmLoading={install.isPending}
|
||||
>
|
||||
模板会更新当前品牌的草稿结构,不会立即改变已发布的小程序。请安装后核对业务内容与视觉模板。
|
||||
</Modal>
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
Form,
|
||||
Input,
|
||||
Modal,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
@@ -16,6 +17,7 @@ import type { Offering } from "@personal-brand/api-client";
|
||||
import { useState } from "react";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { ImageUrlField } from "../../components/ImageUrlField.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
|
||||
export function ServicesPage() {
|
||||
@@ -56,16 +58,19 @@ export function ServicesPage() {
|
||||
const beginOffering = (item?: Offering) => {
|
||||
setEditingOffering(item ?? null);
|
||||
setOfferingOpen(true);
|
||||
const config = item?.config ?? {};
|
||||
offeringForm.setFieldsValue(
|
||||
item
|
||||
? {
|
||||
...item,
|
||||
sections: config.sections ?? [],
|
||||
media: config.media ?? [],
|
||||
cta: config.cta ?? {},
|
||||
kind: item.kind,
|
||||
name: item.name,
|
||||
summary: item.summary ?? "",
|
||||
description: item.description ?? "",
|
||||
priceText: item.priceText ?? "",
|
||||
coverUrl: item.coverUrl ?? "",
|
||||
sortOrder: item.sortOrder,
|
||||
isEnabled: item.isEnabled,
|
||||
}
|
||||
: { kind: "service", isEnabled: true, sortOrder: 0, sections: [], media: [], cta: {} },
|
||||
: { kind: "service", isEnabled: true, sortOrder: 0 },
|
||||
);
|
||||
};
|
||||
return (
|
||||
@@ -129,9 +134,17 @@ export function ServicesPage() {
|
||||
>
|
||||
{item.isEnabled ? "禁用" : "启用"}
|
||||
</Button>
|
||||
<Button danger size="small" onClick={() => deleteOffering.mutate(item.id)}>
|
||||
删除
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title="确认删除这项业务提供项?"
|
||||
description="如果它已经关联咨询表单,系统会阻止删除。"
|
||||
onConfirm={() => deleteOffering.mutate(item.id)}
|
||||
okText="删除"
|
||||
cancelText="取消"
|
||||
>
|
||||
<Button danger size="small" loading={deleteOffering.isPending}>
|
||||
删除
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
@@ -180,85 +193,22 @@ export function ServicesPage() {
|
||||
<Input.TextArea rows={5} />
|
||||
</Form.Item>
|
||||
<Form.Item name="priceText" label="价格展示">
|
||||
<Input />
|
||||
<Input placeholder="例如:按现场评估报价 / ¥ 2,800 起" />
|
||||
</Form.Item>
|
||||
<Form.Item name="coverUrl" label="封面图片 URL">
|
||||
<Input />
|
||||
<Form.Item
|
||||
name="coverUrl"
|
||||
label="封面图片地址"
|
||||
help="填写图片地址;图片上传能力将在后续媒体管理中提供。"
|
||||
>
|
||||
<ImageUrlField placeholder="粘贴服务或产品封面图片地址" />
|
||||
</Form.Item>
|
||||
<Form.List name="sections">
|
||||
{(fields, { add, remove }) => (
|
||||
<>
|
||||
<Form.Item label="内容分区">
|
||||
<Button onClick={() => add({ type: "text" })}>新增分区</Button>
|
||||
</Form.Item>
|
||||
{fields.map(({ key, name, ...restField }) => (
|
||||
<Space key={key} align="start" style={{ display: "flex", marginBottom: 8 }}>
|
||||
<Form.Item {...restField} name={[name, "type"]}>
|
||||
<Select
|
||||
style={{ width: 120 }}
|
||||
options={[
|
||||
{ value: "text", label: "文本" },
|
||||
{ value: "image-list", label: "图片列表" },
|
||||
{ value: "timeline", label: "时间线" },
|
||||
{ value: "faq", label: "常见问题" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "title"]}>
|
||||
<Input placeholder="分区标题" />
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "content"]}>
|
||||
<Input placeholder="分区内容" />
|
||||
</Form.Item>
|
||||
<Button danger onClick={() => remove(name)}>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</Form.List>
|
||||
<Form.List name="media">
|
||||
{(fields, { add, remove }) => (
|
||||
<>
|
||||
<Form.Item label="媒体列表">
|
||||
<Button onClick={() => add({ type: "image" })}>新增媒体</Button>
|
||||
</Form.Item>
|
||||
{fields.map(({ key, name, ...restField }) => (
|
||||
<Space key={key} align="start" style={{ display: "flex", marginBottom: 8 }}>
|
||||
<Form.Item {...restField} name={[name, "url"]}>
|
||||
<Input placeholder="图片 URL" />
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "alt"]}>
|
||||
<Input placeholder="替代文本" />
|
||||
</Form.Item>
|
||||
<Button danger onClick={() => remove(name)}>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</Form.List>
|
||||
<Form.Item label="行动按钮">
|
||||
<Space>
|
||||
<Form.Item name={["cta", "type"]} noStyle>
|
||||
<Select
|
||||
style={{ width: 150 }}
|
||||
allowClear
|
||||
placeholder="按钮行为"
|
||||
options={[
|
||||
{ value: "inquiry", label: "提交咨询" },
|
||||
{ value: "booking", label: "预约服务" },
|
||||
{ value: "contact", label: "联系品牌" },
|
||||
{ value: "external-link", label: "外部链接" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name={["cta", "label"]} noStyle>
|
||||
<Input placeholder="按钮文案" />
|
||||
</Form.Item>
|
||||
</Space>
|
||||
<Form.Item
|
||||
name="sortOrder"
|
||||
label="展示顺序"
|
||||
help="数字越小越靠前,不确定时填写 0。"
|
||||
rules={[{ type: "number", min: 0, max: 9999 }]}
|
||||
>
|
||||
<Input type="number" min={0} max={9999} />
|
||||
</Form.Item>
|
||||
<Form.Item name="isEnabled" label="公开状态">
|
||||
<Select
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Card,
|
||||
Form,
|
||||
Input,
|
||||
Modal,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
Tag,
|
||||
Typography,
|
||||
message,
|
||||
} from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { AdminBrandMember } from "@personal-brand/api-client";
|
||||
import { useState } from "react";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
|
||||
const roleLabels: Record<string, string> = {
|
||||
owner: "负责人",
|
||||
editor: "内容编辑",
|
||||
admin: "管理员",
|
||||
"platform-admin": "平台管理员",
|
||||
};
|
||||
|
||||
export function MembersPage() {
|
||||
const client = createApiClient();
|
||||
const queryClient = useQueryClient();
|
||||
const [addOpen, setAddOpen] = useState(false);
|
||||
const [addForm] = Form.useForm();
|
||||
const members = useQuery({
|
||||
queryKey: ["admin-members"],
|
||||
queryFn: () => client.listAdminMembers(),
|
||||
});
|
||||
const update = useMutation({
|
||||
mutationFn: ({
|
||||
id,
|
||||
body,
|
||||
}: {
|
||||
id: string;
|
||||
body: Partial<Pick<AdminBrandMember, "role" | "isEnabled">>;
|
||||
}) => client.updateAdminMember(id, body),
|
||||
onSuccess: () => {
|
||||
message.success("成员权限已更新");
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-members"] });
|
||||
},
|
||||
});
|
||||
const create = useMutation({
|
||||
mutationFn: (values: {
|
||||
username: string;
|
||||
displayName: string;
|
||||
password: string;
|
||||
role: "owner" | "editor";
|
||||
}) => client.createAdminMember(values),
|
||||
onSuccess: () => {
|
||||
message.success("成员已添加");
|
||||
setAddOpen(false);
|
||||
addForm.resetFields();
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-members"] });
|
||||
},
|
||||
});
|
||||
return (
|
||||
<QueryState
|
||||
loading={members.isLoading}
|
||||
error={members.error}
|
||||
onRetry={() => void members.refetch()}
|
||||
>
|
||||
<AdminPageHeader
|
||||
title="团队成员"
|
||||
description="管理谁可以维护当前品牌。负责人可以调整系统设置,内容编辑只能维护日常经营内容。"
|
||||
extra={
|
||||
<Button type="primary" onClick={() => setAddOpen(true)}>
|
||||
手动添加成员
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<Card>
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="请将初始账号和密码安全地交给成员"
|
||||
description="当前采用负责人手动添加方式;系统不会再次显示成员初始密码。"
|
||||
style={{ marginBottom: 16 }}
|
||||
/>
|
||||
<Table
|
||||
rowKey="id"
|
||||
loading={members.isLoading}
|
||||
dataSource={members.data ?? []}
|
||||
columns={[
|
||||
{
|
||||
title: "成员",
|
||||
render: (_: unknown, item: AdminBrandMember) => item.adminUser.displayName,
|
||||
},
|
||||
{ title: "账号", dataIndex: ["adminUser", "username"] },
|
||||
{
|
||||
title: "角色",
|
||||
dataIndex: "role",
|
||||
render: (value: string, item: AdminBrandMember) => (
|
||||
<Select
|
||||
value={value}
|
||||
options={["owner", "editor"].map((role) => ({
|
||||
value: role,
|
||||
label: roleLabels[role],
|
||||
}))}
|
||||
onChange={(role) => update.mutate({ id: item.id, body: { role } })}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
dataIndex: "isEnabled",
|
||||
render: (value: boolean, item: AdminBrandMember) => (
|
||||
<Select
|
||||
value={value}
|
||||
options={[
|
||||
{ value: true, label: "已启用" },
|
||||
{ value: false, label: "已停用" },
|
||||
]}
|
||||
onChange={(isEnabled) => update.mutate({ id: item.id, body: { isEnabled } })}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "说明",
|
||||
render: (_: unknown, item: AdminBrandMember) => (
|
||||
<Space>
|
||||
<Tag>{roleLabels[item.role] ?? item.role}</Tag>
|
||||
{!item.adminUser.isEnabled ? (
|
||||
<Typography.Text type="danger">账号已停用</Typography.Text>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<MutationError error={update.error} />
|
||||
<MutationError error={create.error} />
|
||||
</Card>
|
||||
<Modal
|
||||
open={addOpen}
|
||||
title="手动添加成员"
|
||||
onCancel={() => {
|
||||
setAddOpen(false);
|
||||
addForm.resetFields();
|
||||
}}
|
||||
onOk={() => addForm.submit()}
|
||||
confirmLoading={create.isPending}
|
||||
destroyOnClose
|
||||
>
|
||||
<Form
|
||||
form={addForm}
|
||||
layout="vertical"
|
||||
onFinish={(values) =>
|
||||
create.mutate(
|
||||
values as {
|
||||
username: string;
|
||||
displayName: string;
|
||||
password: string;
|
||||
role: "owner" | "editor";
|
||||
},
|
||||
)
|
||||
}
|
||||
>
|
||||
<Form.Item
|
||||
name="username"
|
||||
label="登录账号"
|
||||
rules={[{ required: true, message: "请输入登录账号" }]}
|
||||
>
|
||||
<Input placeholder="例如:linran" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="displayName"
|
||||
label="成员姓名"
|
||||
rules={[{ required: true, message: "请输入成员姓名" }]}
|
||||
>
|
||||
<Input placeholder="例如:林然" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="password"
|
||||
label="初始密码"
|
||||
rules={[{ required: true, min: 8, message: "请输入至少 8 位初始密码" }]}
|
||||
extra="添加成功后不会再次显示,请提前告知成员。"
|
||||
>
|
||||
<Input.Password />
|
||||
</Form.Item>
|
||||
<Form.Item name="role" label="角色" initialValue="editor" rules={[{ required: true }]}>
|
||||
<Select
|
||||
options={[
|
||||
{ value: "editor", label: "内容编辑:维护日常经营内容" },
|
||||
{ value: "owner", label: "负责人:可调整系统设置" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import type { TrustContent, TrustContentInput } from "@personal-brand/api-client
|
||||
import { useState } from "react";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { ImageUrlField } from "../../components/ImageUrlField.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
|
||||
const types = [
|
||||
@@ -157,8 +158,12 @@ export function TrustContentPage() {
|
||||
<Form.Item name="content" label="详细内容" rules={[{ required: true }]}>
|
||||
<Input.TextArea rows={8} showCount maxLength={2000} />
|
||||
</Form.Item>
|
||||
<Form.Item name="coverUrl" label="封面图片 URL">
|
||||
<Input />
|
||||
<Form.Item
|
||||
name="coverUrl"
|
||||
label="配图地址"
|
||||
help="粘贴一张可公开访问的图片地址,保存前会显示预览。"
|
||||
>
|
||||
<ImageUrlField placeholder="粘贴案例或经历配图地址" />
|
||||
</Form.Item>
|
||||
<Form.Item name="isPublished" label="公开状态">
|
||||
<Select
|
||||
|
||||
@@ -14,11 +14,59 @@ import {
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { ApiClientError } from "@personal-brand/api-client";
|
||||
import type { BrandFieldDefinition, BrandModule, InquiryForm } from "@personal-brand/api-client";
|
||||
import type {
|
||||
BrandFieldDefinition,
|
||||
BrandModule,
|
||||
BrandTemplateKey,
|
||||
InquiryForm,
|
||||
} from "@personal-brand/api-client";
|
||||
import { useState } from "react";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { MutationError } from "../../components/QueryState.js";
|
||||
|
||||
const inquiryFieldTypes = [
|
||||
{ value: "text", label: "简短文字" },
|
||||
{ value: "textarea", label: "详细说明" },
|
||||
{ value: "phone", label: "联系电话" },
|
||||
{ value: "number", label: "数字" },
|
||||
{ value: "date", label: "日期" },
|
||||
{ value: "image", label: "图片" },
|
||||
{ value: "url", label: "链接" },
|
||||
{ value: "select", label: "单项选择" },
|
||||
{ value: "multi-select", label: "多项选择" },
|
||||
];
|
||||
|
||||
function optionsToText(options: unknown): string {
|
||||
if (!Array.isArray(options)) return "";
|
||||
return options
|
||||
.map((option) => {
|
||||
if (!option || typeof option !== "object") return "";
|
||||
const label = (option as { label?: unknown }).label;
|
||||
return typeof label === "string" ? label : "";
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join("\n");
|
||||
}
|
||||
|
||||
function optionsFromText(value: unknown): Array<{ label: string; value: string }> {
|
||||
if (typeof value !== "string") return [];
|
||||
return value
|
||||
.split(/\r?\n|、|,/)
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean)
|
||||
.map((item) => ({ label: item, value: item }));
|
||||
}
|
||||
|
||||
function supportsIndustry(
|
||||
visual: { supportedIndustryTemplates?: unknown },
|
||||
industry: string,
|
||||
): boolean {
|
||||
return (
|
||||
Array.isArray(visual.supportedIndustryTemplates) &&
|
||||
visual.supportedIndustryTemplates.includes(industry)
|
||||
);
|
||||
}
|
||||
|
||||
export function WorkspacePage() {
|
||||
const client = createApiClient();
|
||||
const queryClient = useQueryClient();
|
||||
@@ -32,7 +80,7 @@ export function WorkspacePage() {
|
||||
description: string;
|
||||
capabilities: string[];
|
||||
} | null>(null);
|
||||
const [previewIndustry, setPreviewIndustry] = useState("personal");
|
||||
const [previewIndustry, setPreviewIndustry] = useState<BrandTemplateKey>("personal");
|
||||
const [previewVisual, setPreviewVisual] = useState("linjing-editorial");
|
||||
const [form] = Form.useForm<Record<string, unknown>>();
|
||||
const [inquiryForm] = Form.useForm<Record<string, unknown>>();
|
||||
@@ -53,6 +101,9 @@ export function WorkspacePage() {
|
||||
queryFn: () => client.previewPublicTemplateCombination(previewIndustry, previewVisual),
|
||||
enabled: Boolean(templateCatalog.data),
|
||||
});
|
||||
const compatibleVisuals = (templateCatalog.data?.visuals ?? []).filter((visual) =>
|
||||
supportsIndustry(visual, query.data?.brand?.templateKey ?? "personal"),
|
||||
);
|
||||
const visualTemplate = useMutation({
|
||||
mutationFn: (key: string) =>
|
||||
client.updateAdminBrand({
|
||||
@@ -247,8 +298,7 @@ export function WorkspacePage() {
|
||||
loading={visualTemplate.isPending}
|
||||
onChange={(key) => setVisualTarget(key)}
|
||||
options={[
|
||||
{ value: "linjing-editorial", label: "林境建筑画册" },
|
||||
{ value: "minimal-neutral", label: "极简留白" },
|
||||
...compatibleVisuals.map((visual) => ({ value: visual.key, label: visual.name })),
|
||||
]}
|
||||
/>
|
||||
{runtimeQuery.data?.visualTemplate && (
|
||||
@@ -285,7 +335,7 @@ export function WorkspacePage() {
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<Typography.Text strong>可用视觉模板</Typography.Text>
|
||||
<Space wrap>
|
||||
{(templateCatalog.data?.visuals ?? []).map((visual) => (
|
||||
{compatibleVisuals.map((visual) => (
|
||||
<Card key={visual.key} size="small" style={{ width: 260 }}>
|
||||
<Typography.Text strong>{visual.name}</Typography.Text>
|
||||
<Typography.Paragraph type="secondary" ellipsis={{ rows: 2 }}>
|
||||
@@ -321,9 +371,7 @@ export function WorkspacePage() {
|
||||
<Typography.Paragraph>
|
||||
当前模板:{runtimeQuery.data?.visualTemplate?.name ?? "林境建筑画册"}
|
||||
</Typography.Paragraph>
|
||||
<Typography.Paragraph>
|
||||
目标模板:{visualTarget === "minimal-neutral" ? "极简留白" : "林境建筑画册"}
|
||||
</Typography.Paragraph>
|
||||
<Typography.Paragraph>目标模板:林境建筑画册</Typography.Paragraph>
|
||||
<Typography.Paragraph type="secondary">
|
||||
只会替换视觉主题和模块变体,不会覆盖品牌内容、业务提供项或咨询记录。
|
||||
</Typography.Paragraph>
|
||||
@@ -418,10 +466,9 @@ export function WorkspacePage() {
|
||||
<Select
|
||||
value={previewVisual}
|
||||
onChange={setPreviewVisual}
|
||||
options={(templateCatalog.data?.visuals ?? []).map((item) => ({
|
||||
value: item.key,
|
||||
label: item.name,
|
||||
}))}
|
||||
options={(templateCatalog.data?.visuals ?? [])
|
||||
.filter((item) => supportsIndustry(item, previewIndustry))
|
||||
.map((item) => ({ value: item.key, label: item.name }))}
|
||||
/>
|
||||
</Space>
|
||||
{combinationPreview.isLoading ? (
|
||||
@@ -490,9 +537,7 @@ export function WorkspacePage() {
|
||||
const value = field as Record<string, unknown>;
|
||||
return {
|
||||
...value,
|
||||
...(Array.isArray(value.options)
|
||||
? { optionsText: JSON.stringify(value.options) }
|
||||
: {}),
|
||||
optionsText: optionsToText(value.options),
|
||||
};
|
||||
}),
|
||||
});
|
||||
@@ -692,15 +737,11 @@ export function WorkspacePage() {
|
||||
: []
|
||||
).map((field) => {
|
||||
const item = field as Record<string, unknown>;
|
||||
if (typeof item.optionsText !== "string") return item;
|
||||
try {
|
||||
const options = JSON.parse(item.optionsText) as unknown;
|
||||
const { optionsText, ...rest } = item;
|
||||
void optionsText;
|
||||
return { ...rest, options };
|
||||
} catch {
|
||||
return item;
|
||||
}
|
||||
const { optionsText, ...rest } = item;
|
||||
const type = typeof rest.type === "string" ? rest.type : "text";
|
||||
return ["select", "radio", "multi-select"].includes(type)
|
||||
? { ...rest, options: optionsFromText(optionsText) }
|
||||
: rest;
|
||||
}),
|
||||
};
|
||||
if (editingForm) updateForm.mutate({ id: editingForm.id, body });
|
||||
@@ -738,47 +779,70 @@ export function WorkspacePage() {
|
||||
{(fields, { add, remove }) => (
|
||||
<>
|
||||
<Form.Item label="表单字段">
|
||||
<Button onClick={() => add({ type: "text", required: false })}>新增字段</Button>
|
||||
<Button
|
||||
onClick={() =>
|
||||
add({
|
||||
key: `field_${Date.now()}`,
|
||||
type: "text",
|
||||
required: false,
|
||||
})
|
||||
}
|
||||
>
|
||||
新增字段
|
||||
</Button>
|
||||
</Form.Item>
|
||||
{fields.map(({ key, name, ...restField }) => (
|
||||
<Space key={key} align="start" style={{ display: "flex", marginBottom: 8 }}>
|
||||
<Form.Item {...restField} name={[name, "key"]} rules={[{ required: true }]}>
|
||||
<Input placeholder="Key" />
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "label"]} rules={[{ required: true }]}>
|
||||
<Input placeholder="字段名称" />
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "type"]}>
|
||||
<Select
|
||||
style={{ width: 120 }}
|
||||
options={[
|
||||
"text",
|
||||
"textarea",
|
||||
"number",
|
||||
"date",
|
||||
"select",
|
||||
"multi-select",
|
||||
"image",
|
||||
"url",
|
||||
"phone",
|
||||
].map((value) => ({ value, label: value }))}
|
||||
/>
|
||||
<Card key={key} size="small" style={{ marginBottom: 12 }}>
|
||||
<Form.Item {...restField} name={[name, "key"]} hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Space align="start" style={{ display: "flex" }}>
|
||||
<Form.Item
|
||||
{...restField}
|
||||
name={[name, "label"]}
|
||||
label="要询问客户什么"
|
||||
rules={[{ required: true, message: "请填写字段名称" }]}
|
||||
style={{ flex: 1 }}
|
||||
>
|
||||
<Input placeholder="例如:联系电话、预计预算、项目地址" />
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "type"]} label="回答方式">
|
||||
<Select style={{ width: 130 }} options={inquiryFieldTypes} />
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "required"]} label="必填">
|
||||
<Select
|
||||
style={{ width: 90 }}
|
||||
options={[
|
||||
{ value: true, label: "必填" },
|
||||
{ value: false, label: "选填" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Button danger onClick={() => remove(name)} style={{ marginTop: 30 }}>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
<Form.Item noStyle shouldUpdate>
|
||||
{({ getFieldValue }) =>
|
||||
["select", "radio"].includes(
|
||||
["select", "radio", "multi-select"].includes(
|
||||
String(getFieldValue(["fieldsSnapshot", name, "type"])),
|
||||
) ? (
|
||||
<Form.Item {...restField} name={[name, "optionsText"]}>
|
||||
<Input placeholder="选项 JSON" />
|
||||
<Form.Item
|
||||
{...restField}
|
||||
name={[name, "optionsText"]}
|
||||
label="可选内容"
|
||||
help="每行填写一个选项,也可以用顿号分隔。"
|
||||
rules={[{ required: true, message: "请至少填写一个选项" }]}
|
||||
>
|
||||
<Input.TextArea
|
||||
rows={2}
|
||||
placeholder="例如:预算内、需要沟通、暂不确定"
|
||||
/>
|
||||
</Form.Item>
|
||||
) : null
|
||||
}
|
||||
</Form.Item>
|
||||
<Button danger onClick={() => remove(name)}>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
</Card>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
|
||||
+128
-13
@@ -49,13 +49,27 @@ const FeatureCapabilitiesPage = React.lazy(() =>
|
||||
default: module.CapabilitiesPage,
|
||||
})),
|
||||
);
|
||||
const FeatureMembersPage = React.lazy(() =>
|
||||
import("./features/team/MembersPage.js").then((module) => ({
|
||||
default: module.MembersPage,
|
||||
})),
|
||||
);
|
||||
const FeaturePublicationPage = React.lazy(() =>
|
||||
import("./features/publication/PublicationPage.js").then((module) => ({
|
||||
default: module.PublicationPage,
|
||||
})),
|
||||
);
|
||||
import { BrowserRouter, Navigate, Route, Routes, useLocation, useNavigate } from "react-router-dom";
|
||||
import "antd/dist/reset.css";
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
const api = createApiClient;
|
||||
|
||||
function Login({ onLogin }: { onLogin: () => void }) {
|
||||
function Login({
|
||||
onLogin,
|
||||
}: {
|
||||
onLogin: (session: { role: string; mustChangePassword: boolean }) => void;
|
||||
}) {
|
||||
const [form] = Form.useForm();
|
||||
const [loading, setLoading] = useState(false);
|
||||
async function submit(values: { username: string; password: string }) {
|
||||
@@ -63,7 +77,9 @@ function Login({ onLogin }: { onLogin: () => void }) {
|
||||
try {
|
||||
const result = await api().loginAdmin(values.username, values.password);
|
||||
localStorage.setItem("adminToken", result.token);
|
||||
onLogin();
|
||||
localStorage.setItem("adminRole", result.role);
|
||||
localStorage.setItem("adminMustChangePassword", String(result.mustChangePassword));
|
||||
onLogin(result);
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : "登录失败");
|
||||
} finally {
|
||||
@@ -87,7 +103,60 @@ function Login({ onLogin }: { onLogin: () => void }) {
|
||||
);
|
||||
}
|
||||
|
||||
function Dashboard({ onLogout }: { onLogout: () => void }) {
|
||||
function ChangePassword({ onComplete }: { onComplete: () => void }) {
|
||||
const [form] = Form.useForm<{
|
||||
currentPassword: string;
|
||||
newPassword: string;
|
||||
confirmPassword: string;
|
||||
}>();
|
||||
const [loading, setLoading] = useState(false);
|
||||
async function submit(values: {
|
||||
currentPassword: string;
|
||||
newPassword: string;
|
||||
confirmPassword: string;
|
||||
}) {
|
||||
if (values.newPassword !== values.confirmPassword) {
|
||||
message.error("两次输入的新密码不一致");
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
await api().changeAdminPassword(values.currentPassword, values.newPassword);
|
||||
localStorage.setItem("adminMustChangePassword", "false");
|
||||
message.success("密码已更新");
|
||||
onComplete();
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : "密码更新失败");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<Card title="首次登录需要修改密码" style={{ maxWidth: 420, margin: "120px auto" }}>
|
||||
<Typography.Paragraph type="secondary">请先设置只有你本人知道的新密码。</Typography.Paragraph>
|
||||
<Form form={form} layout="vertical" onFinish={submit}>
|
||||
<Form.Item name="currentPassword" label="初始密码" rules={[{ required: true }]}>
|
||||
<Input.Password />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="newPassword"
|
||||
label="新密码"
|
||||
rules={[{ required: true, min: 8, message: "请输入至少 8 位新密码" }]}
|
||||
>
|
||||
<Input.Password />
|
||||
</Form.Item>
|
||||
<Form.Item name="confirmPassword" label="确认新密码" rules={[{ required: true }]}>
|
||||
<Input.Password />
|
||||
</Form.Item>
|
||||
<Button type="primary" htmlType="submit" loading={loading} block>
|
||||
保存新密码
|
||||
</Button>
|
||||
</Form>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function Dashboard({ onLogout, role }: { onLogout: () => void; role: string }) {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const brand = useQuery({
|
||||
@@ -109,13 +178,31 @@ function Dashboard({ onLogout }: { onLogout: () => void }) {
|
||||
};
|
||||
const page = location.pathname.split("/")[2] || "overview";
|
||||
const items = [
|
||||
{ key: "overview", label: "当前品牌概览" },
|
||||
{ key: "brand", label: "当前品牌表达" },
|
||||
{ key: "trust", label: "信任内容" },
|
||||
{ key: "services", label: "业务提供项" },
|
||||
{ key: "workspace", label: "模板与设置" },
|
||||
{ key: "capabilities", label: "能力插件" },
|
||||
{ key: "inquiries", label: "咨询记录" },
|
||||
{
|
||||
type: "group" as const,
|
||||
label: "日常经营",
|
||||
children: [
|
||||
{ key: "overview", label: "当前品牌概览" },
|
||||
{ key: "publication", label: "配置与发布" },
|
||||
{ key: "brand", label: "品牌表达" },
|
||||
{ key: "trust", label: "信任内容" },
|
||||
{ key: "services", label: "业务提供项" },
|
||||
{ key: "inquiries", label: "咨询记录" },
|
||||
],
|
||||
},
|
||||
...(role === "editor"
|
||||
? []
|
||||
: [
|
||||
{
|
||||
type: "group" as const,
|
||||
label: "系统管理",
|
||||
children: [
|
||||
{ key: "workspace", label: "模板与设置" },
|
||||
{ key: "capabilities", label: "能力插件" },
|
||||
{ key: "members", label: "团队成员" },
|
||||
],
|
||||
},
|
||||
]),
|
||||
];
|
||||
return (
|
||||
<Layout style={{ minHeight: "100vh" }}>
|
||||
@@ -163,9 +250,20 @@ function Dashboard({ onLogout }: { onLogout: () => void }) {
|
||||
<Suspense fallback={<Card loading />}>
|
||||
<Routes>
|
||||
<Route path="/admin/overview" element={<FeatureOverviewPage />} />
|
||||
<Route
|
||||
path="/admin/publication"
|
||||
element={<FeaturePublicationPage canManageTemplate={role !== "editor"} />}
|
||||
/>
|
||||
<Route path="/admin/brand" element={<FeatureBrandPage />} />
|
||||
<Route path="/admin/workspace" element={<FeatureWorkspacePage />} />
|
||||
<Route path="/admin/capabilities" element={<FeatureCapabilitiesPage />} />
|
||||
{role === "editor" ? null : (
|
||||
<Route path="/admin/workspace" element={<FeatureWorkspacePage />} />
|
||||
)}
|
||||
{role === "editor" ? null : (
|
||||
<Route path="/admin/capabilities" element={<FeatureCapabilitiesPage />} />
|
||||
)}
|
||||
{role === "editor" ? null : (
|
||||
<Route path="/admin/members" element={<FeatureMembersPage />} />
|
||||
)}
|
||||
<Route path="/admin/trust" element={<FeatureTrustContentPage />} />
|
||||
<Route path="/admin/services" element={<FeatureServicesPage />} />
|
||||
<Route path="/admin/inquiries" element={<FeatureInquiriesPage />} />
|
||||
@@ -180,6 +278,10 @@ function Dashboard({ onLogout }: { onLogout: () => void }) {
|
||||
|
||||
function Root() {
|
||||
const [loggedIn, setLoggedIn] = useState(Boolean(localStorage.getItem("adminToken")));
|
||||
const [role, setRole] = useState(localStorage.getItem("adminRole") || "owner");
|
||||
const [mustChangePassword, setMustChangePassword] = useState(
|
||||
localStorage.getItem("adminMustChangePassword") === "true",
|
||||
);
|
||||
React.useEffect(() => {
|
||||
const expire = () => {
|
||||
message.warning("登录状态已失效,请重新登录");
|
||||
@@ -190,9 +292,22 @@ function Root() {
|
||||
}, []);
|
||||
const logout = () => {
|
||||
localStorage.removeItem("adminToken");
|
||||
localStorage.removeItem("adminRole");
|
||||
localStorage.removeItem("adminMustChangePassword");
|
||||
setLoggedIn(false);
|
||||
};
|
||||
return loggedIn ? <Dashboard onLogout={logout} /> : <Login onLogin={() => setLoggedIn(true)} />;
|
||||
if (!loggedIn)
|
||||
return (
|
||||
<Login
|
||||
onLogin={(session) => {
|
||||
setRole(session.role);
|
||||
setMustChangePassword(session.mustChangePassword);
|
||||
setLoggedIn(true);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
if (mustChangePassword) return <ChangePassword onComplete={() => setMustChangePassword(false)} />;
|
||||
return <Dashboard onLogout={logout} role={role} />;
|
||||
}
|
||||
createRoot(document.getElementById("app")!).render(
|
||||
<React.StrictMode>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"lint": "eslint .",
|
||||
"typecheck": "tsc -p tsconfig.json --noEmit",
|
||||
"test": "tsx --test test/**/*.test.ts",
|
||||
"test:integration": "pnpm build && NODE_ENV=test node --env-file=.env --test test/http.integration.test.js",
|
||||
"test:integration": "pnpm build && node --env-file=.env test/run-integration.cjs",
|
||||
"clean": "rimraf dist",
|
||||
"start": "node dist/main.js",
|
||||
"db:generate": "prisma generate",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE "AdminUser" ADD COLUMN "mustChangePassword" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -0,0 +1,16 @@
|
||||
CREATE TABLE "BrandRelease" (
|
||||
"id" TEXT NOT NULL,
|
||||
"brandId" TEXT NOT NULL,
|
||||
"version" INTEGER NOT NULL,
|
||||
"status" TEXT NOT NULL DEFAULT 'published',
|
||||
"snapshot" JSONB NOT NULL,
|
||||
"actorId" TEXT NOT NULL,
|
||||
"note" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"revokedAt" TIMESTAMP(3),
|
||||
CONSTRAINT "BrandRelease_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX "BrandRelease_brandId_version_key" ON "BrandRelease"("brandId", "version");
|
||||
CREATE INDEX "BrandRelease_brandId_status_createdAt_idx" ON "BrandRelease"("brandId", "status", "createdAt");
|
||||
ALTER TABLE "BrandRelease" ADD CONSTRAINT "BrandRelease_brandId_fkey" FOREIGN KEY ("brandId") REFERENCES "BrandProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE "BrandRelease" ADD COLUMN "revokedBy" TEXT;
|
||||
@@ -62,6 +62,23 @@ model BrandProfile {
|
||||
capabilityInstallations CapabilityInstallation[]
|
||||
capabilityAuditLogs CapabilityAuditLog[]
|
||||
adminMemberships BrandMembership[]
|
||||
releases BrandRelease[]
|
||||
}
|
||||
|
||||
model BrandRelease {
|
||||
id String @id @default(uuid())
|
||||
brandId String
|
||||
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
||||
version Int
|
||||
status String @default("published")
|
||||
snapshot Json
|
||||
actorId String
|
||||
note String?
|
||||
createdAt DateTime @default(now())
|
||||
revokedAt DateTime?
|
||||
revokedBy String?
|
||||
@@unique([brandId, version])
|
||||
@@index([brandId, status, createdAt])
|
||||
}
|
||||
|
||||
model CapabilityInstallation {
|
||||
@@ -328,6 +345,7 @@ model AdminUser {
|
||||
displayName String
|
||||
role String @default("admin")
|
||||
isEnabled Boolean @default(true)
|
||||
mustChangePassword Boolean @default(false)
|
||||
lastLoginAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
+742
-171
@@ -1,5 +1,6 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import bcrypt from "bcryptjs";
|
||||
import { buildBrandReleaseSnapshot } from "../src/brand-release.service.js";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
@@ -14,47 +15,660 @@ const runtimeImages = {
|
||||
"https://images.unsplash.com/photo-1603133872878-684f208fb84b?auto=format&fit=crop&w=1000&q=85",
|
||||
"https://images.unsplash.com/photo-1559847844-5315695dadae?auto=format&fit=crop&w=1000&q=85",
|
||||
],
|
||||
personal: [
|
||||
"https://images.unsplash.com/photo-1556761175-b413da4baf72?auto=format&fit=crop&w=1000&q=85",
|
||||
"https://images.unsplash.com/photo-1521737711867-e3b97375f902?auto=format&fit=crop&w=1000&q=85",
|
||||
],
|
||||
};
|
||||
|
||||
async function ensureRuntimeContent(
|
||||
brandId: string,
|
||||
templateKey: "food" | "doors",
|
||||
offerings: Array<{ name: string; summary: string; image: string; categoryKey: string }>,
|
||||
): Promise<void> {
|
||||
type OfferingKind = "service" | "product" | "package" | "subscription";
|
||||
|
||||
interface RuntimeSeedTemplate {
|
||||
brandConfig: Record<string, unknown>;
|
||||
retiredOfferingNames?: string[];
|
||||
offerings: Array<{
|
||||
name: string;
|
||||
summary: string;
|
||||
image: string;
|
||||
kind: OfferingKind;
|
||||
priceText?: string;
|
||||
priceAmount?: number;
|
||||
config: Record<string, unknown>;
|
||||
}>;
|
||||
trustContent: Array<{
|
||||
type: string;
|
||||
title: string;
|
||||
content: string;
|
||||
config?: Record<string, unknown>;
|
||||
}>;
|
||||
inquiryForm: { name: string; fieldsSnapshot: Array<Record<string, unknown>> };
|
||||
}
|
||||
|
||||
const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTemplate> = {
|
||||
personal: {
|
||||
brandConfig: {
|
||||
visualTemplateKey: "linjing-editorial",
|
||||
founder: "林然",
|
||||
title: "品牌策略顾问",
|
||||
slogan: "用清晰的定位与可执行的表达,让专业被看见。",
|
||||
phone: "13900000003",
|
||||
wechat: "linran-brand",
|
||||
studioAddress: "上海市徐汇区创意园区",
|
||||
heroImage: runtimeImages.personal[0],
|
||||
visualPresentation: {
|
||||
home: {
|
||||
proofEyebrow: "专业经验与合作成果",
|
||||
manifestoEyebrow: "工作原则",
|
||||
manifestoTitle: "先厘清问题,再设计表达",
|
||||
worksEyebrow: "合作方式",
|
||||
worksTitle: "品牌策略与顾问服务",
|
||||
worksAction: "查看全部 →",
|
||||
flowEyebrow: "合作流程",
|
||||
flowTitle: "从诊断到持续落地",
|
||||
},
|
||||
offerings: {
|
||||
title: "合作方式",
|
||||
subtitle: "围绕品牌定位、表达与业务转化,选择适合当前阶段的支持。",
|
||||
materialLabel: "服务内容:",
|
||||
hardwareLabel: "合作重点:",
|
||||
detailAction: "查看服务详情 →",
|
||||
inquiryAction: "发起合作咨询",
|
||||
},
|
||||
detail: {
|
||||
priceLabel: "服务参考",
|
||||
spaceLabel: "适合阶段",
|
||||
backgroundTitle: "服务背景",
|
||||
conceptTitle: "工作方法",
|
||||
craftsTitle: "交付内容",
|
||||
materialsTitle: "合作说明",
|
||||
inquiryAction: "发起合作咨询",
|
||||
inquiryHint: "提交信息后由主理人与您沟通。",
|
||||
},
|
||||
profile: {
|
||||
phoneLabel: "联系电话",
|
||||
wechatLabel: "微信",
|
||||
addressLabel: "工作地点",
|
||||
callAction: "呼叫",
|
||||
copyAction: "复制",
|
||||
recordsTitle: "我的咨询记录",
|
||||
recordsCountUnit: "条记录",
|
||||
},
|
||||
inquiry: {
|
||||
eyebrow: "COLLABORATION",
|
||||
title: "合作咨询",
|
||||
subtitle: "留下你的品牌现状与目标,主理人会尽快联系。",
|
||||
submitLabel: "提交合作需求",
|
||||
},
|
||||
success: {
|
||||
eyebrow: "COLLABORATION",
|
||||
title: "已收到你的咨询",
|
||||
intro: "主理人会尽快与你联系。",
|
||||
recordsAction: "查看咨询记录",
|
||||
homeAction: "返回首页",
|
||||
},
|
||||
records: {
|
||||
title: "我的咨询记录",
|
||||
createAction: "新增咨询",
|
||||
emptyTitle: "还没有咨询记录",
|
||||
emptyDescription: "提交一次咨询,开始与你的主理人沟通。",
|
||||
emptyAction: "开始咨询",
|
||||
},
|
||||
},
|
||||
},
|
||||
offerings: [
|
||||
{
|
||||
name: "品牌定位诊断",
|
||||
summary: "梳理现有表达、目标客户与业务优先级,形成清晰的下一步行动建议。",
|
||||
image: runtimeImages.personal[0],
|
||||
kind: "service",
|
||||
config: {
|
||||
categoryKey: "consulting",
|
||||
categoryLabel: "策略咨询",
|
||||
keywords: ["定位", "诊断", "表达"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "个人品牌年度顾问",
|
||||
summary: "持续支持内容策略、产品表达与关键节点决策,建立长期信任资产。",
|
||||
image: runtimeImages.personal[1],
|
||||
kind: "subscription",
|
||||
config: {
|
||||
categoryKey: "advisory",
|
||||
categoryLabel: "长期顾问",
|
||||
keywords: ["陪跑", "内容", "转化"],
|
||||
},
|
||||
},
|
||||
],
|
||||
trustContent: [
|
||||
{
|
||||
type: "profile",
|
||||
title: "关于林然",
|
||||
content: "专注帮助专业服务者建立可信、清晰且能带来合作的个人品牌表达。",
|
||||
},
|
||||
{
|
||||
type: "process",
|
||||
title: "合作方法",
|
||||
content: "诊断现状、明确定位、搭建表达、持续复盘,让每一步都服务于真实业务。",
|
||||
},
|
||||
],
|
||||
inquiryForm: {
|
||||
name: "品牌合作咨询",
|
||||
fieldsSnapshot: [
|
||||
{ key: "name", label: "您的称呼", type: "text", required: true },
|
||||
{ key: "phone", label: "联系电话", type: "phone", required: true },
|
||||
{ key: "remark", label: "目前的品牌或业务问题", type: "textarea", required: true },
|
||||
],
|
||||
},
|
||||
},
|
||||
food: {
|
||||
brandConfig: {
|
||||
visualTemplateKey: "acheng-campus-food",
|
||||
founder: "阿成",
|
||||
title: "私房菜主理人",
|
||||
slogan: "认真做好每一顿家常饭。",
|
||||
phone: "",
|
||||
wechat: "",
|
||||
studioAddress: "大学城生活区东门附近",
|
||||
heroImage: runtimeImages.food[0],
|
||||
visualPresentation: {
|
||||
home: {
|
||||
proofEyebrow: "主理人信任凭证",
|
||||
manifestoEyebrow: "品牌坚持",
|
||||
manifestoTitle: "认真对待每一次托付",
|
||||
worksEyebrow: "今日餐品与预订",
|
||||
worksTitle: "套餐、聚餐与定制餐",
|
||||
worksAction: "查看全部 →",
|
||||
flowEyebrow: "预订流程",
|
||||
flowTitle: "从预订到取餐",
|
||||
},
|
||||
offerings: {
|
||||
title: "今日套餐与定制餐",
|
||||
subtitle: "现做套餐、聚餐预订和定制餐品。",
|
||||
materialLabel: "餐品说明:",
|
||||
hardwareLabel: "预订要点:",
|
||||
detailAction: "查看餐品 →",
|
||||
inquiryAction: "咨询 / 提前预订",
|
||||
},
|
||||
detail: {
|
||||
priceLabel: "参考价格",
|
||||
spaceLabel: "适合场景",
|
||||
backgroundTitle: "餐品说明",
|
||||
conceptTitle: "口味与分量",
|
||||
craftsTitle: "制作方式",
|
||||
materialsTitle: "食材与搭配",
|
||||
inquiryAction: "咨询 / 提前预订",
|
||||
inquiryHint: "提交后由主理人与您确认餐品和时间。",
|
||||
},
|
||||
profile: {
|
||||
phoneLabel: "联系电话",
|
||||
wechatLabel: "微信",
|
||||
addressLabel: "服务地址",
|
||||
callAction: "呼叫",
|
||||
copyAction: "复制",
|
||||
recordsTitle: "我的咨询记录",
|
||||
recordsCountUnit: "条记录",
|
||||
},
|
||||
inquiry: {
|
||||
eyebrow: "CONSULTATION",
|
||||
title: "餐品预订与定制",
|
||||
subtitle: "提交信息后由主理人与您确认时间和需求。",
|
||||
submitLabel: "提交预订需求",
|
||||
},
|
||||
success: {
|
||||
eyebrow: "CONSULTATION",
|
||||
title: "已收到你的预订需求",
|
||||
intro: "主理人会尽快与你确认。",
|
||||
recordsAction: "查看咨询记录",
|
||||
homeAction: "返回首页",
|
||||
},
|
||||
records: {
|
||||
title: "我的预订记录",
|
||||
createAction: "新增预订",
|
||||
emptyTitle: "还没有预订记录",
|
||||
emptyDescription: "提交一次预订需求,开始确认餐品与时间。",
|
||||
emptyAction: "开始预订",
|
||||
},
|
||||
},
|
||||
},
|
||||
offerings: [
|
||||
{
|
||||
name: "红烧肉双拼套餐",
|
||||
summary: "红烧肉、时蔬、米饭",
|
||||
image: runtimeImages.food[0],
|
||||
kind: "package",
|
||||
priceAmount: 2800,
|
||||
config: {
|
||||
categoryKey: "set-meal",
|
||||
categoryLabel: "套餐",
|
||||
keywords: ["现做", "家常", "定制"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "小炒鸡套餐",
|
||||
summary: "现炒鸡块、时蔬、米饭",
|
||||
image: runtimeImages.food[1],
|
||||
kind: "package",
|
||||
priceAmount: 3200,
|
||||
config: {
|
||||
categoryKey: "set-meal",
|
||||
categoryLabel: "套餐",
|
||||
keywords: ["现做", "家常", "定制"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "家庭聚餐私厨",
|
||||
summary: "根据人数、地点和口味人工沟通报价",
|
||||
image: runtimeImages.food[2],
|
||||
kind: "service",
|
||||
config: {
|
||||
categoryKey: "private-chef",
|
||||
categoryLabel: "私厨",
|
||||
keywords: ["现做", "家常", "定制"],
|
||||
},
|
||||
},
|
||||
],
|
||||
trustContent: [
|
||||
{ type: "profile", title: "关于阿成", content: "每天认真做好一顿家常饭。" },
|
||||
{
|
||||
type: "process",
|
||||
title: "认真做饭的流程",
|
||||
content: "提前准备食材,现做现出餐,认真沟通每一次需求。",
|
||||
},
|
||||
],
|
||||
inquiryForm: {
|
||||
name: "家庭聚餐咨询",
|
||||
fieldsSnapshot: [
|
||||
{ key: "name", label: "您的称呼", type: "text", required: true },
|
||||
{ key: "phone", label: "联系电话", type: "phone", required: true },
|
||||
{ key: "remark", label: "需求说明", type: "textarea", required: false },
|
||||
],
|
||||
},
|
||||
},
|
||||
doors: {
|
||||
retiredOfferingNames: ["别墅入户大门", "院门与围合系统", "室内户内门系统"],
|
||||
brandConfig: {
|
||||
visualTemplateKey: "linjing-editorial",
|
||||
founder: "林叙安 (Lin XUAN)",
|
||||
title: "高端门系统建筑研造主理人",
|
||||
slogan: "为当代别墅空间,定制有秩序感与呼吸感的门",
|
||||
phone: "186-0218-9908",
|
||||
wechat: "LIN-ATELIER-2024",
|
||||
studioAddress: "上海市静安区威海路设计中心 A 座 / 杭州良渚研造工坊",
|
||||
avatarUrl:
|
||||
"https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?auto=format&fit=crop&w=240&h=240&q=80",
|
||||
profilePresentation: {
|
||||
coverage: [
|
||||
{
|
||||
title: "直派核心圈",
|
||||
content:
|
||||
"上海、杭州、宁波、苏州、无锡、南京及深圳、广州。主理人及资深装配总工亲赴现场。",
|
||||
},
|
||||
{
|
||||
title: "全国其他城市私邸",
|
||||
content: "接受建筑设计师联合委托,安排远程 3D 激光测绘支持与专用物流直运安装。",
|
||||
},
|
||||
],
|
||||
warranty: [
|
||||
"门体内部防变形航空合金骨架承诺 10 年结构质保;",
|
||||
"重型天地轴、进口地弹簧及磁吸五金 5 年免费维护;",
|
||||
"每樘门出厂前进行 5000 次启闭校正;",
|
||||
"原木天然肌理享有首年 2 次木蜡油保养服务。",
|
||||
],
|
||||
},
|
||||
visualPresentation: {
|
||||
home: {
|
||||
founderBadge: "亲自主理量房",
|
||||
proofEyebrow: "主理人工艺与信任凭证",
|
||||
proofTitle: "14 年,只做门与空间的关系",
|
||||
manifestoEyebrow: "林境门作品质宣言",
|
||||
manifestoTitle: "拒绝流水线拼装",
|
||||
worksEyebrow: "SELECTED WORKS",
|
||||
worksTitle: "精选门系统作品",
|
||||
worksAction: "查看全部 →",
|
||||
flowEyebrow: "全程一对一跟进",
|
||||
flowTitle: "主理人私享定制流程",
|
||||
},
|
||||
offerings: {
|
||||
title: "作品与系统",
|
||||
subtitle: "每一扇门,都是建筑秩序的一部分。",
|
||||
materialLabel: "主材构成:",
|
||||
hardwareLabel: "核心五金:",
|
||||
detailAction: "查看工艺详案 →",
|
||||
inquiryAction: "咨询此类定制",
|
||||
},
|
||||
detail: {
|
||||
priceLabel: "参考定制造价",
|
||||
spaceLabel: "适用空间",
|
||||
backgroundTitle: "项目背景与空间诉求",
|
||||
conceptTitle: "构造深化设计理念",
|
||||
craftsTitle: "节点工艺考究",
|
||||
materialsTitle: "选型物料与五金规格",
|
||||
inquiryAction: "预约上门测量 / 咨询此类方案",
|
||||
inquiryHint: "预约后由主理人进行点对点方案分析",
|
||||
},
|
||||
profile: {
|
||||
phoneLabel: "专线电话",
|
||||
wechatLabel: "工作室微信",
|
||||
addressLabel: "实体工坊",
|
||||
callAction: "呼叫",
|
||||
copyAction: "复制",
|
||||
recordsCountUnit: "条记录",
|
||||
recordsTitle: "我的量房与定制咨询",
|
||||
recordsSubtitle: "追踪主理人出图进度与现场勘测排期",
|
||||
coverageTitle: "直派服务区域与履约说明",
|
||||
warrantyTitle: "一门一档 · 终生质保规约",
|
||||
},
|
||||
inquiry: {
|
||||
eyebrow: "私人执业研造服务",
|
||||
title: "高端门系统定制 · 私享测量预约",
|
||||
subtitle: "主理人林叙安亲自沟通,72 小时内提供空间门体构想分析。",
|
||||
submitLabel: "提交量房与定制评估需求",
|
||||
},
|
||||
success: {
|
||||
eyebrow: "PRIVATE CONSULTATION",
|
||||
title: "已收到你的咨询",
|
||||
intro: "主理人会根据你的项目资料,整理初步判断并在 1 个工作日内与你联系。",
|
||||
recordsAction: "查看咨询记录",
|
||||
homeAction: "返回首页",
|
||||
},
|
||||
records: {
|
||||
title: "我的咨询记录",
|
||||
createAction: "+ 新增预约",
|
||||
emptyTitle: "还没有咨询记录",
|
||||
emptyDescription: "预约一次私享沟通,让我们从你的空间开始。",
|
||||
emptyAction: "开始咨询",
|
||||
},
|
||||
},
|
||||
heroImage: runtimeImages.doors[0],
|
||||
homeHero: {
|
||||
eyebrow: "年度落成实景 · 莫干山庄园",
|
||||
title: "万籁系列 · 铸铜冷锻双轴入户门",
|
||||
slogan: "门高 3.4m · 德国静音地轴",
|
||||
cta: "探索全系作品 →",
|
||||
},
|
||||
},
|
||||
offerings: [
|
||||
{
|
||||
name: "当代铸铜木核防暴装甲门",
|
||||
summary:
|
||||
"项目位于浙北山间独栋庄园,业主需要一扇兼具当代东方仪式感与长期耐候能力的入户大门。",
|
||||
image: runtimeImages.doors[0],
|
||||
kind: "product",
|
||||
priceText: "¥38,000 - ¥85,000 / 樘",
|
||||
config: {
|
||||
categoryKey: "entrance-door",
|
||||
categoryLabel: "入户大门",
|
||||
series: "「万籁」重型天地轴入户系统",
|
||||
tag: "主理人年度代表作",
|
||||
area: "浙江·莫干山私家山庄",
|
||||
detailHero: runtimeImages.doors[0],
|
||||
woodMaterial: "60mm 北美特级黑胡桃整板 + 航空蜂窝铝芯",
|
||||
hardware: "德国 dormakaba 重型地弹簧 + 自主定制实心锻铜一体式长执手",
|
||||
spaceType: "独栋别墅建筑主入口 / 挑高大厅玄关",
|
||||
keywords: ["厚重大气", "隐式天地轴", "隔音 42dB", "抗暴防撬"],
|
||||
details: {
|
||||
background:
|
||||
"项目位于浙北山间独栋庄园,常年多雨潮湿,且冬季山风冷峻。业主期望一扇既有古典厚重仪式感,又能抵御风雨、长久耐候的当代东方大门。",
|
||||
designConcept:
|
||||
"提炼江南屋檐与青砖比例。以暗调冷锻手工铜板包裹耐候钢核,内衬大厚度吸音绝热芯,门体内嵌隐藏式天地承重轴,推拉阻尼丝滑沉稳。",
|
||||
crafts: [
|
||||
"无缝冷锻铜边框,经自然氧化着色",
|
||||
"双道三元乙丙航天级发泡密封胶条,气密性达国标 8 级",
|
||||
"指纹识别模组隐于天然胡桃木纹理深处",
|
||||
],
|
||||
materialsList: [
|
||||
{ name: "门扇主体", spec: "航空铝蜂窝 + 防暴钢板 + 黑胡桃" },
|
||||
{ name: "承重结构", spec: "不锈钢重型天地偏心轴(承重 600KG)" },
|
||||
{ name: "五金执手", spec: "实心黄铜拉丝防指纹覆膜" },
|
||||
{ name: "锁具系统", spec: "C 级多向防暴机械锁芯 + 隐匿式生物辨识" },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "悬挑风琴式耐候双开院门",
|
||||
summary: "以柚木条与耐候钢构建视线遮蔽和透光的微妙平衡,适配长期日晒雨淋的私家庭院入口。",
|
||||
image: runtimeImages.doors[1],
|
||||
kind: "product",
|
||||
priceText: "¥42,000 - ¥98,000 / 樘",
|
||||
config: {
|
||||
categoryKey: "garden-door",
|
||||
categoryLabel: "庭院围墙门",
|
||||
series: "「虚实」透光私家庭院门",
|
||||
tag: "建筑级耐候工艺",
|
||||
area: "上海·佘山高尔夫别墅",
|
||||
detailHero: runtimeImages.doors[1],
|
||||
woodMaterial: "深浸缅甸柚木条格栅 + 氟碳喷涂耐候钢",
|
||||
hardware: "意大利全隐形地埋式液压自闭器 + 静音电控锁",
|
||||
spaceType: "私家庭院入口 / 围墙园林玄关",
|
||||
keywords: ["园林意境", "格栅光影", "耐候耐蚀", "智能对讲协同"],
|
||||
details: {
|
||||
background:
|
||||
"庭院门直面自然日晒雨淋,普通木门易开裂变形,普通铁艺门几年内斑驳锈蚀。本案要求长期免维护的高级自然质感。",
|
||||
designConcept:
|
||||
"利用竖向错落的柚木条构建视线遮蔽与透光的微妙平衡,内部向外望去如薄纱透竹。",
|
||||
crafts: [
|
||||
"微隙热胀冷缩结构槽设计",
|
||||
"隐蔽式水路导流坡口",
|
||||
"院墙铰链锚栓深入混凝土柱芯 300mm",
|
||||
],
|
||||
materialsList: [
|
||||
{ name: "户外木种", spec: "高油脂老料缅甸柚木,经过 180 天自然风干" },
|
||||
{ name: "骨架型材", spec: "4mm 高强度航空铝镁合金" },
|
||||
{ name: "智能五金", spec: "隐藏式地下闭门轴,支持远程授权" },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "通顶极窄边框实木室内门",
|
||||
summary: "以 2.8m - 3.2m 满高通顶系统维持私宅空间的建筑平直感,并与木作一体深化。",
|
||||
image: runtimeImages.doors[2],
|
||||
kind: "product",
|
||||
priceText: "¥7,800 - ¥16,000 / 樘",
|
||||
config: {
|
||||
categoryKey: "interior-door",
|
||||
categoryLabel: "室内户内门",
|
||||
series: "「空灵」2.8m - 3.2m 满高通顶系统",
|
||||
tag: "极简建筑平直感",
|
||||
area: "江苏·苏州金鸡湖独栋",
|
||||
detailHero: runtimeImages.doors[2],
|
||||
woodMaterial: "天然白栓木拉丝烟熏木饰面 + 磁吸阻尼降噪",
|
||||
hardware: "意大利 AGB 磁吸静音门锁 + 隐藏式暗铰链",
|
||||
spaceType: "别墅主卧套房 / 私人藏书阁 / 视听室",
|
||||
keywords: ["满高通顶", "磁吸静音", "极窄边框", "与木作同色"],
|
||||
details: {
|
||||
background:
|
||||
"室内多道门如果尺寸矮小杂乱,会切割私宅的建筑开阔感。业主希望主卧区实现门与护墙板毫无色差、绝对平齐。",
|
||||
designConcept: "门扇高 3.1 米一通到顶,无传统上门套与压边;内嵌双向碳纤维抗弯龙骨。",
|
||||
crafts: [
|
||||
"门框与墙体批荡层融为一体的无框反装工艺",
|
||||
"磁力吸舌落锁轻无声息",
|
||||
"同批原木切片保证纹理与护墙板连贯",
|
||||
],
|
||||
materialsList: [
|
||||
{ name: "抗弯核心", spec: "双组份碳纤维预应力防变形拉力杆" },
|
||||
{ name: "吸音内衬", spec: "德国均质空心桥洞力学板" },
|
||||
{ name: "隐形铰链", spec: "德国 KRONA 三维可调隐形铰链" },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "石材及皮质背景墙一体门",
|
||||
summary: "将门体与背景墙材料、纹理和收口一体深化,保留私宅完整的墙面秩序。",
|
||||
image:
|
||||
"https://images.unsplash.com/photo-1600210492486-724fe5c67fb0?auto=format&fit=crop&w=1000&q=85",
|
||||
kind: "product",
|
||||
priceText: "¥18,000 - ¥36,000 / 樘",
|
||||
config: {
|
||||
categoryKey: "stealth-door",
|
||||
categoryLabel: "装饰隐形门",
|
||||
series: "「无垠」密室及背景墙融合门",
|
||||
tag: "精密收口工程",
|
||||
area: "广东·深圳香蜜湖一号",
|
||||
detailHero:
|
||||
"https://images.unsplash.com/photo-1600210492486-724fe5c67fb0?auto=format&fit=crop&w=1000&q=85",
|
||||
woodMaterial: "3mm 超薄大理石复合蜂窝板 / 进口鞍革手工双缝线",
|
||||
hardware: "感应式电动自开闭装置或碰珠反弹器",
|
||||
spaceType: "雪茄室 / 私人金库 / 地下酒窖 / 视听隐藏储物区",
|
||||
keywords: ["视线隐形", "超薄岩板", "毫厘对缝", "无门把设计"],
|
||||
details: {
|
||||
background:
|
||||
"客厅背景墙长达 9 米,中间有一道通往主人密闭酒窖的通道,突兀开门会破坏整面奢石的连贯韵律。",
|
||||
designConcept: "将奢石切割对纹复合于高刚性合金门扇表面,缝隙控制在 1.5mm 以内。",
|
||||
crafts: [
|
||||
"石材水刀无应力薄切与航空蜂窝背栓复合",
|
||||
"脚踏地砖预埋重力复位转轴",
|
||||
"支持指纹电控联动隐藏灯带",
|
||||
],
|
||||
materialsList: [
|
||||
{ name: "表面饰材", spec: "意大利雪山银狐超薄天然大理石" },
|
||||
{ name: "驱动系统", spec: "低噪步进电机伺服闭门器" },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
trustContent: [
|
||||
{
|
||||
type: "profile",
|
||||
title: "主理人的门作观",
|
||||
content:
|
||||
"国家注册高级室内建筑师,专注高定大门及私宅空间门类系统研发 14 年。拒绝建材量产拼装,以门与空间同构的建筑理念,亲自主理选材、构造深化与落地试装。",
|
||||
config: {
|
||||
stats: [
|
||||
{ value: "14年", label: "高端门系深化经验", sub: "历经百项严苛私宅考验" },
|
||||
{ value: "260+", label: "落地庄园实景案例", sub: "全实景图库,可预约探访" },
|
||||
{ value: "100%", label: "主理人全案跟进", sub: "量房 / 出图 / 选料 / 试装" },
|
||||
{ value: "10年", label: "结构主轴质保承诺", sub: "终生五金润滑维保机制" },
|
||||
],
|
||||
pillars: [
|
||||
{
|
||||
icon: "tree",
|
||||
title: "天然厚板与古铜锻打",
|
||||
desc: "精选 300 年北美黑胡桃、缅甸柚木直拼大板,搭配手工冷锻紫铜及意大利防爆钢核。",
|
||||
},
|
||||
{
|
||||
icon: "ruler",
|
||||
title: "微米级红外高精量房",
|
||||
desc: "德国进口 3D 空间激光扫描,精准捕捉门洞沉降公差与建筑墙体垂直度。",
|
||||
},
|
||||
{
|
||||
icon: "shield",
|
||||
title: "隐匿式重型五金系统",
|
||||
desc: "自主研发三维可调静音承重铰链,单扇承载 450kg,开合轻盈安静。",
|
||||
},
|
||||
],
|
||||
serviceFlow: [
|
||||
{ step: "01", name: "私享沟通", desc: "厘清生活动线与风候环境" },
|
||||
{ step: "02", name: "上门实测", desc: "复核门洞公差与地平基准" },
|
||||
{ step: "03", name: "构造出图", desc: "输出结构图与材质节点方案" },
|
||||
{ step: "04", name: "实样工坊确认", desc: "确认木样、锻铜样与密封节点" },
|
||||
{ step: "05", name: "工坊试装交付", desc: "试装调试后专车直运现场" },
|
||||
{ step: "06", name: "终生私属维护", desc: "建立一门一档数字化档案" },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "portfolio",
|
||||
title: "别墅门系统案例",
|
||||
content: "围绕入户、庭院和室内空间建立完整门系统。",
|
||||
},
|
||||
{
|
||||
type: "process",
|
||||
title: "从测量到交付",
|
||||
content: "现场测量、方案沟通、深化确认和落地交付。",
|
||||
},
|
||||
],
|
||||
inquiryForm: {
|
||||
name: "门系统方案咨询",
|
||||
fieldsSnapshot: [
|
||||
{
|
||||
key: "doorType",
|
||||
label: "期望定制的门类型",
|
||||
type: "select",
|
||||
required: true,
|
||||
options: [
|
||||
"入户大门(防暴铸铜 / 实木)",
|
||||
"庭院围墙门(耐候格栅 / 对开)",
|
||||
"全屋室内门系统(通顶隐形)",
|
||||
"背景墙一体门 / 密室门",
|
||||
"整栋别墅门系统全案一体化",
|
||||
],
|
||||
},
|
||||
{ key: "cityArea", label: "房屋 / 别墅所在城市与楼盘", type: "text", required: true },
|
||||
{
|
||||
key: "projectStage",
|
||||
label: "当前项目阶段",
|
||||
type: "radio",
|
||||
required: true,
|
||||
options: [
|
||||
"土建结构阶段(适合预埋加固)",
|
||||
"水电木工阶段(适合精确测距)",
|
||||
"硬装收尾阶段",
|
||||
"旧宅门体翻新改造",
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "budgetRange",
|
||||
label: "预估门系统投资预算",
|
||||
type: "select",
|
||||
required: false,
|
||||
options: [
|
||||
"5 万 - 10 万",
|
||||
"10 万 - 20 万",
|
||||
"20 万 - 50 万(全宅全案)",
|
||||
"50 万以上(顶级孤品定制)",
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "needMeasure",
|
||||
label: "是否需要主理人上门现场量房",
|
||||
type: "radio",
|
||||
required: true,
|
||||
options: ["需要(预约排期现场勘测)", "暂不需要(先发图纸在线深化评估)"],
|
||||
},
|
||||
{ key: "contactName", label: "贵姓称谓", type: "text", required: true },
|
||||
{ key: "contactPhone", label: "联系手机号(微信同号)", type: "tel", required: true },
|
||||
{ key: "specialNote", label: "空间想法或特殊需求描述", type: "textarea", required: false },
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTemplate): Promise<void> {
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: brandId },
|
||||
data: {
|
||||
config: {
|
||||
founder: templateKey === "doors" ? "林境主理人" : "阿成",
|
||||
title: templateKey === "doors" ? "别墅门系统设计顾问" : "私房菜主理人",
|
||||
slogan:
|
||||
templateKey === "doors" ? "让每一扇门,成为建筑秩序的开始。" : "认真做好每一顿家常饭。",
|
||||
phone: templateKey === "doors" ? "13800000000" : "",
|
||||
wechat: templateKey === "doors" ? "linjing-doors" : "",
|
||||
studioAddress: templateKey === "doors" ? "城市设计中心 3F" : "大学城生活区东门附近",
|
||||
heroImage: runtimeImages[templateKey][0],
|
||||
},
|
||||
config: template.brandConfig,
|
||||
},
|
||||
});
|
||||
for (const [sortOrder, item] of offerings.entries()) {
|
||||
for (const [sortOrder, item] of template.offerings.entries()) {
|
||||
const offering = await prisma.offering.findUnique({
|
||||
where: { brandId_name: { brandId, name: item.name } },
|
||||
});
|
||||
if (!offering) continue;
|
||||
await prisma.offering.update({
|
||||
where: { id: offering.id },
|
||||
data: {
|
||||
coverUrl: item.image,
|
||||
summary: item.summary,
|
||||
sortOrder: sortOrder + 1,
|
||||
isEnabled: true,
|
||||
config: {
|
||||
categoryKey: item.categoryKey,
|
||||
keywords: templateKey === "doors" ? ["定制", "别墅", "门系统"] : ["现做", "家常", "定制"],
|
||||
media: [{ url: item.image, alt: item.name, type: "image" }],
|
||||
sections: [],
|
||||
},
|
||||
const data = {
|
||||
kind: item.kind,
|
||||
coverUrl: item.image,
|
||||
summary: item.summary,
|
||||
priceText: item.priceText ?? "沟通报价",
|
||||
...(item.priceAmount === undefined ? {} : { priceAmount: item.priceAmount }),
|
||||
sortOrder: sortOrder + 1,
|
||||
isEnabled: true,
|
||||
config: {
|
||||
...item.config,
|
||||
media: [{ url: item.image, alt: item.name, type: "image" }],
|
||||
sections: [],
|
||||
},
|
||||
};
|
||||
if (offering) await prisma.offering.update({ where: { id: offering.id }, data });
|
||||
else await prisma.offering.create({ data: { brandId, name: item.name, ...data } });
|
||||
}
|
||||
if (template.retiredOfferingNames?.length) {
|
||||
await prisma.offering.updateMany({
|
||||
where: { brandId, name: { in: template.retiredOfferingNames } },
|
||||
data: { isEnabled: false },
|
||||
});
|
||||
}
|
||||
const moduleDefinitions = [
|
||||
@@ -82,67 +696,74 @@ async function ensureRuntimeContent(
|
||||
select: { id: true, name: true },
|
||||
});
|
||||
for (const [index, item] of incompleteOfferings.entries()) {
|
||||
const image = runtimeImages[templateKey][index % runtimeImages[templateKey].length];
|
||||
const image = template.offerings[index % template.offerings.length].image;
|
||||
await prisma.offering.update({
|
||||
where: { id: item.id },
|
||||
data: {
|
||||
coverUrl: image,
|
||||
config: {
|
||||
categoryKey: "custom",
|
||||
keywords: templateKey === "doors" ? ["定制", "门系统"] : ["家常", "定制"],
|
||||
categoryLabel: "自定义业务",
|
||||
keywords: [],
|
||||
media: [{ url: image, alt: item.name, type: "image" }],
|
||||
sections: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
const trustCount = await prisma.trustContent.count({ where: { brandId } });
|
||||
if (!trustCount) {
|
||||
const trustItems =
|
||||
templateKey === "doors"
|
||||
? [
|
||||
["profile", "主理人的门作观", "从建筑关系出发,认真处理每一扇门。"],
|
||||
["portfolio", "别墅门系统案例", "围绕入户、庭院和室内空间建立完整门系统。"],
|
||||
["process", "从测量到交付", "现场测量、方案沟通、深化确认和落地交付。"],
|
||||
]
|
||||
: [
|
||||
["profile", "关于阿成", "每天认真做好一顿家常饭。"],
|
||||
["process", "认真做饭的流程", "提前准备食材,现做现出餐,认真沟通每一次需求。"],
|
||||
];
|
||||
await prisma.trustContent.createMany({
|
||||
data: trustItems.map(([type, title, content], sortOrder) => ({
|
||||
brandId,
|
||||
type,
|
||||
title,
|
||||
content,
|
||||
sortOrder,
|
||||
isPublished: true,
|
||||
})),
|
||||
});
|
||||
}
|
||||
const formCount = await prisma.inquiryForm.count({ where: { brandId } });
|
||||
if (!formCount) {
|
||||
await prisma.inquiryForm.create({
|
||||
data: {
|
||||
brandId,
|
||||
name: templateKey === "doors" ? "门系统方案咨询" : "家庭聚餐咨询",
|
||||
purpose: "inquiry",
|
||||
targetType: "brand",
|
||||
submissionAction: "create-inquiry",
|
||||
fieldsSnapshot: [
|
||||
{ key: "name", label: "您的称呼", type: "text", required: true },
|
||||
{ key: "phone", label: "联系电话", type: "phone", required: true },
|
||||
{ key: "remark", label: "需求说明", type: "textarea", required: false },
|
||||
],
|
||||
},
|
||||
for (const [sortOrder, item] of template.trustContent.entries()) {
|
||||
const existing = await prisma.trustContent.findFirst({
|
||||
where: { brandId, type: item.type, title: item.title },
|
||||
});
|
||||
const data = { ...item, brandId, sortOrder, isPublished: true };
|
||||
if (existing) await prisma.trustContent.update({ where: { id: existing.id }, data });
|
||||
else await prisma.trustContent.create({ data });
|
||||
}
|
||||
const existingForm = await prisma.inquiryForm.findFirst({
|
||||
where: { brandId, targetType: "brand" },
|
||||
orderBy: { createdAt: "asc" },
|
||||
});
|
||||
const formData = {
|
||||
name: template.inquiryForm.name,
|
||||
purpose: "inquiry",
|
||||
targetType: "brand",
|
||||
submissionAction: "create-inquiry",
|
||||
fieldsSnapshot: template.inquiryForm.fieldsSnapshot,
|
||||
isEnabled: true,
|
||||
} as const;
|
||||
if (existingForm)
|
||||
await prisma.inquiryForm.update({ where: { id: existingForm.id }, data: formData });
|
||||
else await prisma.inquiryForm.create({ data: { brandId, ...formData } });
|
||||
}
|
||||
|
||||
async function ensureSeedRelease(brandId: string, actorId: string): Promise<void> {
|
||||
const snapshot = await buildBrandReleaseSnapshot(prisma, brandId);
|
||||
await prisma.brandRelease.deleteMany({ where: { brandId } });
|
||||
await prisma.brandRelease.create({
|
||||
data: {
|
||||
brandId,
|
||||
version: 1,
|
||||
status: "published",
|
||||
snapshot,
|
||||
actorId,
|
||||
note: "seed 基线发布版本",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const brand = await prisma.brandProfile.upsert({
|
||||
where: { id: "00000000-0000-0000-0000-000000000001" },
|
||||
update: {},
|
||||
update: {
|
||||
slug: "default-brand",
|
||||
name: "阿成家常菜",
|
||||
templateKey: "food",
|
||||
tagline: "现做家常套餐,也为小型聚餐定制一桌热饭菜",
|
||||
description: "每天认真做好一顿家常饭。",
|
||||
hours: "周一至周六 10:30-20:00",
|
||||
address: "大学城生活区东门附近",
|
||||
deliveryNote: "目前支持部分学生宿舍楼配送,无法送达时会主动联系。",
|
||||
},
|
||||
create: {
|
||||
slug: "default-brand",
|
||||
id: "00000000-0000-0000-0000-000000000001",
|
||||
@@ -156,58 +777,7 @@ async function main(): Promise<void> {
|
||||
},
|
||||
});
|
||||
|
||||
const offerings = [
|
||||
{
|
||||
brandId: brand.id,
|
||||
name: "红烧肉双拼套餐",
|
||||
description: "红烧肉、时蔬、米饭",
|
||||
priceText: "¥28 / 份",
|
||||
priceAmount: 2800,
|
||||
sortOrder: 1,
|
||||
},
|
||||
{
|
||||
brandId: brand.id,
|
||||
name: "小炒鸡套餐",
|
||||
description: "现炒鸡块、时蔬、米饭",
|
||||
priceText: "¥25 / 份",
|
||||
priceAmount: 2500,
|
||||
sortOrder: 2,
|
||||
},
|
||||
{
|
||||
brandId: brand.id,
|
||||
name: "家庭聚餐私厨",
|
||||
description: "根据人数、地点和口味人工沟通报价",
|
||||
priceText: "面议",
|
||||
sortOrder: 3,
|
||||
},
|
||||
];
|
||||
for (const offering of offerings) {
|
||||
const existing = await prisma.offering.findFirst({
|
||||
where: { brandId: brand.id, name: offering.name },
|
||||
});
|
||||
if (existing) await prisma.offering.update({ where: { id: existing.id }, data: offering });
|
||||
else await prisma.offering.create({ data: { ...offering, kind: "service" } });
|
||||
}
|
||||
await ensureRuntimeContent(brand.id, "food", [
|
||||
{
|
||||
name: "红烧肉双拼套餐",
|
||||
summary: "红烧肉、时蔬、米饭",
|
||||
image: runtimeImages.food[0],
|
||||
categoryKey: "set-meal",
|
||||
},
|
||||
{
|
||||
name: "小炒鸡套餐",
|
||||
summary: "现炒鸡块、时蔬、米饭",
|
||||
image: runtimeImages.food[1],
|
||||
categoryKey: "set-meal",
|
||||
},
|
||||
{
|
||||
name: "家庭聚餐私厨",
|
||||
summary: "根据人数、地点和口味人工沟通报价",
|
||||
image: runtimeImages.food[2],
|
||||
categoryKey: "private-chef",
|
||||
},
|
||||
]);
|
||||
await ensureRuntimeContent(brand.id, runtimeSeedTemplates.food);
|
||||
|
||||
for (const name of ["普通套餐", "私厨", "配送", "自取", "熟客", "重点跟进"]) {
|
||||
await prisma.tag.upsert({
|
||||
@@ -231,9 +801,52 @@ async function main(): Promise<void> {
|
||||
create: { adminUserId: admin.id, brandId: brand.id, role: "owner" },
|
||||
});
|
||||
|
||||
const personalBrand = await prisma.brandProfile.upsert({
|
||||
where: { id: "00000000-0000-0000-0000-000000000003" },
|
||||
update: {
|
||||
slug: "linran-brand",
|
||||
name: "林然品牌顾问",
|
||||
templateKey: "personal",
|
||||
tagline: "用清晰的定位与可执行的表达,让专业被看见。",
|
||||
description: "为专业服务者提供品牌定位、表达与长期顾问支持。",
|
||||
hours: "周一至周五 10:00-18:00",
|
||||
address: "上海市徐汇区创意园区",
|
||||
contactPhone: "13900000003",
|
||||
contactWechat: "linran-brand",
|
||||
},
|
||||
create: {
|
||||
id: "00000000-0000-0000-0000-000000000003",
|
||||
slug: "linran-brand",
|
||||
name: "林然品牌顾问",
|
||||
templateKey: "personal",
|
||||
tagline: "用清晰的定位与可执行的表达,让专业被看见。",
|
||||
description: "为专业服务者提供品牌定位、表达与长期顾问支持。",
|
||||
hours: "周一至周五 10:00-18:00",
|
||||
address: "上海市徐汇区创意园区",
|
||||
contactPhone: "13900000003",
|
||||
contactWechat: "linran-brand",
|
||||
},
|
||||
});
|
||||
await prisma.brandMembership.upsert({
|
||||
where: { adminUserId_brandId: { adminUserId: admin.id, brandId: personalBrand.id } },
|
||||
update: { isEnabled: true, role: "owner" },
|
||||
create: { adminUserId: admin.id, brandId: personalBrand.id, role: "owner" },
|
||||
});
|
||||
await ensureRuntimeContent(personalBrand.id, runtimeSeedTemplates.personal);
|
||||
|
||||
const doorsBrand = await prisma.brandProfile.upsert({
|
||||
where: { id: "00000000-0000-0000-0000-000000000002" },
|
||||
update: {},
|
||||
update: {
|
||||
slug: "linjing-doors",
|
||||
name: "林境门作",
|
||||
templateKey: "doors",
|
||||
tagline: "为别墅空间定制有秩序感的门系统",
|
||||
description: "从入户大门到室内户内门,提供完整的门系统设计与落地服务。",
|
||||
hours: "周一至周六 09:00-18:00",
|
||||
address: "城市设计中心 3F",
|
||||
contactPhone: "13800000000",
|
||||
contactWechat: "linjing-doors",
|
||||
},
|
||||
create: {
|
||||
id: "00000000-0000-0000-0000-000000000002",
|
||||
slug: "linjing-doors",
|
||||
@@ -247,57 +860,15 @@ async function main(): Promise<void> {
|
||||
contactWechat: "linjing-doors",
|
||||
},
|
||||
});
|
||||
for (const offering of [
|
||||
{
|
||||
name: "别墅入户大门",
|
||||
description: "结合建筑立面与入户动线定制门体、五金和安装方案。",
|
||||
priceText: "预约沟通",
|
||||
sortOrder: 1,
|
||||
},
|
||||
{
|
||||
name: "院门与围合系统",
|
||||
description: "院门、围墙和庭院动线的一体化设计与施工配合。",
|
||||
priceText: "预约沟通",
|
||||
sortOrder: 2,
|
||||
},
|
||||
{
|
||||
name: "室内户内门系统",
|
||||
description: "根据空间风格定制户内门、隐形门和装饰门。",
|
||||
priceText: "预约沟通",
|
||||
sortOrder: 3,
|
||||
},
|
||||
]) {
|
||||
await prisma.offering.upsert({
|
||||
where: { brandId_name: { brandId: doorsBrand.id, name: offering.name } },
|
||||
update: offering,
|
||||
create: { ...offering, brandId: doorsBrand.id, kind: "service" },
|
||||
});
|
||||
}
|
||||
await prisma.brandMembership.upsert({
|
||||
where: { adminUserId_brandId: { adminUserId: admin.id, brandId: doorsBrand.id } },
|
||||
update: { isEnabled: true, role: "owner" },
|
||||
create: { adminUserId: admin.id, brandId: doorsBrand.id, role: "owner" },
|
||||
});
|
||||
await ensureRuntimeContent(doorsBrand.id, "doors", [
|
||||
{
|
||||
name: "别墅入户大门",
|
||||
summary: "结合建筑立面与入户动线定制门体、五金和安装方案。",
|
||||
image: runtimeImages.doors[0],
|
||||
categoryKey: "entrance-door",
|
||||
},
|
||||
{
|
||||
name: "院门与围合系统",
|
||||
summary: "院门、围墙和庭院动线的一体化设计与施工配合。",
|
||||
image: runtimeImages.doors[1],
|
||||
categoryKey: "garden-door",
|
||||
},
|
||||
{
|
||||
name: "室内户内门系统",
|
||||
summary: "根据空间风格定制户内门、隐形门和装饰门。",
|
||||
image: runtimeImages.doors[2],
|
||||
categoryKey: "interior-door",
|
||||
},
|
||||
]);
|
||||
await ensureRuntimeContent(doorsBrand.id, runtimeSeedTemplates.doors);
|
||||
await ensureSeedRelease(brand.id, admin.id);
|
||||
await ensureSeedRelease(personalBrand.id, admin.id);
|
||||
await ensureSeedRelease(doorsBrand.id, admin.id);
|
||||
}
|
||||
|
||||
main().finally(() => prisma.$disconnect());
|
||||
@@ -25,4 +25,12 @@ export class AdminAccessService {
|
||||
if (!membership?.isEnabled) throw new ForbiddenException("管理员没有当前品牌权限");
|
||||
return { subject: identity.subject, brandId: identity.brandId, role: membership.role };
|
||||
}
|
||||
|
||||
async requireRole(request: FastifyRequest, allowedRoles: string[]): Promise<boolean> {
|
||||
const access = await this.requireBrand(request);
|
||||
if (!allowedRoles.includes(access.role)) {
|
||||
throw new ForbiddenException("当前账号没有系统设置权限");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,10 @@ import { signIdentity } from "./auth.js";
|
||||
export class AdminAuthService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async login(username: string, password: string): Promise<{ token: string; displayName: string }> {
|
||||
async login(
|
||||
username: string,
|
||||
password: string,
|
||||
): Promise<{ token: string; displayName: string; mustChangePassword: boolean; role: string }> {
|
||||
const user = await this.prisma.adminUser.findUnique({ where: { username } });
|
||||
if (!user || !user.isEnabled || !(await bcrypt.compare(password, user.passwordHash))) {
|
||||
throw new UnauthorizedException("账号或密码错误");
|
||||
@@ -36,6 +39,23 @@ export class AdminAuthService {
|
||||
role: "admin",
|
||||
}),
|
||||
displayName: user.displayName,
|
||||
mustChangePassword: user.mustChangePassword,
|
||||
role: activeMembership.role,
|
||||
};
|
||||
}
|
||||
|
||||
async changePassword(
|
||||
userId: string,
|
||||
currentPassword: string,
|
||||
newPassword: string,
|
||||
): Promise<void> {
|
||||
const user = await this.prisma.adminUser.findUnique({ where: { id: userId } });
|
||||
if (!user || !(await bcrypt.compare(currentPassword, user.passwordHash))) {
|
||||
throw new UnauthorizedException("当前密码不正确");
|
||||
}
|
||||
await this.prisma.adminUser.update({
|
||||
where: { id: userId },
|
||||
data: { passwordHash: await bcrypt.hash(newPassword, 12), mustChangePassword: false },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,14 @@ export class AdminMembershipGuard implements CanActivate {
|
||||
const request = context.switchToHttp().getRequest<FastifyRequest>();
|
||||
if (request.url.startsWith("/admin/session/login")) return Promise.resolve(true);
|
||||
if (!request.url.startsWith("/admin/")) return Promise.resolve(true);
|
||||
if (
|
||||
/^\/admin\/workspace\/(install|capabilities(?:\/|$)|template(?:\/|$)|modules(?:\/|$)|fields(?:\/|$))/.test(
|
||||
request.url,
|
||||
) ||
|
||||
/^\/admin\/config\/visual-template(?:\/|$)/.test(request.url)
|
||||
) {
|
||||
return this.access.requireRole(request, ["owner", "admin", "platform-admin"]);
|
||||
}
|
||||
return this.access.requireBrand(request).then(() => true);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,12 @@ import {
|
||||
UpdateInquirySubmissionDto,
|
||||
UpdateCapabilityInstallationDto,
|
||||
} from "./admin.dto.js";
|
||||
import { capabilityPlugins, getBrandTemplate, resolveCapabilities } from "@personal-brand/config";
|
||||
import {
|
||||
capabilityPlugins,
|
||||
getBrandTemplate,
|
||||
getTemplateSampleContent,
|
||||
resolveCapabilities,
|
||||
} from "@personal-brand/config";
|
||||
import { TemplateWorkspaceService } from "./template-workspace.service.js";
|
||||
import { validateFieldSnapshot, validateOfferingConfig } from "@personal-brand/validation";
|
||||
|
||||
@@ -176,15 +181,12 @@ class AdminWorkspaceController {
|
||||
@Get("capabilities")
|
||||
async listCapabilities(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
const brandId = this.requireAdmin(request).brandId;
|
||||
const [brand, installations] = await Promise.all([
|
||||
this.prisma.brandProfile.findUnique({
|
||||
where: { id: brandId },
|
||||
select: { templateKey: true },
|
||||
}),
|
||||
const [templateKey, installations] = await Promise.all([
|
||||
this.templateWorkspace.getEffectiveTemplateKey(brandId),
|
||||
this.prisma.capabilityInstallation.findMany({ where: { brandId } }),
|
||||
]);
|
||||
const installed = new Map(installations.map((item) => [item.capabilityKey, item]));
|
||||
const template = getBrandTemplate(brand?.templateKey ?? "personal");
|
||||
const template = getBrandTemplate(templateKey);
|
||||
return (template ? resolveCapabilities(template.capabilities) : []).map((definition) => {
|
||||
const item = installed.get(definition.key);
|
||||
return {
|
||||
@@ -202,15 +204,22 @@ class AdminWorkspaceController {
|
||||
@Get("sample-content/preview")
|
||||
async previewSampleContent(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
const brandId = this.requireAdmin(request).brandId;
|
||||
const templateKey = await this.templateWorkspace.getEffectiveTemplateKey(brandId);
|
||||
const sample = getTemplateSampleContent(templateKey);
|
||||
if (!sample) throw new BadRequestException("模板示例内容不存在");
|
||||
const [offerings, trustContent, fields] = await Promise.all([
|
||||
this.prisma.offering.count({ where: { brandId } }),
|
||||
this.prisma.trustContent.count({ where: { brandId } }),
|
||||
this.prisma.brandFieldDefinition.count({ where: { brandId, source: "sample" } }),
|
||||
]);
|
||||
return {
|
||||
templateKey: "doors",
|
||||
templateKey: sample.templateKey,
|
||||
alreadyImported: offerings > 0 || trustContent > 0 || fields > 0,
|
||||
counts: { offerings: 4, trustContent: 4, fields: 4 },
|
||||
counts: {
|
||||
offerings: sample.offerings.length,
|
||||
trustContent: sample.trustContent.length,
|
||||
fields: sample.fields.length,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -218,6 +227,9 @@ class AdminWorkspaceController {
|
||||
async importSampleContent(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
const identity = this.requireAdmin(request);
|
||||
const brandId = identity.brandId;
|
||||
const templateKey = await this.templateWorkspace.getEffectiveTemplateKey(brandId);
|
||||
const sample = getTemplateSampleContent(templateKey);
|
||||
if (!sample) throw new BadRequestException("模板示例内容不存在");
|
||||
const existing = await this.prisma.brandFieldDefinition.count({
|
||||
where: { brandId, source: "sample" },
|
||||
});
|
||||
@@ -227,54 +239,42 @@ class AdminWorkspaceController {
|
||||
if (existing || existingOffering) throw new BadRequestException("示例内容已经导入");
|
||||
const result = await this.prisma.$transaction(async (tx) => {
|
||||
const offerings = await tx.offering.createMany({
|
||||
data: [
|
||||
["序章·入户门", "为别墅入口定制的整樘门系统", "entrance-door"],
|
||||
["庭院·边界门", "连接建筑与庭院的定制门", "garden-door"],
|
||||
["室内·静谧门", "统一室内空间秩序的户内门", "interior-door"],
|
||||
["一对一门系统设计咨询", "从现场到方案的完整设计沟通", "custom"],
|
||||
].map((item, sortOrder) => ({
|
||||
data: sample.offerings.map((item, sortOrder) => ({
|
||||
brandId,
|
||||
kind: sortOrder === 3 ? "service" : "product",
|
||||
name: item[0]!,
|
||||
summary: item[1]!,
|
||||
config: { categoryKey: item[2]! },
|
||||
kind: item.kind,
|
||||
name: item.name,
|
||||
summary: item.summary,
|
||||
config: { categoryKey: item.categoryKey },
|
||||
sortOrder,
|
||||
isEnabled: true,
|
||||
})),
|
||||
});
|
||||
const trust = await tx.trustContent.createMany({
|
||||
data: ["主理人的门作观", "别墅门系统案例", "从测量到交付", "材料与工艺标准"].map(
|
||||
(title, sortOrder) => ({
|
||||
brandId,
|
||||
type: ["profile", "portfolio", "process", "credential"][sortOrder]!,
|
||||
title,
|
||||
content: "示例内容,待品牌主理人完善。",
|
||||
sortOrder,
|
||||
isPublished: false,
|
||||
}),
|
||||
),
|
||||
data: sample.trustContent.map((item, sortOrder) => ({
|
||||
brandId,
|
||||
type: item.type,
|
||||
title: item.title,
|
||||
content: item.content,
|
||||
sortOrder,
|
||||
isPublished: false,
|
||||
})),
|
||||
});
|
||||
const fields = await tx.brandFieldDefinition.createMany({
|
||||
data: [
|
||||
["projectType", "项目类型", "select"],
|
||||
["projectStage", "项目阶段", "select"],
|
||||
["siteDescription", "项目概况", "textarea"],
|
||||
["phone", "联系方式", "phone"],
|
||||
].map((item, sortOrder) => ({
|
||||
data: sample.fields.map((item, sortOrder) => ({
|
||||
brandId,
|
||||
scope: "inquiry",
|
||||
key: item[0]!,
|
||||
label: item[1]!,
|
||||
type: item[2]!,
|
||||
key: item.key,
|
||||
label: item.label,
|
||||
type: item.type,
|
||||
sortOrder,
|
||||
source: "sample",
|
||||
required: item[2] === "phone",
|
||||
required: item.required,
|
||||
})),
|
||||
});
|
||||
await tx.capabilityAuditLog.create({
|
||||
data: {
|
||||
brandId,
|
||||
capabilityKey: "doors",
|
||||
capabilityKey: sample.capabilityKey,
|
||||
actorId: identity.subject,
|
||||
action: "sample_content_imported",
|
||||
toStatus: "enabled",
|
||||
@@ -294,8 +294,9 @@ class AdminWorkspaceController {
|
||||
): Promise<unknown> {
|
||||
const identity = this.requireAdmin(request);
|
||||
const brandId = identity.brandId;
|
||||
const brand = await this.prisma.brandProfile.findUnique({ where: { id: brandId } });
|
||||
const template = getBrandTemplate(brand?.templateKey ?? "personal");
|
||||
const template = getBrandTemplate(
|
||||
await this.templateWorkspace.getEffectiveTemplateKey(brandId),
|
||||
);
|
||||
if (!template?.capabilities.includes(key as never) && !(key in capabilityPlugins))
|
||||
throw new BadRequestException("能力未被当前模板声明");
|
||||
const existing = await this.prisma.capabilityInstallation.findUnique({
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
IsObject,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MinLength,
|
||||
Matches,
|
||||
Max,
|
||||
Min,
|
||||
@@ -26,6 +27,34 @@ export class UpdateBrandDto {
|
||||
@IsOptional() @IsObject() config?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class UpdateBrandPresentationDto {
|
||||
@IsOptional() @IsObject() identity?: Record<string, unknown>;
|
||||
@IsOptional() @IsObject() home?: Record<string, unknown>;
|
||||
@IsOptional() @IsObject() offerings?: Record<string, unknown>;
|
||||
@IsOptional() @IsObject() detail?: Record<string, unknown>;
|
||||
@IsOptional() @IsObject() profile?: Record<string, unknown>;
|
||||
@IsOptional() @IsObject() inquiry?: Record<string, unknown>;
|
||||
@IsOptional() @IsObject() success?: Record<string, unknown>;
|
||||
@IsOptional() @IsObject() records?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class UpdateBrandMemberDto {
|
||||
@IsOptional() @IsIn(["owner", "editor"]) role?: "owner" | "editor";
|
||||
@IsOptional() @IsBoolean() isEnabled?: boolean;
|
||||
}
|
||||
|
||||
export class CreateBrandMemberDto {
|
||||
@IsString() username!: string;
|
||||
@IsString() displayName!: string;
|
||||
@IsString() @MinLength(8) password!: string;
|
||||
@IsIn(["owner", "editor"]) role!: "owner" | "editor";
|
||||
}
|
||||
|
||||
export class ChangeAdminPasswordDto {
|
||||
@IsString() currentPassword!: string;
|
||||
@IsString() @MinLength(8) newPassword!: string;
|
||||
}
|
||||
|
||||
export class CreateTrustContentDto {
|
||||
@IsIn(["profile", "experience", "credential", "portfolio", "process", "testimonial"])
|
||||
type!: string;
|
||||
|
||||
@@ -16,6 +16,9 @@ import { CustomerInquirySubmissionController } from "./modules/customer/customer
|
||||
import { TemplateWorkspaceService } from "./template-workspace.service.js";
|
||||
import { AdminAccessService } from "./admin-access.service.js";
|
||||
import { AdminMembershipGuard } from "./admin-membership.guard.js";
|
||||
import { BrandReleaseService } from "./brand-release.service.js";
|
||||
import { BrandReleaseApiService } from "./brand-release-api.service.js";
|
||||
import { AdminReleaseController } from "./modules/admin/admin-release.controller.js";
|
||||
import {
|
||||
CustomerSessionController,
|
||||
AdminSessionController,
|
||||
@@ -54,6 +57,7 @@ export class HealthController {
|
||||
TenantController,
|
||||
AdminBookingController,
|
||||
AdminConfigController,
|
||||
AdminReleaseController,
|
||||
],
|
||||
providers: [
|
||||
PrismaService,
|
||||
@@ -63,6 +67,8 @@ export class HealthController {
|
||||
TemplateWorkspaceService,
|
||||
AdminAccessService,
|
||||
AdminMembershipGuard,
|
||||
BrandReleaseService,
|
||||
BrandReleaseApiService,
|
||||
PublicBrandContextService,
|
||||
],
|
||||
exports: [PrismaService, WechatAuthService],
|
||||
|
||||
@@ -2,6 +2,7 @@ import { BadRequestException, Injectable, NotFoundException } from "@nestjs/comm
|
||||
import { BookingStatus, Prisma } from "@prisma/client";
|
||||
import { PrismaService } from "./prisma.service.js";
|
||||
import { canTransitionWorkflow, workflowRegistry } from "@personal-brand/config";
|
||||
import { BrandReleaseService } from "./brand-release.service.js";
|
||||
|
||||
const BASIC_BOOKING_WORKFLOW = workflowRegistry["booking.basic"];
|
||||
|
||||
@@ -23,9 +24,32 @@ export interface CreateBookingInput {
|
||||
|
||||
@Injectable()
|
||||
export class BookingService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly releases: BrandReleaseService,
|
||||
) {}
|
||||
|
||||
async create(brandId: string, customerUserId: string, input: CreateBookingInput) {
|
||||
const snapshot = await this.releases.getPublishedSnapshot(brandId);
|
||||
if (!snapshot) throw new BadRequestException("品牌尚未发布");
|
||||
const publishedOfferingIds = this.releases.publishedOfferingIds(snapshot);
|
||||
if (
|
||||
(input.offeringId && !publishedOfferingIds.has(input.offeringId)) ||
|
||||
input.items?.some((item) => !publishedOfferingIds.has(item.offeringId))
|
||||
) {
|
||||
throw new BadRequestException("业务提供项不存在或暂不可预订");
|
||||
}
|
||||
const requestedOfferingIds = [
|
||||
...(input.offeringId ? [input.offeringId] : []),
|
||||
...(input.items ?? []).map((item) => item.offeringId),
|
||||
];
|
||||
if (requestedOfferingIds.length) {
|
||||
const enabledCount = await this.prisma.offering.count({
|
||||
where: { id: { in: requestedOfferingIds }, brandId, isEnabled: true },
|
||||
});
|
||||
if (enabledCount !== new Set(requestedOfferingIds).size)
|
||||
throw new BadRequestException("业务提供项不存在或暂不可预订");
|
||||
}
|
||||
if (!input.customerName.trim() || (!input.phone?.trim() && !input.wechatId?.trim())) {
|
||||
throw new BadRequestException("称呼和至少一种联系方式为必填项");
|
||||
}
|
||||
@@ -52,23 +76,22 @@ export class BookingService {
|
||||
) {
|
||||
throw new BadRequestException("私厨需求必须填写日期、人数和地点");
|
||||
}
|
||||
const offerings = input.items?.length
|
||||
? await this.prisma.offering.findMany({
|
||||
where: {
|
||||
id: { in: input.items.map((item) => item.offeringId) },
|
||||
brandId,
|
||||
isEnabled: true,
|
||||
},
|
||||
})
|
||||
: [];
|
||||
const offeringMap = new Map(offerings.map((offering) => [offering.id, offering]));
|
||||
const offeringMap = new Map(
|
||||
snapshot.offerings.flatMap((raw) => {
|
||||
if (!raw || typeof raw !== "object") return [];
|
||||
const item = raw as Record<string, unknown>;
|
||||
return typeof item.id === "string" && item.isEnabled === true
|
||||
? [[item.id, item] as const]
|
||||
: [];
|
||||
}),
|
||||
);
|
||||
const items = (input.items ?? []).map((item) => {
|
||||
const offering = offeringMap.get(item.offeringId);
|
||||
if (!offering || offering.priceAmount === null)
|
||||
if (!offering || typeof offering.priceAmount !== "number")
|
||||
throw new BadRequestException("套餐不存在或暂不可预订");
|
||||
return {
|
||||
offeringId: offering.id,
|
||||
serviceNameSnapshot: offering.name,
|
||||
offeringId: item.offeringId,
|
||||
serviceNameSnapshot: String(offering.name),
|
||||
unitPriceSnapshot: offering.priceAmount,
|
||||
quantity: item.quantity,
|
||||
subtotalSnapshot: offering.priceAmount * item.quantity,
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
ConflictException,
|
||||
Injectable,
|
||||
NotFoundException,
|
||||
} from "@nestjs/common";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import {
|
||||
getBrandTemplate,
|
||||
getVisualTemplate,
|
||||
isVisualTemplateCompatible,
|
||||
getDefaultVisualTemplateKey,
|
||||
} from "@personal-brand/config";
|
||||
import { PrismaService } from "./prisma.service.js";
|
||||
import { BrandReleaseService } from "./brand-release.service.js";
|
||||
import { validateFieldSnapshot } from "@personal-brand/validation";
|
||||
|
||||
@Injectable()
|
||||
export class BrandReleaseApiService {
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly snapshots: BrandReleaseService,
|
||||
) {}
|
||||
|
||||
async list(brandId: string): Promise<unknown[]> {
|
||||
return this.prisma.brandRelease.findMany({
|
||||
where: { brandId },
|
||||
orderBy: { version: "desc" },
|
||||
select: {
|
||||
id: true,
|
||||
version: true,
|
||||
status: true,
|
||||
note: true,
|
||||
actorId: true,
|
||||
createdAt: true,
|
||||
revokedAt: true,
|
||||
revokedBy: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async readiness(
|
||||
brandId: string,
|
||||
database: Prisma.TransactionClient = this.prisma,
|
||||
): Promise<{
|
||||
ready: boolean;
|
||||
checks: Array<{ key: string; label: string; passed: boolean }>;
|
||||
}> {
|
||||
const brand = await database.brandProfile.findUnique({
|
||||
where: { id: brandId },
|
||||
select: { name: true, tagline: true, description: true, templateKey: true, config: true },
|
||||
});
|
||||
const installation = await database.brandTemplateInstallation.findFirst({
|
||||
where: { brandId },
|
||||
orderBy: { updatedAt: "desc" },
|
||||
});
|
||||
const template = getBrandTemplate(installation?.templateKey ?? brand?.templateKey ?? "");
|
||||
const config = this.jsonObject(brand?.config);
|
||||
const visualKey =
|
||||
typeof config.visualTemplateKey === "string"
|
||||
? config.visualTemplateKey
|
||||
: getDefaultVisualTemplateKey(brand?.templateKey ?? "personal");
|
||||
const visual = getVisualTemplate(visualKey);
|
||||
const [offerings, forms, trust] = await Promise.all([
|
||||
database.offering.findMany({ where: { brandId, isEnabled: true }, select: { id: true } }),
|
||||
database.inquiryForm.findMany({
|
||||
where: { brandId, isEnabled: true },
|
||||
select: { offeringId: true, fieldsSnapshot: true },
|
||||
}),
|
||||
database.trustContent.count({ where: { brandId, isPublished: true } }),
|
||||
]);
|
||||
const offeringIds = new Set(offerings.map((item) => item.id));
|
||||
const usableForms = forms.filter(
|
||||
(form) =>
|
||||
(form.offeringId === null || offeringIds.has(form.offeringId)) &&
|
||||
Array.isArray(form.fieldsSnapshot) &&
|
||||
form.fieldsSnapshot.length > 0 &&
|
||||
validateFieldSnapshot(form.fieldsSnapshot).length === 0,
|
||||
);
|
||||
const checks = [
|
||||
{ key: "brand", label: "请先完善品牌名称", passed: Boolean(brand?.name.trim()) },
|
||||
{
|
||||
key: "positioning",
|
||||
label: "请先完善品牌定位和介绍",
|
||||
passed: Boolean(brand?.tagline?.trim() && brand.description?.trim()),
|
||||
},
|
||||
{ key: "template", label: "当前行业模板不存在", passed: Boolean(template) },
|
||||
{
|
||||
key: "visual",
|
||||
label: "当前视觉模板不适配行业模板",
|
||||
passed: Boolean(visual && template && isVisualTemplateCompatible(visual, template.key)),
|
||||
},
|
||||
{ key: "offerings", label: "至少需要一项已启用的业务提供项", passed: offerings.length > 0 },
|
||||
{ key: "forms", label: "至少需要一个可用的咨询表单", passed: usableForms.length > 0 },
|
||||
{ key: "trust", label: "至少需要一条已发布的信任内容", passed: trust > 0 },
|
||||
];
|
||||
return { ready: checks.every((check) => check.passed), checks };
|
||||
}
|
||||
|
||||
async publish(brandId: string, actorId: string, note?: string): Promise<unknown> {
|
||||
return this.withVersionRetry(() =>
|
||||
this.prisma.$transaction(
|
||||
async (tx) => {
|
||||
await this.validateForPublish(brandId, tx);
|
||||
const snapshot = await this.snapshots.buildSnapshot(brandId, tx);
|
||||
const latest = await tx.brandRelease.findFirst({
|
||||
where: { brandId },
|
||||
orderBy: { version: "desc" },
|
||||
select: { version: true },
|
||||
});
|
||||
await tx.brandRelease.updateMany({
|
||||
where: { brandId, status: "published" },
|
||||
data: { status: "superseded" },
|
||||
});
|
||||
return tx.brandRelease.create({
|
||||
data: {
|
||||
brandId,
|
||||
version: (latest?.version ?? 0) + 1,
|
||||
status: "published",
|
||||
snapshot: this.snapshots.toPrismaJson(snapshot),
|
||||
actorId,
|
||||
...(note === undefined ? {} : { note }),
|
||||
},
|
||||
});
|
||||
},
|
||||
{ isolationLevel: Prisma.TransactionIsolationLevel.Serializable },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async rollback(
|
||||
brandId: string,
|
||||
actorId: string,
|
||||
version: number,
|
||||
note?: string,
|
||||
): Promise<unknown> {
|
||||
return this.withVersionRetry(() =>
|
||||
this.prisma.$transaction(
|
||||
async (tx) => {
|
||||
const source = await tx.brandRelease.findFirst({
|
||||
where: { brandId, version, status: { in: ["published", "superseded"] } },
|
||||
});
|
||||
if (!source) throw new NotFoundException("发布版本不存在");
|
||||
const snapshot = this.withCurrentTimestamp(source.snapshot);
|
||||
const latest = await tx.brandRelease.findFirst({
|
||||
where: { brandId },
|
||||
orderBy: { version: "desc" },
|
||||
select: { version: true },
|
||||
});
|
||||
await tx.brandRelease.updateMany({
|
||||
where: { brandId, status: "published" },
|
||||
data: { status: "superseded" },
|
||||
});
|
||||
return tx.brandRelease.create({
|
||||
data: {
|
||||
brandId,
|
||||
version: (latest?.version ?? 0) + 1,
|
||||
status: "published",
|
||||
snapshot,
|
||||
actorId,
|
||||
note: note ?? `回滚自版本 ${version}`,
|
||||
},
|
||||
});
|
||||
},
|
||||
{ isolationLevel: Prisma.TransactionIsolationLevel.Serializable },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async revoke(brandId: string, actorId: string): Promise<unknown> {
|
||||
return this.withVersionRetry(() =>
|
||||
this.prisma.$transaction(
|
||||
async (tx) => {
|
||||
const current = await tx.brandRelease.findFirst({
|
||||
where: { brandId, status: "published" },
|
||||
orderBy: { version: "desc" },
|
||||
});
|
||||
if (!current) throw new NotFoundException("当前没有已发布版本");
|
||||
return tx.brandRelease.update({
|
||||
where: { id: current.id },
|
||||
data: { status: "revoked", revokedAt: new Date(), revokedBy: actorId },
|
||||
select: { id: true, version: true, status: true, revokedAt: true, revokedBy: true },
|
||||
});
|
||||
},
|
||||
{ isolationLevel: Prisma.TransactionIsolationLevel.Serializable },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
private async validateForPublish(
|
||||
brandId: string,
|
||||
database: Prisma.TransactionClient,
|
||||
): Promise<void> {
|
||||
const readiness = await this.readiness(brandId, database);
|
||||
const missing = readiness.checks.find((check) => !check.passed);
|
||||
if (missing) throw new BadRequestException(missing.label);
|
||||
}
|
||||
|
||||
private async withVersionRetry<T>(operation: () => Promise<T>): Promise<T> {
|
||||
for (let attempt = 0; attempt < 3; attempt += 1) {
|
||||
try {
|
||||
return await operation();
|
||||
} catch (error) {
|
||||
if (
|
||||
!(error instanceof Prisma.PrismaClientKnownRequestError) ||
|
||||
!["P2002", "P2034"].includes(error.code)
|
||||
)
|
||||
throw error;
|
||||
if (attempt === 2) throw new ConflictException("发布版本冲突,请重试");
|
||||
}
|
||||
}
|
||||
throw new ConflictException("发布版本冲突,请重试");
|
||||
}
|
||||
|
||||
private jsonObject(value: unknown): Record<string, unknown> {
|
||||
return value && typeof value === "object" && !Array.isArray(value)
|
||||
? (value as Record<string, unknown>)
|
||||
: {};
|
||||
}
|
||||
|
||||
private withCurrentTimestamp(value: Prisma.JsonValue): Prisma.InputJsonValue {
|
||||
const snapshot = this.jsonObject(value);
|
||||
return { ...snapshot, generatedAt: new Date().toISOString() };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import {
|
||||
getBrandTemplate,
|
||||
getVisualTemplate,
|
||||
getVisualTemplateManifest,
|
||||
getDefaultVisualTemplateKey,
|
||||
} from "@personal-brand/config";
|
||||
import { PrismaService } from "./prisma.service.js";
|
||||
|
||||
export interface BrandReleaseSnapshot {
|
||||
schemaVersion: "1.0.0";
|
||||
generatedAt: string;
|
||||
templateKey: string;
|
||||
templateDefinition?: ReturnType<typeof getBrandTemplate> | null;
|
||||
visualTemplateDefinition?: ReturnType<typeof getVisualTemplate> | null;
|
||||
visualTemplateManifest?: ReturnType<typeof getVisualTemplateManifest> | null;
|
||||
brand: Record<string, unknown> | null;
|
||||
installation: Record<string, unknown> | null;
|
||||
modules: unknown[];
|
||||
fields: unknown[];
|
||||
offerings: unknown[];
|
||||
forms: unknown[];
|
||||
trustContents: unknown[];
|
||||
capabilities: unknown[];
|
||||
}
|
||||
|
||||
export async function buildBrandReleaseSnapshot(
|
||||
database: Prisma.TransactionClient,
|
||||
brandId: string,
|
||||
): Promise<BrandReleaseSnapshot> {
|
||||
const [brand, installation, modules, fields, offerings, forms, trustContents, capabilities] =
|
||||
await Promise.all([
|
||||
database.brandProfile.findUnique({ where: { id: brandId } }),
|
||||
database.brandTemplateInstallation.findFirst({
|
||||
where: { brandId },
|
||||
orderBy: { updatedAt: "desc" },
|
||||
}),
|
||||
database.brandModule.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
||||
database.brandFieldDefinition.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
||||
database.offering.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
||||
database.inquiryForm.findMany({ where: { brandId }, orderBy: { updatedAt: "desc" } }),
|
||||
database.trustContent.findMany({ where: { brandId }, orderBy: { sortOrder: "asc" } }),
|
||||
database.capabilityInstallation.findMany({ where: { brandId } }),
|
||||
]);
|
||||
const templateKey = installation?.templateKey ?? brand?.templateKey ?? "personal";
|
||||
const config =
|
||||
brand?.config && typeof brand.config === "object" && !Array.isArray(brand.config)
|
||||
? (brand.config as Record<string, unknown>)
|
||||
: {};
|
||||
const visualKey =
|
||||
typeof config.visualTemplateKey === "string"
|
||||
? config.visualTemplateKey
|
||||
: getDefaultVisualTemplateKey(brand?.templateKey ?? "personal");
|
||||
const jsonObject = (value: object): Record<string, unknown> =>
|
||||
JSON.parse(JSON.stringify(value)) as Record<string, unknown>;
|
||||
return {
|
||||
schemaVersion: "1.0.0",
|
||||
generatedAt: new Date().toISOString(),
|
||||
templateKey,
|
||||
templateDefinition: getBrandTemplate(templateKey) ?? null,
|
||||
visualTemplateDefinition: getVisualTemplate(visualKey) ?? null,
|
||||
visualTemplateManifest: getVisualTemplateManifest(visualKey) ?? null,
|
||||
brand: brand ? jsonObject(brand) : null,
|
||||
installation: installation ? jsonObject(installation) : null,
|
||||
modules: modules.map((item) => jsonObject(item)),
|
||||
fields: fields.map((item) => jsonObject(item)),
|
||||
offerings: offerings.map((item) => jsonObject(item)),
|
||||
forms: forms.map((item) => jsonObject(item)),
|
||||
trustContents: trustContents.map((item) => jsonObject(item)),
|
||||
capabilities: capabilities.map((item) => jsonObject(item)),
|
||||
};
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class BrandReleaseService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async getPublishedSnapshot(brandId: string): Promise<BrandReleaseSnapshot | null> {
|
||||
const release = await this.prisma.brandRelease.findFirst({
|
||||
where: { brandId, status: "published" },
|
||||
orderBy: { version: "desc" },
|
||||
select: { snapshot: true },
|
||||
});
|
||||
return release ? (release.snapshot as unknown as BrandReleaseSnapshot) : null;
|
||||
}
|
||||
|
||||
publishedOfferingIds(snapshot: BrandReleaseSnapshot): Set<string> {
|
||||
return new Set(
|
||||
snapshot.offerings.flatMap((raw) => {
|
||||
const item = this.record(raw);
|
||||
return item.isEnabled === true && typeof item.id === "string" ? [item.id] : [];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
publishedForm(snapshot: BrandReleaseSnapshot, formId: string): Record<string, unknown> | null {
|
||||
const offeringIds = this.publishedOfferingIds(snapshot);
|
||||
return (
|
||||
snapshot.forms
|
||||
.map((raw) => this.record(raw))
|
||||
.find((form) => {
|
||||
return (
|
||||
form.id === formId &&
|
||||
form.isEnabled === true &&
|
||||
(form.offeringId === null ||
|
||||
(typeof form.offeringId === "string" && offeringIds.has(form.offeringId)))
|
||||
);
|
||||
}) ?? null
|
||||
);
|
||||
}
|
||||
|
||||
private record(value: unknown): Record<string, unknown> {
|
||||
return value && typeof value === "object" && !Array.isArray(value)
|
||||
? (value as Record<string, unknown>)
|
||||
: {};
|
||||
}
|
||||
|
||||
async buildSnapshot(
|
||||
brandId: string,
|
||||
database: Prisma.TransactionClient = this.prisma,
|
||||
): Promise<BrandReleaseSnapshot> {
|
||||
return buildBrandReleaseSnapshot(database, brandId);
|
||||
}
|
||||
|
||||
toPrismaJson(snapshot: BrandReleaseSnapshot): Prisma.InputJsonValue {
|
||||
return snapshot as unknown as Prisma.InputJsonValue;
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,29 @@ import { Prisma } from "@prisma/client";
|
||||
import type { FastifyRequest } from "fastify";
|
||||
import { PrismaService } from "../../prisma.service.js";
|
||||
import { readIdentity } from "../../auth.js";
|
||||
import { CreateTrustContentDto, UpdateBrandDto, UpdateTrustContentDto } from "../../admin.dto.js";
|
||||
import { getVisualTemplate } from "@personal-brand/config";
|
||||
import {
|
||||
CreateTrustContentDto,
|
||||
UpdateBrandDto,
|
||||
UpdateBrandPresentationDto,
|
||||
UpdateTrustContentDto,
|
||||
} from "../../admin.dto.js";
|
||||
import {
|
||||
getBrandTemplate,
|
||||
getVisualTemplate,
|
||||
isVisualTemplateCompatible,
|
||||
listVisualTemplateKeys,
|
||||
getDefaultVisualTemplateKey,
|
||||
} from "@personal-brand/config";
|
||||
import { AdminAccessService } from "../../admin-access.service.js";
|
||||
import { TemplateWorkspaceService } from "../../template-workspace.service.js";
|
||||
|
||||
@Controller("admin/config")
|
||||
export class AdminConfigController {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly access: AdminAccessService,
|
||||
private readonly templateWorkspace: TemplateWorkspaceService,
|
||||
) {}
|
||||
private brandId(request?: FastifyRequest): string {
|
||||
if (!request) return process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001";
|
||||
const token = request.headers.authorization?.replace(/^Bearer\s+/i, "");
|
||||
@@ -52,6 +69,9 @@ export class AdminConfigController {
|
||||
): Promise<unknown> {
|
||||
this.requireAdmin(request);
|
||||
const { config, ...fields } = body;
|
||||
if (config?.visualTemplateKey !== undefined) {
|
||||
await this.access.requireRole(request, ["owner", "admin", "platform-admin"]);
|
||||
}
|
||||
const current = await this.prisma.brandProfile.findUnique({
|
||||
where: { id: this.brandId(request) },
|
||||
select: { config: true },
|
||||
@@ -62,6 +82,19 @@ export class AdminConfigController {
|
||||
: {};
|
||||
const nextConfig = config ? { ...currentConfig, ...config } : undefined;
|
||||
if (config?.visualTemplateKey && config.visualTemplateKey !== currentConfig.visualTemplateKey) {
|
||||
const templateKey = await this.templateWorkspace.getEffectiveTemplateKey(
|
||||
this.brandId(request),
|
||||
);
|
||||
const visualTemplate =
|
||||
typeof config.visualTemplateKey === "string"
|
||||
? getVisualTemplate(config.visualTemplateKey)
|
||||
: undefined;
|
||||
if (
|
||||
!visualTemplate ||
|
||||
!getBrandTemplate(templateKey) ||
|
||||
!isVisualTemplateCompatible(visualTemplate, templateKey)
|
||||
)
|
||||
throw new BadRequestException("当前视觉模板不适配该行业模板");
|
||||
const installation = await this.prisma.brandTemplateInstallation.findFirst({
|
||||
where: { brandId: this.brandId(request) },
|
||||
});
|
||||
@@ -75,7 +108,8 @@ export class AdminConfigController {
|
||||
previousSnapshots: [
|
||||
...history,
|
||||
{
|
||||
visualTemplateKey: currentConfig.visualTemplateKey ?? "linjing-editorial",
|
||||
visualTemplateKey:
|
||||
currentConfig.visualTemplateKey ?? getDefaultVisualTemplateKey(templateKey),
|
||||
savedAt: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
@@ -91,6 +125,74 @@ export class AdminConfigController {
|
||||
},
|
||||
});
|
||||
}
|
||||
@Patch("presentation")
|
||||
async updatePresentation(
|
||||
@Req() request: FastifyRequest,
|
||||
@Body() body: UpdateBrandPresentationDto,
|
||||
): Promise<unknown> {
|
||||
this.requireAdmin(request);
|
||||
const brandId = this.brandId(request);
|
||||
const brand = await this.prisma.brandProfile.findUnique({
|
||||
where: { id: brandId },
|
||||
select: { config: true },
|
||||
});
|
||||
const config =
|
||||
brand?.config && typeof brand.config === "object" && !Array.isArray(brand.config)
|
||||
? (brand.config as Record<string, unknown>)
|
||||
: {};
|
||||
const previous =
|
||||
config.visualPresentation &&
|
||||
typeof config.visualPresentation === "object" &&
|
||||
!Array.isArray(config.visualPresentation)
|
||||
? (config.visualPresentation as Record<string, unknown>)
|
||||
: {};
|
||||
const nextPresentation = { ...previous };
|
||||
const identity = body.identity;
|
||||
const identityFields = ["founder", "title", "slogan", "phone", "wechat", "studioAddress"];
|
||||
const nextIdentity = identity
|
||||
? Object.fromEntries(
|
||||
identityFields
|
||||
.filter((key) => typeof identity[key] === "string")
|
||||
.map((key) => [key, identity[key]]),
|
||||
)
|
||||
: {};
|
||||
for (const section of [
|
||||
"home",
|
||||
"offerings",
|
||||
"detail",
|
||||
"profile",
|
||||
"inquiry",
|
||||
"success",
|
||||
"records",
|
||||
] as const) {
|
||||
const input = body[section];
|
||||
if (!input) continue;
|
||||
const current =
|
||||
previous[section] &&
|
||||
typeof previous[section] === "object" &&
|
||||
!Array.isArray(previous[section])
|
||||
? (previous[section] as Record<string, unknown>)
|
||||
: {};
|
||||
const values = Object.fromEntries(
|
||||
Object.entries(input).filter(([, value]) => typeof value === "string"),
|
||||
);
|
||||
nextPresentation[section] = { ...current, ...values };
|
||||
}
|
||||
const updated = await this.prisma.brandProfile.update({
|
||||
where: { id: brandId },
|
||||
data: {
|
||||
config: {
|
||||
...config,
|
||||
...nextIdentity,
|
||||
visualPresentation: nextPresentation,
|
||||
} as Prisma.InputJsonValue,
|
||||
},
|
||||
select: { config: true },
|
||||
});
|
||||
return {
|
||||
visualPresentation: (updated.config as Record<string, unknown>).visualPresentation,
|
||||
};
|
||||
}
|
||||
@Get("visual-template/history")
|
||||
getVisualTemplateHistory(@Req() request: FastifyRequest): unknown {
|
||||
this.requireAdmin(request);
|
||||
@@ -169,7 +271,7 @@ export class AdminConfigController {
|
||||
typeof config.visualTemplateKey === "string"
|
||||
? config.visualTemplateKey
|
||||
: "linjing-editorial";
|
||||
const current = getVisualTemplate(currentKey) ?? getVisualTemplate("linjing-editorial");
|
||||
const current = getVisualTemplate(currentKey);
|
||||
return {
|
||||
current: current
|
||||
? {
|
||||
@@ -180,7 +282,7 @@ export class AdminConfigController {
|
||||
variants: current.variants,
|
||||
}
|
||||
: null,
|
||||
available: ["linjing-editorial", "minimal-neutral"],
|
||||
available: listVisualTemplateKeys(),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { Controller, Get, Param, ParseIntPipe, Post, Body, Req } from "@nestjs/common";
|
||||
import type { FastifyRequest } from "fastify";
|
||||
import { AdminAccessService } from "../../admin-access.service.js";
|
||||
import { BrandReleaseApiService } from "../../brand-release-api.service.js";
|
||||
import { PublishBrandReleaseDto } from "../../release.dto.js";
|
||||
|
||||
@Controller("admin/releases")
|
||||
export class AdminReleaseController {
|
||||
constructor(
|
||||
private readonly access: AdminAccessService,
|
||||
private readonly releases: BrandReleaseApiService,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
async list(@Req() request: FastifyRequest): Promise<unknown[]> {
|
||||
const identity = await this.requireBrand(request);
|
||||
return this.releases.list(identity.brandId);
|
||||
}
|
||||
|
||||
@Get("readiness")
|
||||
async readiness(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
const identity = await this.requireBrand(request);
|
||||
return this.releases.readiness(identity.brandId);
|
||||
}
|
||||
|
||||
@Post("publish")
|
||||
async publish(
|
||||
@Req() request: FastifyRequest,
|
||||
@Body() body: PublishBrandReleaseDto,
|
||||
): Promise<unknown> {
|
||||
const identity = await this.requireBrand(request);
|
||||
return this.releases.publish(identity.brandId, identity.subject, body.note);
|
||||
}
|
||||
|
||||
@Post(":version/rollback")
|
||||
async rollback(
|
||||
@Req() request: FastifyRequest,
|
||||
@Param("version", ParseIntPipe) version: number,
|
||||
@Body() body: PublishBrandReleaseDto,
|
||||
): Promise<unknown> {
|
||||
const identity = await this.requireBrand(request);
|
||||
return this.releases.rollback(identity.brandId, identity.subject, version, body.note);
|
||||
}
|
||||
|
||||
@Post("revoke")
|
||||
async revoke(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
const identity = await this.requireBrand(request);
|
||||
return this.releases.revoke(identity.brandId, identity.subject);
|
||||
}
|
||||
|
||||
private requireBrand(request: FastifyRequest): Promise<{ subject: string; brandId: string }> {
|
||||
return this.access.requireBrand(request);
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,14 @@ import type { FastifyRequest } from "fastify";
|
||||
import { PrismaService } from "../../prisma.service.js";
|
||||
import { readIdentity } from "../../auth.js";
|
||||
import { CreateInquirySubmissionDto } from "../../booking.dto.js";
|
||||
import { BrandReleaseService } from "../../brand-release.service.js";
|
||||
|
||||
@Controller("customer/inquiry-submissions")
|
||||
export class CustomerInquirySubmissionController {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly releases: BrandReleaseService,
|
||||
) {}
|
||||
private present<T extends { customerSubject: string; adminNote?: string | null }>(submission: T) {
|
||||
const {
|
||||
customerSubject: _customerSubject,
|
||||
@@ -84,16 +88,27 @@ export class CustomerInquirySubmissionController {
|
||||
@Body() body: CreateInquirySubmissionDto,
|
||||
): Promise<unknown> {
|
||||
const identity = this.identity(request);
|
||||
const snapshot = await this.releases.getPublishedSnapshot(identity.brandId);
|
||||
const publishedForm = snapshot && this.releases.publishedForm(snapshot, body.formId);
|
||||
if (!publishedForm) throw new BadRequestException("咨询表单不存在或品牌尚未发布");
|
||||
const form = await this.prisma.inquiryForm.findFirst({
|
||||
where: {
|
||||
id: body.formId,
|
||||
brandId: identity.brandId,
|
||||
isEnabled: true,
|
||||
OR: [{ offeringId: null }, { offering: { isEnabled: true } }],
|
||||
},
|
||||
});
|
||||
if (!form) throw new BadRequestException("咨询表单不存在");
|
||||
const capabilityKey = form.purpose === "quote-request" ? "quote-request" : "inquiry";
|
||||
const offeringId =
|
||||
typeof publishedForm.offeringId === "string" ? publishedForm.offeringId : null;
|
||||
if (offeringId) {
|
||||
const offering = await this.prisma.offering.findFirst({
|
||||
where: { id: offeringId, brandId: identity.brandId, isEnabled: true },
|
||||
select: { id: true },
|
||||
});
|
||||
if (!offering) throw new BadRequestException("当前业务提供项不可用");
|
||||
}
|
||||
const capabilityKey = publishedForm.purpose === "quote-request" ? "quote-request" : "inquiry";
|
||||
const capability = await this.prisma.capabilityInstallation.findUnique({
|
||||
where: {
|
||||
brandId_capabilityKey: { brandId: identity.brandId, capabilityKey },
|
||||
@@ -101,8 +116,8 @@ export class CustomerInquirySubmissionController {
|
||||
});
|
||||
if (capability && capability.status !== "enabled")
|
||||
throw new BadRequestException("当前咨询能力不可用");
|
||||
const fields = Array.isArray(form.fieldsSnapshot)
|
||||
? (form.fieldsSnapshot as Array<Record<string, unknown>>)
|
||||
const fields = Array.isArray(publishedForm.fieldsSnapshot)
|
||||
? (publishedForm.fieldsSnapshot as Array<Record<string, unknown>>)
|
||||
: [];
|
||||
for (const field of fields) {
|
||||
const key = typeof field.key === "string" ? field.key : "";
|
||||
@@ -126,9 +141,9 @@ export class CustomerInquirySubmissionController {
|
||||
brandId: identity.brandId,
|
||||
customerSubject: identity.subject,
|
||||
inquiryFormId: form.id,
|
||||
offeringId: form.offeringId,
|
||||
formVersion: form.version,
|
||||
fieldsSnapshot: form.fieldsSnapshot as Prisma.InputJsonValue,
|
||||
offeringId,
|
||||
formVersion: Number(publishedForm.version),
|
||||
fieldsSnapshot: publishedForm.fieldsSnapshot as Prisma.InputJsonValue,
|
||||
values: values as Prisma.InputJsonValue,
|
||||
activeFields: Object.fromEntries(Object.keys(values).map((key) => [key, true])),
|
||||
},
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
import { BadRequestException, Controller, Get, Param, Query } from "@nestjs/common";
|
||||
import { PrismaService } from "../../prisma.service.js";
|
||||
import { PublicBrandContextService } from "./public-brand-context.service.js";
|
||||
import { BrandReleaseService } from "../../brand-release.service.js";
|
||||
|
||||
@Controller("public/inquiry-forms")
|
||||
export class PublicInquiryFormController {
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly releases: BrandReleaseService,
|
||||
private readonly brandContext: PublicBrandContextService,
|
||||
) {}
|
||||
@Get(":id")
|
||||
async get(@Param("id") id: string, @Query("brandSlug") brandSlug?: string): Promise<unknown> {
|
||||
const form = await this.prisma.inquiryForm.findFirst({
|
||||
where: {
|
||||
id,
|
||||
brandId: await this.brandContext.resolveId(brandSlug),
|
||||
isEnabled: true,
|
||||
OR: [{ offeringId: null }, { offering: { isEnabled: true } }],
|
||||
},
|
||||
});
|
||||
const snapshot = await this.releases.getPublishedSnapshot(
|
||||
await this.brandContext.resolveId(brandSlug),
|
||||
);
|
||||
const form = snapshot && this.releases.publishedForm(snapshot, id);
|
||||
if (!form) throw new BadRequestException("咨询表单不存在");
|
||||
return form;
|
||||
}
|
||||
|
||||
@@ -1,51 +1,52 @@
|
||||
import { BadRequestException, Controller, Get, Param, Query } from "@nestjs/common";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { PrismaService } from "../../prisma.service.js";
|
||||
import { PublicBrandContextService } from "./public-brand-context.service.js";
|
||||
import { BrandReleaseService } from "../../brand-release.service.js";
|
||||
|
||||
@Controller("public/offerings")
|
||||
export class PublicOfferingController {
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly releases: BrandReleaseService,
|
||||
private readonly brandContext: PublicBrandContextService,
|
||||
) {}
|
||||
@Get()
|
||||
async list(@Query("brandSlug") brandSlug?: string): Promise<unknown> {
|
||||
const brandId = await this.brandContext.resolveId(brandSlug);
|
||||
const items = await this.prisma.offering.findMany({
|
||||
where: { brandId, isEnabled: true },
|
||||
orderBy: { sortOrder: "asc" },
|
||||
include: {
|
||||
inquiryForms: {
|
||||
where: { isEnabled: true },
|
||||
orderBy: { updatedAt: "desc" },
|
||||
select: { id: true, name: true, purpose: true, targetType: true, version: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
return items.map((item) => this.present(item));
|
||||
const snapshot = await this.releases.getPublishedSnapshot(brandId);
|
||||
const forms = snapshot?.forms ?? [];
|
||||
return (snapshot?.offerings ?? [])
|
||||
.filter((raw) => this.object(raw).isEnabled === true)
|
||||
.map((raw) => this.object(raw))
|
||||
.sort((a, b) => Number(a.sortOrder ?? 0) - Number(b.sortOrder ?? 0))
|
||||
.map((item) =>
|
||||
this.present({
|
||||
...item,
|
||||
inquiryForms: forms.filter((raw) => {
|
||||
const form = this.object(raw);
|
||||
return form.offeringId === item.id && form.isEnabled === true;
|
||||
}),
|
||||
}),
|
||||
);
|
||||
}
|
||||
@Get(":id")
|
||||
async get(@Param("id") id: string, @Query("brandSlug") brandSlug?: string): Promise<unknown> {
|
||||
const brandId = await this.brandContext.resolveId(brandSlug);
|
||||
const item = await this.prisma.offering.findFirst({
|
||||
where: {
|
||||
id,
|
||||
brandId,
|
||||
isEnabled: true,
|
||||
},
|
||||
include: {
|
||||
inquiryForms: {
|
||||
where: { isEnabled: true },
|
||||
orderBy: { updatedAt: "desc" },
|
||||
select: { id: true, name: true, purpose: true, targetType: true, version: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
const snapshot = await this.releases.getPublishedSnapshot(brandId);
|
||||
const item = (snapshot?.offerings ?? [])
|
||||
.map((raw) => this.object(raw))
|
||||
.find((offering) => offering.id === id && offering.isEnabled === true);
|
||||
if (!item) throw new BadRequestException("业务提供项不存在");
|
||||
return this.present(item);
|
||||
const forms = (snapshot?.forms ?? []).filter((raw) => {
|
||||
const form = this.object(raw);
|
||||
return form.offeringId === id && form.isEnabled === true;
|
||||
});
|
||||
return this.present({ ...item, inquiryForms: forms });
|
||||
}
|
||||
private present(item: { config: Prisma.JsonValue; [key: string]: unknown }): unknown {
|
||||
private object(value: unknown): Record<string, unknown> {
|
||||
return value && typeof value === "object" && !Array.isArray(value)
|
||||
? (value as Record<string, unknown>)
|
||||
: {};
|
||||
}
|
||||
private present(item: { config?: unknown; [key: string]: unknown }): unknown {
|
||||
const config = (item.config ?? {}) as Record<string, unknown>;
|
||||
return {
|
||||
...item,
|
||||
|
||||
@@ -2,12 +2,14 @@ import { Controller, Get, Query } from "@nestjs/common";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { PrismaService } from "../../prisma.service.js";
|
||||
import { PublicBrandContextService } from "./public-brand-context.service.js";
|
||||
import type { BrandReleaseSnapshot } from "../../brand-release.service.js";
|
||||
import {
|
||||
getBrandTemplate,
|
||||
getVisualTemplate,
|
||||
getVisualTemplateManifest,
|
||||
resolveCapabilities,
|
||||
capabilityPlugins,
|
||||
getDefaultVisualTemplateKey,
|
||||
} from "@personal-brand/config";
|
||||
import type {
|
||||
RuntimeInquiryField,
|
||||
@@ -22,60 +24,77 @@ export class PublicWorkspaceController {
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly brandContext: PublicBrandContextService,
|
||||
) {}
|
||||
private readonly cache = new Map<string, { expiresAt: number; value: unknown }>();
|
||||
@Get()
|
||||
async get(@Query("brandSlug") brandSlug?: string): Promise<unknown> {
|
||||
const brandId = await this.brandContext.resolveId(brandSlug);
|
||||
const cached = process.env.NODE_ENV === "test" ? undefined : this.cache.get(brandId);
|
||||
if (cached && cached.expiresAt > Date.now()) return cached.value;
|
||||
const [
|
||||
brand,
|
||||
modules,
|
||||
fields,
|
||||
offerings,
|
||||
inquiryForms,
|
||||
installation,
|
||||
capabilityInstallations,
|
||||
trustContents,
|
||||
] = await Promise.all([
|
||||
this.prisma.brandProfile.findUnique({ where: { id: brandId } }),
|
||||
this.prisma.brandModule.findMany({
|
||||
where: { brandId, isEnabled: true },
|
||||
orderBy: { sortOrder: "asc" },
|
||||
}),
|
||||
this.prisma.brandFieldDefinition.findMany({
|
||||
where: { brandId, isVisible: true },
|
||||
orderBy: { sortOrder: "asc" },
|
||||
}),
|
||||
this.prisma.offering.findMany({
|
||||
where: { brandId, isEnabled: true },
|
||||
orderBy: { sortOrder: "asc" },
|
||||
}),
|
||||
this.prisma.inquiryForm.findMany({
|
||||
where: {
|
||||
brandId,
|
||||
isEnabled: true,
|
||||
OR: [{ offeringId: null }, { offering: { isEnabled: true } }],
|
||||
},
|
||||
orderBy: { updatedAt: "desc" },
|
||||
}),
|
||||
this.prisma.brandTemplateInstallation.findFirst({
|
||||
where: { brandId },
|
||||
orderBy: { updatedAt: "desc" },
|
||||
}),
|
||||
this.prisma.capabilityInstallation.findMany({ where: { brandId } }),
|
||||
this.prisma.trustContent.findMany({
|
||||
where: { brandId, isPublished: true },
|
||||
orderBy: { sortOrder: "asc" },
|
||||
}),
|
||||
]);
|
||||
const templateKey = installation?.templateKey ?? brand?.templateKey ?? "personal";
|
||||
const template = getBrandTemplate(templateKey);
|
||||
const runtimeCapabilities = capabilityInstallations.length
|
||||
? capabilityInstallations.map((item) => ({
|
||||
key: item.capabilityKey,
|
||||
version: item.capabilityVersion,
|
||||
status: item.status as "enabled" | "disabled" | "degraded",
|
||||
const release = await this.prisma.brandRelease.findFirst({
|
||||
where: { brandId, status: "published" },
|
||||
orderBy: { version: "desc" },
|
||||
select: { version: true, createdAt: true, snapshot: true },
|
||||
});
|
||||
const releaseSnapshot = this.jsonObject(release?.snapshot) as unknown as BrandReleaseSnapshot;
|
||||
if (!release) {
|
||||
return {
|
||||
contractVersion: "1.0",
|
||||
schemaVersion: "1.0.0",
|
||||
publication: { status: "unpublished", version: null },
|
||||
brand: null,
|
||||
template: null,
|
||||
visualTemplate: null,
|
||||
modules: [],
|
||||
offerings: [],
|
||||
inquiryForms: [],
|
||||
capabilities: [],
|
||||
runtimeCapabilities: [],
|
||||
runtimeModules: [],
|
||||
fields: [],
|
||||
trustContent: [],
|
||||
trustPresentation: {},
|
||||
inquiryForm: null,
|
||||
navigation: { tabs: [] },
|
||||
plugins: [],
|
||||
theme: { colors: {} },
|
||||
};
|
||||
}
|
||||
const brandData = this.jsonObject(releaseSnapshot.brand);
|
||||
const modulesData = this.jsonArray(releaseSnapshot.modules).filter(
|
||||
(item) => this.jsonObject(item).isEnabled === true,
|
||||
) as Array<Record<string, unknown>>;
|
||||
const fieldsData = this.jsonArray(releaseSnapshot.fields).filter(
|
||||
(item) => this.jsonObject(item).isVisible === true,
|
||||
);
|
||||
const offeringsData = this.jsonArray(releaseSnapshot.offerings).filter(
|
||||
(item) => this.jsonObject(item).isEnabled === true,
|
||||
) as Array<Record<string, unknown>>;
|
||||
const enabledOfferingIds = new Set(offeringsData.map((item) => item.id));
|
||||
const formsData = this.jsonArray(releaseSnapshot.forms).filter((item) => {
|
||||
const form = this.jsonObject(item);
|
||||
return (
|
||||
form.isEnabled === true &&
|
||||
(form.offeringId === null || enabledOfferingIds.has(form.offeringId))
|
||||
);
|
||||
});
|
||||
const trustData = this.jsonArray(releaseSnapshot.trustContents).filter(
|
||||
(item) => this.jsonObject(item).isPublished === true,
|
||||
) as Array<Record<string, unknown>>;
|
||||
const installationData = this.jsonObject(releaseSnapshot.installation);
|
||||
const templateKeyFromSnapshot =
|
||||
typeof releaseSnapshot.templateKey === "string" ? releaseSnapshot.templateKey : undefined;
|
||||
const templateKey =
|
||||
templateKeyFromSnapshot ??
|
||||
(typeof installationData.templateKey === "string"
|
||||
? installationData.templateKey
|
||||
: undefined) ??
|
||||
(typeof brandData.templateKey === "string" ? brandData.templateKey : "personal");
|
||||
const template = releaseSnapshot.templateDefinition ?? getBrandTemplate(templateKey);
|
||||
const capabilityData = this.jsonArray(releaseSnapshot.capabilities) as Array<
|
||||
Record<string, unknown>
|
||||
>;
|
||||
const runtimeCapabilities = capabilityData.length
|
||||
? capabilityData.map((item) => ({
|
||||
key: this.string(item.capabilityKey),
|
||||
version: this.string(item.capabilityVersion, "1.0.0"),
|
||||
status: this.capabilityStatus(item.status),
|
||||
config:
|
||||
item.config && typeof item.config === "object" && !Array.isArray(item.config)
|
||||
? (item.config as Record<string, unknown>)
|
||||
@@ -90,43 +109,96 @@ export class PublicWorkspaceController {
|
||||
}))
|
||||
: [];
|
||||
const brandConfig =
|
||||
brand?.config && typeof brand.config === "object" && !Array.isArray(brand.config)
|
||||
? (brand.config as Record<string, unknown>)
|
||||
brandData.config && typeof brandData.config === "object" && !Array.isArray(brandData.config)
|
||||
? (brandData.config as Record<string, unknown>)
|
||||
: {};
|
||||
const visualTemplateKey =
|
||||
typeof brandConfig.visualTemplateKey === "string"
|
||||
? brandConfig.visualTemplateKey
|
||||
: "linjing-editorial";
|
||||
: getDefaultVisualTemplateKey(templateKey);
|
||||
const visualTemplate =
|
||||
getVisualTemplate(visualTemplateKey) ?? getVisualTemplate("linjing-editorial");
|
||||
releaseSnapshot.visualTemplateDefinition ?? getVisualTemplate(visualTemplateKey);
|
||||
const visualTemplateManifest =
|
||||
getVisualTemplateManifest(visualTemplateKey) ??
|
||||
getVisualTemplateManifest("linjing-editorial");
|
||||
releaseSnapshot.visualTemplateManifest ?? getVisualTemplateManifest(visualTemplateKey);
|
||||
const runtimeBrand = {
|
||||
...(brand ?? {}),
|
||||
...brandData,
|
||||
...brandConfig,
|
||||
};
|
||||
const runtimeModules: RuntimeModule[] = modules.map((module) => ({
|
||||
key: module.type,
|
||||
type: this.moduleType(module.type),
|
||||
const runtimeModules: RuntimeModule[] = modulesData.map((item) => ({
|
||||
key: this.string(item.type, "custom"),
|
||||
type: this.moduleType(this.string(item.type, "custom")),
|
||||
version: "1.0.0",
|
||||
propsSchema: `module.${module.type}.v1`,
|
||||
dataSource: module.type,
|
||||
config: this.jsonObject(module.config),
|
||||
propsSchema: `module.${this.string(item.type, "custom")}.v1`,
|
||||
dataSource: this.string(item.type, "custom"),
|
||||
config: this.jsonObject(item.config),
|
||||
source:
|
||||
module.source === "custom" ? "custom" : module.source === "template" ? "template" : "core",
|
||||
item.source === "custom" ? "custom" : item.source === "template" ? "template" : "core",
|
||||
schemaVersion: "1.0",
|
||||
}));
|
||||
const runtimeOfferings: RuntimeOffering[] = offerings.map((item) => {
|
||||
const runtimeOfferings: RuntimeOffering[] = offeringsData.map((raw) => {
|
||||
const item = raw;
|
||||
const config = this.jsonObject(item.config);
|
||||
const sections = Array.isArray(config.sections) ? config.sections : [];
|
||||
const details = this.jsonObject(config.details);
|
||||
const media = Array.isArray(config.media)
|
||||
? config.media.flatMap((entry) => {
|
||||
const value = this.jsonObject(entry);
|
||||
return typeof value.url === "string"
|
||||
? [
|
||||
{
|
||||
url: value.url,
|
||||
alt:
|
||||
typeof value.alt === "string"
|
||||
? value.alt
|
||||
: this.string(item.name, "业务提供项"),
|
||||
type: "image" as const,
|
||||
},
|
||||
]
|
||||
: [];
|
||||
})
|
||||
: [];
|
||||
const materialsList = Array.isArray(details.materialsList)
|
||||
? details.materialsList.flatMap((entry) => {
|
||||
const value = this.jsonObject(entry);
|
||||
return typeof value.name === "string" && typeof value.spec === "string"
|
||||
? [{ name: value.name, spec: value.spec }]
|
||||
: [];
|
||||
})
|
||||
: [];
|
||||
return {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
summary: item.summary ?? item.description ?? "",
|
||||
enabled: item.isEnabled,
|
||||
id: this.string(item.id),
|
||||
name: this.string(item.name),
|
||||
summary: typeof item.summary === "string" ? item.summary : this.string(item.description),
|
||||
enabled: item.isEnabled !== false,
|
||||
kind: this.offeringKind(this.string(item.kind, "service")),
|
||||
coverUrl: typeof item.coverUrl === "string" ? item.coverUrl : null,
|
||||
priceText: typeof item.priceText === "string" ? item.priceText : null,
|
||||
priceAmount: typeof item.priceAmount === "number" ? item.priceAmount : null,
|
||||
schemaKey: typeof config.schemaKey === "string" ? config.schemaKey : "offering.default",
|
||||
schemaVersion: typeof config.schemaVersion === "string" ? config.schemaVersion : "1.0.0",
|
||||
presentation: {
|
||||
categoryKey: typeof config.categoryKey === "string" ? config.categoryKey : "custom",
|
||||
categoryLabel:
|
||||
typeof config.categoryLabel === "string" ? config.categoryLabel : "业务提供项",
|
||||
heroImage:
|
||||
typeof config.detailHero === "string"
|
||||
? config.detailHero
|
||||
: typeof item.coverUrl === "string"
|
||||
? item.coverUrl
|
||||
: null,
|
||||
keywords: Array.isArray(config.keywords)
|
||||
? config.keywords.filter((keyword): keyword is string => typeof keyword === "string")
|
||||
: [],
|
||||
media,
|
||||
details: {
|
||||
background: typeof details.background === "string" ? details.background : "",
|
||||
designConcept: typeof details.designConcept === "string" ? details.designConcept : "",
|
||||
crafts: Array.isArray(details.crafts)
|
||||
? details.crafts.filter((craft): craft is string => typeof craft === "string")
|
||||
: [],
|
||||
materialsList,
|
||||
},
|
||||
},
|
||||
sections: sections
|
||||
.filter((section): section is Record<string, unknown> =>
|
||||
Boolean(section && typeof section === "object"),
|
||||
@@ -152,11 +224,12 @@ export class PublicWorkspaceController {
|
||||
"checkbox",
|
||||
"textarea",
|
||||
"date",
|
||||
].includes(String(value.type))
|
||||
].includes(this.string(value.type))
|
||||
? (value.type as RuntimeInquiryField["type"])
|
||||
: "text";
|
||||
const options = Array.isArray(value.options)
|
||||
? value.options.flatMap((option) => {
|
||||
if (typeof option === "string") return [{ label: option, value: option }];
|
||||
if (!option || typeof option !== "object") return [];
|
||||
const item = option as Record<string, unknown>;
|
||||
return typeof item.label === "string" && typeof item.value === "string"
|
||||
@@ -174,9 +247,23 @@ export class PublicWorkspaceController {
|
||||
},
|
||||
];
|
||||
});
|
||||
const inquiryForm = inquiryForms[0] ?? null;
|
||||
const inquiryForm = formsData[0] ?? null;
|
||||
const trustPresentation = trustData.reduce<Record<string, unknown>>((result, raw) => {
|
||||
const item = this.jsonObject(raw);
|
||||
const config = this.jsonObject(item.config);
|
||||
for (const [key, value] of Object.entries(config)) {
|
||||
if (!(key in result)) result[key] = value;
|
||||
}
|
||||
if (item.type === "profile" && typeof result.bio !== "string") result.bio = item.content;
|
||||
return result;
|
||||
}, {});
|
||||
const runtimeWorkspace: RuntimeWorkspace = {
|
||||
schemaVersion: "1.0.0",
|
||||
publication: {
|
||||
status: "published",
|
||||
version: release.version,
|
||||
publishedAt: release.createdAt.toISOString(),
|
||||
},
|
||||
brand: runtimeBrand,
|
||||
navigation: {
|
||||
tabs: [
|
||||
@@ -187,15 +274,24 @@ export class PublicWorkspaceController {
|
||||
},
|
||||
modules: runtimeModules,
|
||||
offerings: runtimeOfferings,
|
||||
inquiryForms: inquiryForms.map((form) => ({
|
||||
key: form.id,
|
||||
version: String(form.version),
|
||||
purpose: this.formPurpose(form.purpose),
|
||||
target: form.targetType === "offering" ? "offering" : "brand",
|
||||
...(form.offeringId ? { targetId: form.offeringId } : {}),
|
||||
submissionAction: this.submissionAction(form.submissionAction),
|
||||
fields: toInquiryFields(form.fieldsSnapshot),
|
||||
})),
|
||||
inquiryForms: formsData.map((raw) => {
|
||||
const form = this.jsonObject(raw);
|
||||
return {
|
||||
key: this.string(form.id),
|
||||
version:
|
||||
typeof form.version === "number"
|
||||
? String(form.version)
|
||||
: this.string(form.version, "1"),
|
||||
purpose: this.formPurpose(this.string(form.purpose, "inquiry")),
|
||||
target: form.targetType === "offering" ? "offering" : "brand",
|
||||
...(typeof form.offeringId === "string" ? { targetId: form.offeringId } : {}),
|
||||
submissionAction: this.submissionAction(
|
||||
this.string(form.submissionAction, "create-inquiry"),
|
||||
),
|
||||
fields: toInquiryFields(form.fieldsSnapshot as Prisma.JsonValue),
|
||||
};
|
||||
}),
|
||||
trustPresentation,
|
||||
capabilities: runtimeCapabilities,
|
||||
plugins: runtimeCapabilities
|
||||
.filter((capability) => capability.status === "enabled")
|
||||
@@ -215,7 +311,10 @@ export class PublicWorkspaceController {
|
||||
template: template
|
||||
? {
|
||||
key: template.key,
|
||||
version: installation?.templateVersion ?? template.version,
|
||||
version:
|
||||
typeof installationData.templateVersion === "string"
|
||||
? installationData.templateVersion
|
||||
: template.version,
|
||||
name: template.name,
|
||||
}
|
||||
: null,
|
||||
@@ -224,21 +323,19 @@ export class PublicWorkspaceController {
|
||||
key: visualTemplate.key,
|
||||
version: visualTemplate.version,
|
||||
name: visualTemplate.name,
|
||||
supportedIndustryTemplates: visualTemplate.supportedIndustryTemplates,
|
||||
variants: visualTemplate.variants,
|
||||
}
|
||||
: null,
|
||||
visualTemplateManifest,
|
||||
capabilities: runtimeCapabilities,
|
||||
runtimeCapabilities,
|
||||
modules,
|
||||
runtimeModules,
|
||||
fields,
|
||||
offerings,
|
||||
trustContent: trustContents,
|
||||
fields: fieldsData,
|
||||
trustContent: trustData,
|
||||
trustPresentation,
|
||||
inquiryForm,
|
||||
};
|
||||
if (process.env.NODE_ENV !== "test")
|
||||
this.cache.set(brandId, { expiresAt: Date.now() + 30_000, value: response });
|
||||
return response;
|
||||
}
|
||||
private jsonObject(value: unknown): Record<string, unknown> {
|
||||
@@ -246,10 +343,22 @@ export class PublicWorkspaceController {
|
||||
? (value as Record<string, unknown>)
|
||||
: {};
|
||||
}
|
||||
private string(value: unknown, fallback = ""): string {
|
||||
return typeof value === "string" ? value : fallback;
|
||||
}
|
||||
private capabilityStatus(value: unknown): "enabled" | "disabled" | "degraded" {
|
||||
return value === "disabled" || value === "degraded" ? value : "enabled";
|
||||
}
|
||||
private jsonArray(value: unknown): Prisma.JsonValue[] {
|
||||
return Array.isArray(value) ? (value as Prisma.JsonValue[]) : [];
|
||||
}
|
||||
private moduleType(value: string): RuntimeModule["type"] {
|
||||
const aliases: Record<string, RuntimeModule["type"]> = {
|
||||
identity: "brand-hero",
|
||||
trust: "trust-proof",
|
||||
offering: "offering-list",
|
||||
contact: "founder-card",
|
||||
};
|
||||
const known: RuntimeModule["type"][] = [
|
||||
"brand-hero",
|
||||
"founder-card",
|
||||
@@ -264,8 +373,9 @@ export class PublicWorkspaceController {
|
||||
"records",
|
||||
"custom",
|
||||
];
|
||||
const type = aliases[value] ?? value;
|
||||
return (
|
||||
known.includes(value as RuntimeModule["type"]) ? value : "custom"
|
||||
known.includes(type as RuntimeModule["type"]) ? type : "custom"
|
||||
) as RuntimeModule["type"];
|
||||
}
|
||||
private sectionType(value: unknown): RuntimeOffering["sections"][number]["type"] {
|
||||
@@ -274,6 +384,12 @@ export class PublicWorkspaceController {
|
||||
? (value as (typeof known)[number])
|
||||
: "text";
|
||||
}
|
||||
private offeringKind(value: string): RuntimeOffering["kind"] {
|
||||
const known: RuntimeOffering["kind"][] = ["service", "product", "package", "subscription"];
|
||||
return known.includes(value as RuntimeOffering["kind"])
|
||||
? (value as RuntimeOffering["kind"])
|
||||
: "service";
|
||||
}
|
||||
private formPurpose(value: string): RuntimeWorkspace["inquiryForms"][number]["purpose"] {
|
||||
return value === "booking" || value === "quote-request" ? value : "inquiry";
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { BadRequestException, Controller, Get, Param, Query } from "@nestjs/common";
|
||||
import { PrismaService } from "../../prisma.service.js";
|
||||
import { PublicBrandContextService } from "./public-brand-context.service.js";
|
||||
import { BrandReleaseService } from "../../brand-release.service.js";
|
||||
import {
|
||||
brandTemplates,
|
||||
getBrandTemplate,
|
||||
getVisualTemplate,
|
||||
isVisualTemplateCompatible,
|
||||
resolveCapabilities,
|
||||
visualTemplates,
|
||||
} from "@personal-brand/config";
|
||||
@@ -12,50 +13,59 @@ import {
|
||||
@Controller("public")
|
||||
export class PublicController {
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly releases: BrandReleaseService,
|
||||
private readonly brandContext: PublicBrandContextService,
|
||||
) {}
|
||||
|
||||
@Get("brand")
|
||||
async brand(@Query("brandSlug") brandSlug?: string): Promise<unknown> {
|
||||
return this.prisma.brandProfile.findUnique({
|
||||
where: {
|
||||
id: await this.brandContext.resolveId(brandSlug),
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
templateKey: true,
|
||||
tagline: true,
|
||||
description: true,
|
||||
avatarUrl: true,
|
||||
coverUrl: true,
|
||||
hours: true,
|
||||
address: true,
|
||||
deliveryNote: true,
|
||||
contactPhone: true,
|
||||
contactWechat: true,
|
||||
},
|
||||
});
|
||||
const snapshot = await this.releases.getPublishedSnapshot(
|
||||
await this.brandContext.resolveId(brandSlug),
|
||||
);
|
||||
if (!snapshot?.brand) return null;
|
||||
const keys = [
|
||||
"id",
|
||||
"name",
|
||||
"templateKey",
|
||||
"tagline",
|
||||
"description",
|
||||
"avatarUrl",
|
||||
"coverUrl",
|
||||
"hours",
|
||||
"address",
|
||||
"deliveryNote",
|
||||
"contactPhone",
|
||||
"contactWechat",
|
||||
];
|
||||
return Object.fromEntries(keys.map((key) => [key, snapshot.brand?.[key] ?? null]));
|
||||
}
|
||||
}
|
||||
|
||||
@Controller("public/trust-content")
|
||||
export class PublicTrustContentController {
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly releases: BrandReleaseService,
|
||||
private readonly brandContext: PublicBrandContextService,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
async list(@Query("brandSlug") brandSlug?: string): Promise<unknown> {
|
||||
return this.prisma.trustContent.findMany({
|
||||
where: {
|
||||
brandId: await this.brandContext.resolveId(brandSlug),
|
||||
isPublished: true,
|
||||
},
|
||||
orderBy: [{ type: "asc" }, { sortOrder: "asc" }],
|
||||
});
|
||||
const snapshot = await this.releases.getPublishedSnapshot(
|
||||
await this.brandContext.resolveId(brandSlug),
|
||||
);
|
||||
return (snapshot?.trustContents ?? [])
|
||||
.filter((item) =>
|
||||
Boolean(
|
||||
item &&
|
||||
typeof item === "object" &&
|
||||
(item as Record<string, unknown>).isPublished === true,
|
||||
),
|
||||
)
|
||||
.sort((left, right) => {
|
||||
const a = left as { type: string; sortOrder: number };
|
||||
const b = right as { type: string; sortOrder: number };
|
||||
return a.type.localeCompare(b.type) || a.sortOrder - b.sortOrder;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +73,10 @@ export class PublicTrustContentController {
|
||||
export class PublicTemplateController {
|
||||
@Get()
|
||||
list(): unknown {
|
||||
return { industries: Object.values(brandTemplates), visuals: Object.values(visualTemplates) };
|
||||
return {
|
||||
industries: Object.values(brandTemplates),
|
||||
visuals: Object.values(visualTemplates),
|
||||
};
|
||||
}
|
||||
|
||||
@Get("preview")
|
||||
@@ -72,8 +85,10 @@ export class PublicTemplateController {
|
||||
@Query("visual") visual = "linjing-editorial",
|
||||
): unknown {
|
||||
const industryTemplate = getBrandTemplate(industry);
|
||||
const visualTemplate = getVisualTemplate(visual) ?? getVisualTemplate("linjing-editorial");
|
||||
const visualTemplate = getVisualTemplate(visual);
|
||||
if (!industryTemplate || !visualTemplate) throw new BadRequestException("模板组合不存在");
|
||||
if (!isVisualTemplateCompatible(visualTemplate, industryTemplate.key))
|
||||
throw new BadRequestException("当前视觉模板不适配所选行业模板");
|
||||
return {
|
||||
industry: industryTemplate,
|
||||
visual: visualTemplate,
|
||||
|
||||
@@ -1,22 +1,39 @@
|
||||
import { BadRequestException, Body, Controller, Post } from "@nestjs/common";
|
||||
import {
|
||||
BadRequestException,
|
||||
Body,
|
||||
Controller,
|
||||
Post,
|
||||
Query,
|
||||
Req,
|
||||
UnauthorizedException,
|
||||
} from "@nestjs/common";
|
||||
import type { FastifyRequest } from "fastify";
|
||||
import { PrismaService } from "../../prisma.service.js";
|
||||
import { WechatAuthService } from "../../wechat-auth.js";
|
||||
import { AdminAuthService } from "../../admin-auth.service.js";
|
||||
import { AdminLoginDto, WechatLoginDto } from "../../admin-auth.dto.js";
|
||||
import { signIdentity } from "../../auth.js";
|
||||
import { PublicBrandContextService } from "../public/public-brand-context.service.js";
|
||||
import { ChangeAdminPasswordDto } from "../../admin.dto.js";
|
||||
import { readIdentity } from "../../auth.js";
|
||||
|
||||
@Controller("customer/session")
|
||||
export class CustomerSessionController {
|
||||
constructor(
|
||||
private readonly wechatAuth: WechatAuthService,
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly brandContext: PublicBrandContextService,
|
||||
) {}
|
||||
|
||||
@Post("wechat")
|
||||
async wechatLogin(@Body() body: WechatLoginDto): Promise<{ token: string }> {
|
||||
async wechatLogin(
|
||||
@Body() body: WechatLoginDto,
|
||||
@Query("brandSlug") brandSlug?: string,
|
||||
): Promise<{ token: string }> {
|
||||
const session = await this.wechatAuth.exchangeCode(body.code);
|
||||
const brandId = await this.brandContext.resolveId(brandSlug);
|
||||
const brand = await this.prisma.brandProfile.findUnique({
|
||||
where: { id: process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001" },
|
||||
where: { id: brandId },
|
||||
select: { id: true },
|
||||
});
|
||||
if (!brand) throw new BadRequestException("品牌尚未初始化");
|
||||
@@ -36,7 +53,22 @@ export class AdminSessionController {
|
||||
constructor(private readonly auth: AdminAuthService) {}
|
||||
|
||||
@Post("login")
|
||||
login(@Body() body: AdminLoginDto): Promise<{ token: string; displayName: string }> {
|
||||
login(
|
||||
@Body() body: AdminLoginDto,
|
||||
): Promise<{ token: string; displayName: string; mustChangePassword: boolean; role: string }> {
|
||||
return this.auth.login(body.username, body.password);
|
||||
}
|
||||
|
||||
@Post("change-password")
|
||||
async changePassword(
|
||||
@Req() request: FastifyRequest,
|
||||
@Body() body: ChangeAdminPasswordDto,
|
||||
): Promise<{ changed: true }> {
|
||||
const token = request.headers.authorization?.replace(/^Bearer\s+/i, "");
|
||||
if (!token) throw new UnauthorizedException("缺少管理员登录态");
|
||||
const identity = readIdentity(token);
|
||||
if (identity.role !== "admin") throw new UnauthorizedException("管理员登录态无效");
|
||||
await this.auth.changePassword(identity.subject, body.currentPassword, body.newPassword);
|
||||
return { changed: true };
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
import {
|
||||
Controller,
|
||||
BadRequestException,
|
||||
Body,
|
||||
ConflictException,
|
||||
ForbiddenException,
|
||||
Get,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Req,
|
||||
UnauthorizedException,
|
||||
@@ -10,10 +14,105 @@ import {
|
||||
import type { FastifyRequest } from "fastify";
|
||||
import { PrismaService } from "../../prisma.service.js";
|
||||
import { readIdentity, signIdentity } from "../../auth.js";
|
||||
import { AdminAccessService } from "../../admin-access.service.js";
|
||||
import { CreateBrandMemberDto, UpdateBrandMemberDto } from "../../admin.dto.js";
|
||||
import bcrypt from "bcryptjs";
|
||||
|
||||
@Controller("admin/brands")
|
||||
export class TenantController {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly access: AdminAccessService,
|
||||
) {}
|
||||
|
||||
@Get("members")
|
||||
async listMembers(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
await this.access.requireRole(request, ["owner", "admin", "platform-admin"]);
|
||||
const current = this.adminIdentity(request);
|
||||
return this.prisma.brandMembership.findMany({
|
||||
where: { brandId: current.brandId },
|
||||
include: {
|
||||
adminUser: { select: { id: true, username: true, displayName: true, isEnabled: true } },
|
||||
},
|
||||
orderBy: { createdAt: "asc" },
|
||||
});
|
||||
}
|
||||
|
||||
@Post("members")
|
||||
async createMember(
|
||||
@Req() request: FastifyRequest,
|
||||
@Body() body: CreateBrandMemberDto,
|
||||
): Promise<unknown> {
|
||||
await this.access.requireRole(request, ["owner", "admin", "platform-admin"]);
|
||||
const actor = this.adminIdentity(request);
|
||||
const username = body.username.trim();
|
||||
const displayName = body.displayName.trim();
|
||||
if (!username || !displayName) throw new BadRequestException("账号和显示名称不能为空");
|
||||
const existing = await this.prisma.adminUser.findUnique({ where: { username } });
|
||||
if (existing) throw new ConflictException("账号已存在,请使用其他账号");
|
||||
const passwordHash = await bcrypt.hash(body.password, 12);
|
||||
const member = await this.prisma.$transaction(async (tx) => {
|
||||
const adminUser = await tx.adminUser.create({
|
||||
data: {
|
||||
username,
|
||||
displayName,
|
||||
passwordHash,
|
||||
role: "admin",
|
||||
isEnabled: true,
|
||||
mustChangePassword: true,
|
||||
},
|
||||
});
|
||||
return tx.brandMembership.create({
|
||||
data: {
|
||||
adminUserId: adminUser.id,
|
||||
brandId: actor.brandId,
|
||||
role: body.role,
|
||||
isEnabled: true,
|
||||
},
|
||||
include: {
|
||||
adminUser: { select: { id: true, username: true, displayName: true, isEnabled: true } },
|
||||
},
|
||||
});
|
||||
});
|
||||
return member;
|
||||
}
|
||||
|
||||
@Patch("members/:id")
|
||||
async updateMember(
|
||||
@Req() request: FastifyRequest,
|
||||
@Param("id") id: string,
|
||||
@Body() body: UpdateBrandMemberDto,
|
||||
): Promise<unknown> {
|
||||
await this.access.requireRole(request, ["owner", "admin", "platform-admin"]);
|
||||
const actor = this.adminIdentity(request);
|
||||
const membership = await this.prisma.brandMembership.findFirst({
|
||||
where: { id, brandId: actor.brandId },
|
||||
});
|
||||
if (!membership) throw new BadRequestException("成员不存在");
|
||||
if (membership.adminUserId === actor.subject) {
|
||||
if (body.isEnabled === false || (body.role && body.role !== membership.role)) {
|
||||
throw new BadRequestException("不能修改自己的角色或停用自己");
|
||||
}
|
||||
}
|
||||
const nextRole = body.role ?? membership.role;
|
||||
const nextEnabled = body.isEnabled ?? membership.isEnabled;
|
||||
if (membership.role === "owner" && (nextRole !== "owner" || !nextEnabled)) {
|
||||
const ownerCount = await this.prisma.brandMembership.count({
|
||||
where: { brandId: actor.brandId, role: "owner", isEnabled: true },
|
||||
});
|
||||
if (ownerCount <= 1) throw new BadRequestException("品牌至少需要保留一位启用的负责人");
|
||||
}
|
||||
return this.prisma.brandMembership.update({
|
||||
where: { id: membership.id },
|
||||
data: {
|
||||
...(body.role ? { role: body.role } : {}),
|
||||
...(body.isEnabled === undefined ? {} : { isEnabled: body.isEnabled }),
|
||||
},
|
||||
include: {
|
||||
adminUser: { select: { id: true, username: true, displayName: true, isEnabled: true } },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@Get()
|
||||
async list(@Req() request: FastifyRequest): Promise<unknown> {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { IsOptional, IsString } from "class-validator";
|
||||
|
||||
export class PublishBrandReleaseDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
note?: string;
|
||||
}
|
||||
@@ -1,11 +1,33 @@
|
||||
import { BadRequestException, Injectable } from "@nestjs/common";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { getBrandTemplate, getVisualTemplateManifest } from "@personal-brand/config";
|
||||
import {
|
||||
getBrandTemplate,
|
||||
getVisualTemplate,
|
||||
getVisualTemplateManifest,
|
||||
getDefaultVisualTemplateKey,
|
||||
isVisualTemplateCompatible,
|
||||
} from "@personal-brand/config";
|
||||
import type { BrandTemplateKey } from "@personal-brand/types";
|
||||
import { PrismaService } from "./prisma.service.js";
|
||||
|
||||
@Injectable()
|
||||
export class TemplateWorkspaceService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
async getEffectiveTemplateKey(brandId: string): Promise<BrandTemplateKey> {
|
||||
const [installation, brand] = await Promise.all([
|
||||
this.prisma.brandTemplateInstallation.findFirst({
|
||||
where: { brandId },
|
||||
orderBy: { updatedAt: "desc" },
|
||||
select: { templateKey: true },
|
||||
}),
|
||||
this.prisma.brandProfile.findUnique({
|
||||
where: { id: brandId },
|
||||
select: { templateKey: true },
|
||||
}),
|
||||
]);
|
||||
const key = installation?.templateKey ?? brand?.templateKey ?? "personal";
|
||||
return getBrandTemplate(key) ? (key as BrandTemplateKey) : "personal";
|
||||
}
|
||||
async install(brandId: string, templateKey: "personal" | "food" | "doors") {
|
||||
const template = getBrandTemplate(templateKey);
|
||||
if (!template) throw new BadRequestException("行业模板不存在");
|
||||
@@ -23,14 +45,22 @@ export class TemplateWorkspaceService {
|
||||
brand?.config && typeof brand.config === "object" && !Array.isArray(brand.config)
|
||||
? (brand.config as Record<string, unknown>)
|
||||
: {};
|
||||
const configuredVisualTemplateKey =
|
||||
typeof brandConfig.visualTemplateKey === "string" ? brandConfig.visualTemplateKey : undefined;
|
||||
const visualTemplateKey =
|
||||
typeof brandConfig.visualTemplateKey === "string"
|
||||
? brandConfig.visualTemplateKey
|
||||
: templateKey === "doors"
|
||||
? "linjing-editorial"
|
||||
: "minimal-neutral";
|
||||
configuredVisualTemplateKey &&
|
||||
getVisualTemplate(configuredVisualTemplateKey) &&
|
||||
isVisualTemplateCompatible(getVisualTemplate(configuredVisualTemplateKey)!, templateKey)
|
||||
? configuredVisualTemplateKey
|
||||
: getDefaultVisualTemplateKey(templateKey);
|
||||
const visualManifest = getVisualTemplateManifest(visualTemplateKey);
|
||||
if (!visualManifest) throw new BadRequestException("视觉模板不存在");
|
||||
const visualTemplate = getVisualTemplate(visualTemplateKey);
|
||||
if (
|
||||
!visualManifest ||
|
||||
!visualTemplate ||
|
||||
!isVisualTemplateCompatible(visualTemplate, templateKey)
|
||||
)
|
||||
throw new BadRequestException("当前视觉模板不适配行业模板");
|
||||
const templatePackageSnapshot = {
|
||||
schemaVersion: "1.0",
|
||||
version: template.version,
|
||||
@@ -39,6 +69,14 @@ export class TemplateWorkspaceService {
|
||||
capabilities: template.capabilities,
|
||||
};
|
||||
return this.prisma.$transaction(async (tx) => {
|
||||
if (brandConfig.visualTemplateKey === undefined) {
|
||||
await tx.brandProfile.update({
|
||||
where: { id: brandId },
|
||||
data: {
|
||||
config: { ...brandConfig, visualTemplateKey },
|
||||
},
|
||||
});
|
||||
}
|
||||
const installation = await tx.brandTemplateInstallation.create({
|
||||
data: {
|
||||
brandId,
|
||||
|
||||
@@ -2,6 +2,8 @@ import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { BadRequestException, NotFoundException } from "@nestjs/common";
|
||||
import { BookingService } from "../src/booking.service.js";
|
||||
import type { PrismaService } from "../src/prisma.service.js";
|
||||
import type { BrandReleaseService } from "../src/brand-release.service.js";
|
||||
|
||||
const brandId = "brand-1";
|
||||
const customerId = "customer-1";
|
||||
@@ -11,20 +13,20 @@ const offering = {
|
||||
priceAmount: 2800,
|
||||
};
|
||||
|
||||
function createPrisma(overrides: Record<string, unknown> = {}): any {
|
||||
function createPrisma(overrides: Record<string, unknown> = {}): PrismaService {
|
||||
return {
|
||||
offering: {
|
||||
findMany: async () => [offering],
|
||||
count: async () => 1,
|
||||
},
|
||||
booking: {
|
||||
create: async ({ data }: any) => ({
|
||||
create: async ({ data }: { data: { estimatedAmount: number | null } }) => ({
|
||||
bookingNo: "AC-test",
|
||||
status: "received",
|
||||
estimatedAmount: data.estimatedAmount,
|
||||
createdAt: new Date(),
|
||||
}),
|
||||
findFirst: async () => null,
|
||||
update: async ({ data }: any) => ({ status: data.status }),
|
||||
update: async ({ data }: { data: { status: string } }) => ({ status: data.status }),
|
||||
findMany: async () => [],
|
||||
count: async () => 0,
|
||||
},
|
||||
@@ -32,12 +34,20 @@ function createPrisma(overrides: Record<string, unknown> = {}): any {
|
||||
bookingTag: { deleteMany: {}, createMany: {} },
|
||||
$transaction: async (callback: (tx: unknown) => unknown) => callback(undefined),
|
||||
...overrides,
|
||||
};
|
||||
} as unknown as PrismaService;
|
||||
}
|
||||
|
||||
function createService(prisma = createPrisma()): BookingService {
|
||||
const releases = {
|
||||
getPublishedSnapshot: async () => ({ offerings: [{ ...offering, isEnabled: true }] }),
|
||||
publishedOfferingIds: () => new Set([offering.id]),
|
||||
} as unknown as BrandReleaseService;
|
||||
return new BookingService(prisma, releases);
|
||||
}
|
||||
|
||||
test("创建普通套餐订单时保存价格快照和预计金额", async () => {
|
||||
const prisma = createPrisma();
|
||||
const result = await new BookingService(prisma).create(brandId, customerId, {
|
||||
const result = await createService(prisma).create(brandId, customerId, {
|
||||
requestType: "package",
|
||||
customerName: "陈同学",
|
||||
wechatId: "wx-test",
|
||||
@@ -51,7 +61,7 @@ test("创建普通套餐订单时保存价格快照和预计金额", async () =>
|
||||
test("普通套餐不能在没有明细时创建", async () => {
|
||||
await assert.rejects(
|
||||
() =>
|
||||
new BookingService(createPrisma()).create(brandId, customerId, {
|
||||
createService().create(brandId, customerId, {
|
||||
requestType: "package",
|
||||
customerName: "陈同学",
|
||||
phone: "13800000000",
|
||||
@@ -69,14 +79,14 @@ test("客户只能取消自己的 received 订单", async () => {
|
||||
},
|
||||
});
|
||||
await assert.rejects(
|
||||
() => new BookingService(prisma).cancelForCustomer(brandId, customerId, "booking-1"),
|
||||
() => createService(prisma).cancelForCustomer(brandId, customerId, "booking-1"),
|
||||
(error: unknown) => error instanceof BadRequestException,
|
||||
);
|
||||
});
|
||||
|
||||
test("取消不存在或不属于当前客户的订单返回不存在", async () => {
|
||||
await assert.rejects(
|
||||
() => new BookingService(createPrisma()).cancelForCustomer(brandId, customerId, "missing"),
|
||||
() => createService().cancelForCustomer(brandId, customerId, "missing"),
|
||||
(error: unknown) => error instanceof NotFoundException,
|
||||
);
|
||||
});
|
||||
@@ -91,15 +101,15 @@ test("订单状态只能按定义的状态机流转", async () => {
|
||||
workflowKey: "booking.basic",
|
||||
workflowVersion: "1.0.0",
|
||||
}),
|
||||
update: async ({ data }: any) => data,
|
||||
update: async ({ data }: { data: { status: string } }) => data,
|
||||
},
|
||||
$transaction: async (callback: (tx: any) => unknown) =>
|
||||
$transaction: async (callback: (tx: unknown) => unknown) =>
|
||||
callback({
|
||||
booking: { update: async ({ data }: any) => data },
|
||||
booking: { update: async ({ data }: { data: { status: string } }) => data },
|
||||
bookingStateTransition: { create: async () => undefined },
|
||||
}),
|
||||
});
|
||||
const bookings = new BookingService(prisma);
|
||||
const bookings = createService(prisma);
|
||||
assert.equal(
|
||||
(await bookings.updateStatus(brandId, "booking-1", "contacting")).status,
|
||||
"contacting",
|
||||
@@ -116,7 +126,7 @@ test("更新订单标签时拒绝其他品牌的标签", async () => {
|
||||
tag: { findMany: async () => [] },
|
||||
});
|
||||
await assert.rejects(
|
||||
() => new BookingService(prisma).updateTags(brandId, "booking-1", ["foreign-tag"]),
|
||||
() => createService(prisma).updateTags(brandId, "booking-1", ["foreign-tag"]),
|
||||
(error: unknown) => error instanceof BadRequestException,
|
||||
);
|
||||
});
|
||||
@@ -2,7 +2,8 @@ import assert from "node:assert/strict";
|
||||
import { after, before, test } from "node:test";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { createApp } from "../dist/main.js";
|
||||
import { signIdentity } from "../dist/auth.js";
|
||||
import { readIdentity, signIdentity } from "../dist/auth.js";
|
||||
import { WechatAuthService } from "../dist/wechat-auth.js";
|
||||
|
||||
let app;
|
||||
const prisma = new PrismaClient();
|
||||
@@ -20,11 +21,183 @@ before(async () => {
|
||||
|
||||
after(async () => {
|
||||
await app.close();
|
||||
await prisma.brandRelease.deleteMany({ where: { brandId } });
|
||||
await prisma.booking.deleteMany({ where: { id: { in: createdBookingIds } } });
|
||||
await prisma.customerUser.deleteMany({ where: { openid } });
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
|
||||
test("admin release lifecycle is authorized, brand-scoped, and versioned", async () => {
|
||||
const missing = await request("/admin/releases");
|
||||
assert.equal(missing.statusCode, 401);
|
||||
assert.equal((await request("/admin/releases/readiness")).statusCode, 401);
|
||||
|
||||
const customer = await request("/admin/releases", {
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
});
|
||||
assert.equal(customer.statusCode, 403);
|
||||
assert.equal(
|
||||
(
|
||||
await request("/admin/releases/readiness", {
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
})
|
||||
).statusCode,
|
||||
403,
|
||||
);
|
||||
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
assert.equal(login.statusCode, 201);
|
||||
const adminToken = JSON.parse(login.body).token;
|
||||
const readiness = await request("/admin/releases/readiness", {
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
assert.equal(readiness.statusCode, 200);
|
||||
assert.equal(JSON.parse(readiness.body).ready, true);
|
||||
const enabledForms = await prisma.inquiryForm.findMany({
|
||||
where: { brandId, isEnabled: true },
|
||||
select: { id: true },
|
||||
});
|
||||
await prisma.inquiryForm.updateMany({ where: { brandId }, data: { isEnabled: false } });
|
||||
try {
|
||||
const noForms = await request("/admin/releases/readiness", {
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
assert.equal(JSON.parse(noForms.body).ready, false);
|
||||
assert.equal(
|
||||
JSON.parse(noForms.body).checks.find((check) => check.key === "forms")?.passed,
|
||||
false,
|
||||
);
|
||||
} finally {
|
||||
await prisma.inquiryForm.updateMany({
|
||||
where: { id: { in: enabledForms.map((form) => form.id) } },
|
||||
data: { isEnabled: true },
|
||||
});
|
||||
}
|
||||
const originalBrand = await prisma.brandProfile.findUniqueOrThrow({ where: { id: brandId } });
|
||||
await prisma.brandProfile.update({ where: { id: brandId }, data: { tagline: "" } });
|
||||
const incomplete = await request("/admin/releases/readiness", {
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
assert.equal(JSON.parse(incomplete.body).ready, false);
|
||||
assert.equal(
|
||||
(
|
||||
await request("/admin/releases/publish", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
payload: {},
|
||||
})
|
||||
).statusCode,
|
||||
400,
|
||||
);
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: brandId },
|
||||
data: { tagline: "集成测试待发布标语" },
|
||||
});
|
||||
const beforePublish = JSON.parse((await request("/public/workspace")).body);
|
||||
assert.equal(beforePublish.brand.tagline, originalBrand.tagline);
|
||||
const published = await request("/admin/releases/publish", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
payload: { note: "集成测试发布" },
|
||||
});
|
||||
assert.equal(published.statusCode, 201);
|
||||
const first = JSON.parse(published.body);
|
||||
assert.equal(first.version, 2);
|
||||
assert.equal(first.status, "published");
|
||||
assert.equal(
|
||||
JSON.parse((await request("/public/workspace")).body).brand.tagline,
|
||||
"集成测试待发布标语",
|
||||
);
|
||||
const draftOnlyForm = await prisma.inquiryForm.create({
|
||||
data: {
|
||||
brandId,
|
||||
name: "未发布的草稿表单",
|
||||
fieldsSnapshot: [{ key: "phone", type: "phone", label: "手机", required: true }],
|
||||
},
|
||||
});
|
||||
const draftSubmission = await request("/customer/inquiry-submissions", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
payload: { formId: draftOnlyForm.id, values: { phone: "13871112222" } },
|
||||
});
|
||||
assert.equal(draftSubmission.statusCode, 400);
|
||||
|
||||
const listed = await request("/admin/releases", {
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
assert.equal(listed.statusCode, 200);
|
||||
assert.equal(JSON.parse(listed.body)[0].version, 2);
|
||||
|
||||
const concurrent = await Promise.all(
|
||||
["并发发布 A", "并发发布 B"].map((note) =>
|
||||
request("/admin/releases/publish", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
payload: { note },
|
||||
}),
|
||||
),
|
||||
);
|
||||
assert.deepEqual(
|
||||
concurrent.map((item) => item.statusCode),
|
||||
[201, 201],
|
||||
);
|
||||
assert.deepEqual(
|
||||
concurrent.map((item) => JSON.parse(item.body).version).sort((a, b) => a - b),
|
||||
[3, 4],
|
||||
);
|
||||
|
||||
const rolledBack = await request("/admin/releases/1/rollback", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
});
|
||||
assert.equal(rolledBack.statusCode, 201);
|
||||
assert.equal(JSON.parse(rolledBack.body).version, 5);
|
||||
assert.equal(
|
||||
JSON.parse((await request("/public/workspace")).body).brand.tagline,
|
||||
originalBrand.tagline,
|
||||
);
|
||||
|
||||
const revoked = await request("/admin/releases/revoke", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
payload: {},
|
||||
});
|
||||
assert.equal(revoked.statusCode, 201);
|
||||
assert.equal(JSON.parse(revoked.body).status, "revoked");
|
||||
assert.equal(JSON.parse(revoked.body).revokedBy, readIdentity(adminToken).subject);
|
||||
const unpublished = JSON.parse((await request("/public/workspace")).body);
|
||||
assert.equal(unpublished.publication.status, "unpublished");
|
||||
assert.equal(unpublished.brand, null);
|
||||
assert.deepEqual(unpublished.offerings, []);
|
||||
assert.deepEqual(JSON.parse((await request("/public/offerings")).body), []);
|
||||
const revokedSubmission = await request("/customer/inquiry-submissions", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
payload: { formId: draftOnlyForm.id, values: { phone: "13871112222" } },
|
||||
});
|
||||
assert.equal(revokedSubmission.statusCode, 400);
|
||||
const revokedBooking = await request("/customer/bookings", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
payload: {
|
||||
requestType: "inquiry",
|
||||
customerName: "集成测试客户",
|
||||
wechatId: "integration-wechat",
|
||||
contactPreference: "wechat",
|
||||
},
|
||||
});
|
||||
assert.equal(revokedBooking.statusCode, 400);
|
||||
await prisma.inquiryForm.delete({ where: { id: draftOnlyForm.id } });
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: brandId },
|
||||
data: { tagline: originalBrand.tagline },
|
||||
});
|
||||
assert.equal((await publishReleaseForTests("恢复集成测试基线")).statusCode, 201);
|
||||
});
|
||||
|
||||
async function request(url, options = {}) {
|
||||
return app
|
||||
.getHttpAdapter()
|
||||
@@ -32,6 +205,19 @@ async function request(url, options = {}) {
|
||||
.inject({ method: "GET", url, ...options });
|
||||
}
|
||||
|
||||
async function publishReleaseForTests(note = "集成测试发布") {
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
return request("/admin/releases/publish", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { note },
|
||||
});
|
||||
}
|
||||
|
||||
test("health and public content are available without authentication", async () => {
|
||||
const health = await request("/health");
|
||||
assert.equal(health.statusCode, 200);
|
||||
@@ -68,6 +254,91 @@ test("health and public content are available without authentication", async ()
|
||||
assert.equal(missingSlug.statusCode, 404);
|
||||
});
|
||||
|
||||
test("visual template compatibility is enforced by catalog, preview, and brand switching", async () => {
|
||||
const catalog = await request("/public/templates");
|
||||
assert.equal(catalog.statusCode, 200);
|
||||
const visuals = JSON.parse(catalog.body).visuals;
|
||||
assert.deepEqual(
|
||||
visuals.find((visual) => visual.key === "linjing-editorial").supportedIndustryTemplates,
|
||||
["personal", "doors"],
|
||||
);
|
||||
const incompatiblePreview = await request(
|
||||
"/public/templates/preview?industry=food&visual=linjing-editorial",
|
||||
);
|
||||
assert.equal(incompatiblePreview.statusCode, 400);
|
||||
const compatiblePreview = await request(
|
||||
"/public/templates/preview?industry=doors&visual=linjing-editorial",
|
||||
);
|
||||
assert.equal(compatiblePreview.statusCode, 200);
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const compatibleSwitch = await request("/admin/config/brand", {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { config: { visualTemplateKey: "acheng-campus-food" } },
|
||||
});
|
||||
assert.equal(compatibleSwitch.statusCode, 200);
|
||||
});
|
||||
|
||||
test("seeded public workspaces keep personal, food, and doors brands isolated", async () => {
|
||||
const expected = [
|
||||
{
|
||||
slug: "linran-brand",
|
||||
id: "00000000-0000-0000-0000-000000000003",
|
||||
templateKey: "personal",
|
||||
founder: "林然",
|
||||
offeringKind: "service",
|
||||
categoryLabel: "策略咨询",
|
||||
},
|
||||
{
|
||||
slug: "default-brand",
|
||||
id: "00000000-0000-0000-0000-000000000001",
|
||||
templateKey: "food",
|
||||
founder: "阿成",
|
||||
offeringKind: "package",
|
||||
categoryLabel: "套餐",
|
||||
},
|
||||
{
|
||||
slug: "linjing-doors",
|
||||
id: "00000000-0000-0000-0000-000000000002",
|
||||
templateKey: "doors",
|
||||
founder: "林叙安 (Lin XUAN)",
|
||||
offeringKind: "product",
|
||||
categoryLabel: "入户大门",
|
||||
},
|
||||
];
|
||||
const workspaces = await Promise.all(
|
||||
expected.map(async (item) => {
|
||||
const response = await request(`/public/workspace?brandSlug=${item.slug}`);
|
||||
assert.equal(response.statusCode, 200);
|
||||
const workspace = JSON.parse(response.body);
|
||||
assert.equal(workspace.brand.id, item.id);
|
||||
assert.equal(workspace.template.key, item.templateKey);
|
||||
assert.ok(workspace.visualTemplate?.key);
|
||||
assert.ok(workspace.visualTemplateManifest?.pages?.length > 0);
|
||||
assert.equal(workspace.brand.founder, item.founder);
|
||||
assert.ok(workspace.trustContent.length > 0);
|
||||
assert.ok(workspace.trustPresentation);
|
||||
assert.ok(workspace.inquiryForm);
|
||||
assert.equal(workspace.inquiryForm.isEnabled, true);
|
||||
assert.ok(workspace.offerings.length > 0);
|
||||
assert.ok(workspace.offerings.every((offering) => offering.brandId === undefined));
|
||||
assert.ok(
|
||||
workspace.offerings.some(
|
||||
(offering) =>
|
||||
offering.kind === item.offeringKind &&
|
||||
offering.presentation?.categoryLabel === item.categoryLabel,
|
||||
),
|
||||
);
|
||||
return workspace;
|
||||
}),
|
||||
);
|
||||
assert.equal(new Set(workspaces.map((workspace) => workspace.brand.id)).size, 3);
|
||||
});
|
||||
|
||||
test("public workspace uses brand-scoped capability installations and preserves status", async () => {
|
||||
await prisma.capabilityInstallation.deleteMany({ where: { brandId } });
|
||||
const installation = await prisma.capabilityInstallation.create({
|
||||
@@ -80,6 +351,8 @@ test("public workspace uses brand-scoped capability installations and preserves
|
||||
},
|
||||
});
|
||||
try {
|
||||
const published = await publishReleaseForTests();
|
||||
assert.equal(published.statusCode, 201);
|
||||
const response = await request("/public/workspace");
|
||||
assert.equal(response.statusCode, 200);
|
||||
const body = JSON.parse(response.body);
|
||||
@@ -125,6 +398,135 @@ test("admin can update declared capability status with authorization and audit",
|
||||
await prisma.capabilityAuditLog.deleteMany({ where: { brandId } });
|
||||
});
|
||||
|
||||
test("editor membership can manage brand content but cannot change system settings", async () => {
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const identity = readIdentity(token);
|
||||
const membership = await prisma.brandMembership.findUnique({
|
||||
where: { adminUserId_brandId: { adminUserId: identity.subject, brandId } },
|
||||
});
|
||||
assert.ok(membership);
|
||||
await prisma.brandMembership.update({ where: { id: membership.id }, data: { role: "editor" } });
|
||||
try {
|
||||
const offerings = await request("/admin/workspace/offerings", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(offerings.statusCode, 200);
|
||||
const capabilities = await request("/admin/workspace/capabilities", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(capabilities.statusCode, 403);
|
||||
const visualHistory = await request("/admin/config/visual-template/history", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(visualHistory.statusCode, 403);
|
||||
const visualUpdate = await request("/admin/config/brand", {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { config: { visualTemplateKey: "unknown-visual" } },
|
||||
});
|
||||
assert.equal(visualUpdate.statusCode, 403);
|
||||
} finally {
|
||||
await prisma.brandMembership.update({
|
||||
where: { id: membership.id },
|
||||
data: { role: membership.role },
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test("owner can manage brand members without removing the final owner", async () => {
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const identity = readIdentity(token);
|
||||
const members = await request("/admin/brands/members", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(members.statusCode, 200);
|
||||
const current = JSON.parse(members.body).find((item) => item.adminUserId === identity.subject);
|
||||
assert.ok(current);
|
||||
const selfDisable = await request(`/admin/brands/members/${current.id}`, {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { isEnabled: false },
|
||||
});
|
||||
assert.equal(selfDisable.statusCode, 400);
|
||||
const created = await request("/admin/brands/members", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: {
|
||||
username: `editor-${Date.now()}`,
|
||||
displayName: "测试编辑",
|
||||
password: "test-password-123",
|
||||
role: "editor",
|
||||
},
|
||||
});
|
||||
assert.equal(created.statusCode, 201);
|
||||
const guestMembership = JSON.parse(created.body);
|
||||
try {
|
||||
const updated = await request(`/admin/brands/members/${guestMembership.id}`, {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { isEnabled: false },
|
||||
});
|
||||
assert.equal(updated.statusCode, 200);
|
||||
assert.equal(JSON.parse(updated.body).isEnabled, false);
|
||||
} finally {
|
||||
await prisma.brandMembership.delete({ where: { id: guestMembership.id } });
|
||||
await prisma.adminUser.delete({ where: { id: guestMembership.adminUser.id } });
|
||||
}
|
||||
});
|
||||
|
||||
test("manually created member must change the initial password before normal use", async () => {
|
||||
const ownerLogin = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const ownerToken = JSON.parse(ownerLogin.body).token;
|
||||
const username = `first-login-${Date.now()}`;
|
||||
const created = await request("/admin/brands/members", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${ownerToken}` },
|
||||
payload: {
|
||||
username,
|
||||
displayName: "首次登录测试",
|
||||
password: "initial-password-123",
|
||||
role: "editor",
|
||||
},
|
||||
});
|
||||
assert.equal(created.statusCode, 201);
|
||||
const member = JSON.parse(created.body);
|
||||
assert.equal(member.adminUser.mustChangePassword, undefined);
|
||||
try {
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username, password: "initial-password-123" },
|
||||
});
|
||||
assert.equal(login.statusCode, 201);
|
||||
assert.equal(JSON.parse(login.body).mustChangePassword, true);
|
||||
const changed = await request("/admin/session/change-password", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${JSON.parse(login.body).token}` },
|
||||
payload: { currentPassword: "initial-password-123", newPassword: "updated-password-123" },
|
||||
});
|
||||
assert.equal(changed.statusCode, 201);
|
||||
const updatedLogin = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username, password: "updated-password-123" },
|
||||
});
|
||||
assert.equal(updatedLogin.statusCode, 201);
|
||||
assert.equal(JSON.parse(updatedLogin.body).mustChangePassword, false);
|
||||
} finally {
|
||||
await prisma.brandMembership.delete({ where: { id: member.id } });
|
||||
await prisma.adminUser.delete({ where: { id: member.adminUser.id } });
|
||||
}
|
||||
});
|
||||
|
||||
test("admin can install optional quote capability without industry-specific branching", async () => {
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
@@ -138,6 +540,7 @@ test("admin can install optional quote capability without industry-specific bran
|
||||
});
|
||||
assert.equal(response.statusCode, 200);
|
||||
assert.equal(JSON.parse(response.body).capabilityKey, "quote-request");
|
||||
assert.equal((await publishReleaseForTests()).statusCode, 201);
|
||||
const workspace = await request("/public/workspace");
|
||||
assert.ok(JSON.parse(workspace.body).plugins.some((plugin) => plugin.key === "quote-request"));
|
||||
await prisma.capabilityInstallation.deleteMany({
|
||||
@@ -204,16 +607,13 @@ test("admin can install doors industry template through the shared runtime contr
|
||||
const workspace = await request("/public/workspace");
|
||||
assert.equal(workspace.statusCode, 200);
|
||||
const body = JSON.parse(workspace.body);
|
||||
assert.equal(body.template.key, "doors");
|
||||
assert.ok(body.modules.some((item) => item.type === "offering"));
|
||||
assert.ok(body.modules.some((item) => item.type === "inquiry"));
|
||||
assert.deepEqual(
|
||||
body.runtimeCapabilities.map((item) => item.key),
|
||||
["offerings", "inquiry"],
|
||||
);
|
||||
assert.ok(Array.isArray(body.offerings));
|
||||
assert.ok(Array.isArray(body.fields));
|
||||
assert.ok(body.fields.every((field) => typeof field.key === "string"));
|
||||
assert.equal(body.template.key, "food");
|
||||
assert.equal(body.publication.status, "published");
|
||||
const samplePreview = await request("/admin/workspace/sample-content/preview", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(samplePreview.statusCode, 200);
|
||||
assert.equal(JSON.parse(samplePreview.body).templateKey, "doors");
|
||||
} finally {
|
||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId } });
|
||||
await prisma.brandModule.deleteMany({ where: { brandId } });
|
||||
@@ -222,6 +622,8 @@ test("admin can install doors industry template through the shared runtime contr
|
||||
});
|
||||
|
||||
test("admin can preview and import sample content idempotently", async () => {
|
||||
const originalBrand = await prisma.brandProfile.findUnique({ where: { id: brandId } });
|
||||
await prisma.brandProfile.update({ where: { id: brandId }, data: { templateKey: "doors" } });
|
||||
await prisma.offering.deleteMany({
|
||||
where: {
|
||||
brandId,
|
||||
@@ -262,6 +664,10 @@ test("admin can preview and import sample content idempotently", async () => {
|
||||
});
|
||||
await prisma.brandFieldDefinition.deleteMany({ where: { brandId, source: "sample" } });
|
||||
await prisma.capabilityAuditLog.deleteMany({ where: { brandId, capabilityKey: "doors" } });
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: brandId },
|
||||
data: { templateKey: originalBrand?.templateKey ?? "food" },
|
||||
});
|
||||
});
|
||||
|
||||
test("admin can install a template and public workspace exposes enabled configuration", async () => {
|
||||
@@ -284,7 +690,7 @@ test("admin can install a template and public workspace exposes enabled configur
|
||||
});
|
||||
assert.equal(installed.statusCode, 201);
|
||||
assert.equal(JSON.parse(installed.body).template.key, "personal");
|
||||
assert.equal(JSON.parse(installed.body).visualTemplate.key, "minimal-neutral");
|
||||
assert.equal(JSON.parse(installed.body).visualTemplate.key, "linjing-editorial");
|
||||
assert.equal(JSON.parse(installed.body).installation.configSnapshot.schemaVersion, "1.0");
|
||||
try {
|
||||
const previewUnauthorized = await request("/admin/workspace/template/preview");
|
||||
@@ -324,19 +730,11 @@ test("admin can install a template and public workspace exposes enabled configur
|
||||
assert.equal(publicWorkspace.statusCode, 200);
|
||||
const workspaceBody = JSON.parse(publicWorkspace.body);
|
||||
assert.equal(workspaceBody.contractVersion, "1.0");
|
||||
assert.equal(workspaceBody.template.key, "personal");
|
||||
assert.deepEqual(workspaceBody.capabilities, [
|
||||
{ key: "offerings", version: "1.0.0", status: "enabled", config: {} },
|
||||
{ key: "inquiry", version: "1.0.0", status: "enabled", config: {} },
|
||||
]);
|
||||
assert.deepEqual(workspaceBody.runtimeCapabilities, [
|
||||
{ key: "offerings", version: "1.0.0", status: "enabled", config: {} },
|
||||
{ key: "inquiry", version: "1.0.0", status: "enabled", config: {} },
|
||||
]);
|
||||
assert.equal(workspaceBody.modules.length, 5);
|
||||
assert.equal(workspaceBody.runtimeModules.length, 5);
|
||||
assert.equal(workspaceBody.template.key, "food");
|
||||
assert.ok(workspaceBody.modules.length > 0);
|
||||
assert.equal(workspaceBody.modules.length, workspaceBody.runtimeModules.length);
|
||||
assert.equal(workspaceBody.runtimeModules[0].schemaVersion, "1.0");
|
||||
assert.equal(workspaceBody.inquiryForm, null);
|
||||
assert.ok(workspaceBody.inquiryForm);
|
||||
const conflict = await request("/admin/workspace/install", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -424,18 +822,18 @@ test("admin visual template selection is reflected in public runtime workspace",
|
||||
const updated = await request("/admin/config/brand", {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { config: { visualTemplateKey: "minimal-neutral" } },
|
||||
payload: { config: { visualTemplateKey: "acheng-campus-food" } },
|
||||
});
|
||||
assert.equal(updated.statusCode, 200);
|
||||
try {
|
||||
const runtime = await request("/public/workspace");
|
||||
assert.equal(runtime.statusCode, 200);
|
||||
const body = JSON.parse(runtime.body);
|
||||
assert.equal(body.visualTemplate.key, "minimal-neutral");
|
||||
assert.equal(body.visualTemplate.key, "acheng-campus-food");
|
||||
assert.equal(body.visualTemplate.version, "1.0.0");
|
||||
assert.equal(body.theme.colors.accent, "#4B5563");
|
||||
assert.equal(body.visualTemplate.variants.hero, "minimal");
|
||||
assert.equal(body.visualTemplateManifest.key, "minimal-neutral");
|
||||
assert.equal(body.theme.colors.accent, "#E87532");
|
||||
assert.equal(body.visualTemplate.variants.hero, "stall-board");
|
||||
assert.equal(body.visualTemplateManifest.key, "acheng-campus-food");
|
||||
assert.equal(body.visualTemplateManifest.brandFirst, true);
|
||||
assert.deepEqual(
|
||||
body.visualTemplateManifest.pages.map((page) => page.key),
|
||||
@@ -450,6 +848,50 @@ test("admin visual template selection is reflected in public runtime workspace",
|
||||
}
|
||||
});
|
||||
|
||||
test("public workspace exposes declared brand and trust presentation data", async () => {
|
||||
const doorsBrand = await prisma.brandProfile.findUnique({ where: { slug: "linjing-doors" } });
|
||||
assert.ok(doorsBrand);
|
||||
const original = doorsBrand;
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: doorsBrand.id },
|
||||
data: {
|
||||
config: {
|
||||
...(original?.config && typeof original.config === "object" ? original.config : {}),
|
||||
homeHero: { title: "尚未发布的集成测试首页标题" },
|
||||
},
|
||||
},
|
||||
});
|
||||
try {
|
||||
const runtime = await request("/public/workspace?brandSlug=linjing-doors");
|
||||
assert.equal(runtime.statusCode, 200);
|
||||
const body = JSON.parse(runtime.body);
|
||||
assert.equal(body.brand.founder, "林叙安 (Lin XUAN)");
|
||||
assert.equal(body.brand.title, "高端门系统建筑研造主理人");
|
||||
assert.notEqual(body.brand.homeHero.title, "尚未发布的集成测试首页标题");
|
||||
assert.equal(body.trustPresentation.stats.length, 4);
|
||||
assert.equal(body.trustPresentation.pillars.length, 3);
|
||||
assert.equal(body.trustPresentation.serviceFlow.length, 6);
|
||||
assert.equal(body.brand.profilePresentation.coverage.length, 2);
|
||||
assert.equal(body.brand.profilePresentation.warranty.length, 4);
|
||||
assert.equal(body.brand.visualPresentation.home.proofTitle, "14 年,只做门与空间的关系");
|
||||
assert.equal(body.brand.visualPresentation.inquiry.submitLabel, "提交量房与定制评估需求");
|
||||
assert.equal(body.brand.visualPresentation.records.emptyAction, "开始咨询");
|
||||
assert.equal(body.offerings.length, 4);
|
||||
assert.ok(body.offerings.every((offering) => offering.presentation.heroImage));
|
||||
assert.ok(
|
||||
body.offerings.every((offering) => offering.presentation.details.materialsList.length),
|
||||
);
|
||||
const doorType = body.inquiryForms[0].fields.find((field) => field.key === "doorType");
|
||||
assert.equal(doorType.options.length, 5);
|
||||
assert.equal(doorType.options[0].value, "入户大门(防暴铸铜 / 实木)");
|
||||
} finally {
|
||||
await prisma.brandProfile.update({
|
||||
where: { id: doorsBrand.id },
|
||||
data: { config: original?.config ?? {} },
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test("admin can create and version an inquiry form", async () => {
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
@@ -537,6 +979,7 @@ test("admin can create and version an inquiry form", async () => {
|
||||
});
|
||||
assert.equal(blockedCapability.statusCode, 400);
|
||||
await prisma.capabilityInstallation.delete({ where: { id: capability.id } });
|
||||
assert.equal((await publishReleaseForTests()).statusCode, 201);
|
||||
const publicForm = await request(`/public/inquiry-forms/${id}`);
|
||||
assert.equal(publicForm.statusCode, 200);
|
||||
const publicOffering = await request(`/public/offerings/${offering.id}`);
|
||||
@@ -554,6 +997,13 @@ test("admin can create and version an inquiry form", async () => {
|
||||
(form) => form.key === id,
|
||||
);
|
||||
assert.deepEqual(runtimeForm.fields[1].options, [{ label: "微信", value: "wechat" }]);
|
||||
await prisma.inquiryForm.update({
|
||||
where: { id },
|
||||
data: {
|
||||
version: 3,
|
||||
fieldsSnapshot: [{ key: "draft_only", type: "text", label: "草稿字段", required: true }],
|
||||
},
|
||||
});
|
||||
const submission = await request("/customer/inquiry-submissions", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
@@ -561,6 +1011,7 @@ test("admin can create and version an inquiry form", async () => {
|
||||
});
|
||||
assert.equal(submission.statusCode, 201);
|
||||
assert.equal(JSON.parse(submission.body).formVersion, 2);
|
||||
assert.equal(JSON.parse(submission.body).fieldsSnapshot[0].key, "budget");
|
||||
assert.equal(JSON.parse(submission.body).offeringId, offering.id);
|
||||
assert.deepEqual(JSON.parse(submission.body).values, { budget: 1000 });
|
||||
assert.equal((await request("/customer/inquiry-submissions")).statusCode, 401);
|
||||
@@ -687,10 +1138,10 @@ test("admin can manage offerings and public endpoint hides disabled offerings",
|
||||
assert.equal(listed.statusCode, 200);
|
||||
assert.ok(JSON.parse(listed.body).some((item) => item.id === id));
|
||||
const publicItem = await request(`/public/offerings/${id}`);
|
||||
assert.equal(publicItem.statusCode, 200);
|
||||
assert.equal(publicItem.statusCode, 400);
|
||||
const publicList = await request("/public/offerings");
|
||||
assert.equal(publicList.statusCode, 200);
|
||||
assert.ok(JSON.parse(publicList.body).some((item) => item.id === id));
|
||||
assert.ok(!JSON.parse(publicList.body).some((item) => item.id === id));
|
||||
const updated = await request(`/admin/workspace/offerings/${id}`, {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -705,7 +1156,7 @@ test("admin can manage offerings and public endpoint hides disabled offerings",
|
||||
payload: { isEnabled: true },
|
||||
});
|
||||
assert.equal(reenabled.statusCode, 200);
|
||||
assert.equal((await request(`/public/offerings/${id}`)).statusCode, 200);
|
||||
assert.equal((await request(`/public/offerings/${id}`)).statusCode, 400);
|
||||
} finally {
|
||||
const deleted = await request(`/admin/workspace/offerings/${id}`, {
|
||||
method: "DELETE",
|
||||
@@ -936,7 +1387,7 @@ test("admin can read and update brand and service configuration", async () => {
|
||||
const projectedService = JSON.parse(publicServices.body).find(
|
||||
(item) => item.id === serviceBefore.id,
|
||||
);
|
||||
assert.equal(projectedService.priceText, "集成测试价格");
|
||||
assert.equal(projectedService.priceText, serviceBefore.priceText);
|
||||
|
||||
const listedServices = await request("/admin/workspace/offerings", {
|
||||
headers: { authorization: `Bearer ${adminToken}` },
|
||||
@@ -981,6 +1432,57 @@ test("admin can read and update brand and service configuration", async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("admin can update user-facing brand presentation without replacing other config", async () => {
|
||||
assert.equal(
|
||||
(await request("/admin/config/presentation", { method: "PATCH", payload: { home: {} } }))
|
||||
.statusCode,
|
||||
401,
|
||||
);
|
||||
assert.equal(
|
||||
(
|
||||
await request("/admin/config/presentation", {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
payload: { home: {} },
|
||||
})
|
||||
).statusCode,
|
||||
403,
|
||||
);
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const brand = await prisma.brandProfile.findUnique({ where: { id: brandId } });
|
||||
assert.ok(brand);
|
||||
const originalConfig = brand.config;
|
||||
try {
|
||||
const response = await request("/admin/config/presentation", {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: {
|
||||
identity: { founder: "可编辑主理人", title: "品牌主理人", ignoredNumber: 123 },
|
||||
home: { proofTitle: "用户可编辑的信任标题", ignoredNumber: 123 },
|
||||
inquiry: { submitLabel: "开始沟通" },
|
||||
},
|
||||
});
|
||||
assert.equal(response.statusCode, 200);
|
||||
const presentation = JSON.parse(response.body).visualPresentation;
|
||||
assert.equal(presentation.home.proofTitle, "用户可编辑的信任标题");
|
||||
assert.equal(presentation.home.ignoredNumber, undefined);
|
||||
assert.equal(presentation.inquiry.submitLabel, "开始沟通");
|
||||
const runtime = await request("/public/workspace");
|
||||
assert.notEqual(JSON.parse(runtime.body).brand.founder, "可编辑主理人");
|
||||
assert.notEqual(JSON.parse(runtime.body).brand.title, "品牌主理人");
|
||||
assert.notEqual(
|
||||
JSON.parse(runtime.body).brand.visualPresentation.home.proofTitle,
|
||||
"用户可编辑的信任标题",
|
||||
);
|
||||
} finally {
|
||||
await prisma.brandProfile.update({ where: { id: brandId }, data: { config: originalConfig } });
|
||||
}
|
||||
});
|
||||
|
||||
test("admin can manage trust content", async () => {
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
@@ -1004,7 +1506,7 @@ test("admin can manage trust content", async () => {
|
||||
const publicContent = await request("/public/trust-content");
|
||||
assert.equal(publicContent.statusCode, 200);
|
||||
const publicItems = JSON.parse(publicContent.body);
|
||||
assert.ok(publicItems.some((item) => item.id === id));
|
||||
assert.ok(!publicItems.some((item) => item.id === id));
|
||||
assert.ok(!publicItems.some((item) => item.id === JSON.parse(draft.body).id));
|
||||
try {
|
||||
const list = await request("/admin/config/trust-content", {
|
||||
@@ -1047,6 +1549,33 @@ test("wechat login validates the request DTO before exchanging the code", async
|
||||
assert.equal(response.statusCode, 400);
|
||||
});
|
||||
|
||||
test("wechat login creates a customer session for the requested brand", async () => {
|
||||
const doorsBrand = await prisma.brandProfile.findUnique({ where: { slug: "linjing-doors" } });
|
||||
assert.ok(doorsBrand);
|
||||
const sessionOpenid = `doors-login-${Date.now()}`;
|
||||
const wechatAuth = app.get(WechatAuthService);
|
||||
const originalExchangeCode = wechatAuth.exchangeCode;
|
||||
wechatAuth.exchangeCode = async () => ({ openid: sessionOpenid });
|
||||
try {
|
||||
const response = await request("/customer/session/wechat?brandSlug=linjing-doors", {
|
||||
method: "POST",
|
||||
payload: { code: "test-code" },
|
||||
});
|
||||
assert.equal(response.statusCode, 201);
|
||||
const identity = readIdentity(JSON.parse(response.body).token);
|
||||
assert.equal(identity.brandId, doorsBrand.id);
|
||||
assert.equal(identity.role, "customer");
|
||||
assert.ok(
|
||||
await prisma.customerUser.findUnique({
|
||||
where: { brandId_openid: { brandId: doorsBrand.id, openid: sessionOpenid } },
|
||||
}),
|
||||
);
|
||||
} finally {
|
||||
wechatAuth.exchangeCode = originalExchangeCode;
|
||||
await prisma.customerUser.deleteMany({ where: { openid: sessionOpenid } });
|
||||
}
|
||||
});
|
||||
|
||||
test("customer booking DTO rejects incomplete package requests", async () => {
|
||||
const response = await request("/customer/bookings", {
|
||||
method: "POST",
|
||||
@@ -1087,6 +1616,16 @@ test("customer can create and cancel a package booking", async () => {
|
||||
where: { brandId, isEnabled: true, priceAmount: { not: null } },
|
||||
});
|
||||
assert.ok(service);
|
||||
const release = await prisma.brandRelease.findFirst({
|
||||
where: { brandId, status: "published" },
|
||||
orderBy: { version: "desc" },
|
||||
});
|
||||
const publishedOffering = release?.snapshot?.offerings?.find?.((item) => item.id === service.id);
|
||||
assert.ok(publishedOffering);
|
||||
await prisma.offering.update({
|
||||
where: { id: service.id },
|
||||
data: { priceAmount: service.priceAmount + 500, name: `${service.name}草稿` },
|
||||
});
|
||||
const created = await request("/customer/bookings", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
@@ -1098,14 +1637,20 @@ test("customer can create and cancel a package booking", async () => {
|
||||
items: [{ offeringId: service.id, quantity: 2 }],
|
||||
},
|
||||
});
|
||||
await prisma.offering.update({
|
||||
where: { id: service.id },
|
||||
data: { priceAmount: service.priceAmount, name: service.name },
|
||||
});
|
||||
assert.equal(created.statusCode, 201);
|
||||
const createdBody = JSON.parse(created.body);
|
||||
assert.equal(createdBody.estimatedAmount, service.priceAmount * 2);
|
||||
assert.equal(createdBody.estimatedAmount, publishedOffering.priceAmount * 2);
|
||||
const booking = await prisma.booking.findUnique({ where: { bookingNo: createdBody.bookingNo } });
|
||||
assert.ok(booking);
|
||||
assert.equal(booking.workflowKey, "booking.basic");
|
||||
assert.equal(booking.currentState, "received");
|
||||
assert.equal(booking.offeringId, service.id);
|
||||
const bookingItem = await prisma.bookingItem.findFirst({ where: { bookingId: booking.id } });
|
||||
assert.equal(bookingItem?.serviceNameSnapshot, publishedOffering.name);
|
||||
const initialTransitions = await prisma.bookingStateTransition.findMany({
|
||||
where: { bookingId: booking.id },
|
||||
});
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
const { randomBytes } = require("node:crypto");
|
||||
const { spawnSync } = require("node:child_process");
|
||||
const { PrismaClient } = require("@prisma/client");
|
||||
|
||||
const databaseUrl = process.env.DATABASE_URL;
|
||||
if (!databaseUrl) throw new Error("DATABASE_URL is required for integration tests");
|
||||
|
||||
const schema = `pb_test_${randomBytes(8).toString("hex")}`;
|
||||
const testUrl = new URL(databaseUrl);
|
||||
testUrl.searchParams.set("schema", schema);
|
||||
const testEnvironment = { ...process.env, DATABASE_URL: testUrl.toString(), NODE_ENV: "test" };
|
||||
const administrator = new PrismaClient();
|
||||
|
||||
function run(command, args) {
|
||||
const result = spawnSync(command, args, { stdio: "inherit", env: testEnvironment });
|
||||
if (result.error) throw result.error;
|
||||
return result.status ?? 1;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
let created = false;
|
||||
let status = 1;
|
||||
try {
|
||||
await administrator.$executeRawUnsafe(`CREATE SCHEMA "${schema}"`);
|
||||
created = true;
|
||||
if (run("pnpm", ["exec", "prisma", "migrate", "deploy"]) !== 0) return status;
|
||||
if (run("pnpm", ["db:seed"]) !== 0) return status;
|
||||
status = run(process.execPath, ["--test", "test/http.integration.test.js"]);
|
||||
return status;
|
||||
} finally {
|
||||
if (created) await administrator.$executeRawUnsafe(`DROP SCHEMA "${schema}" CASCADE`);
|
||||
await administrator.$disconnect();
|
||||
process.exitCode = status;
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
const DEFAULT_API_BASE_URL = "http://172.16.6.123:3001";
|
||||
const DEFAULT_API_BASE_URL = "http://localhost:3001";
|
||||
const DEFAULT_BRAND_SLUG = "default-brand";
|
||||
|
||||
App({
|
||||
|
||||
+1
-26
@@ -2,6 +2,7 @@
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/services/index",
|
||||
"pages/stall-service/index",
|
||||
"pages/booking/index",
|
||||
"pages/bookings/index",
|
||||
"pages/offering/detail",
|
||||
@@ -14,31 +15,5 @@
|
||||
"navigationBarBackgroundColor": "#FBF7F1",
|
||||
"navigationBarTextStyle": "black",
|
||||
"backgroundColor": "#FBF7F1"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#7A4A2B",
|
||||
"selectedColor": "#B54A2C",
|
||||
"backgroundColor": "#FFFFFF",
|
||||
"borderStyle": "white",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"text": "首页",
|
||||
"iconPath": "assets/tab/home.png",
|
||||
"selectedIconPath": "assets/tab/home-selected.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/services/index",
|
||||
"text": "案例与体系",
|
||||
"iconPath": "assets/tab/briefcase.png",
|
||||
"selectedIconPath": "assets/tab/briefcase-selected.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/bookings/index",
|
||||
"text": "主理人与我",
|
||||
"iconPath": "assets/tab/user.png",
|
||||
"selectedIconPath": "assets/tab/user-selected.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
Component({
|
||||
properties: { brand: { type: Object, value: {} }, variant: { type: String, value: "default" } },
|
||||
properties: {
|
||||
brand: { type: Object, value: {} },
|
||||
presentation: { type: Object, value: {} },
|
||||
variant: { type: String, value: "default" },
|
||||
},
|
||||
});
|
||||
@@ -1 +1 @@
|
||||
<view class="founder"><image class="avatar" src="{{brand.avatarUrl || 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?auto=format&fit=crop&w=240&h=240&q=80'}}"/><view><text class="founder-name">{{brand.founder}}</text><text class="founder-title">{{brand.title}}</text><text class="quote">“{{brand.slogan}}”</text></view><text class="badge">亲自主理量房</text></view>
|
||||
<view class="founder"><image wx:if="{{brand.avatarUrl}}" class="avatar" src="{{brand.avatarUrl}}"/><view wx:else class="avatar avatar-placeholder">{{brand.founder}}</view><view><text class="founder-name">{{brand.founder}}</text><text class="founder-title">{{brand.title}}</text><text class="quote">“{{brand.slogan}}”</text></view><text wx:if="{{presentation.founderBadge}}" class="badge">{{presentation.founderBadge}}</text></view>
|
||||
@@ -12,6 +12,15 @@
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
}
|
||||
.avatar-placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
background: #eee;
|
||||
color: #777;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.founder-name {
|
||||
display: block;
|
||||
font: 34rpx serif;
|
||||
|
||||
@@ -12,7 +12,7 @@ Component({
|
||||
choose(e) {
|
||||
const field = this.data.fields.find((item) => item.key === e.currentTarget.dataset.key);
|
||||
const option = field?.options?.[e.detail.value];
|
||||
if (option) this.triggerEvent("input", { key: field.key, value: option.value });
|
||||
if (option) this.triggerEvent("input", { key: field.key, value: option.value ?? option });
|
||||
},
|
||||
dateChange(e) {
|
||||
this.triggerEvent("input", { key: e.currentTarget.dataset.key, value: e.detail.value });
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
Component({
|
||||
properties: { item: { type: Object, value: {} } },
|
||||
properties: {
|
||||
item: { type: Object, value: {} },
|
||||
presentation: { type: Object, value: {} },
|
||||
},
|
||||
methods: {
|
||||
inquire() {
|
||||
this.triggerEvent("inquire");
|
||||
|
||||
@@ -1 +1 @@
|
||||
<view class="detail"><image class="hero" src="{{item.image}}" mode="aspectFill"/><view class="content"><text class="category">{{item.category}} · {{item.tag}}</text><text class="title">{{item.name}}</text><text class="series">{{item.series}}</text><text class="price">{{item.priceRange}}</text><text class="desc">{{item.desc}}</text><view class="chips"><text wx:for="{{item.keywords}}" wx:key="*this">{{item}}</text></view></view><view class="bar"><button bindtap="inquire">预约测量 / 获取方案</button></view></view>
|
||||
<view class="detail"><view class="hero-wrap"><image class="hero" src="{{item.detailHero || item.image}}" mode="aspectFill"/><view class="hero-shade"></view><view class="hero-copy"><text>{{item.category}} · {{item.area}}</text><text>{{item.name}}</text><text>{{item.series}}</text></view></view><view class="content"><view class="price-card"><view><text>{{presentation.priceLabel}}</text><text>{{item.priceRange}}</text></view><view><text>{{presentation.spaceLabel}}</text><text>{{item.spaceType}}</text></view></view><view class="detail-section"><text class="section-title">{{presentation.backgroundTitle}}</text><text class="body">{{item.details.background || item.desc}}</text></view><view wx:if="{{item.details.designConcept}}" class="detail-section"><text class="section-title">{{presentation.conceptTitle}}</text><text class="body warm">{{item.details.designConcept}}</text></view><view wx:if="{{item.details.crafts.length}}" class="detail-section"><text class="section-title">{{presentation.craftsTitle}}</text><view wx:for="{{item.details.crafts}}" wx:key="*this" class="craft"><text>0{{index + 1}}</text><text>{{item}}</text></view></view><view wx:if="{{item.details.materialsList.length}}" class="detail-section"><text class="section-title">{{presentation.materialsTitle}}</text><view class="materials"><view wx:for="{{item.details.materialsList}}" wx:key="name"><text>{{item.name}}</text><text>{{item.spec}}</text></view></view></view><view class="chips"><text wx:for="{{item.keywords}}" wx:key="*this">{{item}}</text></view></view><view class="bar"><button bindtap="inquire">{{presentation.inquiryAction}}</button><text>{{presentation.inquiryHint}}</text></view></view>
|
||||
@@ -9,9 +9,138 @@
|
||||
height: 600rpx;
|
||||
display: block;
|
||||
}
|
||||
.hero-wrap {
|
||||
position: relative;
|
||||
height: 520rpx;
|
||||
overflow: hidden;
|
||||
background: #202221;
|
||||
}
|
||||
.hero-wrap .hero {
|
||||
height: 100%;
|
||||
}
|
||||
.hero-shade {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(180deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.78));
|
||||
}
|
||||
.hero-copy {
|
||||
position: absolute;
|
||||
right: 40rpx;
|
||||
bottom: 32rpx;
|
||||
left: 40rpx;
|
||||
color: #fff;
|
||||
}
|
||||
.hero-copy text {
|
||||
display: block;
|
||||
}
|
||||
.hero-copy text:first-child {
|
||||
color: #d9c8b2;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
.hero-copy text:nth-child(2) {
|
||||
margin-top: 12rpx;
|
||||
font: 38rpx serif;
|
||||
}
|
||||
.hero-copy text:last-child {
|
||||
margin-top: 8rpx;
|
||||
color: rgba(255, 255, 255, 0.72);
|
||||
font-size: 23rpx;
|
||||
}
|
||||
.content {
|
||||
padding: 42rpx 40rpx;
|
||||
}
|
||||
.price-card {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 24rpx;
|
||||
padding: 26rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 16rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.price-card view:last-child {
|
||||
text-align: right;
|
||||
}
|
||||
.price-card text {
|
||||
display: block;
|
||||
}
|
||||
.price-card text:first-child {
|
||||
color: #77736b;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
.price-card text:last-child {
|
||||
margin-top: 8rpx;
|
||||
color: #8a6846;
|
||||
font: 25rpx serif;
|
||||
}
|
||||
.detail-section {
|
||||
margin-top: 38rpx;
|
||||
}
|
||||
.section-title {
|
||||
display: block;
|
||||
padding-left: 16rpx;
|
||||
border-left: 5rpx solid #8a6846;
|
||||
color: #202221;
|
||||
font: 27rpx serif;
|
||||
}
|
||||
.body {
|
||||
display: block;
|
||||
margin-top: 16rpx;
|
||||
padding: 24rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 14rpx;
|
||||
background: #fff;
|
||||
color: #252525;
|
||||
font-size: 23rpx;
|
||||
line-height: 1.8;
|
||||
}
|
||||
.warm {
|
||||
background: #efece6;
|
||||
}
|
||||
.craft {
|
||||
display: flex;
|
||||
gap: 18rpx;
|
||||
margin-top: 14rpx;
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 12rpx;
|
||||
background: #fff;
|
||||
color: #252525;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.65;
|
||||
}
|
||||
.craft text:first-child {
|
||||
flex: 0 0 auto;
|
||||
color: #8a6846;
|
||||
font-family: monospace;
|
||||
font-weight: 700;
|
||||
}
|
||||
.materials {
|
||||
margin-top: 16rpx;
|
||||
overflow: hidden;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 12rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.materials view {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 24rpx;
|
||||
padding: 20rpx;
|
||||
color: #252525;
|
||||
font-size: 21rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.materials view + view {
|
||||
border-top: 1rpx solid #e6ded5;
|
||||
}
|
||||
.materials text:first-child {
|
||||
flex: 0 0 auto;
|
||||
color: #77736b;
|
||||
}
|
||||
.materials text:last-child {
|
||||
text-align: right;
|
||||
}
|
||||
.category {
|
||||
font-size: 21rpx;
|
||||
color: #8a6846;
|
||||
@@ -65,3 +194,10 @@
|
||||
color: #fff;
|
||||
border-radius: 0;
|
||||
}
|
||||
.bar text {
|
||||
display: block;
|
||||
margin-top: 10rpx;
|
||||
color: #77736b;
|
||||
text-align: center;
|
||||
font-size: 19rpx;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
Component({
|
||||
properties: {
|
||||
offerings: { type: Array, value: [] },
|
||||
presentation: { type: Object, value: {} },
|
||||
variant: { type: String, value: "default" },
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -1 +1 @@
|
||||
<view class="section"><view class="section-head"><view><text class="eyebrow dark">SELECTED WORKS</text><text class="section-title">精选门系统作品</text></view><text class="more" bindtap="more">查看全部 →</text></view><view wx:for="{{offerings}}" wx:key="id" class="work-card" data-id="{{item.id}}" bindtap="open"><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="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="more">{{presentation.worksAction}}</text></view><view wx:for="{{offerings}}" wx:key="id" class="work-card" data-id="{{item.id}}" bindtap="open"><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>
|
||||
@@ -1,5 +1,9 @@
|
||||
Component({
|
||||
properties: { brand: { type: Object, value: {} }, recordsCount: { type: Number, value: 0 } },
|
||||
properties: {
|
||||
brand: { type: Object, value: {} },
|
||||
presentation: { type: Object, value: {} },
|
||||
recordsCount: { type: Number, value: 0 },
|
||||
},
|
||||
methods: {
|
||||
call() {
|
||||
this.triggerEvent("call");
|
||||
|
||||
@@ -1 +1 @@
|
||||
<view class="profile"><view class="contact-card"><view class="identity"><view class="avatar">林</view><view><text class="founder">{{brand.founder}}</text><text class="role">{{brand.title}}</text></view></view><view class="line"><text>专线电话</text><view><text>{{brand.phone}}</text><button bindtap="call">呼叫</button></view></view><view class="line"><text>工作室微信</text><view><text>{{brand.wechat}}</text><button bindtap="copy">复制</button></view></view><view class="line"><text>实体工坊</text><text>{{brand.studioAddress}}</text></view></view><view class="entry" bindtap="records"><text>我的量房与定制咨询</text><text>{{recordsCount}} 条记录 ›</text></view></view>
|
||||
<view class="profile"><view class="contact-card"><view class="identity"><image wx:if="{{brand.avatarUrl}}" class="avatar" src="{{brand.avatarUrl}}" mode="aspectFill"/><view wx:else class="avatar">{{brand.founder}}</view><view><text class="founder">{{brand.founder}}</text><text class="role">{{brand.title}}</text></view></view><view class="line"><text>{{presentation.phoneLabel || '联系电话'}}</text><view><text>{{brand.phone}}</text><button bindtap="call">{{presentation.callAction || '呼叫'}}</button></view></view><view class="line"><text>{{presentation.wechatLabel || '微信'}}</text><view><text>{{brand.wechat}}</text><button bindtap="copy">{{presentation.copyAction || '复制'}}</button></view></view><view class="line"><text>{{presentation.addressLabel || '工作地址'}}</text><text>{{brand.studioAddress}}</text></view></view><view class="entry" bindtap="records"><text>{{presentation.recordsTitle || '我的咨询记录'}}</text><text>{{recordsCount}} {{presentation.recordsCountUnit || '条记录'}} ›</text></view></view>
|
||||
@@ -1,5 +1,8 @@
|
||||
Component({
|
||||
properties: { records: { type: Array, value: [] } },
|
||||
properties: {
|
||||
records: { type: Array, value: [] },
|
||||
presentation: { type: Object, value: {} },
|
||||
},
|
||||
methods: {
|
||||
create() {
|
||||
this.triggerEvent("create");
|
||||
|
||||
@@ -1 +1 @@
|
||||
<view class="records"><view wx:if="{{!records.length}}" class="empty"><text class="empty-title">还没有咨询记录</text><text>预约一次私享沟通,让我们从你的空间开始。</text><button bindtap="create">开始咨询</button></view><view wx:else><view class="record" wx:for="{{records}}" wx:key="id"><view class="record-head"><text>{{item.type}}</text><text class="status">{{item.status}}</text></view><text class="project">{{item.project}} · {{item.offeringName}}</text><text class="meta">档案编号 {{item.id}} {{item.createdAt}}</text><view wx:if="{{item.timeline.length}}" class="timeline"><view wx:for="{{item.timeline}}" wx:key="createdAt" class="timeline-item"><text class="timeline-dot">●</text><text>{{item.status}} · {{item.createdAt}}</text></view></view></view></view></view>
|
||||
<view class="records"><view wx:if="{{!records.length}}" class="empty"><text class="empty-title">{{presentation.emptyTitle}}</text><text>{{presentation.emptyDescription}}</text><button bindtap="create">{{presentation.emptyAction}}</button></view><view wx:else><view class="record" wx:for="{{records}}" wx:key="id"><view class="record-head"><text>{{item.type}}</text><text class="status">{{item.status}}</text></view><text class="project">{{item.project}} · {{item.offeringName}}</text><text class="meta">档案编号 {{item.id}} {{item.createdAt}}</text><view wx:if="{{item.timeline.length}}" class="timeline"><view wx:for="{{item.timeline}}" wx:key="createdAt" class="timeline-item"><text class="timeline-dot">●</text><text>{{item.status}} · {{item.createdAt}}</text></view></view></view></view></view>
|
||||
@@ -1,5 +1,8 @@
|
||||
Component({
|
||||
properties: { record: { type: Object, value: {} } },
|
||||
properties: {
|
||||
record: { type: Object, value: {} },
|
||||
presentation: { type: Object, value: {} },
|
||||
},
|
||||
methods: {
|
||||
records() {
|
||||
this.triggerEvent("records");
|
||||
|
||||
@@ -1 +1 @@
|
||||
<view class="success"><view class="mark">✓</view><text class="eyebrow">PRIVATE CONSULTATION</text><text class="title">已收到你的咨询</text><text class="intro">主理人会根据你的项目资料,整理初步判断并在 1 个工作日内与你联系。</text><view class="summary"><view><text>档案编号</text><text>{{record.id}}</text></view><view><text>定制类型</text><text>{{record.type}}</text></view><view><text>当前状态</text><text>{{record.status}}</text></view></view><button bindtap="records">查看咨询记录</button><button class="secondary" bindtap="home">返回首页</button></view>
|
||||
<view class="success"><view class="mark">✓</view><text class="eyebrow">{{presentation.eyebrow}}</text><text class="title">{{presentation.title}}</text><text class="intro">{{presentation.intro}}</text><view class="summary"><view><text>档案编号</text><text>{{record.id}}</text></view><view><text>定制类型</text><text>{{record.type}}</text></view><view><text>当前状态</text><text>{{record.status}}</text></view></view><button bindtap="records">{{presentation.recordsAction}}</button><button class="secondary" bindtap="home">{{presentation.homeAction}}</button></view>
|
||||
@@ -1,3 +1,7 @@
|
||||
Component({
|
||||
properties: { content: { type: Object, value: {} }, variant: { type: String, value: "default" } },
|
||||
properties: {
|
||||
content: { type: Object, value: {} },
|
||||
presentation: { type: Object, value: {} },
|
||||
variant: { type: String, value: "default" },
|
||||
},
|
||||
});
|
||||
@@ -1 +1 @@
|
||||
<view class="trust"><text class="eyebrow">林境门作品质宣言</text><text class="section-title light">拒绝流水线拼装</text><view wx:for="{{content.pillars}}" wx:key="title"><text class="work-name light">{{item.title}}</text><text class="body light-body">{{item.desc}}</text></view></view>
|
||||
<view class="trust"><text class="eyebrow">{{presentation.manifestoEyebrow}}</text><text class="section-title light">{{presentation.manifestoTitle}}</text><view wx:for="{{content.pillars}}" wx:key="title"><text class="work-name light">{{item.title}}</text><text class="body light-body">{{item.desc}}</text></view></view>
|
||||
@@ -1,3 +1,7 @@
|
||||
Component({
|
||||
properties: { content: { type: Object, value: {} }, variant: { type: String, value: "default" } },
|
||||
properties: {
|
||||
content: { type: Object, value: {} },
|
||||
presentation: { type: Object, value: {} },
|
||||
variant: { type: String, value: "default" },
|
||||
},
|
||||
});
|
||||
@@ -1 +1,11 @@
|
||||
<view class="intro"><text class="eyebrow dark">主理人工艺与信任凭证</text><text class="section-title">14 年,只做门与空间的关系</text><text class="body">{{content.bio}}</text><view class="stats"><view wx:for="{{content.stats}}" wx:key="value"><text class="stat-value">{{item.value}}</text><text class="stat-label">{{item.label}}</text><text class="body">{{item.sub}}</text></view></view></view>
|
||||
<view class="trust-section">
|
||||
<view class="trust-head"><text class="eyebrow">{{presentation.proofEyebrow || '信任凭证'}}</text></view>
|
||||
<view class="stats">
|
||||
<view wx:for="{{content.stats}}" wx:key="value" class="stat-card"><text class="stat-value">{{item.value}}</text><text class="stat-label">{{item.label}}</text><text class="stat-sub">{{item.sub}}</text></view>
|
||||
</view>
|
||||
<view class="manifesto">
|
||||
<view class="manifesto-head"><text>{{presentation.manifestoEyebrow}}</text><text>{{presentation.manifestoTitle}}</text></view>
|
||||
<view wx:for="{{content.pillars}}" wx:key="title" class="pillar"><view class="pillar-icon">{{item.icon === 'tree' ? '木' : item.icon === 'ruler' ? '尺' : '盾'}}</view><view><text class="pillar-title">{{item.title}}</text><text class="pillar-desc">{{item.desc}}</text></view></view>
|
||||
</view>
|
||||
<view class="flow-card"><text class="flow-eyebrow">{{presentation.flowEyebrow}}</text><text class="flow-title">{{presentation.flowTitle}}</text><view class="flow-grid"><view wx:for="{{content.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,7 +1,11 @@
|
||||
.intro {
|
||||
margin-top: 22rpx;
|
||||
padding: 28rpx;
|
||||
background: #fff;
|
||||
.trust-section {
|
||||
padding: 0 40rpx 42rpx;
|
||||
}
|
||||
.trust-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.eyebrow {
|
||||
display: block;
|
||||
@@ -9,26 +13,21 @@
|
||||
font-size: 20rpx;
|
||||
letter-spacing: 3rpx;
|
||||
}
|
||||
.section-title {
|
||||
display: block;
|
||||
margin-top: 12rpx;
|
||||
font: 40rpx serif;
|
||||
}
|
||||
.body {
|
||||
display: block;
|
||||
margin-top: 12rpx;
|
||||
color: #77736b;
|
||||
font-size: 25rpx;
|
||||
line-height: 1.7;
|
||||
.trust-link {
|
||||
color: #8a6846;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
.stats {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
margin-top: 24rpx;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 18rpx;
|
||||
}
|
||||
.stats view {
|
||||
padding: 16rpx 0;
|
||||
border-top: 1rpx solid #e6ded5;
|
||||
.stat-card {
|
||||
padding: 22rpx;
|
||||
background: #fff;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
.stat-value {
|
||||
display: block;
|
||||
@@ -38,4 +37,123 @@
|
||||
.stat-label {
|
||||
display: block;
|
||||
font-size: 22rpx;
|
||||
margin-top: 4rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
.stat-sub {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
color: #77736b;
|
||||
font-size: 18rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.manifesto {
|
||||
padding: 28rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #202221;
|
||||
color: #fff;
|
||||
}
|
||||
.manifesto-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding-bottom: 18rpx;
|
||||
margin-bottom: 20rpx;
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.12);
|
||||
color: #d9c8b2;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
.manifesto-head text:last-child {
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
font-size: 18rpx;
|
||||
}
|
||||
.pillar {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.pillar-icon {
|
||||
width: 44rpx;
|
||||
height: 44rpx;
|
||||
flex: 0 0 44rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 8rpx;
|
||||
background: rgba(138, 104, 70, 0.3);
|
||||
color: #d9c8b2;
|
||||
font-size: 18rpx;
|
||||
}
|
||||
.pillar-title,
|
||||
.pillar-desc {
|
||||
display: block;
|
||||
}
|
||||
.pillar-title {
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.pillar-desc {
|
||||
margin-top: 5rpx;
|
||||
color: rgba(255, 255, 255, 0.62);
|
||||
font-size: 18rpx;
|
||||
line-height: 1.55;
|
||||
}
|
||||
.flow-card {
|
||||
margin-top: 22rpx;
|
||||
padding: 32rpx 24rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 20rpx;
|
||||
background: #efece6;
|
||||
text-align: center;
|
||||
}
|
||||
.flow-eyebrow,
|
||||
.flow-title,
|
||||
.flow-sub {
|
||||
display: block;
|
||||
}
|
||||
.flow-eyebrow {
|
||||
color: #8a6846;
|
||||
font-size: 18rpx;
|
||||
letter-spacing: 2rpx;
|
||||
}
|
||||
.flow-title {
|
||||
margin-top: 6rpx;
|
||||
font: 30rpx serif;
|
||||
}
|
||||
.flow-sub {
|
||||
margin-top: 8rpx;
|
||||
color: #77736b;
|
||||
font-size: 18rpx;
|
||||
}
|
||||
.flow-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16rpx;
|
||||
margin-top: 26rpx;
|
||||
text-align: left;
|
||||
}
|
||||
.flow-item {
|
||||
padding: 18rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 14rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.flow-step,
|
||||
.flow-name,
|
||||
.flow-desc {
|
||||
display: block;
|
||||
}
|
||||
.flow-step {
|
||||
color: #8a6846;
|
||||
font-size: 18rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.flow-name {
|
||||
margin-top: 5rpx;
|
||||
font-size: 21rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
.flow-desc {
|
||||
margin-top: 6rpx;
|
||||
color: #77736b;
|
||||
font-size: 17rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
Component({
|
||||
properties: {
|
||||
active: { type: String, value: "home" },
|
||||
navigation: { type: Array, value: [] },
|
||||
},
|
||||
data: {
|
||||
tabs: [],
|
||||
},
|
||||
methods: {
|
||||
navigate(e) {
|
||||
const tab = e.currentTarget.dataset.tab;
|
||||
if (!tab || tab.key === this.data.active) return;
|
||||
wx.navigateTo({ url: tab.page });
|
||||
},
|
||||
},
|
||||
observers: {
|
||||
navigation(navigation) {
|
||||
this.setData({
|
||||
tabs: Array.isArray(navigation)
|
||||
? navigation.map((item) => ({
|
||||
...item,
|
||||
page: item.page && item.page.startsWith("/") ? item.page : `/${item.page || ""}`,
|
||||
}))
|
||||
: [],
|
||||
});
|
||||
},
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.setData({ tabs: this.data.navigation || [] });
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{ "component": true }
|
||||
@@ -0,0 +1 @@
|
||||
<view class="runtime-tab-bar"><view wx:for="{{tabs}}" wx:key="key" class="tab {{active === item.key ? 'active' : ''}}" data-tab="{{item}}" bindtap="navigate"><text class="icon">{{item.key === 'home' ? '⌂' : item.key === 'dishes' ? '♨' : item.key === 'service' ? '⌖' : item.key === 'owner' ? '♙' : item.key === 'booking' ? '✉' : '◈'}}</text><text>{{item.label}}</text></view></view>
|
||||
@@ -0,0 +1,32 @@
|
||||
.runtime-tab-bar {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 20;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
padding: 10rpx 6rpx calc(10rpx + env(safe-area-inset-bottom));
|
||||
border-top: 1rpx solid #eee5dc;
|
||||
background: rgba(255, 255, 255, 0.97);
|
||||
box-shadow: 0 -8rpx 24rpx rgba(48, 32, 20, 0.08);
|
||||
}
|
||||
.tab {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
color: #9a8d83;
|
||||
font-size: 19rpx;
|
||||
}
|
||||
.icon {
|
||||
height: 34rpx;
|
||||
font-size: 31rpx;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
.tab.active {
|
||||
color: #e87532;
|
||||
font-weight: 700;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
Component({
|
||||
properties: {
|
||||
brand: { type: Object, value: {} },
|
||||
presentation: { type: Object, value: {} },
|
||||
trustContent: { type: Object, value: {} },
|
||||
offerings: { type: Array, value: [] },
|
||||
},
|
||||
methods: {
|
||||
openOffering(e) {
|
||||
this.triggerEvent("select", { id: e.currentTarget.dataset.id });
|
||||
},
|
||||
openInquiry() {
|
||||
this.triggerEvent("inquiry");
|
||||
},
|
||||
openOfferings() {
|
||||
this.triggerEvent("offerings");
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{ "component": true }
|
||||
@@ -0,0 +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 class="notice-time">{{presentation.stallTime || '今日营业中'}}</text></view><view class="actions"><button bindtap="openInquiry">预约 / 定制</button><button class="muted" bindtap="openOfferings">今日菜单</button></view></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 class="promise"><text class="eyebrow light">{{presentation.manifestoEyebrow || '阿成的开档底线'}}</text><text class="promise-title">{{presentation.manifestoTitle || '真材实料,当天现做'}}</text><view wx:for="{{trustContent.pillars}}" wx:key="title" class="promise-item"><text>✓</text><text>{{item.title}}</text></view></view></view>
|
||||
@@ -0,0 +1,177 @@
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 20rpx 28rpx 48rpx;
|
||||
background: #fff8f0;
|
||||
color: #29231f;
|
||||
}
|
||||
.brand-card {
|
||||
padding: 28rpx;
|
||||
border: 1rpx solid #f2d9c6;
|
||||
border-radius: 28rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 12rpx 30rpx rgba(145, 75, 33, 0.08);
|
||||
}
|
||||
.identity {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
align-items: center;
|
||||
}
|
||||
.identity image {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
border: 4rpx solid #ffd9bb;
|
||||
border-radius: 50%;
|
||||
background: #fff1e5;
|
||||
}
|
||||
.name,
|
||||
.title,
|
||||
.slogan,
|
||||
.notice-title,
|
||||
.notice text,
|
||||
.eyebrow,
|
||||
.heading,
|
||||
.more,
|
||||
.dish-name,
|
||||
.dish-sub,
|
||||
.price,
|
||||
.promise-title,
|
||||
.promise-item text {
|
||||
display: block;
|
||||
}
|
||||
.name {
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.title {
|
||||
margin-top: 6rpx;
|
||||
color: #a2613b;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
.slogan {
|
||||
margin-top: 10rpx;
|
||||
color: #7a6a60;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
.notice {
|
||||
position: relative;
|
||||
margin-top: 24rpx;
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #f8d7b4;
|
||||
border-radius: 20rpx;
|
||||
background: #fff7df;
|
||||
color: #6b4a35;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.notice-title {
|
||||
font-weight: 700;
|
||||
color: #4f3020;
|
||||
}
|
||||
.notice-time {
|
||||
position: absolute;
|
||||
right: 18rpx;
|
||||
top: 18rpx;
|
||||
color: #c65c28;
|
||||
font-size: 19rpx;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 14rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.actions button {
|
||||
flex: 1;
|
||||
height: 76rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #e87532;
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
line-height: 76rpx;
|
||||
}
|
||||
.actions .muted {
|
||||
background: #fff0e5;
|
||||
color: #b85e2c;
|
||||
}
|
||||
.section-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: end;
|
||||
margin: 34rpx 4rpx 18rpx;
|
||||
}
|
||||
.eyebrow {
|
||||
color: #d2652b;
|
||||
font-size: 19rpx;
|
||||
letter-spacing: 2rpx;
|
||||
}
|
||||
.heading {
|
||||
margin-top: 8rpx;
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.more {
|
||||
color: #d2652b;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
.dish-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16rpx;
|
||||
}
|
||||
.dish {
|
||||
overflow: hidden;
|
||||
border: 1rpx solid #f2e2d6;
|
||||
border-radius: 22rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.dish image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 220rpx;
|
||||
background: #f3e7de;
|
||||
}
|
||||
.dish-copy {
|
||||
padding: 18rpx;
|
||||
}
|
||||
.dish-name {
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.dish-sub {
|
||||
margin-top: 6rpx;
|
||||
color: #8c7b70;
|
||||
font-size: 19rpx;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.price {
|
||||
margin-top: 14rpx;
|
||||
color: #dc6429;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.promise {
|
||||
margin-top: 28rpx;
|
||||
padding: 28rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #3b2118;
|
||||
color: #fff;
|
||||
}
|
||||
.light {
|
||||
color: #ffc79f;
|
||||
}
|
||||
.promise-title {
|
||||
margin-top: 8rpx;
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.promise-item {
|
||||
display: flex;
|
||||
gap: 12rpx;
|
||||
margin-top: 18rpx;
|
||||
color: #ffe5d2;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
.promise-item text:first-child {
|
||||
color: #ff9a5a;
|
||||
font-weight: 700;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
Component({
|
||||
properties: {
|
||||
brand: { type: Object, value: {} },
|
||||
presentation: { type: Object, value: {} },
|
||||
offerings: { type: Array, value: [] },
|
||||
},
|
||||
methods: {
|
||||
open(e) {
|
||||
this.triggerEvent("open", { id: e.currentTarget.dataset.id });
|
||||
},
|
||||
inquire() {
|
||||
this.triggerEvent("inquire");
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{ "component": true }
|
||||
@@ -0,0 +1 @@
|
||||
<view class="page"><view class="head"><text class="eyebrow">{{brand.name}}</text><text class="title">{{presentation.title || '今日菜单'}}</text><text class="subtitle">{{presentation.subtitle || '现做现吃,支持提前预留和团体定制'}}</text></view><view class="tip">米饭免费续,口味和忌口都可以在预约时备注</view><view class="list"><view wx:for="{{offerings}}" wx:key="id" class="dish" data-id="{{item.id}}" bindtap="open"><image src="{{item.image}}" mode="aspectFill"/><view class="copy"><text class="name">{{item.name}}</text><text class="desc">{{item.desc}}</text><view class="bottom"><text class="price">{{item.priceRange}}</text><text class="action">查看详情 ›</text></view></view></view></view><button class="cta" bindtap="inquire">团体活动 / 定制餐咨询</button></view>
|
||||
@@ -0,0 +1,93 @@
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 28rpx;
|
||||
background: #fff8f0;
|
||||
color: #29231f;
|
||||
}
|
||||
.eyebrow {
|
||||
display: block;
|
||||
color: #d2652b;
|
||||
font-size: 19rpx;
|
||||
letter-spacing: 2rpx;
|
||||
}
|
||||
.title {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
font-size: 42rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.subtitle {
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
color: #8c7b70;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.tip {
|
||||
margin-top: 22rpx;
|
||||
padding: 18rpx 20rpx;
|
||||
border: 1rpx solid #f8d7b4;
|
||||
border-radius: 18rpx;
|
||||
background: #fff7df;
|
||||
color: #8c5c39;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
.list {
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
.dish {
|
||||
display: flex;
|
||||
gap: 18rpx;
|
||||
margin-bottom: 16rpx;
|
||||
padding: 14rpx;
|
||||
border: 1rpx solid #f2e2d6;
|
||||
border-radius: 22rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.dish image {
|
||||
width: 196rpx;
|
||||
height: 196rpx;
|
||||
flex: none;
|
||||
border-radius: 16rpx;
|
||||
background: #f3e7de;
|
||||
}
|
||||
.copy {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
}
|
||||
.name {
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.desc {
|
||||
margin-top: 10rpx;
|
||||
color: #8c7b70;
|
||||
font-size: 20rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.bottom {
|
||||
display: flex;
|
||||
align-items: end;
|
||||
justify-content: space-between;
|
||||
margin-top: auto;
|
||||
}
|
||||
.price {
|
||||
color: #dc6429;
|
||||
font-size: 25rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.action {
|
||||
color: #d2652b;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
.cta {
|
||||
margin: 22rpx 0 0;
|
||||
height: 76rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #e87532;
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
line-height: 76rpx;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
Component({
|
||||
properties: {
|
||||
brand: { type: Object, value: {} },
|
||||
presentation: { type: Object, value: {} },
|
||||
recordsCount: { type: Number, value: 0 },
|
||||
},
|
||||
methods: {
|
||||
call() {
|
||||
this.triggerEvent("call");
|
||||
},
|
||||
copy() {
|
||||
this.triggerEvent("copy");
|
||||
},
|
||||
records() {
|
||||
this.triggerEvent("records");
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{ "component": true }
|
||||
@@ -0,0 +1 @@
|
||||
<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>{{presentation.coverageContent || '支持校园摊位自取、宿舍配送和班级活动定制。'}}</text></view><view class="card" bindtap="records"><text class="card-title">我的预约记录</text><text>{{recordsCount}} 条记录 ›</text></view></view>
|
||||
@@ -0,0 +1,72 @@
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 28rpx;
|
||||
background: #fff8f0;
|
||||
color: #29231f;
|
||||
}
|
||||
.profile-card {
|
||||
padding: 36rpx 28rpx;
|
||||
text-align: center;
|
||||
border-radius: 28rpx;
|
||||
background: #3b2118;
|
||||
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;
|
||||
}
|
||||
.name {
|
||||
margin-top: 18rpx;
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.title {
|
||||
margin-top: 6rpx;
|
||||
color: #ffc79f;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.bio {
|
||||
margin-top: 16rpx;
|
||||
color: #ffe5d2;
|
||||
font-size: 23rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.contact {
|
||||
display: flex;
|
||||
gap: 14rpx;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
.contact button {
|
||||
flex: 1;
|
||||
height: 70rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #e87532;
|
||||
color: #fff;
|
||||
font-size: 22rpx;
|
||||
line-height: 70rpx;
|
||||
}
|
||||
.card {
|
||||
margin-top: 18rpx;
|
||||
padding: 26rpx;
|
||||
border: 1rpx solid #f2d9c6;
|
||||
border-radius: 22rpx;
|
||||
background: #fff;
|
||||
color: #7a6a60;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.7;
|
||||
}
|
||||
.card-title {
|
||||
margin-bottom: 10rpx;
|
||||
color: #4b2b1d;
|
||||
font-size: 27rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
Component({
|
||||
properties: {
|
||||
brand: { type: Object, value: {} },
|
||||
presentation: { type: Object, value: {} },
|
||||
hero: { type: Object, value: {} },
|
||||
trustContent: { type: Object, value: {} },
|
||||
offerings: { type: Array, value: [] },
|
||||
},
|
||||
methods: {
|
||||
selectOffering(event) {
|
||||
this.triggerEvent("select", { id: event.currentTarget.dataset.id });
|
||||
},
|
||||
goWorks() {
|
||||
this.triggerEvent("works");
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{ "component": true }
|
||||
@@ -0,0 +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="{{brand.heroImage}}" 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="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>
|
||||
@@ -0,0 +1,261 @@
|
||||
.page {
|
||||
background: #f7f5f1;
|
||||
color: #252525;
|
||||
padding-bottom: 30rpx;
|
||||
}
|
||||
.founder-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
align-items: flex-start;
|
||||
margin: 32rpx 40rpx 20rpx;
|
||||
padding: 28rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 28rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.avatar {
|
||||
width: 112rpx;
|
||||
height: 112rpx;
|
||||
flex: 0 0 112rpx;
|
||||
border: 4rpx solid #d9c8b2;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.founder-copy {
|
||||
min-width: 0;
|
||||
padding-right: 78rpx;
|
||||
}
|
||||
.founder-name,
|
||||
.founder-title,
|
||||
.quote,
|
||||
.eyebrow,
|
||||
.hero-title,
|
||||
.hero-slogan,
|
||||
.section-title,
|
||||
.body,
|
||||
.stat-value,
|
||||
.stat-label,
|
||||
.stat-sub,
|
||||
.pillar-title,
|
||||
.pillar-desc,
|
||||
.work-category,
|
||||
.work-name,
|
||||
.work-desc,
|
||||
.flow-eyebrow,
|
||||
.flow-title,
|
||||
.flow-step,
|
||||
.flow-name,
|
||||
.flow-desc {
|
||||
display: block;
|
||||
}
|
||||
.founder-name {
|
||||
font: 30rpx serif;
|
||||
}
|
||||
.founder-title {
|
||||
margin-top: 6rpx;
|
||||
color: #77736b;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
.quote {
|
||||
margin-top: 14rpx;
|
||||
font: 21rpx serif;
|
||||
}
|
||||
.badge {
|
||||
position: absolute;
|
||||
top: 24rpx;
|
||||
right: 20rpx;
|
||||
padding: 8rpx 12rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #f3ede6;
|
||||
color: #8a6846;
|
||||
font-size: 18rpx;
|
||||
}
|
||||
.hero {
|
||||
position: relative;
|
||||
height: 400rpx;
|
||||
margin: 0 40rpx 42rpx;
|
||||
overflow: hidden;
|
||||
border-radius: 28rpx;
|
||||
}
|
||||
.hero-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.hero-shade {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(180deg, rgba(20, 22, 21, 0.1), rgba(20, 22, 21, 0.82));
|
||||
}
|
||||
.hero-copy {
|
||||
position: absolute;
|
||||
right: 28rpx;
|
||||
bottom: 28rpx;
|
||||
left: 28rpx;
|
||||
color: #fff;
|
||||
}
|
||||
.eyebrow {
|
||||
margin-bottom: 14rpx;
|
||||
color: #d9c8b2;
|
||||
font-size: 18rpx;
|
||||
letter-spacing: 3rpx;
|
||||
}
|
||||
.dark {
|
||||
color: #8a6846;
|
||||
}
|
||||
.hero-title,
|
||||
.section-title {
|
||||
font: 34rpx serif;
|
||||
}
|
||||
.hero-slogan {
|
||||
margin-top: 10rpx;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
.hero-button {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 12rpx 16rpx;
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.3);
|
||||
color: #d9c8b2;
|
||||
font-size: 19rpx;
|
||||
}
|
||||
.intro,
|
||||
.section {
|
||||
padding: 0 40rpx 48rpx;
|
||||
}
|
||||
.body {
|
||||
color: #77736b;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.8;
|
||||
}
|
||||
.stats {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16rpx;
|
||||
margin-top: 22rpx;
|
||||
}
|
||||
.stats view {
|
||||
padding: 22rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 20rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.stat-value {
|
||||
color: #8a6846;
|
||||
font: 38rpx serif;
|
||||
}
|
||||
.stat-label {
|
||||
margin-top: 4rpx;
|
||||
font-size: 22rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
.stat-sub {
|
||||
margin-top: 6rpx;
|
||||
color: #77736b;
|
||||
font-size: 18rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.trust {
|
||||
padding: 42rpx 40rpx;
|
||||
background: #202221;
|
||||
color: #fff;
|
||||
}
|
||||
.light {
|
||||
color: #fff;
|
||||
}
|
||||
.pillar {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
.pillar-title {
|
||||
color: #fff;
|
||||
font: 28rpx serif;
|
||||
}
|
||||
.pillar-desc {
|
||||
margin-top: 8rpx;
|
||||
color: #c6c2ba;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.65;
|
||||
}
|
||||
.section-head {
|
||||
display: flex;
|
||||
align-items: end;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 22rpx;
|
||||
}
|
||||
.more {
|
||||
color: #8a6846;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
.work-card {
|
||||
margin-bottom: 24rpx;
|
||||
overflow: hidden;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 28rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.work-card image {
|
||||
width: 100%;
|
||||
height: 300rpx;
|
||||
}
|
||||
.work-info {
|
||||
padding: 24rpx;
|
||||
}
|
||||
.work-category {
|
||||
color: #8a6846;
|
||||
font-size: 19rpx;
|
||||
}
|
||||
.work-name {
|
||||
margin: 10rpx 0;
|
||||
font: 28rpx serif;
|
||||
}
|
||||
.work-desc {
|
||||
color: #77736b;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.flow {
|
||||
margin: 0 40rpx 42rpx;
|
||||
padding: 30rpx 24rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 20rpx;
|
||||
background: #efece6;
|
||||
text-align: center;
|
||||
}
|
||||
.flow-eyebrow {
|
||||
color: #8a6846;
|
||||
font-size: 18rpx;
|
||||
letter-spacing: 2rpx;
|
||||
}
|
||||
.flow-title {
|
||||
margin-top: 6rpx;
|
||||
font: 30rpx serif;
|
||||
}
|
||||
.flow-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16rpx;
|
||||
margin-top: 24rpx;
|
||||
text-align: left;
|
||||
}
|
||||
.flow-item {
|
||||
padding: 18rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 14rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.flow-step {
|
||||
color: #8a6846;
|
||||
font-size: 18rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.flow-name {
|
||||
margin-top: 5rpx;
|
||||
font-size: 21rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
.flow-desc {
|
||||
margin-top: 6rpx;
|
||||
color: #77736b;
|
||||
font-size: 17rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
Component({
|
||||
properties: {
|
||||
brand: { type: Object, value: {} },
|
||||
presentation: { type: Object, value: {} },
|
||||
recordsCount: { type: Number, value: 0 },
|
||||
},
|
||||
methods: {
|
||||
call() {
|
||||
this.triggerEvent("call");
|
||||
},
|
||||
copy() {
|
||||
this.triggerEvent("copy");
|
||||
},
|
||||
records() {
|
||||
this.triggerEvent("records");
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-icon": "/miniprogram_npm/tdesign-miniprogram/icon/icon"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<view class="profile">
|
||||
<view class="founder-card">
|
||||
<view class="identity">
|
||||
<image class="avatar" src="{{brand.avatarUrl}}" mode="aspectFill" />
|
||||
<view><text class="founder">{{brand.founder}}</text><text class="role">{{brand.title}}</text></view>
|
||||
</view>
|
||||
<view class="contact-lines">
|
||||
<view class="contact-line"><text class="label">{{presentation.phoneLabel}}</text><view class="contact-action"><text class="value">{{brand.phone}}</text><button bindtap="call"><t-icon name="call" size="24rpx" />{{presentation.callAction}}</button></view></view>
|
||||
<view class="contact-line"><text class="label">{{presentation.wechatLabel}}</text><view class="contact-action"><text class="value accent">{{brand.wechat}}</text><button bindtap="copy"><t-icon name="file-copy" size="24rpx" />{{presentation.copyAction}}</button></view></view>
|
||||
<view class="contact-line address"><text class="label">{{presentation.addressLabel}}</text><text class="address-value">{{brand.studioAddress}}</text></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="records-card" bindtap="records">
|
||||
<view class="entry-icon"><t-icon name="logo-notion" size="34rpx" /></view>
|
||||
<view class="entry-copy"><text>{{presentation.recordsTitle}}</text><text>{{presentation.recordsSubtitle}}</text></view>
|
||||
<view class="entry-count"><text>{{recordsCount}} {{presentation.recordsCountUnit}}</text><t-icon name="chevron-right" size="30rpx" /></view>
|
||||
</view>
|
||||
<view class="info-card">
|
||||
<view class="card-title"><t-icon name="map" size="32rpx" /><text>{{presentation.coverageTitle}}</text></view>
|
||||
<view wx:for="{{brand.profilePresentation.coverage}}" wx:key="title" class="note"><text class="note-title">{{item.title}}</text><text>{{item.content}}</text></view>
|
||||
</view>
|
||||
<view class="info-card">
|
||||
<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>
|
||||
@@ -0,0 +1,194 @@
|
||||
.profile {
|
||||
min-height: 100vh;
|
||||
padding: 28rpx 32rpx 56rpx;
|
||||
background: #f7f5f1;
|
||||
color: #252525;
|
||||
}
|
||||
.founder-card {
|
||||
padding: 34rpx 30rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #202221;
|
||||
color: #fff;
|
||||
box-shadow: 0 12rpx 34rpx rgba(32, 34, 33, 0.12);
|
||||
}
|
||||
.identity {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 22rpx;
|
||||
}
|
||||
.avatar {
|
||||
width: 92rpx;
|
||||
height: 92rpx;
|
||||
border: 2rpx solid #8a6846;
|
||||
border-radius: 50%;
|
||||
background: #343736;
|
||||
}
|
||||
.founder,
|
||||
.role,
|
||||
.label,
|
||||
.value,
|
||||
.address-value,
|
||||
.entry-copy text,
|
||||
.entry-count text,
|
||||
.note-title,
|
||||
.note text,
|
||||
.warranty text {
|
||||
display: block;
|
||||
}
|
||||
.founder {
|
||||
font: 34rpx serif;
|
||||
}
|
||||
.role {
|
||||
margin-top: 8rpx;
|
||||
color: #d9c8b2;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.contact-lines {
|
||||
margin-top: 24rpx;
|
||||
border-top: 1rpx solid rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
.contact-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
padding-top: 18rpx;
|
||||
margin-top: 18rpx;
|
||||
border-top: 1rpx solid rgba(255, 255, 255, 0.1);
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.contact-line:first-child {
|
||||
border-top: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
.label {
|
||||
flex: 0 0 auto;
|
||||
color: rgba(255, 255, 255, 0.52);
|
||||
}
|
||||
.contact-action {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
}
|
||||
.value {
|
||||
color: #fff;
|
||||
font-family: monospace;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.accent {
|
||||
color: #d9c8b2;
|
||||
}
|
||||
.contact-action button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 5rpx;
|
||||
min-width: 86rpx;
|
||||
height: 46rpx;
|
||||
margin: 0;
|
||||
padding: 0 12rpx;
|
||||
border-radius: 9rpx;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: #d9c8b2;
|
||||
font-size: 20rpx;
|
||||
line-height: 46rpx;
|
||||
}
|
||||
.address {
|
||||
align-items: flex-start;
|
||||
}
|
||||
.address-value {
|
||||
max-width: 410rpx;
|
||||
color: rgba(255, 255, 255, 0.82);
|
||||
line-height: 1.55;
|
||||
text-align: right;
|
||||
}
|
||||
.records-card,
|
||||
.info-card {
|
||||
margin-top: 20rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 18rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 10rpx 30rpx -12rpx rgba(32, 34, 33, 0.08);
|
||||
}
|
||||
.records-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
padding: 26rpx;
|
||||
}
|
||||
.entry-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 66rpx;
|
||||
height: 66rpx;
|
||||
border-radius: 12rpx;
|
||||
background: rgba(138, 104, 70, 0.1);
|
||||
color: #8a6846;
|
||||
}
|
||||
.entry-copy {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.entry-copy text:first-child {
|
||||
color: #202221;
|
||||
font-size: 25rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
.entry-copy text:last-child {
|
||||
margin-top: 7rpx;
|
||||
color: #77736b;
|
||||
font-size: 20rpx;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.entry-count {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
flex: 0 0 auto;
|
||||
color: #8a6846;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
.info-card {
|
||||
padding: 28rpx;
|
||||
}
|
||||
.card-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
color: #202221;
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.card-title t-icon {
|
||||
color: #8a6846;
|
||||
}
|
||||
.note {
|
||||
margin-top: 18rpx;
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 12rpx;
|
||||
background: #f7f5f1;
|
||||
color: #57534e;
|
||||
font-size: 23rpx;
|
||||
line-height: 1.7;
|
||||
}
|
||||
.note-title {
|
||||
margin-bottom: 5rpx;
|
||||
color: #202221;
|
||||
font-size: 23rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.warranty {
|
||||
display: flex;
|
||||
gap: 10rpx;
|
||||
margin-top: 16rpx;
|
||||
color: #77736b;
|
||||
font-size: 23rpx;
|
||||
line-height: 1.65;
|
||||
}
|
||||
.dot {
|
||||
flex: 0 0 auto;
|
||||
color: #8a6846;
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
"tdesign-miniprogram": "^1.16.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test:fixture": "node test/validate-fixture.cjs",
|
||||
"test:fixture": "node test/validate-fixture.cjs && node --test test/runtime-workspace.test.cjs",
|
||||
"test:visual-fixture": "node test/validate-visual-fixture.cjs",
|
||||
"lint": "eslint src --ext .ts",
|
||||
"typecheck": "tsc -p tsconfig.json --noEmit",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { request, customerRequest } = require("../../utils/request");
|
||||
const { request, customerRequest, customerTokenKey } = require("../../utils/request");
|
||||
const { getTemplate } = require("../../utils/templates");
|
||||
Page({
|
||||
data: {
|
||||
@@ -70,13 +70,13 @@ Page({
|
||||
this.setData({ submitting: false });
|
||||
wx.showToast({ title: error.message || "提交失败", icon: "none" });
|
||||
});
|
||||
const token = wx.getStorageSync("customerToken");
|
||||
const token = wx.getStorageSync(customerTokenKey());
|
||||
if (token) return send();
|
||||
wx.login({
|
||||
success: (login) =>
|
||||
request("/customer/session/wechat", { method: "POST", data: { code: login.code } })
|
||||
.then((result) => {
|
||||
wx.setStorageSync("customerToken", result.token);
|
||||
wx.setStorageSync(customerTokenKey(), result.token);
|
||||
send();
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@@ -1,28 +1,49 @@
|
||||
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
const { customerRequest, customerTokenKey } = require("../../utils/request");
|
||||
Page({
|
||||
data: {
|
||||
brand: {},
|
||||
trustContent: [],
|
||||
records: [],
|
||||
pageRenderer: "",
|
||||
error: "",
|
||||
templateKey: "",
|
||||
navigation: [],
|
||||
},
|
||||
onLoad() {
|
||||
loadWorkspaceWithFallback().then((workspace) =>
|
||||
this.setData({
|
||||
brand: workspace.brand || {},
|
||||
trustContent: workspace.trustContent || [],
|
||||
records: wx.getStorageSync("linjingInquiryRecords") || [],
|
||||
}),
|
||||
);
|
||||
loadWorkspaceWithFallback()
|
||||
.then((workspace) =>
|
||||
this.setData({
|
||||
brand: workspace.brand || {},
|
||||
trustContent: workspace.trustContent || [],
|
||||
pageRenderer: workspace.pageRenderers?.profile || "",
|
||||
records: [],
|
||||
templateKey: workspace.visualTemplate?.key || "",
|
||||
navigation: workspace.navigation || [],
|
||||
}),
|
||||
)
|
||||
.catch((error) => this.setData({ error: error.message }));
|
||||
},
|
||||
onShow() {
|
||||
this.setData({ records: wx.getStorageSync("linjingInquiryRecords") || [] });
|
||||
this.loadRecords();
|
||||
},
|
||||
loadRecords() {
|
||||
if (!wx.getStorageSync(customerTokenKey())) return this.setData({ records: [] });
|
||||
customerRequest("/customer/inquiry-submissions")
|
||||
.then((records) => this.setData({ records: Array.isArray(records) ? records : [] }))
|
||||
.catch(() => this.setData({ records: [] }));
|
||||
},
|
||||
call() {
|
||||
wx.makePhoneCall({ phoneNumber: (this.data.brand.contactPhone || "").replace(/[^0-9-]/g, "") });
|
||||
wx.makePhoneCall({
|
||||
phoneNumber: (this.data.brand.phone || this.data.brand.contactPhone || "").replace(
|
||||
/[^0-9-]/g,
|
||||
"",
|
||||
),
|
||||
});
|
||||
},
|
||||
copyWechat() {
|
||||
wx.setClipboardData({
|
||||
data: this.data.brand.contactWechat || "",
|
||||
data: this.data.brand.wechat || this.data.brand.contactWechat || "",
|
||||
success: () => wx.showToast({ title: "微信号已复制", icon: "none" }),
|
||||
});
|
||||
},
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"navigationBarTextStyle": "black",
|
||||
"usingComponents": {
|
||||
"t-icon": "/miniprogram_npm/tdesign-miniprogram/icon/icon",
|
||||
"profile-module": "/components/modules/profile/profile"
|
||||
"profile-module": "/components/modules/profile/profile",
|
||||
"linjing-profile": "/components/templates/linjing-profile/linjing-profile",
|
||||
"acheng-profile": "/components/templates/acheng-profile/acheng-profile",
|
||||
"runtime-tab-bar": "/components/runtime-tab-bar/runtime-tab-bar"
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
<view class="page"><profile-module brand="{{brand}}" records-count="{{records.length}}" bind:call="call" bind:copy="copyWechat" bind:records="recordsPage" /><view class="info-card"><view class="card-title"><t-icon name="map" size="34rpx"/> <text>直派服务区域与履约说明</text></view><view class="note"><text class="note-title">直派核心圈:</text><text>上海、杭州、宁波、苏州、无锡、南京及深圳、广州。主理人及资深装配总工亲赴现场。</text></view><view class="note"><text class="note-title">全国其他城市私邸:</text><text>接受建筑设计师联合委托,安排远程 3D 激光测绘支持与专用物流直运安装。</text></view></view><view class="info-card"><view class="card-title"><t-icon name="secured" size="34rpx"/> <text>一门一档 · 终生质保规约</text></view><text class="bullet">门体内部防变形航空合金骨架承诺 10 年结构质保;</text><text class="bullet">重型天地轴、进口地弹簧及磁吸五金 5 年免费维护;</text><text class="bullet">每樘门出厂前进行 5000 次启闭校正;</text><text class="bullet">原木天然肌理享有首年 2 次木蜡油保养服务。</text></view></view>
|
||||
<view class="page"><view wx:if="{{error}}" class="runtime-error">{{error}}</view><block wx:else><acheng-profile wx:if="{{pageRenderer === 'acheng-profile'}}" brand="{{brand}}" presentation="{{brand.visualPresentation.profile}}" records-count="{{records.length}}" bind:call="call" bind:copy="copyWechat" bind:records="recordsPage" /><linjing-profile wx:elif="{{pageRenderer === 'linjing-profile'}}" brand="{{brand}}" presentation="{{brand.visualPresentation.profile}}" records-count="{{records.length}}" bind:call="call" bind:copy="copyWechat" bind:records="recordsPage" /><block wx:else><profile-module brand="{{brand}}" presentation="{{brand.visualPresentation.profile}}" records-count="{{records.length}}" bind:call="call" bind:copy="copyWechat" bind:records="recordsPage" /></block><runtime-tab-bar template-key="{{templateKey}}" active="owner" /></block></view>
|
||||
@@ -1,9 +1,19 @@
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 28rpx 32rpx 56rpx;
|
||||
padding: 0;
|
||||
background: #f7f5f1;
|
||||
color: #252525;
|
||||
}
|
||||
.runtime-error {
|
||||
margin: 48rpx 0;
|
||||
padding: 28rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 14rpx;
|
||||
background: #fff;
|
||||
color: #8a6846;
|
||||
font-size: 25rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.contact-card {
|
||||
padding: 34rpx 30rpx;
|
||||
background: #202221;
|
||||
@@ -151,3 +161,6 @@
|
||||
display: inline-flex;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 150rpx;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
const config = require("../../utils/config");
|
||||
Page({
|
||||
data: {
|
||||
brand: {},
|
||||
@@ -6,50 +7,66 @@ Page({
|
||||
offerings: [],
|
||||
modules: [],
|
||||
moduleVariants: {},
|
||||
pageRenderer: "",
|
||||
layout: [],
|
||||
theme: {},
|
||||
hero: {
|
||||
image:
|
||||
"https://images.unsplash.com/photo-1600585154340-be6161a56a0c?auto=format&fit=crop&w=900&q=80",
|
||||
eyebrow: "",
|
||||
title: "",
|
||||
slogan: "",
|
||||
cta: "了解业务与服务 →",
|
||||
},
|
||||
hero: { image: "", eyebrow: "", title: "", slogan: "", cta: "" },
|
||||
loading: false,
|
||||
loadedBrandSlug: "",
|
||||
templateKey: "",
|
||||
navigation: [],
|
||||
},
|
||||
onLoad() {
|
||||
this.loadWorkspace();
|
||||
},
|
||||
onShow() {
|
||||
if (this.data.loadedBrandSlug && this.data.loadedBrandSlug !== config.brandSlug) {
|
||||
this.loadWorkspace();
|
||||
}
|
||||
},
|
||||
loadWorkspace() {
|
||||
this.setData({ loading: true });
|
||||
loadWorkspaceWithFallback().then((workspace) => {
|
||||
const activeBrand = workspace.brand || {};
|
||||
const activeOfferings = workspace.offerings || [];
|
||||
const layout = workspace.layout?.home || [
|
||||
"founder-card",
|
||||
"brand-hero",
|
||||
"trust-proof",
|
||||
"trust-manifesto",
|
||||
"offering-list",
|
||||
];
|
||||
const firstOffering = activeOfferings[0] || {};
|
||||
this.setData({
|
||||
brand: activeBrand,
|
||||
trustContent: workspace.trustContent || [],
|
||||
offerings: activeOfferings,
|
||||
modules: workspace.modules || [],
|
||||
moduleVariants: workspace.moduleVariants || {},
|
||||
layout,
|
||||
theme: workspace.theme || {},
|
||||
hero: {
|
||||
...this.data.hero,
|
||||
image: activeBrand.heroImage || this.data.hero.image,
|
||||
eyebrow: activeBrand.tagline || activeBrand.name,
|
||||
title: firstOffering.name || activeBrand.name,
|
||||
slogan: activeBrand.description || "以专业经验建立长期信任",
|
||||
},
|
||||
loading: false,
|
||||
});
|
||||
wx.setNavigationBarTitle({ title: activeBrand.name || "个人品牌" });
|
||||
});
|
||||
loadWorkspaceWithFallback()
|
||||
.then((workspace) => {
|
||||
const activeBrand = workspace.brand || {};
|
||||
const activeOfferings = workspace.offerings || [];
|
||||
const layout = workspace.layout?.home || [
|
||||
"founder-card",
|
||||
"brand-hero",
|
||||
"trust-proof",
|
||||
"trust-manifesto",
|
||||
"offering-list",
|
||||
];
|
||||
const firstOffering = activeOfferings[0] || {};
|
||||
const configuredHero =
|
||||
activeBrand.homeHero && typeof activeBrand.homeHero === "object"
|
||||
? activeBrand.homeHero
|
||||
: {};
|
||||
this.setData({
|
||||
brand: activeBrand,
|
||||
trustContent: workspace.trustContent || [],
|
||||
offerings: activeOfferings,
|
||||
modules: workspace.modules || [],
|
||||
moduleVariants: workspace.moduleVariants || {},
|
||||
pageRenderer: workspace.pageRenderers?.home || "",
|
||||
layout,
|
||||
theme: workspace.theme || {},
|
||||
hero: {
|
||||
...this.data.hero,
|
||||
image: activeBrand.heroImage || this.data.hero.image,
|
||||
eyebrow: activeBrand.tagline || activeBrand.name,
|
||||
title: firstOffering.name || activeBrand.name,
|
||||
slogan: activeBrand.description || "",
|
||||
...configuredHero,
|
||||
},
|
||||
loading: false,
|
||||
loadedBrandSlug: config.brandSlug,
|
||||
templateKey: workspace.visualTemplate?.key || "",
|
||||
navigation: workspace.navigation || [],
|
||||
});
|
||||
wx.setNavigationBarTitle({ title: activeBrand.name || "个人品牌" });
|
||||
})
|
||||
.catch((error) => this.setData({ error: error.message, loading: false }));
|
||||
},
|
||||
showModule(e) {
|
||||
return this.data.layout.includes(e);
|
||||
@@ -65,6 +82,6 @@ Page({
|
||||
wx.navigateTo({ url: "/pages/inquiry/index" });
|
||||
},
|
||||
goProfile() {
|
||||
wx.switchTab({ url: "/pages/bookings/index" });
|
||||
wx.navigateTo({ url: "/pages/bookings/index" });
|
||||
},
|
||||
});
|
||||
@@ -1,10 +1,13 @@
|
||||
{
|
||||
"navigationBarTitleText": "品牌首页",
|
||||
"usingComponents": {
|
||||
"linjing-home": "/components/templates/linjing-home/linjing-home",
|
||||
"acheng-home": "/components/templates/acheng-home/acheng-home",
|
||||
"founder-card": "/components/modules/founder-card/founder-card",
|
||||
"brand-hero": "/components/modules/brand-hero/brand-hero",
|
||||
"trust-proof": "/components/modules/trust-proof/trust-proof",
|
||||
"trust-manifesto": "/components/modules/trust-manifesto/trust-manifesto",
|
||||
"offering-list": "/components/modules/offering-list/offering-list"
|
||||
"offering-list": "/components/modules/offering-list/offering-list",
|
||||
"runtime-tab-bar": "/components/runtime-tab-bar/runtime-tab-bar"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,17 @@
|
||||
<view class="page">
|
||||
<view wx:if="{{error}}" class="runtime-error">{{error}}</view>
|
||||
<block wx:else>
|
||||
<linjing-home wx:if="{{pageRenderer === 'linjing-home'}}" brand="{{brand}}" presentation="{{brand.visualPresentation.home}}" hero="{{hero}}" trust-content="{{trustContent}}" offerings="{{offerings}}" bind:select="selectOffering" bind:works="goWorks" />
|
||||
<acheng-home wx:elif="{{pageRenderer === 'acheng-home'}}" brand="{{brand}}" presentation="{{brand.visualPresentation.home}}" trust-content="{{trustContent}}" offerings="{{offerings}}" bind:select="selectOffering" bind:inquiry="goInquiry" bind:offerings="goWorks" />
|
||||
<block wx:else>
|
||||
<block wx:for="{{layout}}" wx:key="*this" wx:for-item="moduleKey">
|
||||
<founder-card wx:if="{{moduleKey === 'founder-card'}}" brand="{{brand}}" variant="{{moduleVariants[moduleKey]}}" />
|
||||
<founder-card wx:if="{{moduleKey === 'founder-card'}}" brand="{{brand}}" presentation="{{brand.visualPresentation.home}}" variant="{{moduleVariants[moduleKey]}}" />
|
||||
<brand-hero wx:if="{{moduleKey === 'brand-hero'}}" hero="{{hero}}" variant="{{moduleVariants[moduleKey]}}" bind:explore="goWorks" />
|
||||
<trust-proof wx:if="{{moduleKey === 'trust-proof'}}" content="{{trustContent}}" variant="{{moduleVariants[moduleKey]}}" />
|
||||
<trust-manifesto wx:if="{{moduleKey === 'trust-manifesto'}}" content="{{trustContent}}" variant="{{moduleVariants[moduleKey]}}" />
|
||||
<offering-list wx:if="{{moduleKey === 'offering-list'}}" offerings="{{offerings}}" variant="{{moduleVariants[moduleKey]}}" bind:open="selectOffering" bind:more="goWorks" />
|
||||
<trust-proof wx:if="{{moduleKey === 'trust-proof'}}" content="{{trustContent}}" presentation="{{brand.visualPresentation.home}}" variant="{{moduleVariants[moduleKey]}}" />
|
||||
<trust-manifesto wx:if="{{moduleKey === 'trust-manifesto'}}" content="{{trustContent}}" presentation="{{brand.visualPresentation.home}}" variant="{{moduleVariants[moduleKey]}}" />
|
||||
<offering-list wx:if="{{moduleKey === 'offering-list'}}" offerings="{{offerings}}" presentation="{{brand.visualPresentation.home}}" variant="{{moduleVariants[moduleKey]}}" bind:open="selectOffering" bind:more="goWorks" />
|
||||
</block>
|
||||
</block>
|
||||
</block>
|
||||
</view>
|
||||
<runtime-tab-bar template-key="{{templateKey}}" active="home" />
|
||||
@@ -4,6 +4,16 @@
|
||||
min-height: 100vh;
|
||||
padding-bottom: 30rpx;
|
||||
}
|
||||
.runtime-error {
|
||||
margin: 48rpx 32rpx;
|
||||
padding: 28rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 14rpx;
|
||||
background: #fff;
|
||||
color: #8a6846;
|
||||
font-size: 25rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.founder {
|
||||
margin: 32rpx 40rpx 20rpx;
|
||||
padding: 28rpx;
|
||||
@@ -206,3 +216,6 @@
|
||||
height: 72rpx;
|
||||
line-height: 72rpx;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 150rpx;
|
||||
}
|
||||
@@ -1,11 +1,17 @@
|
||||
const { customerRequest } = require("../../utils/request");
|
||||
const { customerRequest, customerTokenKey } = require("../../utils/request");
|
||||
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
|
||||
Page({
|
||||
data: { record: {} },
|
||||
data: { record: {}, presentation: {} },
|
||||
onLoad(options) {
|
||||
loadWorkspaceWithFallback()
|
||||
.then((workspace) =>
|
||||
this.setData({ presentation: workspace.brand?.visualPresentation?.success || {} }),
|
||||
)
|
||||
.catch(() => {});
|
||||
const record = wx.getStorageSync("latestInquirySubmission") || {};
|
||||
if (record.id === options.id) this.setData({ record });
|
||||
if (options.id && wx.getStorageSync("customerToken")) {
|
||||
if (options.id && wx.getStorageSync(customerTokenKey())) {
|
||||
customerRequest("/customer/inquiry-submissions/" + encodeURIComponent(options.id))
|
||||
.then((submission) =>
|
||||
this.setData({
|
||||
@@ -25,6 +31,6 @@ Page({
|
||||
wx.redirectTo({ url: "/pages/records/index" });
|
||||
},
|
||||
home() {
|
||||
wx.switchTab({ url: "/pages/index/index" });
|
||||
wx.navigateTo({ url: "/pages/index/index" });
|
||||
},
|
||||
});
|
||||
@@ -1 +1 @@
|
||||
<success-summary record="{{record}}" bind:records="viewRecords" bind:home="home" />
|
||||
<success-summary record="{{record}}" presentation="{{presentation}}" bind:records="viewRecords" bind:home="home" />
|
||||
@@ -1,5 +1,5 @@
|
||||
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
const { request, customerRequest } = require("../../utils/request");
|
||||
const { request, customerRequest, customerTokenKey } = require("../../utils/request");
|
||||
Page({
|
||||
data: {
|
||||
offering: null,
|
||||
@@ -8,31 +8,42 @@ Page({
|
||||
title: "需求咨询",
|
||||
subtitle: "提交信息后由主理人与你联系",
|
||||
submitLabel: "提交需求",
|
||||
presentation: {},
|
||||
values: {},
|
||||
fields: [],
|
||||
formId: "",
|
||||
error: "",
|
||||
templateKey: "",
|
||||
navigation: [],
|
||||
},
|
||||
onLoad(options) {
|
||||
loadWorkspaceWithFallback().then((workspace) => {
|
||||
const offering =
|
||||
(workspace.offerings || []).find((item) => item.id === options.offeringId) || null;
|
||||
const forms = workspace.inquiryForms || [];
|
||||
const form =
|
||||
forms.find((item) => item.targetId && item.targetId === options.offeringId) ||
|
||||
forms.find((item) => item.target === "brand") ||
|
||||
forms[0];
|
||||
const isQuote =
|
||||
form?.purpose === "quote-request" ||
|
||||
(workspace.plugins || []).some((plugin) => plugin.key === "quote-request");
|
||||
this.setData({
|
||||
offering,
|
||||
fields: form?.fields || workspace.fields || [],
|
||||
formId: form?.key || form?.id || "",
|
||||
title: isQuote ? "获取报价方案" : "需求咨询",
|
||||
eyebrow: isQuote ? "QUOTE REQUEST" : "CONSULTATION",
|
||||
submitLabel: isQuote ? "提交报价需求" : "提交需求",
|
||||
});
|
||||
});
|
||||
loadWorkspaceWithFallback()
|
||||
.then((workspace) => {
|
||||
const offering =
|
||||
(workspace.offerings || []).find((item) => item.id === options.offeringId) || null;
|
||||
const forms = workspace.inquiryForms || [];
|
||||
const form =
|
||||
forms.find((item) => item.targetId && item.targetId === options.offeringId) ||
|
||||
forms.find((item) => item.target === "brand") ||
|
||||
forms[0];
|
||||
const isQuote =
|
||||
form?.purpose === "quote-request" ||
|
||||
(workspace.plugins || []).some((plugin) => plugin.key === "quote-request");
|
||||
const presentation = workspace.brand?.visualPresentation?.inquiry || {};
|
||||
this.setData({
|
||||
offering,
|
||||
fields: form?.fields || workspace.fields || [],
|
||||
formId: form?.key || form?.id || "",
|
||||
title: isQuote ? "获取报价方案" : presentation.title || "需求咨询",
|
||||
eyebrow: isQuote ? "QUOTE REQUEST" : presentation.eyebrow || "CONSULTATION",
|
||||
subtitle: presentation.subtitle || "提交信息后由主理人与你联系",
|
||||
submitLabel: isQuote ? "提交报价需求" : presentation.submitLabel || "提交需求",
|
||||
presentation,
|
||||
templateKey: workspace.visualTemplate?.key || "",
|
||||
navigation: workspace.navigation || [],
|
||||
});
|
||||
})
|
||||
.catch((error) => this.setData({ error: error.message }));
|
||||
},
|
||||
onInput(e) {
|
||||
this.setData({ ["values." + e.currentTarget.dataset.key]: e.detail.value });
|
||||
@@ -69,12 +80,12 @@ Page({
|
||||
this.setData({ submitting: false });
|
||||
wx.showToast({ title: error.message || "提交失败,请重试", icon: "none" });
|
||||
};
|
||||
if (wx.getStorageSync("customerToken")) return send().catch(fail);
|
||||
if (wx.getStorageSync(customerTokenKey())) return send().catch(fail);
|
||||
wx.login({
|
||||
success: (login) =>
|
||||
request("/customer/session/wechat", { method: "POST", data: { code: login.code } })
|
||||
.then((result) => {
|
||||
wx.setStorageSync("customerToken", result.token);
|
||||
wx.setStorageSync(customerTokenKey(), result.token);
|
||||
return send();
|
||||
})
|
||||
.catch(fail),
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"brand-field": "/components/ui/brand-field/brand-field",
|
||||
"brand-loading": "/components/ui/brand-loading/brand-loading",
|
||||
"brand-empty": "/components/ui/brand-empty/brand-empty",
|
||||
"inquiry-form": "/components/modules/inquiry-form/inquiry-form"
|
||||
"inquiry-form": "/components/modules/inquiry-form/inquiry-form",
|
||||
"runtime-tab-bar": "/components/runtime-tab-bar/runtime-tab-bar"
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
<view class="page"><view class="head"><text class="eyebrow">{{eyebrow}}</text><text class="title">{{title}}</text><text class="sub">{{offering ? offering.name : subtitle}}</text></view><inquiry-form fields="{{fields}}" values="{{values}}" submitting="{{submitting}}" submit-label="{{submitLabel}}" bind:input="onComponentInput" bind:submit="submit" /></view>
|
||||
<view class="page"><view wx:if="{{error}}" class="runtime-error">{{error}}</view><block wx:else><view class="head"><text class="eyebrow">{{eyebrow}}</text><text class="title">{{title}}</text><text class="sub">{{offering ? offering.name : subtitle}}</text></view><view wx:if="{{presentation.note}}" class="booking-note"><text>{{presentation.note}}</text></view><view class="form-panel"><inquiry-form fields="{{fields}}" values="{{values}}" submitting="{{submitting}}" submit-label="{{submitLabel}}" bind:input="onComponentInput" bind:submit="submit" /></view></block></view>
|
||||
@@ -3,6 +3,91 @@
|
||||
background: #f7f5f1;
|
||||
color: #252525;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 150rpx;
|
||||
}
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
background: #fff8f0;
|
||||
color: #29231f;
|
||||
}
|
||||
.booking-hero {
|
||||
padding: 52rpx 32rpx 30rpx;
|
||||
background: linear-gradient(180deg, #fff1df, #fff8f0);
|
||||
}
|
||||
.booking-hero .eyebrow {
|
||||
display: block;
|
||||
color: #c65c28;
|
||||
font-size: 22rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
.booking-hero .title {
|
||||
display: block;
|
||||
margin-top: 14rpx;
|
||||
font-size: 44rpx;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.booking-hero .sub {
|
||||
display: block;
|
||||
margin-top: 14rpx;
|
||||
color: #7a6a60;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.7;
|
||||
}
|
||||
.booking-note {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 0 32rpx 20rpx;
|
||||
padding: 20rpx 22rpx;
|
||||
border: 1rpx solid #f3d1b2;
|
||||
border-radius: 20rpx;
|
||||
background: #fff;
|
||||
color: #a4562d;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
.form-panel {
|
||||
margin: 0 24rpx;
|
||||
padding: 10rpx 8rpx 24rpx;
|
||||
border: 1rpx solid #f1e1d5;
|
||||
border-radius: 28rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 12rpx 28rpx rgba(145, 75, 33, 0.06);
|
||||
}
|
||||
.form-panel .form {
|
||||
padding: 20rpx;
|
||||
}
|
||||
.form-panel .field {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.form-panel .label {
|
||||
color: #4f3020;
|
||||
font-weight: 700;
|
||||
}
|
||||
.form-panel input,
|
||||
.form-panel textarea,
|
||||
.form-panel .picker-value {
|
||||
border: 1rpx solid #eaded5;
|
||||
border-radius: 16rpx;
|
||||
background: #fffaf6;
|
||||
}
|
||||
.form-panel .submit {
|
||||
height: 82rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #e87532;
|
||||
color: #fff;
|
||||
line-height: 82rpx;
|
||||
}
|
||||
.runtime-error {
|
||||
margin: 48rpx 32rpx;
|
||||
padding: 28rpx;
|
||||
border: 1rpx solid #e6ded5;
|
||||
border-radius: 14rpx;
|
||||
background: #fff;
|
||||
color: #8a6846;
|
||||
font-size: 25rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.head {
|
||||
background: #252827;
|
||||
color: #fff;
|
||||
@@ -65,3 +150,6 @@
|
||||
font-size: 20rpx;
|
||||
margin-top: 26rpx;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 150rpx;
|
||||
}
|
||||
Loaded 100 of 317 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user