良田高拍仪集成WEB说明

良田高拍仪集成WEB说明

                                                                                                                ——By wuhebin 20180705

1.    硬件说明:良田高拍仪S620A3F(R) 带二代身份证阅读器和拍照摄像头等


2. WEB平台集成读卡器功能说明(注只支持IE浏览器,高版本IE或360需要在兼容模式下:

 

3.    WEB增加控件OCX代码如下:

<div>

       <object id="view1"type="application/x-eloamplugin" width="600"height="300" name="view"></object>

       <object id="view2" type="application/x-eloamplugin"width="600" height="300"name="view"></object>

   </div>

 

   <div>

       <object id="thumb1"type="application/x-eloamplugin" width="1208"height="150" name="thumb"></object>

   </div>

4.    JavaScript调用

如果仅需要二代证阅读和拍照功能。只需要'DevChange'和'IdCard'监听代码。拍照功能必须开摄像头OpenVideoMain()。

开启高拍仪资源:

plugin().Global_InitDevs();

关闭页面或者返回页面前最好调用关闭高拍仪资源:

plugin().Global_DeinitIdCard();


5.我的代码如下:

/*
* 新ERP系统 使用良田高拍仪扫描身份证或者拍照上传到系统
* 页面js使用,by wuhebin
*/

//注意:

//前台页面返回或者关闭页面必须调用一下代码
/*关闭所有高拍仪资源 by wuhebin 注意:如果需要拍照功能必须调用*/
//    var ret = me.plugin().Global_DeinitDevs();


me.initEloam = function(){

    //高拍仪代码///
    me.readIDcard = false;
    me.plugin = function(){//获取组件对象
        return document.getElementById('view1');
    }
    me.MainView =  function ()
    {
        return document.getElementById('view1');
    }

    /*关闭摄像头资源*/
    me.CloseVideoMain = function ()
    {
        if (me.VideoMain)
        {
            me.plugin().Video_Release(me.VideoMain);
            me.VideoMain = null;

        }			
    }

    /*开启摄像头资源*/
    me.OpenVideoMain = function ()
    {
        me.CloseVideoMain();

        if (!me.DeviceMain)
            return;

        var SelectType = me.plugin().Device_GetSubtype(me.DeviceMain);


        var nResolution = 0;


        me.VideoMain = me.plugin().Device_CreateVideo(me.DeviceMain, nResolution, SelectType);

        if (me.VideoMain)
        {
            me.MainView().View_SelectVideo(me.VideoMain);

        }
    }

    me.addEvent = function (obj, name, func)
    {
        if (obj.attachEvent) {
            obj.detachEvent("on" + name, func);
            obj.attachEvent("on" + name, func);
        } else {
            obj.removeEventListener(name, func, false);
            obj.addEventListener(name, func, false);
        }
    }

    //获取身份证数据
    me.getIcardData = function (){
        var data = {};
        data.empName = me.plugin().Global_GetIdCardData(1);
        data.empSex = me.plugin().Global_GetIdCardData(2);
        if(data.empSex){
            if("男" == data.empSex){
                data.empSex = "1";
            }else{
                data.empSex = "2";
            }
        }
        data.empNation = me.plugin().Global_GetIdCardData(3);
        if(data.empNation){
            if("汉" == data.empNation){
                data.empNation = "01";
            }else if("苗" == data.empNation){
                data.empNation = "02";
            }else if("侗" == data.empNation){
                data.empNation = "03";
            }else if("白" == data.empNation){
                data.empNation = "04";
            }else if("土家" == data.empNation){
                data.empNation = "05";
            }else if("仫佬" == data.empNation){
                data.empNation = "06";
            }else if("彝" == data.empNation){
                data.empNation = "07";
            }else if("革家" == data.empNation){
                data.empNation = "08";
            }else if("穿青" == data.empNation){
                data.empNation = "09";
            }else if("水" == data.empNation){
                data.empNation = "10";
            }else if("布依" == data.empNation){
                data.empNation = "12";
            }else if("瑶" == data.empNation){
                data.empNation = "13";
            }else if("回" == data.empNation){
                data.empNation = "11";
            }
            else if("壮" == data.empNation){
                data.empNation = "17";
            }else if("黎" == data.empNation){
                data.empNation = "14";
            }else if("畲" == data.empNation){
                data.empNation = "15";
            }else if("黎" == data.empNation){
                data.empNation = "14";
            }else{
                data.empNation = "";
            }
        }
        data.empBirthday = me.plugin().Global_GetIdCardData(4)+"-"+ me.plugin().Global_GetIdCardData(5)+"-"+ me.plugin().Global_GetIdCardData(6);
        var birthday= new Date((me.plugin().Global_GetIdCardData(4)+"-"+ me.plugin().Global_GetIdCardData(5)+"-"+ me.plugin().Global_GetIdCardData(6)).replace(/-/g, "\/"));   
        var d = new Date();   
        //年龄        
        //data.extNum1 = d.getFullYear()-birthday.getFullYear()-((d.getMonth()<birthday.getMonth()|| d.getMonth()==birthday.getMonth() && d.getDate()<birthday.getDate())?1:0);
        //身份证地址
        data.empRegisteredPlace = me.plugin().Global_GetIdCardData(7);
        //身份证号
        data.empIndentity = me.plugin().Global_GetIdCardData(8);
        return data;  

    }

    //设备接入
    me.addEvent(me.plugin(), 'DevChange', DevChange);
    //绑定事件,读取身份证信息
    me.addEvent(me.plugin(), "IdCard", readId);    

}


//初始化视频设备 拍照功能必须绑定此事件
function DevChange (type, idx, dbt) {

    if(1 == type)//视频设备
    {
        if(1 == dbt)//设备到达
        {
            var deviceType = me.plugin().Global_GetEloamType(1, idx);
            if(1 == deviceType)//主摄像头
            {
                if(null == me.DeviceMain){
                    me.DeviceMain = me.plugin().Global_CreateDevice(1, idx);
                }
            }
            else if(2 == deviceType || 3 == deviceType)//辅摄像头
            {
                if(null == me.DeviceMain){
                    me.DeviceMain = me.plugin().Global_CreateDevice(1, idx);
                }
            }

            if(me.DeviceMain){
                me.OpenVideoMain();
            }

        }
        else if(2 == dbt)//设备丢失
        {

        }
    }
}

me.doStart = function(){
    debugger;
    me.ret = me.plugin().Global_InitDevs();

    if(me.ret)
    {
        //进行人脸识别初始化时,视频应处于关闭状态
        me.plugin().InitFaceDetect();
    }

    if( !me.plugin().Global_VideoCapInit())
    {
        $.messager.alert("","初始化失败!","error");
    } 
    if(me.plugin().Global_InitIdCard())
    {
        if(me.plugin().Global_DiscernIdCard())
        {

            me.readIDcard = true;
            setTimeout(function () { 
                $.messager.alert("系统提示","请刷卡!","info");
            }, 2000);
        }
        else
        {
            $.messager.alert("系统提示","二代证阅读已启动!","error");
        }
    }
    else
    {
        $.messager.alert("系统提示","初始化二代证阅读器失败!","error");
    }
}

me.doExit = function(){
    debugger;
    me.plugin().Global_StopIdCardDiscern();
    me.plugin().Global_DeinitIdCard();
    if(me.DeviceMain)
    {
        me.plugin().Device_Release(me.DeviceMain);
        me.DeviceMain = null;		
    }
    me.readIDcard = false;

    /*关闭所有高拍仪资源 by wuhebin 注意:如果需要拍照功能必须调用*/
    var ret = me.plugin().Global_DeinitDevs();
    if(ret){
        $.messager.alert("","已停止!","info");
    }else{
        $.messager.alert("","已停止!","info");
    }


}



/***拍照例子 by wuhebin 20180629 ***/
me.Scan=function(){
    debugger;

    var imgList = me.plugin().Video_CreateImageList(me.VideoMain , 0, 0);
    console.log("me.VideoMain:"+me.VideoMain+";;imgList:"+imgList);
    var img = me.plugin().ImageList_GetImage(imgList, 0);
    me.plugin().Image_Release(img);
    var tempImg = me.plugin().Image_GetBase64(img, 2, 0);

    if(tempImg){
        var dc = new DataSet();
        dc.setParameter("imgData", tempImg);
        me.requestData({
            "module":"idcard",
            "action":"IDCardAction",
            "event":"show",
            "dataSet":dc,
            "success":function(){
                //设置图片labId,并刷新图片
                var empPicture = me.dataCenter.getParameter("labId") || "";
                me.byId("empImage").extfileinput("setValue", empPicture);
                var dataSet = new DataSet();
                dataSet.setParameter("lobId", empPicture);
                if (_application._identifier) {
                    dataSet.setHeader(constant.IDENTIFIER, _application._identifier);
                }
                var dataObj = dataSet.clone();
                dataObj["requestComponent"] = "1";
                var url = contextPath + "/fileinput/FileUploadAction/downLoad.do?"+ constant.PARAM_DATA_KEY + "=" + encodeURIComponent(JSON.toStr(dataObj));
                $(".photoImg" + "empImage", me.container).attr("src", url);
                $(".photoImg" + "empImage", me.container).height(120);
                $(".photoImg" + "empImage", me.container).width(90);
                $.messager.alert("系统提示","拍照成功!","info");
            }
        });
    }else{
        $.messager.alert("系统提示","拍照失败,请关闭后重新开启再拍照!","info");
    }

}



//刷卡时自动调用上传身份证头像图片并填充解析的数据到页面,例子
function readId(){

    debugger;
    // 	var data = me.getIcardData();
    // 	var image = me.plugin().Global_GetIdCardImage(1);//1表示头像, 2表示正面, 3表示反面 ...
    // 	var tempImg = me.plugin().Image_GetBase64(image, 2, 0);
    // 	me.plugin().Image_Release(image);
    // 	var dc = new DataSet();
    //     dc.setParameter("imgData", tempImg);
    // 	me.requestData({
    //     	"module":"idcard",
    //         "action":"IDCardAction",
    //         "event":"show",
    //         "dataSet":dc,
    //         "success":function(){
    //me.refreshEmpPic(data);
    //         	$.messager.alert("","扫描成功!","info");
    //         }
    //     });

}


me.refreshEmpPic = function(data){

    //设置图片labId,并刷新图片
    var empPicture = me.dataCenter.getParameter("labId") || "";
    me.byId("empImage").extfileinput("setValue", empPicture);
    var dataSet = new DataSet();
    dataSet.setParameter("lobId", empPicture);
    if (_application._identifier) {
        dataSet.setHeader(constant.IDENTIFIER, _application._identifier);
    }
    var dataObj = dataSet.clone();
    dataObj["requestComponent"] = "1";
    var url = contextPath + "/fileinput/FileUploadAction/downLoad.do?"+ constant.PARAM_DATA_KEY + "=" + encodeURIComponent(JSON.toStr(dataObj));
    $(".photoImg" + "empImage", me.container).attr("src", url);
    //设置身份证信息
    var combobox = ["empSex","empNation"];
    var datebox = ["empBirthday"];
    for(var i in data){
        if(_.indexOf(combobox, i) >= 0){
            me.byId(i).extcombobox("setValue", data[i]);
        }else if(_.indexOf(datebox, i) >= 0){
           // console.log("empBirthday:setValue"+data[i]);
            me.byId(i).extdate("setValue", data[i]);
        }else{
            me.byId(i).val(data[i]);
        }
    }

}

6.注意上面是我们平台的写法,var me = this;封装了一些方法;使用时请客官实现自己的方法的形式;

      实例里的me.initEloam();方法需要初始化。同理window.load等

7.各位所需要的良田高拍仪的demo文件和调试文件下载链接如下:

良田高拍仪控件及调试ActiveX实例文档等下载

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值