diff --git a/apps/api/src/http.ts b/apps/api/src/http.ts
index 9139cc0..d1b9c53 100644
--- a/apps/api/src/http.ts
+++ b/apps/api/src/http.ts
@@ -15,7 +15,10 @@ export class RequestIdMiddleware {
requestId,
);
}
- console.info("api request", { method: request.method, url: request.url, requestId });
+ (request as FastifyRequest & { requestId?: string }).requestId = requestId;
+ if (process.env.NODE_ENV === "development") {
+ console.info("api request", { method: request.method, url: request.url, requestId });
+ }
next();
}
}
@@ -39,7 +42,7 @@ export class ApiExceptionFilter implements ExceptionFilter {
code: `HTTP_${status}`,
message: typeof detail === "string" ? detail : "请求失败",
},
- requestId: request.headers["x-request-id"] ?? null,
+ requestId: (request as FastifyRequest & { requestId?: string }).requestId ?? request.headers["x-request-id"] ?? null,
});
}
}
diff --git a/apps/miniapp/pages/booking/index.js b/apps/miniapp/pages/booking/index.js
index e30c913..7723252 100644
--- a/apps/miniapp/pages/booking/index.js
+++ b/apps/miniapp/pages/booking/index.js
@@ -1,7 +1,7 @@
const API = getApp().globalData.apiBaseUrl;
Page({
data: { service: {}, form: {}, serviceId: '', quantity: 1, fulfillment: 'pickup', submitting: false },
- onLoad(query) { wx.request({ url: API + '/public/services', success: (res) => { const service = res.data.find((item) => item.id === query.serviceId) || res.data.find((item) => item.priceAmount !== null) || {}; this.setData({ service, serviceId: service.id || '' }); } }); },
+ onLoad(query) { wx.request({ url: API + '/public/services', success: (res) => { const services = Array.isArray(res.data) ? res.data : []; const service = services.find((item) => item.id === query.serviceId) || services.find((item) => item.priceAmount !== null) || {}; this.setData({ service, serviceId: service.id || '' }); }, fail: () => 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 }); },
diff --git a/apps/miniapp/pages/booking/index.wxml b/apps/miniapp/pages/booking/index.wxml
index 88588c3..cd2d33b 100644
--- a/apps/miniapp/pages/booking/index.wxml
+++ b/apps/miniapp/pages/booking/index.wxml
@@ -1 +1,7 @@
-{{service.name || '选择预约服务'}}{{service.priceText || '人工沟通报价'}}今日可订数量{{quantity}} 份取餐方式● 提交后由摊主人工确认,确认后再安排制作。
+
+ {{service.name || '选择预约服务'}}{{service.priceText || '人工沟通报价'}}今日可订
+ 数量{{quantity}} 份
+ 取餐方式
+
+ ● 提交后由摊主人工确认,确认后再安排制作。
+
diff --git a/apps/miniapp/pages/bookings/index.js b/apps/miniapp/pages/bookings/index.js
index 7727b9e..0f57050 100644
--- a/apps/miniapp/pages/bookings/index.js
+++ b/apps/miniapp/pages/bookings/index.js
@@ -1,2 +1,10 @@
-const API=getApp().globalData.apiBaseUrl;
-Page({data:{loading:true,bookings:[]},onLoad(){this.load()},onShow(){this.load()},load(){const token=wx.getStorageSync('customerToken');if(!token){this.setData({loading:false});return}wx.request({url:API+'/customer/bookings',header:{Authorization:'Bearer '+token},success:r=>this.setData({bookings:r.data,loading:false}),fail:()=>this.setData({loading:false})})},cancel(e){const id=e.currentTarget.dataset.id;wx.showModal({title:'取消预约',content:'确定取消这笔预约吗?',success:r=>{if(!r.confirm)return;wx.request({url:API+'/customer/bookings/'+id+'/cancel',method:'POST',header:{Authorization:'Bearer '+wx.getStorageSync('customerToken'),'content-type':'application/json'},data:{},success:res=>{if(res.statusCode<300)this.load();else wx.showToast({title:res.data?.error?.message||'取消失败',icon:'none'})},fail:err=>wx.showToast({title:err.errMsg||'网络请求失败',icon:'none'})})}})}});
+const API = getApp().globalData.apiBaseUrl;
+const STATUS_LABELS = { received: '待确认', contacting: '沟通中', confirmed: '已确认', completed: '已完成', cancelled: '已取消' };
+const FULFILLMENT_LABELS = { pickup: '自取', delivery: '配送' };
+Page({
+ data: { loading: true, error: '', bookings: [], cancellingId: '' },
+ 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: '' }); wx.request({ url: API + '/customer/bookings', header: { Authorization: 'Bearer ' + token }, success: (res) => { if (res.statusCode >= 300) return this.setData({ loading: false, error: res.data?.error?.message || '订单加载失败' }); const bookings = (Array.isArray(res.data) ? res.data : []).map((item) => ({ ...item, statusLabel: STATUS_LABELS[item.status] || '未知状态', fulfillmentLabel: FULFILLMENT_LABELS[item.fulfillmentType] || '待确认', serviceName: item.service?.name || item.items?.[0]?.serviceName || '红烧肉家常套餐', quantityLabel: `${item.items?.[0]?.quantity || 1} 份` })); this.setData({ bookings, loading: false }); }, fail: (error) => this.setData({ loading: false, error: error.errMsg || '网络请求失败' }) }); },
+ retry() { this.load(); }, contact() { 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 }); wx.request({ url: API + '/customer/bookings/' + id + '/cancel', method: 'POST', header: { Authorization: 'Bearer ' + wx.getStorageSync('customerToken'), 'content-type': 'application/json' }, data: {}, success: (res) => { this.setData({ cancellingId: '' }); if (res.statusCode < 300) { wx.showToast({ title: '已取消预约', icon: 'success' }); this.load(); } else wx.showToast({ title: res.data?.error?.message || '取消失败', icon: 'none' }); }, fail: (error) => { this.setData({ cancellingId: '' }); wx.showToast({ title: error.errMsg || '网络请求失败', icon: 'none' }); } }); } }); }
+});
diff --git a/apps/miniapp/pages/bookings/index.wxml b/apps/miniapp/pages/bookings/index.wxml
index 9ce4995..4d4ba34 100644
--- a/apps/miniapp/pages/bookings/index.wxml
+++ b/apps/miniapp/pages/bookings/index.wxml
@@ -1 +1,16 @@
-我的订单☎加载中...完成预约后,订单会显示在这里待确认摊主会尽快联系你✓{{item.service.name || '红烧肉家常套餐'}}{{item.items[0].quantity}} 份 · {{item.fulfillmentType || '自取'}} · {{item.requestedTime || '今天 12:30'}}取消后请及时告知摊主,避免食材浪费。常见问题 ›○ 怎么确认预约? ›○ 配送范围有多远? ›○ 可以改时间吗? ›
+
+ 我的订单☎
+ 加载中...
+ {{error}}
+ 完成预约后,订单会显示在这里
+
+ 订单状态查看每笔预约的最新进展✓
+
+ {{item.serviceName}}{{item.quantityLabel}} · {{item.fulfillmentLabel}} · {{item.requestedTime || '时间待确认'}}
+
+
+ 取消后请及时告知摊主,避免食材浪费。
+
+ 常见问题 ›○ 怎么确认预约? ›○ 配送范围有多远? ›○ 可以改时间吗? ›
+
+