Files
persionalBrand/packages/template-linjing-editorial/miniapp/pages/index/index.js
T

51 lines
1.7 KiB
JavaScript

const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
Page({
data: {
brand: {},
trustPresentation: {},
offerings: [],
hero: { image: "", eyebrow: "", title: "", slogan: "", cta: "" },
error: "",
},
onLoad() {
loadWorkspaceWithFallback()
.then((workspace) => {
const brand = workspace.brand || {};
const offerings = workspace.offerings || [];
const credentials = (workspace.trustItems || []).filter(
(item) => item.type === "credential",
);
const credential =
credentials.find((item) => Object.keys(item.config || {}).length > 0) || credentials[0];
const configuredHero =
brand.homeHero && typeof brand.homeHero === "object" ? brand.homeHero : {};
this.setData({
brand,
trustPresentation: {
...(workspace.trustPresentation || {}),
bio: credential?.content || "",
},
offerings,
hero: {
...this.data.hero,
image: brand.heroImage || "",
eyebrow: brand.tagline || brand.name,
title: (offerings[0] && offerings[0].name) || brand.name,
slogan: workspace.templateData?.designPhilosophy || brand.description || "",
...configuredHero,
image: brand.heroImage || "",
},
});
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" });
},
});