vue华视电子身份证阅读器的使用

      ie还是谷歌都是可以用的

         只需要直接启用华视电子身份证阅读器的服务来的,至于服务已经上传到了网上   华视阅读器服务,下载下来解压,找到对应的华视电子读卡服务.exe文件,路径是CVR-100N SDK开发包下载\开发资料\网页版开发包\华视电子读卡服务.exe,双击打开之后,然后你在代码中,就可以使用对应的服务的方法(接口);

 

首先是api文件,我是因为把接口单独放在一个js文件中,在vue文件中引用的,所以可能跟你们的有点不一样,你们的代码有可能是直接在vue中访问接口,但是我知道你们肯定会随机应变的,只要把我的对应的网址接口拿出来就行,如下是我的代码:api文件取名为api.js

// 连接身份证读卡器
export function openDevice(data){
    return axios({
        url:'axios://127.0.0.1:19196/OpenDevice',
        method:'GET'
    })
}
// 读取身份证
export function readIdCard(data){
    return axios({
        url:'axios://127.0.0.1:19196/readcard',
        method:'GET'
    })
}
// 断开连接读卡器
export function closeDevice(data){
    return axios({
        url:'axios://127.0.0.1:19196/CloseDevice',
        method:'GET'
    })
}

然后在vue中使用需要导入对应的接口文件:

<script>
import {
        openDevice,
        readIdCard,
        closeDevice
    } from '@/api'
// 在methods中调用
methods:{
// 连接读卡器
            openDevice() {
                openDevice().then(res => {
                    if (res.data.resultFlag == 0) {
                        // 连接成功
                        this.$message.success("连接读卡器成功!")
                        // this.timerCard = setInterval(this.readCard, 1000);
                        // this.readCard();
                    }
                })
            },
            // 身份证读取信息
            readCard() {
                readIdCard().then(res => {
                    for (let s of this.tableDataCard) {
                        s.userName = res.data.partyName
                        s.certificateNo = res.data.certNumber
                        let index = this.tableDataCard.findIndex(ticket => ticket.certificateNo == s
                            .certificateNo);
                        if (index == -1) this.tableDataCard.push(obj)
                    }
                })
            },
            // 断开连接身份证
            closeDevice() {
                closeDevice().then(res => {
                    if (res.data.resultFlag == 0) {
                        // 连接成功
                        this.$message.warning("断开连接")
                    }
                })
            },
}
</script>

以上就是直接调用电子读卡服务的接口,这样不用给浏览器安装插件都可以使用,因为我们调用的是原生的接口

参考链接:https://blog.csdn.net/qq_32154641/article/details/119536128

posted @ 2022-06-14 15:04  喆星高照  阅读(1528)  评论(0)    收藏  举报