feat: 收口多品牌与模板构建基础
This commit is contained in:
1 parent
0425a1c672
commit
77224ea51f
317 files changed
+11290
-1158
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user