refactor: 引入品牌行业模板配置

This commit is contained in:
que01 committed 2026-09-19 12:26:29 +08:00
1 parent 653fe596ac
commit 3c7ce2a8fa
10 files changed
+15 -8

No files matched your search

@@ -0,0 +1 @@
ALTER TABLE "BrandProfile" ADD COLUMN "templateKey" TEXT NOT NULL DEFAULT 'food';
+1
View File
@@ -34,6 +34,7 @@ enum FulfillmentType {
model BrandProfile {
id String @id @default(uuid())
name String
templateKey String @default("food")
tagline String?
description String?
avatarUrl String?
+1
View File
@@ -10,6 +10,7 @@ async function main(): Promise<void> {
create: {
id: "00000000-0000-0000-0000-000000000001",
name: "阿成家常菜",
templateKey: "food",
tagline: "现做家常套餐,也为小型聚餐定制一桌热饭菜",
description: "每天认真做好一顿家常饭。",
hours: "周一至周六 10:30-20:00",
+1
View File
@@ -2,6 +2,7 @@ import { IsArray, IsBoolean, IsIn, IsInt, IsOptional, IsString, Max, Min } from
export class UpdateBrandDto {
@IsOptional() @IsString() name?: string;
@IsOptional() @IsString() templateKey?: string;
@IsOptional() @IsString() tagline?: string;
@IsOptional() @IsString() description?: string;
@IsOptional() @IsString() avatarUrl?: string;
+1
View File
@@ -48,6 +48,7 @@ export class PublicController {
select: {
id: true,
name: true,
templateKey: true,
tagline: true,
description: true,
avatarUrl: true,
+3 -2
View File
@@ -2,14 +2,15 @@ const { request } = require('../../utils/request');
const config = require('../../utils/config');
Page({
data: { loading: true, error: '', brand: {}, services: [] },
data: { loading: true, error: '', brand: {}, services: [], copy: {} },
onLoad() { this.load(); },
load() {
this.setData({ loading: true, error: '' });
Promise.all([request('/public/brand'), request('/public/services')]).then(([brand, services]) => {
getApp().globalData.brand = brand;
wx.setNavigationBarTitle({ title: brand.name || '个人品牌' });
this.setData({ brand, services, loading: false });
const copy = brand.templateKey === 'food' ? { hero: '今天吃什么', heroSub: '现做家常饭', about: '品牌简介', description: '个人经营的家常小灶,套餐现做,也可预约小型聚餐和私厨定制。', primary: '预约套餐', secondary: '咨询私厨', timeLabel: '营业时间', time: '11:00—20:00', addressLabel: '摊位地址', address: '校园路社区便民点 12 号', noteLabel: '配送说明', note: '满 30 元周边配送,也可自取' } : { hero: brand.name || '个人品牌', heroSub: brand.tagline || '把专业能力,变成值得信赖的体验', about: '关于我', description: '这里展示你的专业背景、工作方式与品牌理念。', primary: '查看服务', secondary: '发起咨询', timeLabel: '服务时间', time: '工作日 10:00—18:00', addressLabel: '所在位置', address: '线上 / 线下均可沟通', noteLabel: '合作说明', note: '提交需求后,我会尽快与你联系' };
this.setData({ brand, services, copy, loading: false });
}).catch(() => this.setData({ loading: false, error: '暂时无法加载内容' }));
},
selectService(event) { wx.navigateTo({ url: '/pages/booking/index?serviceId=' + encodeURIComponent(event.currentTarget.dataset.id) }); },
+4 -4
View File
@@ -3,10 +3,10 @@
<view wx:if="{{loading}}" class="state">加载中...</view>
<view wx:elif="{{error}}" class="state error">{{error}}<button bindtap="load">重试</button></view>
<block wx:else>
<view class="hero"><image wx:if="{{brand.coverUrl}}" src="{{brand.coverUrl}}" mode="aspectFill"/><view wx:else class="hero-placeholder"></view><view class="hero-copy"><text>{{brand.name || '个人品牌'}}</text><text>{{brand.tagline || '把专业能力,变成值得信赖的体验'}}</text></view></view>
<view class="intro"><text class="section-title">关于我</text><text class="intro-copy">{{brand.description || '这里展示你的专业背景、工作方式与品牌理念。'}}</text></view>
<view class="info-card"><view><text class="info-label">服务时间</text><text>{{brand.hours || '工作日 10:00—18:00'}}</text></view><text class="chevron">›</text><view><text class="info-label">所在位置</text><text>{{brand.address || '线上 / 线下均可沟通'}}</text></view><view class="line"></view><view><text class="info-label">合作说明</text><text>{{brand.deliveryNote || '提交需求后,我会尽快与你联系'}}</text></view></view>
<view class="actions"><button class="primary" bindtap="goServices">查看服务</button><button class="secondary" bindtap="goPrivateChef">发起咨询</button></view>
<view class="hero"><image wx:if="{{brand.coverUrl}}" src="{{brand.coverUrl}}" mode="aspectFill"/><view wx:else class="hero-placeholder"></view><view class="hero-copy"><text>{{copy.hero}}</text><text>{{copy.heroSub}}</text></view></view>
<view class="intro"><text class="section-title">{{copy.about}}</text><text class="intro-copy">{{brand.description || copy.description}}</text></view>
<view class="info-card"><view><text class="info-label">{{copy.timeLabel}}</text><text>{{brand.hours || copy.time}}</text></view><text class="chevron">›</text><view><text class="info-label">{{copy.addressLabel}}</text><text>{{brand.address || copy.address}}</text></view><view class="line"></view><view><text class="info-label">{{copy.noteLabel}}</text><text>{{brand.deliveryNote || copy.note}}</text></view></view>
<view class="actions"><button class="primary" bindtap="goServices">{{copy.primary}}</button><button class="secondary" bindtap="goPrivateChef">{{copy.secondary}}</button></view>
<view class="section-title services-title">今日服务</view>
<view wx:for="{{services}}" wx:key="id" class="service" data-id="{{item.id}}" bindtap="selectService"><view><text class="service-name">{{item.name}}</text><text class="description">{{item.description}}</text></view><text class="price">{{item.priceText}}</text></view>
</block>
+1 -1
View File
@@ -1,2 +1,2 @@
const { request } = require('../../utils/request');
Page({ data: { loading: true, error: '', services: [], filtered: [], category: 'package' }, onLoad() { request('/public/services').then((services) => this.setData({ services, filtered: services.filter((item) => item.priceAmount !== null), loading: false })).catch(() => this.setData({ loading: false, error: '服务加载失败' })); }, switchCategory(e) { const category = e.currentTarget.dataset.category; const filtered = category === 'package' ? this.data.services.filter((item) => item.priceAmount !== null) : this.data.services.filter((item) => item.priceAmount === null); this.setData({ category, filtered }); }, book(e) { wx.navigateTo({ url: '/pages/booking/index?serviceId=' + encodeURIComponent(e.currentTarget.dataset.id) }); } });
Page({ data: { loading: true, error: '', services: [], filtered: [], category: 'package', labels: {} }, onLoad() { Promise.all([request('/public/services'), request('/public/brand')]).then(([services, brand]) => { const labels = brand.templateKey === 'food' ? { sub: '今日可订', first: '普通套餐', firstSub: '日常家常饭', second: '私厨服务', secondSub: '聚餐定制', available: '今日可订', unavailable: '暂不可订', empty: '暂无可订服务' } : { sub: '可咨询', first: '标准服务', firstSub: '清晰的服务方案', second: '定制合作', secondSub: '按需求沟通', available: '可咨询', unavailable: '暂不可用', empty: '暂无可咨询服务' }; this.setData({ services, labels, filtered: services.filter((item) => item.priceAmount !== null), loading: false }); }).catch(() => this.setData({ loading: false, error: '服务加载失败' })); }, switchCategory(e) { const category = e.currentTarget.dataset.category; const filtered = category === 'package' ? this.data.services.filter((item) => item.priceAmount !== null) : this.data.services.filter((item) => item.priceAmount === null); this.setData({ category, filtered }); }, book(e) { wx.navigateTo({ url: '/pages/booking/index?serviceId=' + encodeURIComponent(e.currentTarget.dataset.id) }); } });
+1 -1
View File
@@ -1 +1 @@
<view class="page"><view class="heading"><text>服务列表</text><text class="sub">可咨询</text></view><view class="categories"><view class="category package {{category === 'package' ? 'selected' : ''}}" data-category="package" bindtap="switchCategory"><text class="category-title">● 标准服务</text><text>清晰的服务方案</text></view><view class="category chef {{category === 'private_chef' ? 'selected' : ''}}" data-category="private_chef" bindtap="switchCategory"><text class="category-title">● 定制合作</text><text>按需求沟通</text></view></view><view wx:if="{{loading}}" class="state">加载中...</view><view wx:elif="{{error}}" class="state">{{error}}</view><view wx:elif="{{!filtered.length}}" class="state">暂无可咨询服务</view><view wx:else><view wx:for="{{filtered}}" wx:key="id" class="card" data-id="{{item.id}}" bindtap="book"><view class="dish-image"><image wx:if="{{item.coverUrl}}" src="{{item.coverUrl}}" mode="aspectFill"/><view wx:else class="dish-placeholder"></view></view><view class="card-content"><view class="card-head"><view class="name">{{item.name}}</view><text class="available">{{item.bookingEnabled ? '可咨询' : '暂不可用'}}</text></view><text class="desc">{{item.description}}</text><view class="card-bottom"><text class="price">{{item.priceText || '沟通报价'}}</text><button size="mini">{{item.priceAmount ? '了解服务' : '发起咨询'}}</button></view></view></view></view></view>
<view class="page"><view class="heading"><text>服务列表</text><text class="sub">{{labels.sub}}</text></view><view class="categories"><view class="category package {{category === 'package' ? 'selected' : ''}}" data-category="package" bindtap="switchCategory"><text class="category-title">● {{labels.first}}</text><text>{{labels.firstSub}}</text></view><view class="category chef {{category === 'private_chef' ? 'selected' : ''}}" data-category="private_chef" bindtap="switchCategory"><text class="category-title">● {{labels.second}}</text><text>{{labels.secondSub}}</text></view></view><view wx:if="{{loading}}" class="state">加载中...</view><view wx:elif="{{error}}" class="state">{{error}}</view><view wx:elif="{{!filtered.length}}" class="state">{{labels.empty}}</view><view wx:else><view wx:for="{{filtered}}" wx:key="id" class="card" data-id="{{item.id}}" bindtap="book"><view class="dish-image"><image wx:if="{{item.coverUrl}}" src="{{item.coverUrl}}" mode="aspectFill"/><view wx:else class="dish-placeholder"></view></view><view class="card-content"><view class="card-head"><view class="name">{{item.name}}</view><text class="available">{{item.bookingEnabled ? labels.available : labels.unavailable}}</text></view><text class="desc">{{item.description}}</text><view class="card-bottom"><text class="price">{{item.priceText || '面议'}}</text><button size="mini">{{item.priceAmount ? '预约' : '咨询'}}</button></view></view></view></view></view>