1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
| <template>
| <basic-container class="formsss">
| <div class="formssstitle">身份证信息</div>
| <avue-form
| ref="form"
| v-model="obj"
| :option="option"
| res="formss"
| @reset-change="emptytChange"
| >
| <!-- @submit="submit" -->
| <template slot-scope="{ type, disabled }" slot="imgs">
| <div class="imgss">
| <img :src="obj.imgs" alt="" />
| </div>
| </template>
| <template slot-scope="{ type, disabled }" slot="fingerprintForm">
| <div class="zhiwenMain">
| <iframe
| id="zhiwen"
| ref="zhiwen"
| src="/zhiwenDemo/CID.html"
| frameborder="0"
| width="100%"
| height="100%"
| name="zhiwen"
| ></iframe>
| </div>
| </template>
| </avue-form>
| </basic-container>
| </template>
|
| <script>
| import CertCtl from "./sfzJS";
| import { mapGetters } from "vuex";
| export default {
| computed: {
| ...mapGetters([
| "userInfo",
| "cardInfor",
| "haveCardid",
| "useZhiWen",
| "isClears",
| ]),
| },
| watch: {
| isClears() {
| if (this.isClears) {
| this.obj = {
| name: "",
| national: "",
| certAddress: "",
| sex: "",
| imgs: "",
| yxqend: "",
| yxqstart: "",
| birthday: "",
| id: "",
| qfjg: "",
| };
| this.emptytChange();
| this.$store.commit("setIsClears", false);
| }
| },
| },
| mounted() {
| // console.log(CertCtl);
| try {
| // 开始连接设备
| //调用对应的连接方法,并赋值给result
| this.cardShebei = CertCtl.connect();
| //如果result为空,代表读卡插件未启动
| if (this.cardShebei == "") {
| console.log("未启动读卡插件!1");
| this.$confirm(
| "未安装身份证设备驱动,请安装后重试!点击确定开始刷新页面,点击取消需手动刷新?",
| "提示",
| {
| confirmButtonText: "确定",
| cancelButtonText: "取消",
| type: "warning",
| }
| )
| .then(() => {
| location.reload();
| })
| .catch(() => {
| // this.$message({
| // type: 'info',
| // message: '已取消删除'
| // });
| });
| this.noone = true;
| return;
| } else {
| //result页面回显
| console.log("ok!");
| }
| } catch (e) {
| // console.log(e, "未启动读卡插件!2");
| }
|
| if (this.intTime) {
| clearInterval(this.intTime);
| this.setIntervals();
| } else {
| this.setIntervals();
| }
| },
| data() {
| return {
| cardShebei: "",
| intTime: "", //自动获取身份证;
| obj: {},
| noone: false,
| option: {
| // mockBtn: true,
| // submitText: "完成",
| // printBtn: true,
| // emptyBtn: false,
| size: "small",
| labelWidth: 70,
| submitBtn: false,
| disabled: true,
| column: [
| {
| label: "姓名",
| prop: "name",
| },
| {
| label: "性别",
| prop: "sex",
| },
| {
| label: "民族",
| prop: "national",
| },
| {
| label: "出生日期",
| prop: "birthday",
| },
| {
| label: "照片",
| prop: "imgs",
| // listType: "picture-img",
| // type: "upload",
| // disabled: true,
| },
| {
| label: "指纹",
| prop: "fingerprintForm",
| },
| {
| label: "身份号码",
| prop: "id",
| },
| {
| label: "签发机关",
| prop: "qfjg",
| },
| {
| label: "起始日期",
| prop: "yxqstart",
| },
| {
| label: "截止日期",
| prop: "yxqend",
| },
| {
| label: "住址",
| prop: "certAddress",
| span: 24,
| },
| // {
| // label: "最新住址",
| // prop: "address",
| // },
| ],
| },
| };
| },
| methods: {
| setIntervals: function () {
| let that = this;
| if (this.noone) {
| console.log("请安装驱动!");
| return;
| }
| this.intTime = setInterval(function () {
| if (!that.haveCardid) {
| //定时读卡
| let result = CertCtl.readCert();
| if (result == "") {
| console.log("未启动读卡插件!3");
| } else {
| var resultObj = eval("(" + result + ")");
| //resultFlag为0代表读卡成功
| if (resultObj.resultFlag == "0") {
| //回显相关数据
| // console.log(resultObj, 123);
| const data = resultObj.resultContent;
| // 判断是否是重新读卡
| // if (that.obj.id == data.certNumber) {
| // //同一张身份证-不更新数据
| // return;
| // }
| //赋值数据
| that.obj = {
| name: data.partyName,
| national: data.nation,
| certAddress: data.certAddress,
| // sex:
| // data.certType == 0
| // ? "未知"
| // : data.certType == 1
| // ? "男"
| // : data.certType == 2
| // ? "女"
| // : data.certType == 9
| // ? "未说明"
| // : "未能识别",
| sex:
| data.gender == 0
| ? "女"
| : data.gender == 1
| ? "男"
| : "未能识别",
| imgs: "data:image/bmp;base64," + data.identityPic,
| yxqend:
| data.expDate.slice(0, 4) +
| "-" +
| data.expDate.slice(4, 6) +
| "-" +
| data.expDate.slice(6, 8),
| yxqstart:
| data.effDate.slice(0, 4) +
| "-" +
| data.effDate.slice(4, 6) +
| "-" +
| data.effDate.slice(6, 8),
| birthday:
| data.bornDay.slice(0, 4) +
| "-" +
| data.bornDay.slice(4, 6) +
| "-" +
| data.bornDay.slice(6, 8),
| id: data.certNumber,
| qfjg: data.certOrg,
| };
| // console.log("应用数据");
| that.$store.commit("setCardInfor", that.obj);
| that.$store.commit("setCardidState", true);
| } else if (resultObj.resultFlag == "-1") {
| if (resultObj.errorMsg == "端口打开失败") {
| console.log("读卡器未连接");
| } else {
| // console.log(resultObj.errorMsg);
| //无卡片提醒
| that.obj = {
| id: "",
| };
| }
| } else if (resultObj.resultFlag == "-2") {
| console.log(resultObj.errorMsg);
| }
| }
| }
| }, 1000);
| },
| emptytChange() {
| this.$store.commit("setCardidState", false);
| let zhiwen = {
| featuredatas: "",
| imgBMP: "",
| url: "",
| isoks: false,
| clear: true,
| };
| this.useZhiWen("setZhiwenData", zhiwen);
| // this.$message.success("清空身份证数据");
| },
| // useZhiWen: function (fn, vals) {
| // //读取指纹实例
| // let val = vals || "";
| // var winzhiwen = document.getElementById("zhiwen").contentWindow;
| // return winzhiwen[fn](val);
| // },
| },
| beforeDestroy() {
| clearInterval(this.intTime);
| this.intTime = null;
| },
| };
| </script>
| <style lang="scss" scoped>
| .zhiwenMain {
| width: 180px;
| height: 247px;
| // border: 1px solid rgba($color: #d3d3d3, $alpha: 1);
| }
| .formsss {
| height: 100% !important;
| // overflow-x: hidden;
| // border: 1px solid rgb(0, 255, 64);
| // overflow-y: scroll;
| }
| .imgss {
| height: 182px;
| width: 138px;
| border: 1px solid rgba($color: #d3d3d3, $alpha: 1);
| border-radius: 5px;
| img {
| width: 100%;
| height: 100%;
| }
| }
| </style>
|
|