欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 焦点 > 身份证阅读器API模式 VUE Dorado7

身份证阅读器API模式 VUE Dorado7

2024/11/20 13:25:31 来源:https://blog.csdn.net/tanzongbiao/article/details/142235919  浏览:    关键词:身份证阅读器API模式 VUE Dorado7

VUE 新框架

// 身份证扫描
readIdCard(type) {// 1.连接axios.get('http://localhost:19196/openDevice').then(res => {if (res.data.resultFlag === 0) {// 2.读卡axios.get('http://localhost:19196/readCard').then((res) => {if (res.data.resultFlag === 0) {// this.$message.success('读卡成功')// 信息处理this.form.name = res.data.partyNamethis.form.idCard = res.data.certNumberthis.form.nationality = res.data.nationthis.form.birthday = res.data.bornDaythis.form.sex = res.data.gender === '男' ? 1 : res.data.gender === '女' ? 2 : 0this.form.expDate = res.data.expDatethis.form.residence = res.data.certOrgthis.form.addr = res.data.certAddressthis.form.photo = 'data:image/jpeg;base64,' + res.data.identityPic// 签到打卡if (type === 'in') {this.loading = truetrainClassApi.signIn({ idCard: this.form.idCard }).then(res => {this.loading = falseif (res.code !== 200) {this.$message.error(res.msg)return}this.$message.success(res.msg)this.getByPage()}).catch(() => {this.loading = false})} else if (type === 'off') { // 签退打卡this.loading = truetrainClassApi.signOff({ idCard: this.form.idCard }).then(res => {this.loading = falseif (res.code !== 200) {this.$message.error(res.msg)return}this.$message.success(res.msg)this.getByPage()}).catch(() => {this.loading = false})}// 3.断开axios.get('http://localhost:19196/CloseDevice').then(res => {/* if (res.data.resultFlag !== 0) {this.$alert('断开失败', '提示', { type: 'error' })} */})} else {this.$alert('读卡失败', '提示', { type: 'error' })}})} else {this.$alert('连接失败', '提示', { type: 'error' })}})
},

Dorado7 新版身份证阅读器API模式

/*** 身份证阅读器(API模式)【注意:需使用https模式才行 否者会被跨域拦截】* like12 add,20240913*/
// @Bind #idCardApiBtn.onClick
!function(self, employeeForm, employeeDataSet){// 1.连接var xhr = new XMLHttpRequest();xhr.open('GET', 'http://127.0.0.1:19196/OpenDevice', true);// xhr.withCredentials = true; // 如果需要的话xhr.onreadystatechange = function() {if (xhr.readyState === 4 && xhr.status === 200) {var resData = JSON.parse(xhr.responseText);// console.log(resData);if(resData.resultFlag == 0){// 2.读卡xhr.open('GET', 'http://127.0.0.1:19196/readCard', true);xhr.onreadystatechange = function() {if (xhr.readyState === 4 && xhr.status === 200) {var resData = JSON.parse(xhr.responseText);// console.log(resData);if(resData.resultFlag == 0){// 信息处理var name = resData.partyName;var idCard = resData.certNumber;var nationality = resData.nation;var birthday = resData.bornDay;var sex = resData.gender === '男' ? 1 : resData.gender === '女' ? 0 : 2; // 本系统为1男0女2未知/*var expDate = resData.expDate;var residence = resData.certOrg;*/var addr = resData.certAddress;var photo = resData.identityPic;// var photo = 'data:image/jpeg;base64,' + resData.identityPic;/*console.log(name);console.log(idCard);console.log(nationality);console.log(birthday);console.log(sex);console.log(expDate);console.log(residence);console.log(addr);// console.log(photo);*/// 出生日期格式转换var birthdayStr = birthday.substr(0, 4) + '-' + birthday.substr(4, 2) + '-' + birthday.substr(6, 2);// 赋值employeeDataSet.getData("#").set('employeeName', name);employeeDataSet.getData("#").set('employeeSex', sex);employeeDataSet.getData("#").set('idCard', idCard);employeeDataSet.getData("#").set('employeeBirthday', birthdayStr);employeeDataSet.getData("#").set('nationality', nationality);employeeDataSet.getData("#").set('registeredResidence', addr);// 保存图片var saveAction = view.get("#saveIdCardPhotoAction");saveAction.set("parameter", {"photo": photo,"idCard": idCard});saveAction.execute(function(returnVal){if(returnVal.indexOf(".jpg") != -1){// 保存图片地址employeeDataSet.getData("#").set('employeePhoto', returnVal);employeeForm.refreshData();// 显示照片view.set('#photoContainer.content', getImage(returnVal));}});// 3.断开xhr.open('GET', 'http://127.0.0.1:19196/CloseDevice', true);xhr.onreadystatechange = function() {};xhr.send();}}};xhr.send();}}};xhr.send();
};

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com