|
@@ -113,44 +113,76 @@ export default {
|
|
|
|
|
|
const ectype = ['qrcode', 'qrcode2', 'face', 'idcard2']
|
|
const ectype = ['qrcode', 'qrcode2', 'face', 'idcard2']
|
|
|
|
|
|
- const executeReadCard = (cardtype) => {
|
|
|
|
- const nowbiztype = props.biztype || currentBiztype.value
|
|
|
|
- if (cardtype !== 'qrcode') {
|
|
|
|
- startLoading()
|
|
|
|
- }
|
|
|
|
- const param = `${cardtype}_${nowbiztype}`
|
|
|
|
- axios('http://localhost:8321/readcard/entry?param=' + param)
|
|
|
|
- .then((res) => {
|
|
|
|
- endLoading()
|
|
|
|
- if (res.data.code === 200) {
|
|
|
|
- const result = {
|
|
|
|
- mdtrtCertType: cardtype,
|
|
|
|
- readCardResult: ectype.indexOf(cardtype) > -1 ? JSON.stringify(JSON.parse(res.data.data).data) : res.data.data,
|
|
|
|
- readCardBizType: nowbiztype,
|
|
|
|
- }
|
|
|
|
- ctx.emit('success', result)
|
|
|
|
- ElMessageBox.alert(res.data.message, '提示', {
|
|
|
|
- type: 'success',
|
|
|
|
- showCancelButton: false,
|
|
|
|
- }).then(() => {
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- ElMessageBox.alert(res.data.message.trim(), '错误', {
|
|
|
|
- type: 'error',
|
|
|
|
- showCancelButton: false,
|
|
|
|
- }).then(() => {
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+const executeReadCard = (cardtype) => {
|
|
|
|
+ const nowbiztype = props.biztype || currentBiztype.value
|
|
|
|
+ if (cardtype !== 'qrcode') {
|
|
|
|
+ startLoading()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 特殊处理:社保卡使用江苏医保自动初始化接口
|
|
|
|
+ let requestUrl
|
|
|
|
+ if (cardtype === 'sicard') {
|
|
|
|
+ requestUrl = 'http://localhost:8321/readcard/jiangsu/readcard_auto'
|
|
|
|
+ } else {
|
|
|
|
+ const param = `${cardtype}_${nowbiztype}`
|
|
|
|
+ requestUrl = 'http://localhost:8321/readcard/entry?param=' + param
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ axios(requestUrl)
|
|
|
|
+ .then((res) => {
|
|
|
|
+ endLoading()
|
|
|
|
+
|
|
|
|
+ // 处理江苏医保接口返回数据格式转换为泰和医院格式
|
|
|
|
+ let processedData = res.data
|
|
|
|
+ if (cardtype === 'sicard' && res.data.success !== undefined) {
|
|
|
|
+ // 江苏医保接口格式转换为泰和医院格式
|
|
|
|
+ processedData = {
|
|
|
|
+ code: res.data.success ? 200 : (res.data.code || 1001),
|
|
|
|
+ type: 'sicard',
|
|
|
|
+ // 关键:将江苏医保的结构化数据转换为泰和医院期望的字符串格式
|
|
|
|
+ data: res.data.data ? (
|
|
|
|
+ typeof res.data.data === 'string'
|
|
|
|
+ ? res.data.data
|
|
|
|
+ : JSON.stringify(res.data.data)
|
|
|
|
+ ) : '',
|
|
|
|
+ // 江苏医保没有sign字段,设为空字符串
|
|
|
|
+ sign: '',
|
|
|
|
+ message: res.data.message || (res.data.success ? '读取社保卡成功。' : '读取社保卡失败。')
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (processedData.code === 200) {
|
|
|
|
+ const result = {
|
|
|
|
+ mdtrtCertType: cardtype,
|
|
|
|
+ // 对于社保卡(sicard),直接使用data字段,不需要JSON解析
|
|
|
|
+ readCardResult: ectype.indexOf(cardtype) > -1
|
|
|
|
+ ? JSON.stringify(JSON.parse(processedData.data).data)
|
|
|
|
+ : processedData.data,
|
|
|
|
+ readCardBizType: nowbiztype,
|
|
|
|
+ }
|
|
|
|
+ ctx.emit('success', result)
|
|
|
|
+ ElMessageBox.alert(processedData.message, '提示', {
|
|
|
|
+ type: 'success',
|
|
|
|
+ showCancelButton: false,
|
|
|
|
+ }).then(() => {
|
|
})
|
|
})
|
|
- .catch((e) => {
|
|
|
|
- endLoading()
|
|
|
|
- ElMessageBox.alert(e, '错误', {
|
|
|
|
- type: 'error',
|
|
|
|
- showCancelButton: false,
|
|
|
|
- }).then(() => {
|
|
|
|
- })
|
|
|
|
|
|
+ } else {
|
|
|
|
+ ElMessageBox.alert((processedData.message || '读卡失败').trim(), '错误', {
|
|
|
|
+ type: 'error',
|
|
|
|
+ showCancelButton: false,
|
|
|
|
+ }).then(() => {
|
|
})
|
|
})
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch((e) => {
|
|
|
|
+ endLoading()
|
|
|
|
+ ElMessageBox.alert(e.message || e, '错误', {
|
|
|
|
+ type: 'error',
|
|
|
|
+ showCancelButton: false,
|
|
|
|
+ }).then(() => {
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
|
|
return {
|
|
return {
|
|
currentBiztype,
|
|
currentBiztype,
|