Files
persionalBrand/apps/miniapp/pages/index/index.js
T

71 lines
2.1 KiB
JavaScript

const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
Page({
data: {
brand: {},
trustContent: [],
offerings: [],
modules: [],
moduleVariants: {},
layout: [],
theme: {},
hero: {
image:
"https://images.unsplash.com/photo-1600585154340-be6161a56a0c?auto=format&fit=crop&w=900&q=80",
eyebrow: "",
title: "",
slogan: "",
cta: "了解业务与服务 →",
},
loading: false,
},
onLoad() {
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 || "个人品牌" });
});
},
showModule(e) {
return this.data.layout.includes(e);
},
selectOffering(e) {
const id = e.detail ? e.detail.id : e.currentTarget.dataset.id;
wx.navigateTo({ url: "/pages/offering/detail?id=" + id });
},
goWorks() {
wx.switchTab({ url: "/pages/services/index" });
},
goInquiry() {
wx.navigateTo({ url: "/pages/inquiry/index" });
},
goProfile() {
wx.switchTab({ url: "/pages/bookings/index" });
},
});