refactor: 重构模板叠加式编译产物

This commit is contained in:
que01 committed 2026-09-26 11:21:29 +08:00
1 parent c46297b13b
commit 25d1fe983c
93 files changed
+870 -2467

No files matched your search

@@ -0,0 +1,37 @@
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
const { customerRequest, customerTokenKey } = require("../../utils/request");
Page({
data: { brand: {}, records: [], error: "" },
onLoad() {
loadWorkspaceWithFallback()
.then((workspace) => this.setData({ brand: workspace.brand || {} }))
.catch((error) => this.setData({ error: error.message }));
},
onShow() {
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.phone || this.data.brand.contactPhone || "").replace(
/[^0-9-]/g,
"",
),
});
},
copyWechat() {
wx.setClipboardData({
data: this.data.brand.wechat || this.data.brand.contactWechat || "",
success: () => wx.showToast({ title: "微信号已复制", icon: "none" }),
});
},
recordsPage() {
wx.navigateTo({ url: "/pages/records/index" });
},
});
@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "主理人与我",
"navigationBarBackgroundColor": "#FBF7F1",
"navigationBarTextStyle": "black",
"usingComponents": {
"linjing-profile": "/components/templates/linjing-profile/linjing-profile"
}
}
@@ -0,0 +1,4 @@
<view class="page">
<view wx:if="{{error}}" class="runtime-error">{{error}}</view>
<linjing-profile wx:else brand="{{brand}}" presentation="{{brand.visualPresentation.profile}}" records-count="{{records.length}}" bind:call="call" bind:copy="copyWechat" bind:records="recordsPage" />
</view>
@@ -0,0 +1 @@
/* 页面样式由林境模板组件提供。 */
@@ -0,0 +1,41 @@
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
Page({
data: {
brand: {},
trustContent: {},
offerings: [],
hero: { image: "", eyebrow: "", title: "", slogan: "", cta: "" },
error: "",
},
onLoad() {
loadWorkspaceWithFallback()
.then((workspace) => {
const brand = workspace.brand || {};
const offerings = workspace.offerings || [];
const configuredHero =
brand.homeHero && typeof brand.homeHero === "object" ? brand.homeHero : {};
this.setData({
brand,
trustContent: workspace.trustPresentation || {},
offerings,
hero: {
...this.data.hero,
image: brand.heroImage || "",
eyebrow: brand.tagline || brand.name,
title: (offerings[0] && offerings[0].name) || brand.name,
slogan: brand.description || "",
...configuredHero,
},
});
wx.setNavigationBarTitle({ title: brand.name || "个人品牌" });
})
.catch((error) => this.setData({ error: error.message }));
},
selectOffering(event) {
wx.navigateTo({ url: "/pages/offering/detail?id=" + event.detail.id });
},
goWorks() {
wx.switchTab({ url: "/pages/services/index" });
},
});
@@ -0,0 +1,6 @@
{
"navigationBarTitleText": "品牌首页",
"usingComponents": {
"linjing-home": "/components/templates/linjing-home/linjing-home"
}
}
@@ -0,0 +1,4 @@
<view class="page">
<view wx:if="{{error}}" class="runtime-error">{{error}}</view>
<linjing-home wx:else brand="{{brand}}" presentation="{{brand.visualPresentation.home}}" hero="{{hero}}" trust-content="{{trustContent}}" offerings="{{offerings}}" bind:select="selectOffering" bind:works="goWorks" />
</view>
@@ -0,0 +1 @@
/* 页面样式由林境模板组件提供。 */
@@ -0,0 +1,22 @@
const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
Page({
data: { brand: {}, presentation: {}, offerings: [], error: "" },
onLoad() {
loadWorkspaceWithFallback()
.then((workspace) =>
this.setData({
brand: workspace.brand || {},
presentation: workspace.brand?.visualPresentation?.offerings || {},
offerings: workspace.offerings || [],
}),
)
.catch((error) => this.setData({ error: error.message }));
},
open(event) {
wx.navigateTo({ url: "/pages/offering/detail?id=" + event.detail.id });
},
inquire() {
wx.navigateTo({ url: "/pages/inquiry/index" });
},
});
@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "案例与体系",
"navigationBarBackgroundColor": "#FBF7F1",
"navigationBarTextStyle": "black",
"usingComponents": {
"linjing-offerings": "/components/templates/linjing-offerings/linjing-offerings"
}
}
@@ -0,0 +1,4 @@
<view class="page">
<view wx:if="{{error}}" class="runtime-error">{{error}}</view>
<linjing-offerings wx:else brand="{{brand}}" presentation="{{presentation}}" offerings="{{offerings}}" bind:open="open" bind:more="inquire" />
</view>
@@ -0,0 +1 @@
/* 页面样式由林境模板组件提供。 */
@@ -413,15 +413,5 @@
"capabilityKey": "inquiry"
}
},
"renderers": {
"home": "linjing-home",
"offerings": "linjing-offerings",
"profile": "linjing-profile"
},
"runtimeOwnedPages": ["detail", "inquiry", "success", "records"],
"ownedPaths": [
"components/templates/linjing-home",
"components/templates/linjing-offerings",
"components/templates/linjing-profile"
]
"pages": ["pages/index/index", "pages/services/index", "pages/bookings/index"]
}