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:
+29
-3
@@ -144,7 +144,33 @@ const appointmentDB = {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatRecord,
|
||||
appointmentDB
|
||||
/**
|
||||
* 获取小程序码
|
||||
* @param {string} scene - 场景值
|
||||
* @param {string} page - 页面路径
|
||||
* @returns {Promise<string>} Base64图片数据
|
||||
*/
|
||||
async function getWxacode(scene, page = 'pages/scan/result/index') {
|
||||
const envVersion = wx.getAccountInfoSync().miniProgram.envVersion
|
||||
|
||||
const base64Data = await request({
|
||||
url: BASE_URL + API.WXACODE,
|
||||
method: 'POST',
|
||||
header: { 'content-type': 'application/json' },
|
||||
data: {
|
||||
scene,
|
||||
page,
|
||||
width: 430,
|
||||
envVersion
|
||||
}
|
||||
})
|
||||
|
||||
return `data:image/jpeg;base64,${base64Data}`
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
request,
|
||||
formatRecord,
|
||||
appointmentDB,
|
||||
getWxacode
|
||||
}
|
||||
|
||||
+2
-1
@@ -26,7 +26,8 @@ const API = {
|
||||
APPOINTMENT_LIST: '/api/wx-mini/appointment/list',
|
||||
APPOINTMENT_CREATE: '/api/wx-mini/appointment/create',
|
||||
APPOINTMENT_CANCEL: '/api/wx-mini/appointment/cancel',
|
||||
APPOINTMENT_DETAIL: '/api/wx-mini/appointment/detail'
|
||||
APPOINTMENT_DETAIL: '/api/wx-mini/appointment/detail',
|
||||
WXACODE: '/api/wx-mini/wxacode'
|
||||
}
|
||||
|
||||
console.log('[config] 当前环境:', wx.getAccountInfoSync().miniProgram.envVersion, 'BASE_URL:', BASE_URL)
|
||||
|
||||
Reference in New Issue
Block a user