|
@@ -80,8 +80,11 @@ export default {
|
|
|
executeReadCard()
|
|
|
}
|
|
|
|
|
|
- const executeReadCard = () => {
|
|
|
+ const executeReadCard = (retryCount = 0) => {
|
|
|
const nowbiztype = props.biztype || currentBiztype.value
|
|
|
+ const maxRetries = 5 // 最大重试次数
|
|
|
+ const retryDelay = 1500 // 重试间隔时间(毫秒)
|
|
|
+
|
|
|
// const param = `qrcode_${nowbiztype}`
|
|
|
const param = `jiangsu_qrcode_${nowbiztype}`
|
|
|
// axios('http://localhost:8321/readcard/entry?param=' + param)
|
|
@@ -102,16 +105,38 @@ export default {
|
|
|
showClose: true
|
|
|
})
|
|
|
} else {
|
|
|
- ElMessageBox.alert(res.data.message.trim(), '错误', {
|
|
|
+ // 进行重试
|
|
|
+ if (retryCount < maxRetries) {
|
|
|
+ setTimeout(() => {
|
|
|
+ console.log(`电子凭证读取失败,正在进行第 ${retryCount + 1} 次重试...`)
|
|
|
+ executeReadCard(retryCount + 1)
|
|
|
+ }, retryDelay)
|
|
|
+ } else {
|
|
|
+ const errorMessage = res.data.message || '读卡失败'
|
|
|
+ const finalMessage = `${errorMessage.trim()}(已重试${maxRetries}次)`
|
|
|
+
|
|
|
+ ElMessageBox.alert(finalMessage, '错误', {
|
|
|
+ type: 'error',
|
|
|
+ showCancelButton: false,
|
|
|
+ }).then(() => {})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).catch((e) => {
|
|
|
+ // 进行重试
|
|
|
+ if (retryCount < maxRetries) {
|
|
|
+ setTimeout(() => {
|
|
|
+ console.log(`电子凭证读取网络错误,正在进行第 ${retryCount + 1} 次重试...`)
|
|
|
+ executeReadCard(retryCount + 1)
|
|
|
+ }, retryDelay)
|
|
|
+ } else {
|
|
|
+ const errorMessage = e.message || e
|
|
|
+ const finalMessage = `${errorMessage}(已重试${maxRetries}次)`
|
|
|
+
|
|
|
+ ElMessageBox.alert(finalMessage, '错误', {
|
|
|
type: 'error',
|
|
|
showCancelButton: false,
|
|
|
}).then(() => {})
|
|
|
}
|
|
|
- }).catch((e) => {
|
|
|
- ElMessageBox.alert(e, '错误', {
|
|
|
- type: 'error',
|
|
|
- showCancelButton: false,
|
|
|
- }).then(() => {})
|
|
|
})
|
|
|
}
|
|
|
|