From 102e6c08675690a3bfe1d3387fd552ddb291fa9f Mon Sep 17 00:00:00 2001 From: sexygoat <1538832180@qq.com> Date: Thu, 16 Apr 2026 17:14:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=99=BB=E5=BD=95=E6=89=AB=E4=B8=80?= =?UTF-8?q?=E6=89=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 4 +++- pages/login/login.vue | 42 +++++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/manifest.json b/manifest.json index 1895a4c..3029751 100644 --- a/manifest.json +++ b/manifest.json @@ -17,7 +17,9 @@ "delay" : 0 }, /* 模块配置 */ - "modules" : {}, + "modules" : { + "Barcode" : {} + }, /* 应用发布信息 */ "distribute" : { /* android打包配置 */ diff --git a/pages/login/login.vue b/pages/login/login.vue index d498ec4..89e7cbe 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -127,29 +127,29 @@ const handleScanLogin = () => { // #ifdef H5 - if (typeof wx === 'undefined' || !wx.scanQRCode) { - uni.showToast({ title: '请在微信中打开', icon: 'none' }); - return; - } - wx.scanQRCode({ - needResult: 1, - scanType: ['qrCode', 'barCode'], - success: (res) => { - const result = res.resultStr; - if (result && result.includes('device_id')) { - const match = result.match(/device_id[=]([^&]*)/); - if (match && match[1]) { - identifier.value = match[1]; - handleLogin(); + if (typeof wx !== 'undefined' && wx.scanQRCode) { + wx.scanQRCode({ + needResult: 1, + scanType: ['qrCode', 'barCode'], + success: (res) => { + const result = res.resultStr; + if (result && result.includes('device_id')) { + const match = result.match(/device_id[=]([^&]*)/); + if (match && match[1]) { + identifier.value = match[1]; + handleLogin(); + } + } else { + uni.showToast({ title: '无效的二维码', icon: 'none' }); } - } else { - uni.showToast({ title: '无效的二维码', icon: 'none' }); + }, + fail: () => { + uni.showToast({ title: '扫码失败,请重试', icon: 'none' }); } - }, - fail: () => { - uni.showToast({ title: '扫码失败', icon: 'none' }); - } - }); + }); + } else { + uni.showToast({ title: '扫一扫功能暂不可用', icon: 'none' }); + } // #endif // #ifndef H5 uni.showToast({ title: '请在微信中打开', icon: 'none' });