feat: 登录扫一扫
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 45s

This commit is contained in:
sexygoat
2026-04-16 17:14:43 +08:00
parent b56f68636c
commit 102e6c0867
2 changed files with 24 additions and 22 deletions

View File

@@ -17,7 +17,9 @@
"delay" : 0 "delay" : 0
}, },
/* */ /* */
"modules" : {}, "modules" : {
"Barcode" : {}
},
/* */ /* */
"distribute" : { "distribute" : {
/* android */ /* android */

View File

@@ -127,29 +127,29 @@
const handleScanLogin = () => { const handleScanLogin = () => {
// #ifdef H5 // #ifdef H5
if (typeof wx === 'undefined' || !wx.scanQRCode) { if (typeof wx !== 'undefined' && wx.scanQRCode) {
uni.showToast({ title: '请在微信中打开', icon: 'none' }); wx.scanQRCode({
return; needResult: 1,
} scanType: ['qrCode', 'barCode'],
wx.scanQRCode({ success: (res) => {
needResult: 1, const result = res.resultStr;
scanType: ['qrCode', 'barCode'], if (result && result.includes('device_id')) {
success: (res) => { const match = result.match(/device_id[=]([^&]*)/);
const result = res.resultStr; if (match && match[1]) {
if (result && result.includes('device_id')) { identifier.value = match[1];
const match = result.match(/device_id[=]([^&]*)/); handleLogin();
if (match && match[1]) { }
identifier.value = match[1]; } else {
handleLogin(); uni.showToast({ title: '无效的二维码', icon: 'none' });
} }
} else { },
uni.showToast({ title: '无效的二维码', icon: 'none' }); fail: () => {
uni.showToast({ title: '扫码失败,请重试', icon: 'none' });
} }
}, });
fail: () => { } else {
uni.showToast({ title: '扫码失败', icon: 'none' }); uni.showToast({ title: '扫一扫功能暂不可用', icon: 'none' });
} }
});
// #endif // #endif
// #ifndef H5 // #ifndef H5
uni.showToast({ title: '请在微信中打开', icon: 'none' }); uni.showToast({ title: '请在微信中打开', icon: 'none' });