This commit is contained in:
@@ -186,6 +186,22 @@
|
|||||||
doLogin();
|
doLogin();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const parseScanIdentifier = (resultStr) => {
|
||||||
|
const scanValue = (resultStr || '').trim();
|
||||||
|
if (!scanValue) return '';
|
||||||
|
|
||||||
|
const barcodeMatch = scanValue.match(/^[A-Z0-9_]+,(.+)$/);
|
||||||
|
if (barcodeMatch) return barcodeMatch[1].trim();
|
||||||
|
|
||||||
|
if (scanValue.includes('?')) {
|
||||||
|
const params = new URLSearchParams(scanValue.split('?')[1]);
|
||||||
|
return params.get('cardNum') || params.get('identifier') || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = scanValue.match(/=([^=]+)$/);
|
||||||
|
return match ? match[1].trim() : scanValue;
|
||||||
|
};
|
||||||
|
|
||||||
const handleScanLogin = async () => {
|
const handleScanLogin = async () => {
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
try {
|
try {
|
||||||
@@ -199,24 +215,13 @@
|
|||||||
const resultStr = await wxScan();
|
const resultStr = await wxScan();
|
||||||
console.log('扫码结果:', resultStr);
|
console.log('扫码结果:', resultStr);
|
||||||
|
|
||||||
let value = '';
|
const value = parseScanIdentifier(resultStr);
|
||||||
|
|
||||||
// 解析二维码内容
|
|
||||||
if (resultStr.includes('?')) {
|
|
||||||
const params = new URLSearchParams(resultStr.split('?')[1]);
|
|
||||||
value = params.get('cardNum') || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!value) {
|
|
||||||
const match = resultStr.match(/=([^=]+)$/);
|
|
||||||
value = match ? match[1] : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
identifier.value = value;
|
identifier.value = value;
|
||||||
handleLogin();
|
handleLogin();
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({ title: '无效的二维码', icon: 'none' });
|
uni.showToast({ title: '无效的扫码内容', icon: 'none' });
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('扫码错误:', err);
|
console.error('扫码错误:', err);
|
||||||
|
|||||||
Reference in New Issue
Block a user