新增h5qrcode依赖
This commit is contained in:
+115
-30
@@ -989,21 +989,39 @@
|
||||
|
||||
const processScanResult = async (scanResult) => {
|
||||
try {
|
||||
console.log('===== 处理扫码结果 =====');
|
||||
console.log('扫码结果对象:', scanResult);
|
||||
console.log('scanType:', scanResult.scanType);
|
||||
console.log('result:', scanResult.result);
|
||||
console.log('path:', scanResult.path);
|
||||
|
||||
let deviceNo;
|
||||
if (scanResult.scanType == 'MANUAL') {
|
||||
deviceNo = scanResult.result;
|
||||
} else if (scanResult.scanType == '"QR_CODE"') {
|
||||
deviceNo = getQueryString(scanResult.result, 'deviceNo')
|
||||
console.log('手动输入模式,设备号:', deviceNo);
|
||||
} else if (scanResult.scanType == 'QR_CODE') {
|
||||
// 修复:移除多余的引号
|
||||
deviceNo = getQueryString(scanResult.result, 'deviceNo');
|
||||
console.log('二维码扫描模式,提取设备号:', deviceNo);
|
||||
} else {
|
||||
deviceNo = getQueryString(scanResult.path || scanResult.result, 'deviceNo')
|
||||
deviceNo = getQueryString(scanResult.path || scanResult.result, 'deviceNo');
|
||||
console.log('其他模式,提取设备号:', deviceNo);
|
||||
}
|
||||
|
||||
console.log('最终设备号:', deviceNo);
|
||||
|
||||
if (!deviceNo) {
|
||||
console.warn('未能提取到设备号');
|
||||
uni.showToast({
|
||||
title: t('home.invalidQRCode'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
});
|
||||
// 关闭扫码页面
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否有使用中的订单
|
||||
@@ -1011,10 +1029,24 @@
|
||||
|
||||
if (inUseRes && inUseRes.code === 200 && inUseRes.data) {
|
||||
const inUseOrder = inUseRes.data
|
||||
uni.reLaunch({
|
||||
url: `/pages/order/detail?orderId=${inUseOrder.orderId}&deviceId=${deviceNo || inUseOrder.deviceNo}`
|
||||
})
|
||||
return
|
||||
// 先关闭扫码页,再跳转
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 1 && pages[pages.length - 1].route.includes('scan')) {
|
||||
uni.navigateBack({
|
||||
success: () => {
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: `/pages/order/detail?orderId=${inUseOrder.orderId}&deviceId=${deviceNo || inUseOrder.deviceNo}`
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.reLaunch({
|
||||
url: `/pages/order/detail?orderId=${inUseOrder.orderId}&deviceId=${deviceNo || inUseOrder.deviceNo}`
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否有待支付订单
|
||||
@@ -1022,9 +1054,23 @@
|
||||
|
||||
if (orderRes && orderRes.code === 200 && orderRes.data) {
|
||||
const unpaidOrder = orderRes.data
|
||||
uni.navigateTo({
|
||||
url: `/pages/order/payment?orderId=${unpaidOrder.orderId}`
|
||||
})
|
||||
// 先关闭扫码页,再跳转
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 1 && pages[pages.length - 1].route.includes('scan')) {
|
||||
uni.navigateBack({
|
||||
success: () => {
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/order/payment?orderId=${unpaidOrder.orderId}`
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/order/payment?orderId=${unpaidOrder.orderId}`
|
||||
});
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const deviceInfoRes = await getDeviceInfo(deviceNo)
|
||||
@@ -1032,40 +1078,79 @@
|
||||
if (deviceInfoRes.code == 200 && deviceInfoRes.data && deviceInfoRes.data.device) {
|
||||
const deviceInfo = deviceInfoRes.data.device
|
||||
|
||||
// 先关闭扫码页,再跳转
|
||||
const pages = getCurrentPages();
|
||||
const closeScanPageAndNavigate = (url) => {
|
||||
if (pages.length > 1 && pages[pages.length - 1].route.includes('scan')) {
|
||||
uni.navigateBack({
|
||||
success: () => {
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({ url });
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({ url });
|
||||
}
|
||||
};
|
||||
|
||||
if (deviceInfo.feeConfig) {
|
||||
try {
|
||||
const feeConfig = JSON.parse(deviceInfo.feeConfig)
|
||||
uni.navigateTo({
|
||||
url: `/pages/device/detail?deviceNo=${deviceNo}&feeConfig=${encodeURIComponent(deviceInfo.feeConfig)}`
|
||||
})
|
||||
closeScanPageAndNavigate(`/pages/device/detail?deviceNo=${deviceNo}&feeConfig=${encodeURIComponent(deviceInfo.feeConfig)}`);
|
||||
} catch (e) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/device/detail?deviceNo=${deviceNo}`
|
||||
})
|
||||
closeScanPageAndNavigate(`/pages/device/detail?deviceNo=${deviceNo}`);
|
||||
}
|
||||
} else {
|
||||
closeScanPageAndNavigate(`/pages/device/detail?deviceNo=${deviceNo}`);
|
||||
}
|
||||
} else {
|
||||
// 先关闭扫码页,再跳转
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 1 && pages[pages.length - 1].route.includes('scan')) {
|
||||
uni.navigateBack({
|
||||
success: () => {
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/device/detail?deviceNo=${deviceNo}`
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/device/detail?deviceNo=${deviceNo}`
|
||||
})
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// uni.showToast({
|
||||
// title: t('device.getDeviceInfoFailed'),
|
||||
// icon: 'none'
|
||||
// })
|
||||
uni.navigateTo({
|
||||
url: `/pages/device/detail?deviceNo=${deviceNo}`
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取设备信息异常:', error)
|
||||
uni.navigateTo({
|
||||
url: `/pages/device/detail?deviceNo=${deviceNo}`
|
||||
})
|
||||
// 先关闭扫码页,再跳转
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 1 && pages[pages.length - 1].route.includes('scan')) {
|
||||
uni.navigateBack({
|
||||
success: () => {
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/device/detail?deviceNo=${deviceNo}`
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/device/detail?deviceNo=${deviceNo}`
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('处理扫码结果失败:', error)
|
||||
// 关闭扫码页面
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 1 && pages[pages.length - 1].route.includes('scan')) {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user