refactor: 引入品牌行业模板配置
This commit is contained in:
1 parent
653fe596ac
commit
3c7ce2a8fa
10 files changed
+15
-8
No files matched your search
@@ -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) }); },
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user