const { getWxacode } = require('../../utils/api') Component({ data: { visible: false, qrcodeId: '', loading: true, qrcodePath: '' }, methods: { async show(id) { this.setData({ visible: true, qrcodeId: id, loading: true, qrcodePath: '' }) try { const base64Image = await getWxacode(id, 'pages/scan/result/index') this.setData({ qrcodePath: base64Image, loading: false }) } catch (err) { console.error('获取小程序码失败', err) wx.showToast({ title: '二维码生成失败', icon: 'none' }) this.setData({ loading: false }) } }, onClose() { this.setData({ visible: false, qrcodeId: '', qrcodePath: '' }) } } })