From e2007b008a6f1fb59e53cd643864bdf4c0e90045 Mon Sep 17 00:00:00 2001 From: sexygoat <1538832180@qq.com> Date: Fri, 17 Apr 2026 16:48:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=AB=E4=B8=80=E6=89=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/wxsdk.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/utils/wxsdk.js b/utils/wxsdk.js index b35b515..a758213 100644 --- a/utils/wxsdk.js +++ b/utils/wxsdk.js @@ -42,7 +42,16 @@ export async function initWxConfig() { * @returns {Promise} 扫码结果字符串 */ export function wxScan() { + console.log('wx 对象:', wx) + console.log('window.wx:', window.wx) + console.log('window.jWeixin:', window.jWeixin) return new Promise((resolve, reject) => { + if (!wx) { + const msg = 'wx 对象不存在,请在微信环境中使用' + console.error(msg) + reject(new Error(msg)) + return + } wx.scanQRCode({ needResult: 1, scanType: ['qrCode', 'barCode'], @@ -52,7 +61,7 @@ export function wxScan() { }, fail(err) { console.error('扫码失败:', err) - reject(err) + reject(new Error(err?.errMsg || JSON.stringify(err) || '扫码失败')) } }) })