feat: 实现微信小程序码生成功能
- 新增 pages/scan/result/ 扫码结果页,展示预约详情 - 实现微信小程序码生成(wxacode.getUnlimited) - 添加环境版本自动检测(release/trial/develop) - 优化 qrcode-modal 组件,使用 Base64 图片替代本地生成 - 统一 API 接口抽离到 api.js 和 config.js - 优化代码结构,提升可读性和维护性 主要变更: 1. utils/api.js: 新增 getWxacode() 接口,支持生成小程序码 2. components/qrcode-modal: 改用 API 生成小程序码,移除本地 QRCode 依赖 3. pages/scan/result: 新增扫码结果展示页,解析 scene 参数 4. utils/config.js: 新增 WXACODE 配置项
This commit is contained in:
+17
-17
@@ -1,4 +1,3 @@
|
||||
// pages/scan/result/index.js
|
||||
const { appointmentDB, formatRecord } = require('../../../utils/api')
|
||||
|
||||
Page({
|
||||
@@ -9,48 +8,49 @@ Page({
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
const id = options.id
|
||||
const id = this.extractId(options)
|
||||
if (!id) {
|
||||
this.setData({
|
||||
loading: false,
|
||||
error: '缺少预约记录ID'
|
||||
})
|
||||
this.setData({ loading: false, error: '缺少预约记录ID' })
|
||||
return
|
||||
}
|
||||
this.loadRecordDetail(id)
|
||||
},
|
||||
|
||||
extractId(options) {
|
||||
if (options.id) return options.id
|
||||
if (!options.scene) return null
|
||||
|
||||
const scene = decodeURIComponent(options.scene)
|
||||
return scene.startsWith('id=') ? scene.substring(3) : scene
|
||||
},
|
||||
|
||||
async loadRecordDetail(id) {
|
||||
try {
|
||||
this.setData({ loading: true })
|
||||
const result = await appointmentDB.getDetail(id)
|
||||
|
||||
if (!result) {
|
||||
this.setData({
|
||||
loading: false,
|
||||
error: '预约记录不存在'
|
||||
})
|
||||
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
|
||||
...formatRecord(result),
|
||||
statusText: statusMap[result.status] || result.status
|
||||
},
|
||||
loading: false
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('加载预约记录详情失败', err)
|
||||
this.setData({
|
||||
loading: false,
|
||||
error: '加载失败,请稍后重试'
|
||||
})
|
||||
this.setData({ loading: false, error: '加载失败,请稍后重试' })
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user