|
|
@@ -52,6 +52,7 @@ import { openDevice, readcard, closeDevice } from '@/api/HuashiReaderApi'
|
|
|
import { getReaderConnect, getReaderDisconnect, getReadCert } from '@/api/JinlunReaderApi'
|
|
|
import donsee from '@/api/donsee'
|
|
|
import { getServerConfig, isEmpty } from '@/utils'
|
|
|
+import HuashiReaderWsApi from '@/api/HuashiReaderWsApi'
|
|
|
|
|
|
export default {
|
|
|
data () {
|
|
|
@@ -61,7 +62,8 @@ export default {
|
|
|
tempValue: '',
|
|
|
loading: false,
|
|
|
comName: '', // 身份证阅读器端口号
|
|
|
- deviceName: this.$localStore.get('idDevice') // 身份证阅读器类型。 zk 中控; hs 华视
|
|
|
+ deviceName: this.$localStore.get('idDevice'), // 身份证阅读器类型。 zk 中控; hs 华视
|
|
|
+ hsWsApi: null
|
|
|
}
|
|
|
},
|
|
|
props: {
|
|
|
@@ -83,6 +85,11 @@ export default {
|
|
|
default: '读取卡号'
|
|
|
}
|
|
|
},
|
|
|
+ mounted () {
|
|
|
+ if (this.deviceName === 'hs-ws') {
|
|
|
+ this.hsWsApi = new HuashiReaderWsApi()
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
// IC卡位数补全
|
|
|
padString (e) {
|
|
|
@@ -129,6 +136,11 @@ export default {
|
|
|
|
|
|
this.finished = false
|
|
|
|
|
|
+ if (this.deviceName === 'hs-ws') {
|
|
|
+ this.handleHsWebSocket()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
// 东信EST-100R
|
|
|
if (this.deviceName === 'donsee-100R') {
|
|
|
this.handleDonsee100R()
|
|
|
@@ -159,6 +171,52 @@ export default {
|
|
|
|
|
|
this.getDevice()
|
|
|
},
|
|
|
+ handleHsWebSocket () {
|
|
|
+ if (!this.hsWsApi) {
|
|
|
+ this.hsWsApi = new HuashiReaderWsApi()
|
|
|
+ }
|
|
|
+ if (this.hsWsApi.isConnected) {
|
|
|
+ this.loading = true
|
|
|
+ this.active = true
|
|
|
+ this.hsWsApi.addMessageListener((res) => {
|
|
|
+ if (res.data === 'failed to obtain ID card information') {
|
|
|
+ this.$message.error('读取失败,请重试')
|
|
|
+ this.getIdInfo()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const alldata = res.data.split('|')
|
|
|
+ console.log(alldata)
|
|
|
+
|
|
|
+ if (alldata.length.length && alldata[0] === '卡认证失败') {
|
|
|
+ this.$message.error('读取失败,请重试')
|
|
|
+ this.loading = false
|
|
|
+ this.active = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (alldata.length >= 17) {
|
|
|
+ this.$emit('change', { Name: alldata[3], IDNumber: alldata[8] })
|
|
|
+ this.loading = false
|
|
|
+ this.active = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ this.hsWsApi.readIDCard(10 * 1000)
|
|
|
+ } else {
|
|
|
+ this.loading = false
|
|
|
+ this.active = false
|
|
|
+ this.hsWsApi.closeConnect()
|
|
|
+ this.hsWsApi.connect((isConnected) => {
|
|
|
+ if (isConnected) {
|
|
|
+ // this.timer && clearTimeout(this.timer)
|
|
|
+ this.handleHsWebSocket()
|
|
|
+ } else {
|
|
|
+ this.$message.error('身份证读卡器暂时无法使用,请检查;')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
handleTecsun () {
|
|
|
this.loading = true
|
|
|
this.active = true
|
|
|
@@ -440,6 +498,8 @@ export default {
|
|
|
}
|
|
|
|
|
|
this.cardSearchTimer && clearTimeout(this.cardSearchTimer)
|
|
|
+
|
|
|
+ this.hsWsApi && this.hsWsApi.closeConnect()
|
|
|
}
|
|
|
}
|
|
|
</script>
|