// pages/scan/result/index.js const { appointmentDB, formatRecord } = require('../../../utils/api') Page({ data: { record: null, loading: true, error: '' }, onLoad(options) { const id = options.id if (!id) { this.setData({ loading: false, error: '缺少预约记录ID' }) return } this.loadRecordDetail(id) }, async loadRecordDetail(id) { try { this.setData({ loading: true }) const result = await appointmentDB.getDetail(id) if (!result) { this.setData({ loading: false, error: '预约记录不存在' }) return } const formatted = formatRecord(result) const statusMap = { 'pending': '待审核', 'approved': '已通过', 'rejected': '已拒绝', 'cancelled': '已取消' } this.setData({ record: { ...formatted, statusText: statusMap[formatted.status] || formatted.status }, loading: false }) } catch (err) { console.error('加载预约记录详情失败', err) this.setData({ loading: false, error: '加载失败,请稍后重试' }) } } })