Browse Source

2222222222

LIJU 2 months ago
parent
commit
25b292b8d6

+ 32 - 7
src/components/medical-insurance/read-electronic-si-card/index.vue

@@ -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(() => {})
                 })
         }
 

+ 1 - 1
src/components/medical-insurance/readcard/Index.vue

@@ -1,6 +1,6 @@
 <template>
   <el-dropdown style="margin: 0 10px" trigger="click" @command="beforeReadCard">
-    <el-button type="primary">读卡&nbsp
+    <el-button type="primary">读卡&nbsp;
       <el-icon>
         <ArrowDown/>
       </el-icon>