diff --git a/apps/miniapp/pages/booking/index.js b/apps/miniapp/pages/booking/index.js index 9d21314..612c46e 100644 --- a/apps/miniapp/pages/booking/index.js +++ b/apps/miniapp/pages/booking/index.js @@ -1,7 +1,8 @@ const { request, customerRequest } = require('../../utils/request'); +const { getTemplate } = require('../../utils/templates'); Page({ - data: { service: {}, form: {}, serviceId: '', quantity: 1, fulfillment: 'pickup', submitting: false }, - onLoad(query) { request('/public/services').then((services) => { const list = Array.isArray(services) ? services : []; const service = list.find((item) => item.id === query.serviceId) || list.find((item) => item.priceAmount !== null) || {}; this.setData({ service, serviceId: service.id || '' }); }).catch(() => wx.showToast({ title: '服务加载失败', icon: 'none' })); }, + data: { service: {}, form: {}, serviceId: '', quantity: 1, fulfillment: 'pickup', submitting: false, template: getTemplate('personal') }, + onLoad(query) { Promise.all([request('/public/services'), request('/public/brand')]).then(([services, brand]) => { const list = Array.isArray(services) ? services : []; const service = list.find((item) => item.id === query.serviceId) || list.find((item) => item.priceAmount !== null) || {}; this.setData({ service, serviceId: service.id || '', template: getTemplate(brand.templateKey) }); }).catch(() => wx.showToast({ title: '服务加载失败', icon: 'none' })); }, input(event) { this.setData({ ['form.' + event.currentTarget.dataset.key]: event.detail.value }); }, chooseFulfillment(event) { this.setData({ fulfillment: event.currentTarget.dataset.value }); }, increase() { if (this.data.quantity < 50) this.setData({ quantity: this.data.quantity + 1 }); }, @@ -10,11 +11,11 @@ Page({ const form = this.data.form; if (!this.data.serviceId) return wx.showToast({ title: '请先选择服务', icon: 'none' }); if (!form.customerName || !form.wechatId) return wx.showToast({ title: '请填写称呼和联系方式', icon: 'none' }); - if (this.data.fulfillment === 'delivery' && !form.deliveryAddress) return wx.showToast({ title: '请填写配送地址', icon: 'none' }); + if (this.data.fulfillment === 'delivery' && !form.deliveryAddress) return wx.showToast({ title: '请填写' + this.data.template.locationLabel, icon: 'none' }); this.setData({ submitting: true }); const send = () => customerRequest('/customer/bookings', { method: 'POST', - data: { requestType: 'package', customerName: form.customerName, wechatId: form.wechatId, contactPreference: 'wechat', fulfillmentType: this.data.fulfillment, deliveryAddress: form.deliveryAddress, requestedTime: form.requestedTime, note: form.note, items: [{ serviceId: this.data.serviceId, quantity: this.data.quantity }] }, + data: { requestType: this.data.template.requestType, customerName: form.customerName, wechatId: form.wechatId, contactPreference: 'wechat', fulfillmentType: this.data.fulfillment, deliveryAddress: form.deliveryAddress, requestedTime: form.requestedTime, note: form.note, items: [{ serviceId: this.data.serviceId, quantity: this.data.quantity }] }, }).then(() => { this.setData({ submitting: false }); wx.showToast({ title: '预约已提交' }); diff --git a/apps/miniapp/pages/booking/index.wxml b/apps/miniapp/pages/booking/index.wxml index fc06bc6..576f616 100644 --- a/apps/miniapp/pages/booking/index.wxml +++ b/apps/miniapp/pages/booking/index.wxml @@ -1,7 +1,7 @@ - {{service.name || '选择预约服务'}}{{service.priceText || '人工沟通报价'}}今日可订 + {{service.name || '选择服务'}}{{service.priceText || '沟通报价'}}{{template.available}} 数量{{quantity}} 份 - 合作方式 - - ● 提交后品牌方会与你确认需求、时间和合作方式。 + {{template.modeLabel}} + + ● {{template.submitNotice}} diff --git a/apps/miniapp/utils/templates.js b/apps/miniapp/utils/templates.js index 1c80574..9fbf0fd 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: '暂无可订服务' }, - 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: '暂无可咨询服务' }, + 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: 'package', modeLabel: '沟通方式', modeA: '线上沟通', modeB: '线下沟通', locationLabel: '沟通方式或地点', locationPlaceholder: '请输入会议方式、地点或链接', notePlaceholder: '请介绍你的需求、预算或期待结果', submitNotice: '提交后品牌方会与你确认需求、时间和合作方式。', submitLabel: '提交需求' }, }; function getTemplate(key) { return TEMPLATES[key] || TEMPLATES.personal; } module.exports = { getTemplate, TEMPLATES };