test.htm
8.1 KB
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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新中新二代证阅读器控件测试程序JavaScript</title>
<script language="JavaScript1.2">
function FindReader_onclick()
{
var str;
str = SynCardOcx1.FindReader();
if (str > 0)
{
if(str>1000)
{
str =document.all['S1'].value+ "读卡器连接在USB " + str+"\r\n" ;
}
else
{
str =document.all['S1'].value+ "读卡器连接在COM " + str+"\r\n" ;
}
}
else
{
str =document.all['S1'].value+ "没有找到读卡器\r\n";
}
document.all['S1'].value=str;
}
function ReadSAMID_onclick()
{
var str=SynCardOcx1.GetSAMID();
document.all['S1'].value=document.all['S1'].value+"读卡器SAMID为:"+str+"\r\n";
}
function Clear_onclick()
{
document.all['S1'].value="";
}
function ReadCard_onclick()
{
var nRet;
nRet = SynCardOcx1.ReadCardMsg();
if(nRet==0)
{
document.all['S1'].value=document.all['S1'].value+"读卡成功\r\n";
document.all['S1'].value=document.all['S1'].value+"姓名:"+SynCardOcx1.NameA +"\r\n";
document.all['S1'].value=document.all['S1'].value+"性别:"+SynCardOcx1.Sex +"\r\n";
document.all['S1'].value=document.all['S1'].value+"民族:"+SynCardOcx1.Nation +"\r\n";
document.all['S1'].value=document.all['S1'].value+"出生日期:"+SynCardOcx1.Born +"\r\n";
document.all['S1'].value=document.all['S1'].value+"地址:"+SynCardOcx1.Address +"\r\n";
document.all['S1'].value=document.all['S1'].value+"身份证号:"+SynCardOcx1.CardNo +"\r\n";
document.all['S1'].value=document.all['S1'].value+"有效期开始:"+SynCardOcx1.UserLifeB +"\r\n";
document.all['S1'].value=document.all['S1'].value+"有效期结束:"+SynCardOcx1.UserLifeE +"\r\n";
document.all['S1'].value=document.all['S1'].value+"发证机关:"+SynCardOcx1.Police +"\r\n";
document.all['S1'].value=document.all['S1'].value+"照片文件名:"+SynCardOcx1.PhotoName +"\r\n";
}
}
function ReadCardAuto_onclick()
{
SynCardOcx1.SetloopTime(1000);
SynCardOcx1.SetReadType(1);
}
function PhotoPath_onclick()
{
var str="";
SynCardOcx1.SetPhotoPath(0,str);
document.all['S1'].value=document.all['S1'].value+"照片保存路径设置为C盘根目录\r\n";
}
function PhotoPath2_onclick()
{
var str="";
SynCardOcx1.SetPhotoPath(1,str);
document.all['S1'].value=document.all['S1'].value+"照片保存路径设置为当前目录\r\n";
}
function PhotoPath3_onclick()
{
var str="D:\\Photo";
var nRet;
nRet= SynCardOcx1.SetPhotoPath(2,str);
if(nRet == 0)
{
document.all['S1'].value=document.all['S1'].value+"照片保存路径设置为"+str+"\r\n";
}
else
{
document.all['S1'].value=document.all['S1'].value+"照片保存路径设置失败\r\n";
}
}
function PhotoType_onclick()
{
var nRet;
nRet=SynCardOcx1.SetPhotoType(0);
if(nRet==0)
{
document.all['S1'].value=document.all['S1'].value+"照片保存格式设置为Bmp\r\n";
}
}
function PhotoType2_onclick()
{
var nRet;
nRet=SynCardOcx1.SetPhotoType(1);
if(nRet==0)
{
document.all['S1'].value=document.all['S1'].value+"照片保存格式设置为Jpeg\r\n";
}
}
function PhotoType3_onclick()
{
var nRet;
nRet=SynCardOcx1.SetPhotoType(2);
if(nRet==0)
{
document.all['S1'].value=document.all['S1'].value+"照片保存格式设置为Base64\r\n";
}
}
function PhotoName_onclick()
{
var nRet;
nRet=SynCardOcx1.SetPhotoName(0);
if(nRet==0)
{
document.all['S1'].value=document.all['S1'].value+"照片保存文件名设置为tmp\r\n";
}
}
function PhotoName2_onclick()
{
var nRet;
nRet=SynCardOcx1.SetPhotoName(1);
if(nRet==0)
{
document.all['S1'].value=document.all['S1'].value+"照片保存文件名设置为 姓名\r\n";
}
}
function PhotoName3_onclick()
{
var nRet;
nRet=SynCardOcx1.SetPhotoName(2);
if(nRet==0)
{
document.all['S1'].value=document.all['S1'].value+"照片保存文件名设置为 身份证号\r\n";
}
}
function PhotoName4_onclick()
{
var nRet;
nRet=SynCardOcx1.SetPhotoName(3);
if(nRet==0)
{
document.all['S1'].value=document.all['S1'].value+"照片保存文件名设置为 姓名_身份证号\r\n";
}
}
function PhotoName5_onclick()
{
var str= SynCardOcx1.Base64Photo;
document.all['S1'].value=document.all['S1'].value+str+" \r\n";
}
function M1Reset_onclick()
{
var str= SynCardOcx1.M1Reset();
document.all['S1'].value=document.all['S1'].value+str+" \r\n";
}
function M1Halt_onclick()
{
var str= SynCardOcx1.M1Halt;
document.all['S1'].value=document.all['S1'].value+str+" \r\n";
}
function M1AuthenKey_onclick()
{
//BSTR M1AuthenKey(LONG KeyType, LONG BlockNo, LPCTSTR uKey, LPCTSTR uKey2, LPCTSTR uKey3, LPCTSTR uKey4, LPCTSTR uKey5, LPCTSTR uKey6)
//LONG KeyType 0=A密钥 1=B密钥
//LONG BlockNo 扇区号
//uKey~uKey6 密钥
//返回0成功
var str= SynCardOcx1.M1AuthenKey(0,0,"255","255","255","255","255","255");
document.all['S1'].value=document.all['S1'].value+str+" \r\n";
}
function M1Read_onclick()
{
//BSTR M1ReadBlock(LONG BlockNo)
//LONG BlockNo 块号
//返回数据位16进制 16个字节 空格分隔
var str= SynCardOcx1.M1ReadBlock(1);
document.all['S1'].value=document.all['S1'].value+str+" \r\n";
}
function M1Write_onclick()
{
//BSTR M1WriteBlock(LONG BlockNo, LPCTSTR uData, LPCTSTR uData2, LPCTSTR uData3, LPCTSTR uData4, LPCTSTR uData5, LPCTSTR uData6, LPCTSTR uData7, LPCTSTR uData8, LPCTSTR uData9, LPCTSTR uData10, LPCTSTR uData11, LPCTSTR uData12, LPCTSTR uData13, LPCTSTR uData14, LPCTSTR uData15, LPCTSTR uData16)
//LONG BlockNo 块号
//uData 数据 数据位0,应写为00, 1写为01,12写为12
var str= SynCardOcx1.M1WriteBlock(1,"0","0","0","0","0","1","0","1","0","0","0","0","0","0","0","0");
document.all['S1'].value=document.all['S1'].value+str+" \r\n";
}
function load(){
// PhotoPath_onclick();
// PhotoName4_onclick();
// FindReader_onclick();
// ReadCard_onclick();
// ReadCardAuto_onclick();
}
</script>
</head>
<body leftmargin="0" topmargin="0" onLoad="load();">
<p>
<object classid="clsid:46E4B248-8A41-45C5-B896-738ED44C1587" id="SynCardOcx1" codeBase="SynCardOcx.CAB#version=1,0,0,1" width="0" height="0" >
</object>
</p>
<form method="POST" action="--WEBBOT-SELF--" name="form1">
<p>
<textarea rows="17" name="S1" cols="82"></textarea></p>
<p>
<input type="button" value="自动寻找读卡器" name="FindReadBtn" onclick="FindReader_onclick()">
<input type="button" value="获得SAMID" name="GetSAMIDBtn" onclick="ReadSAMID_onclick()">
<input type="button" value="手动读卡" name="ReadCardBtn" onclick="ReadCard_onclick()">
<input type="button" value="自动读卡" name="ReadCardAutoBtn" onclick="ReadCardAuto_onclick()">
<input type="button" value="清除所有信息" name="ClearBtn" onclick="Clear_onclick()"></p>
<p>
照片保存路径:
<input type="button" value="C盘根目录" name="PathBtn" onclick="PhotoPath_onclick()">
<input type="button" value="当前目录" name="Path2Btn" onclick="PhotoPath2_onclick()">
<input type="button" value="指定路径" name="Path3Btn" onclick="PhotoPath3_onclick()"></p>
<p>
照片保存格式:
<input type="button" value="bmp" name="PhotoTypeBtn" onclick="PhotoType_onclick()">
<input type="button" value="Jpeg" name="PhotoType2Btn" onclick="PhotoType2_onclick()">
<input type="button" value="Base64" name="PhotoType3Btn" onclick="PhotoType3_onclick()"></p>
<p>
照片文件名格式:
<input type="button" value="tmp" name="PhotoNameBtn" onclick="PhotoName_onclick()">
<input type="button" value="姓名" name="PhotoName2Btn" onclick="PhotoName2_onclick()">
<input type="button" value="身份证号" name="PhotoName3Btn" onclick="PhotoName3_onclick()">
<input type="button" value="姓名_身份证号" name="PhotoName4Btn" onclick="PhotoName4_onclick()">
<input type="button" value="Base64照片" name="PhotoName4Btn0" onclick="PhotoName5_onclick()"></p>
<p>
M1卡操作:
<input type="button" value="M1卡复位" name="M1ResetBtn" onclick="M1Reset_onclick()">
<input type="button" value="M1卡Halt" name="M1HaltBtn" onclick="M1Halt_onclick()">
<input type="button" value="M1卡密钥验证" name="M1AuthenKeyBtn" onclick="M1AuthenKey_onclick()">
<input type="button" value="M1卡读块" name="M1ReadBtn" onclick="M1Read_onclick()">
<input type="button" value="M1卡写块" name="M1WriteBtn" onclick="M1Write_onclick()"></p>
</form>
</body>
</html>