修改过页面
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
6.5 KiB

1 year ago
  1. <template>
  2. <div>
  3. <!-- <object
  4. classid="clsid:05782014-9FF7-468C-BE96-8EDC73084202"
  5. id="IcCardReader"
  6. viewastext
  7. width="0"
  8. height="0"
  9. ></object> -->
  10. <table
  11. border="0"
  12. style="border-collapse: collapse"
  13. width="200"
  14. height="100"
  15. >
  16. <tr>
  17. <td width="160">
  18. <textarea rows="2" cols="40" id="CardIDShower" name="S1"></textarea>
  19. </td>
  20. </tr>
  21. <tr>
  22. <td width="160">
  23. <input
  24. type="button"
  25. value=" 读 卡 "
  26. @click="readcard()"
  27. />
  28. </td>
  29. </tr>
  30. </table>
  31. </div>
  32. </template>
  33. <script>
  34. var strls = "";
  35. var errorno = "";
  36. //控制字定义,控制字指定,控制字的含义请查看本公司网站提供的动态库说明
  37. //javascript无法自定义常量, 你可以使用变量代替
  38. var BLOCK0_EN = 0x01;//读第一块的(16个字节)
  39. var BLOCK1_EN = 0x02;//读第二块的(16个字节)
  40. var BLOCK2_EN = 0x04;//读第三块的(16个字节)
  41. var NEEDSERIAL = 0x08;//仅读指定序列号的卡
  42. var EXTERNKEY = 0x10;//用明码认证密码,产品开发完成后,建议把密码放到设备的只写区,然后用该区的密码后台认证,这样谁都不知道密码是多少,需要这方面支持请联系
  43. var NEEDHALT = 0x20;//读/写完卡后立即休眠该卡,相当于这张卡不在感应区。要相重新操作该卡必要拿开卡再放上去
  44. var myctrlword = 0;
  45. var myareano = 0;
  46. var authmode = 0;
  47. var mypiccserial = "";
  48. var mypicckey = "";
  49. var piccdata0_2 = "";
  50. var mypicckey_old = "";//旧密码
  51. var mypicckey_new = "";//新密码
  52. export default {
  53. name: "index",
  54. data() {
  55. return {};
  56. },
  57. methods: {
  58. readcard() {
  59. //指定控制字
  60. myctrlword = BLOCK0_EN + BLOCK1_EN + BLOCK2_EN + EXTERNKEY;
  61. //指定区号
  62. myareano = 8; //指定为第8区
  63. //批定密码模式
  64. authmode = 1; //大于0表示用A密码认证,推荐用A密码认证
  65. //指定序列号,未知卡序列号时可指定为8个0
  66. mypiccserial = "00000000";
  67. //指定密码,以下密码为厂家出厂密码
  68. mypicckey = "ffffffffffff";
  69. var CardIDShower = document.getElementById('CardIDShower')
  70. strls = window.IcCardReader.piccreadex(
  71. myctrlword,
  72. mypiccserial,
  73. myareano,
  74. authmode,
  75. mypicckey
  76. );
  77. errorno = strls.substr(0, 4);
  78. if (errorno == "ER00") {
  79. this.beep();
  80. }
  81. switch (errorno) {
  82. case "ER08":
  83. alert("寻不到卡");
  84. break;
  85. case "ER09":
  86. alert("寻不到卡");
  87. break;
  88. case "ER10":
  89. alert("寻不到卡");
  90. break;
  91. case "ER11":
  92. CardIDShower.value = "密码认证错误\r\n";
  93. CardIDShower.value = CardIDShower.value + strls + "\r\n";
  94. CardIDShower.value =
  95. CardIDShower.value + "其中错误号为:" + errorno + "\r\n";
  96. CardIDShower.value =
  97. CardIDShower.value +
  98. "卡十六进制序列号为:" +
  99. strls.substr(5, 8) +
  100. "\r\n";
  101. alert("密码认证错误");
  102. break;
  103. case "ER12":
  104. CardIDShower.value = "密码认证错误" + "\r\n";
  105. CardIDShower.value = CardIDShower.value + strls + "\r\n";
  106. CardIDShower.value =
  107. CardIDShower.value + "其中错误号为:" + errorno + "\r\n";
  108. CardIDShower.value =
  109. CardIDShower.value +
  110. "卡十六进制序列号为:" +
  111. strls.substr(5, 8) +
  112. "\r\n";
  113. alert("密码认证错误");
  114. break;
  115. case "ER13":
  116. CardIDShower.value = "读卡错误" + "\r\n";
  117. CardIDShower.value = CardIDShower.value + strls + "\r\n";
  118. CardIDShower.value =
  119. CardIDShower.value + "其中错误号为:" + errorno + "\r\n";
  120. CardIDShower.value =
  121. CardIDShower.value +
  122. "卡十六进制序列号为:" +
  123. strls.substr(5, 8) +
  124. "\r\n";
  125. alert("读卡错误");
  126. break;
  127. case "ER14":
  128. CardIDShower.value = "写卡错误" + "\r\n";
  129. CardIDShower.value = CardIDShower.value + strls + "\r\n";
  130. CardIDShower.value =
  131. CardIDShower.value + "其中错误号为:" + errorno + "\r\n";
  132. CardIDShower.value =
  133. CardIDShower.value +
  134. "卡十六进制序列号为:" +
  135. strls.substr(5, 8) +
  136. "\r\n";
  137. alert("写卡错误");
  138. break;
  139. case "ER21":
  140. alert("没找到动态库");
  141. break;
  142. case "ER22":
  143. alert("动态库或驱动程序异常");
  144. break;
  145. case "ER23":
  146. alert("读卡器未插上或动态库或驱动程序异常");
  147. break;
  148. case "ER24":
  149. alert("操作超时,一般是动态库没有反应");
  150. break;
  151. case "ER25":
  152. alert("发送字数不够");
  153. break;
  154. case "ER26":
  155. alert("发送的CRC错");
  156. break;
  157. case "ER27":
  158. alert("接收的字数不够");
  159. break;
  160. case "ER28":
  161. alert("接收的CRC错");
  162. break;
  163. case "ER29":
  164. alert("函数输入参数格式错误,请仔细查看");
  165. break;
  166. default:
  167. //读卡成功,其中ER00表示完全成功,ER01表示完全没读到卡数据,ER02表示仅读该卡的第一块成功,,ER02表示仅读该卡的第一二块成功,这是刷卡太快原因
  168. CardIDShower.value = "读卡成功" + "\r\n";
  169. // CardIDShower.value = CardIDShower.value + strls + "\r\n";
  170. // CardIDShower.value = CardIDShower.value + "其中错误号为:" + errorno + "\r\n";
  171. CardIDShower.value =
  172. CardIDShower.value +
  173. "卡十六进制序列号为:" +
  174. strls.substr(5, 8) +
  175. "\r\n";
  176. // CardIDShower.value = CardIDShower.value + "该区第一块十六进制数据为:" + strls.substr(14,32) + "\r\n";
  177. // CardIDShower.value = CardIDShower.value + "该区第二块十六进制数据为:" + strls.substr(46,32) + "\r\n";
  178. // CardIDShower.value = CardIDShower.value + "该区第三块十六进制数据为:" + strls.substr(78,32) + "\r\n";
  179. break;
  180. }
  181. },
  182. beep() {
  183. IcCardReader.pcdbeep(100); //100表示响100毫秒
  184. },
  185. clears1() {
  186. //alert("abc");
  187. CardIDShower.value = "";
  188. },
  189. },
  190. };
  191. </script>
  192. <style>
  193. </style>