refactor: 统一小程序品牌运行时数据入口
This commit is contained in:
1 parent
accc113b2a
commit
947e6d1ac3
4 files changed
+58
-9
No files matched your search
@@ -1,18 +1,18 @@
|
||||
const { brand, trustContent } = require("../../utils/linjing-data");
|
||||
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
Page({
|
||||
data: {
|
||||
brand, trustContent, records: [],
|
||||
brand: {}, trustContent: [], records: [],
|
||||
},
|
||||
onLoad() {
|
||||
this.setData({ records: wx.getStorageSync("linjingInquiryRecords") || [] });
|
||||
loadWorkspaceWithFallback().then((workspace) => this.setData({ brand: workspace.brand || {}, trustContent: workspace.trustContent || [], records: wx.getStorageSync("linjingInquiryRecords") || [] }));
|
||||
},
|
||||
onShow() {
|
||||
this.setData({ records: wx.getStorageSync("linjingInquiryRecords") || [] });
|
||||
},
|
||||
call() {
|
||||
wx.makePhoneCall({ phoneNumber: brand.phone.replace(/[^0-9-]/g, "") });
|
||||
wx.makePhoneCall({ phoneNumber: (this.data.brand.contactPhone || "").replace(/[^0-9-]/g, "") });
|
||||
},
|
||||
copyWechat() { wx.setClipboardData({ data: brand.wechat, success: () => wx.showToast({ title: "微信号已复制", icon: "none" }) }); },
|
||||
copyWechat() { wx.setClipboardData({ data: this.data.brand.contactWechat || "", success: () => wx.showToast({ title: "微信号已复制", icon: "none" }) }); },
|
||||
recordsPage() { wx.navigateTo({ url: "/pages/records/index" }); },
|
||||
inquire() {
|
||||
wx.navigateTo({ url: "/pages/inquiry/index" });
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const { offerings } = require("../../utils/linjing-data");
|
||||
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
Page({
|
||||
data: { offering: null, submitting: false, values: { name: "", phone: "", city: "", doorType: "", note: "" }, fields: [{ key: "name", label: "联系人", placeholder: "请输入称呼" }, { key: "phone", label: "手机号码", placeholder: "请输入手机号" }, { key: "city", label: "项目所在城市", placeholder: "例如:上海 · 佘山" }, { key: "doorType", label: "希望定制的门类型", placeholder: "入户门 / 庭院门 / 室内门" }, { key: "note", label: "补充说明", placeholder: "告诉我们你的空间和需求" }] },
|
||||
onLoad(options) { this.setData({ offering: offerings.find((item) => item.id === options.offeringId) || null }); },
|
||||
onLoad(options) { loadWorkspaceWithFallback().then((workspace) => { const offering = (workspace.offerings || []).find((item) => item.id === options.offeringId) || null; this.setData({ offering, fields: workspace.fields?.length ? workspace.fields : this.data.fields }); }); },
|
||||
onInput(e) { this.setData({ ["values." + e.currentTarget.dataset.key]: e.detail.value }); },
|
||||
onComponentInput(e) { this.setData({ ["values." + e.detail.key]: e.detail.value }); },
|
||||
submit() { const values = this.data.values; if (!values.name || !values.phone) return wx.showToast({ title: "请填写联系人和手机号", icon: "none" }); this.setData({ submitting: true }); setTimeout(() => { const id = "LJ" + Date.now().toString().slice(-8); const record = { id, offeringName: this.data.offering ? this.data.offering.name : "门系统定制咨询", type: values.doorType || "门系统定制", project: values.city || "待确认项目", status: "待主理人复核图纸", createdAt: new Date().toLocaleDateString("zh-CN"), values }; const records = wx.getStorageSync("linjingInquiryRecords") || []; wx.setStorageSync("linjingInquiryRecords", [record].concat(records)); this.setData({ submitting: false }); wx.redirectTo({ url: "/pages/inquiry-success/index?id=" + id }); }, 500); },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { offerings } = require("../../utils/linjing-data");
|
||||
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
|
||||
Page({
|
||||
data: { item: null, loading: true },
|
||||
onLoad(options) { const item = offerings.find((entry) => entry.id === options.id) || offerings[0]; this.setData({ item, loading: false }); wx.setNavigationBarTitle({ title: item.category }); },
|
||||
onLoad(options) { loadWorkspaceWithFallback().then((workspace) => { const offerings = workspace.offerings || []; const item = offerings.find((entry) => entry.id === options.id) || offerings[0]; if (!item) return this.setData({ loading: false }); this.setData({ item, loading: false }); wx.setNavigationBarTitle({ title: item.category || item.name }); }); },
|
||||
inquire() { wx.navigateTo({ url: "/pages/inquiry/index?offeringId=" + this.data.item.id }); },
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
# 品牌运行时与多品牌隔离推进计划
|
||||
|
||||
## 目标
|
||||
|
||||
个人品牌是产品主线,行业模板、视觉模板和能力插件都必须在品牌隔离的运行时上下文中工作。Admin 与小程序不得维护第二套实时品牌数据。
|
||||
|
||||
## 当前结论
|
||||
|
||||
- 数据模型已经普遍包含 `brandId`,但 Admin 运行时仍依赖 `DEFAULT_BRAND_ID`,当前属于单品牌运行模式。
|
||||
- `BrandProfile` 及其品牌业务表应是实时品牌内容的唯一来源。
|
||||
- `BrandTemplateInstallation.configSnapshot` 仅用于模板版本、升级和回滚,不得覆盖实时品牌内容。
|
||||
- `RuntimeWorkspace` 是 Admin 和小程序统一消费的读取契约。
|
||||
- 小程序静态数据只能作为按模板选择的离线 fallback,不能覆盖成功的 API 返回。
|
||||
|
||||
## 阶段
|
||||
|
||||
### Phase 1:统一品牌运行时数据
|
||||
|
||||
- Admin 页面统一通过 `/admin/workspace` 获取运行时数据。
|
||||
- 小程序页面移除直接读取行业静态数据的路径。
|
||||
- fallback 按 `personal`、`food`、`doors` 模板拆分。
|
||||
- API 成功时不允许 fallback 覆盖 API 数据。
|
||||
- 增加三模板数据一致性和 API 失败 fallback 测试。
|
||||
|
||||
### Phase 2:品牌上下文与权限隔离
|
||||
|
||||
- 增加 `AdminUser`、`BrandMembership` 和角色模型。
|
||||
- 从 token 与 membership 解析可信当前品牌,不再依赖 `DEFAULT_BRAND_ID`。
|
||||
- 所有 Admin 查询、写入、删除强制使用服务端品牌上下文。
|
||||
- 增加跨品牌越权集成测试。
|
||||
|
||||
### Phase 3:公开品牌解析与缓存隔离
|
||||
|
||||
- 生产环境支持 `brandSlug` 或 `appId -> brandId` 解析。
|
||||
- Runtime Workspace 缓存按品牌和版本隔离。
|
||||
- 公开接口只返回当前品牌已发布内容。
|
||||
|
||||
### Phase 4:行业能力扩展
|
||||
|
||||
- 在前 3 个阶段通过验收前,不新增行业专属页面。
|
||||
- 后续行业差异继续通过模板、模块、能力插件和声明式字段表达。
|
||||
|
||||
## 交付门槛
|
||||
|
||||
- API integration tests 通过。
|
||||
- Admin production build 通过。
|
||||
- 小程序结构和视觉 fixture 通过。
|
||||
- personal、food、doors 不得出现跨行业文案、字段或业务数据污染。
|
||||
- 每个完成阶段使用一个完整、可审查的提交收口。
|
||||
Reference in new issue
Block a user