const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace"); const { openPage } = require("../../utils/navigation"); Page({ data: { brand: {}, presentation: {}, config: {}, offerings: [], error: "", loading: true, opened: -1, }, onLoad() { this.reload(); }, reload() { this.setData({ loading: true, error: "" }); loadWorkspaceWithFallback() .then((workspace) => { const brand = workspace.brand || {}; this.setData({ brand, presentation: brand.visualPresentation?.offerings || {}, config: brand.atelier || {}, offerings: workspace.offerings || [], trustItems: workspace.trustItems || [], loading: false, }); }) .catch((error) => this.setData({ error: error.message, loading: false })); }, inquiry() { openPage("/pages/inquiry/index"); }, services() { openPage("/pages/services/index"); }, contact() { openPage("/pages/bookings/index"); }, records() { openPage("/pages/records/index"); }, detail(event) { openPage("/pages/offering/detail?id=" + encodeURIComponent(event.currentTarget.dataset.id)); }, toggle(event) { const index = Number(event.currentTarget.dataset.index); this.setData({ opened: this.data.opened === index ? -1 : index }); }, copy() { if (this.data.brand.contactWechat) wx.setClipboardData({ data: this.data.brand.contactWechat }); }, });