import { View, Text, Image, Button } from "@tarojs/components"; import Taro from "@tarojs/taro"; import type { RuntimeWorkspace } from "@personal-brand/types"; import type { TemplateProps } from "../../../apps/taro/src/runtime/template"; import { navigate } from "../../../apps/taro/src/runtime/navigation"; import { object, offering, presentation, slot, text, rows, } from "../../../apps/taro/src/runtime/content"; import { inquiryPluginState, pluginStateText } from "../../../apps/taro/src/runtime/plugins"; import "./style.css"; function Home({ workspace }: { workspace: RuntimeWorkspace }) { const b = workspace.brand; const p = presentation(workspace, "home"); const hero = object(b.homeHero); const credential = slot(workspace, "credential"); const t = workspace.trustPresentation; return ( {text(b.avatarUrl) && ( )} {text(b.founder)} {text(b.title)} “{text(b.description)}” {p.founderBadge && {p.founderBadge}} navigate("offerings")} > {text(hero.eyebrow) || text(b.tagline)} {text(hero.title) || text(b.name)} {text(hero.slogan) || text(workspace.templateData.designPhilosophy) || text(b.description)} {text(hero.cta) || "查看作品"} {p.proofEyebrow} {p.proofTitle} {credential?.content} {t.stats?.map((item, index) => ( {item.value} {item.label} {item.sub} ))} {p.manifestoEyebrow} {p.manifestoTitle} {t.pillars?.map((item, index) => ( {item.title} {item.desc} ))} {p.worksEyebrow} {p.worksTitle} navigate("offerings")}> {p.worksAction} {workspace.offerings.map(offering).map((item) => ( navigate("detail", { id: item.id })} > {item.category} · {item.area} {item.name} {[item.series, ...item.keywords.slice(0, 2)].filter(Boolean).join(" · ")} ))} {p.flowEyebrow} {p.flowTitle} {t.serviceFlow?.map((step, index) => ( {step.step} {step.name} {step.desc} ))} ); } function Profile({ workspace }: { workspace: RuntimeWorkspace }) { const b = workspace.brand; const p = presentation(workspace, "profile"); const config = object(b.profilePresentation); return ( {text(b.avatarUrl) && ( )} {text(b.founder)} {text(b.title)} {text(b.contactPhone) && ( {p.phoneLabel || "电话"} {text(b.contactPhone)} )} {text(b.contactWechat) && ( {p.wechatLabel || "微信"} {text(b.contactWechat)} )} {text(b.address) && ( {p.addressLabel || "地址"} {text(b.address)} )} navigate("records")} > {p.recordsTitle || "我的咨询记录"} {p.recordsSubtitle} 查看 › {rows(config.coverage).length > 0 && ( {p.coverageTitle} {rows(config.coverage).map((item, index) => ( {item.title} {item.content} ))} )} {Array.isArray(config.warranty) && config.warranty.length > 0 && ( {p.warrantyTitle} {config.warranty.map((item, index) => ( • {text(item)} ))} )} {workspace.trustItems.map((item) => ( {item.title} {item.summary && {item.summary}} {item.content} ))} ); } function List({ workspace }: { workspace: RuntimeWorkspace }) { const p = presentation(workspace, "offerings"); return ( {p.worksEyebrow} {p.worksTitle || "作品与服务"} {p.subtitle} {workspace.offerings.map(offering).map((item) => ( navigate("detail", { id: item.id })} > {item.category} · {item.area} {item.name} {item.desc} {item.priceRange} {p.detailAction || "了解详情 →"} ))} {p.closingText} {p.closingAction && (inquiryPluginState(workspace).enabled ? ( ) : ( {inquiryPluginState(workspace).disabledHint || `${p.closingAction}暂不可用`} ))} ); } function Detail({ workspace, id }: { workspace: RuntimeWorkspace; id?: string }) { const found = workspace.offerings.find((item) => item.id === id); if (!found) return ( 未找到该作品 ); const item = offering(found); const p = presentation(workspace, "detail"); return ( {item.category} · {item.area} {item.name} {item.series} {p.priceLabel} {item.priceRange} {p.spaceLabel} {text(item.presentation.spaceType)} {p.backgroundTitle} {item.details.background || item.desc} {item.details.designConcept && ( {p.conceptTitle} {item.details.designConcept} )} {item.details.crafts.length > 0 && ( {p.craftsTitle} {item.details.crafts.map((craft, index) => ( 0{index + 1} {craft} ))} )} {item.details.materialsList.length > 0 && ( {p.materialsTitle} {item.details.materialsList.map((material, index) => ( {material.name} {material.spec} ))} )} {item.keywords.map((word, index) => ( {word} ))} {inquiryPluginState(workspace).enabled ? ( ) : ( {inquiryPluginState(workspace).disabledHint || "咨询暂不可用"} )} {p.inquiryHint} ); } const formTargets: Record = { inquiry: "linjing-editorial.inquiry.consultation", success: "linjing-editorial.success.successCopy", records: "linjing-editorial.records.recordsCopy", }; export function TemplatePage({ workspace, page, children, offeringId }: TemplateProps) { if (page === "home") return ; if (page === "offerings") return ; if (page === "profile" || page === "service") return ; if (page === "detail") return ; return ( {children} ); }