From 60c2937ee2c97d252e78ebc6e3313f2cf397c736 Mon Sep 17 00:00:00 2001 From: que01 Date: Sat, 19 Sep 2026 12:42:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AE=A9=E8=AE=A2=E5=8D=95=E6=96=87?= =?UTF-8?q?=E6=A1=88=E9=9A=8F=E8=A1=8C=E4=B8=9A=E6=A8=A1=E6=9D=BF=E5=88=87?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/miniapp/pages/bookings/index.js | 7 ++++--- apps/miniapp/pages/bookings/index.wxml | 4 ++-- apps/miniapp/utils/labels.js | 6 +++--- apps/miniapp/utils/templates.js | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/miniapp/pages/bookings/index.js b/apps/miniapp/pages/bookings/index.js index a03b4bd..98b26c8 100644 --- a/apps/miniapp/pages/bookings/index.js +++ b/apps/miniapp/pages/bookings/index.js @@ -1,9 +1,10 @@ -const { customerRequest } = require('../../utils/request'); +const { request, customerRequest } = require('../../utils/request'); const { bookingViewModel } = require('../../utils/labels'); +const { getTemplate } = require('../../utils/templates'); Page({ - data: { loading: true, error: '', bookings: [], cancellingId: '' }, + data: { loading: true, error: '', bookings: [], cancellingId: '', template: getTemplate('personal') }, onLoad() { this.load(); }, onShow() { this.load(); }, - load() { const token = wx.getStorageSync('customerToken'); if (!token) return this.setData({ loading: false, bookings: [], error: '' }); this.setData({ loading: true, error: '' }); customerRequest('/customer/bookings').then((items) => this.setData({ bookings: (Array.isArray(items) ? items : []).map(bookingViewModel), loading: false })).catch((error) => this.setData({ loading: false, error: error.message || '网络请求失败' })); }, + load() { const token = wx.getStorageSync('customerToken'); if (!token) return this.setData({ loading: false, bookings: [], error: '' }); this.setData({ loading: true, error: '' }); Promise.all([customerRequest('/customer/bookings'), request('/public/brand')]).then(([items, brand]) => { getApp().globalData.brand = brand; const template = getTemplate(brand.templateKey); this.setData({ template, bookings: (Array.isArray(items) ? items : []).map((item) => bookingViewModel(item, template)), loading: false }); }).catch((error) => this.setData({ loading: false, error: error.message || '网络请求失败' })); }, retry() { this.load(); }, contact() { const brand = getApp().globalData.brand || {}; if (brand.contactPhone) return wx.makePhoneCall({ phoneNumber: brand.contactPhone }); if (brand.contactWechat) return wx.showModal({ title: '联系品牌方', content: '微信号:' + brand.contactWechat, showCancel: false }); wx.showToast({ title: '暂未配置联系方式', icon: 'none' }); }, cancel(e) { const id = e.currentTarget.dataset.id; if (this.data.cancellingId) return; wx.showModal({ title: '取消预约', content: '确定取消这笔预约吗?', success: (result) => { if (!result.confirm) return; this.setData({ cancellingId: id }); customerRequest('/customer/bookings/' + id + '/cancel', { method: 'POST', data: {} }).then(() => { this.setData({ cancellingId: '' }); wx.showToast({ title: '已取消预约', icon: 'success' }); this.load(); }).catch((error) => { this.setData({ cancellingId: '' }); wx.showToast({ title: error.message || '取消失败', icon: 'none' }); }); } }); } }); diff --git a/apps/miniapp/pages/bookings/index.wxml b/apps/miniapp/pages/bookings/index.wxml index 99e1405..5b0ccc2 100644 --- a/apps/miniapp/pages/bookings/index.wxml +++ b/apps/miniapp/pages/bookings/index.wxml @@ -8,8 +8,8 @@ {{item.serviceName}}{{item.quantityLabel}} · {{item.fulfillmentLabel}} · {{item.requestedTime || '时间待确认'}} {{item.estimatedAmount ? '¥'+item.estimatedAmount/100 : '人工沟通报价'}}{{item.statusLabel}} - - 如需调整,请尽早联系品牌方。 + + {{template.cancelNote}} 常见问题 ›○ 怎么确认预约? ›○ 配送范围有多远? ›○ 可以改时间吗? › diff --git a/apps/miniapp/utils/labels.js b/apps/miniapp/utils/labels.js index 91afa4b..1e28cb5 100644 --- a/apps/miniapp/utils/labels.js +++ b/apps/miniapp/utils/labels.js @@ -1,11 +1,11 @@ const STATUS_LABELS = { received: '待确认', contacting: '沟通中', confirmed: '已确认', completed: '已完成', cancelled: '已取消' }; -const FULFILLMENT_LABELS = { pickup: '线上沟通', delivery: '线下沟通' }; +const FULFILLMENT_LABELS = { pickup: '自取', delivery: '配送' }; -function bookingViewModel(item) { +function bookingViewModel(item, template) { return { ...item, statusLabel: STATUS_LABELS[item.status] || '未知状态', - fulfillmentLabel: FULFILLMENT_LABELS[item.fulfillmentType] || '待确认', + fulfillmentLabel: template?.modeLabels?.[item.fulfillmentType] || FULFILLMENT_LABELS[item.fulfillmentType] || '待确认', serviceName: item.service?.name || item.items?.[0]?.serviceNameSnapshot || '未命名服务', quantityLabel: `${item.items?.[0]?.quantity || 1} 份`, }; diff --git a/apps/miniapp/utils/templates.js b/apps/miniapp/utils/templates.js index 2e37fb5..b7d03ea 100644 --- a/apps/miniapp/utils/templates.js +++ b/apps/miniapp/utils/templates.js @@ -1,6 +1,6 @@ const TEMPLATES = { - food: { hero: '今天吃什么', heroSub: '现做家常饭', about: '品牌简介', description: '个人经营的家常小灶,套餐现做,也可预约小型聚餐和私厨定制。', primary: '预约套餐', secondary: '咨询私厨', timeLabel: '营业时间', time: '11:00—20:00', addressLabel: '摊位地址', address: '校园路社区便民点 12 号', noteLabel: '配送说明', note: '满 30 元周边配送,也可自取', serviceSub: '今日可订', first: '普通套餐', firstSub: '日常家常饭', second: '私厨服务', secondSub: '聚餐定制', available: '今日可订', unavailable: '暂不可订', empty: '暂无可订服务', bookingTitle: '预约套餐', requestType: 'package', modeLabel: '取餐方式', modeA: '自取', modeB: '配送', locationLabel: '配送地址', locationPlaceholder: '请输入配送地址', notePlaceholder: '口味、餐具或其他说明', submitNotice: '提交后由摊主人工确认,确认后再安排制作。', submitLabel: '提交预约' }, - personal: { hero: '个人品牌', heroSub: '把专业能力,变成值得信赖的体验', about: '关于我', description: '这里展示你的专业背景、工作方式与品牌理念。', primary: '查看服务', secondary: '发起咨询', timeLabel: '服务时间', time: '工作日 10:00—18:00', addressLabel: '所在位置', address: '线上 / 线下均可沟通', noteLabel: '合作说明', note: '提交需求后,我会尽快与你联系', serviceSub: '可咨询', first: '标准服务', firstSub: '清晰的服务方案', second: '定制合作', secondSub: '按需求沟通', available: '可咨询', unavailable: '暂不可用', empty: '暂无可咨询服务', bookingTitle: '合作咨询', requestType: 'inquiry', modeLabel: '沟通方式', modeA: '线上沟通', modeB: '线下沟通', locationLabel: '沟通方式或地点', locationPlaceholder: '请输入会议方式、地点或链接', notePlaceholder: '请介绍你的需求、预算或期待结果', submitNotice: '提交后品牌方会与你确认需求、时间和合作方式。', submitLabel: '提交需求' }, + food: { modeLabels: { pickup: '自取', delivery: '配送' }, contactLabel: '联系摊主', cancelLabel: '取消预约', cancelNote: '取消后请及时告知摊主,避免食材浪费。', hero: '今天吃什么', heroSub: '现做家常饭', about: '品牌简介', description: '个人经营的家常小灶,套餐现做,也可预约小型聚餐和私厨定制。', primary: '预约套餐', secondary: '咨询私厨', timeLabel: '营业时间', time: '11:00—20:00', addressLabel: '摊位地址', address: '校园路社区便民点 12 号', noteLabel: '配送说明', note: '满 30 元周边配送,也可自取', serviceSub: '今日可订', first: '普通套餐', firstSub: '日常家常饭', second: '私厨服务', secondSub: '聚餐定制', available: '今日可订', unavailable: '暂不可订', empty: '暂无可订服务', bookingTitle: '预约套餐', requestType: 'package', modeLabel: '取餐方式', modeA: '自取', modeB: '配送', locationLabel: '配送地址', locationPlaceholder: '请输入配送地址', notePlaceholder: '口味、餐具或其他说明', submitNotice: '提交后由摊主人工确认,确认后再安排制作。', submitLabel: '提交预约' }, + personal: { modeLabels: { pickup: '线上沟通', delivery: '线下沟通' }, contactLabel: '联系品牌方', cancelLabel: '取消申请', cancelNote: '如需调整,请尽早联系品牌方。', hero: '个人品牌', heroSub: '把专业能力,变成值得信赖的体验', about: '关于我', description: '这里展示你的专业背景、工作方式与品牌理念。', primary: '查看服务', secondary: '发起咨询', timeLabel: '服务时间', time: '工作日 10:00—18:00', addressLabel: '所在位置', address: '线上 / 线下均可沟通', noteLabel: '合作说明', note: '提交需求后,我会尽快与你联系', serviceSub: '可咨询', first: '标准服务', firstSub: '清晰的服务方案', second: '定制合作', secondSub: '按需求沟通', available: '可咨询', unavailable: '暂不可用', empty: '暂无可咨询服务', bookingTitle: '合作咨询', requestType: 'inquiry', modeLabel: '沟通方式', modeA: '线上沟通', modeB: '线下沟通', locationLabel: '沟通方式或地点', locationPlaceholder: '请输入会议方式、地点或链接', notePlaceholder: '请介绍你的需求、预算或期待结果', submitNotice: '提交后品牌方会与你确认需求、时间和合作方式。', submitLabel: '提交需求' }, }; function getTemplate(key) { return TEMPLATES[key] || TEMPLATES.personal; } module.exports = { getTemplate, TEMPLATES };