当前位置:   article > 正文

开源鸿蒙系统4.0社保卡读卡器开发包适配

开源鸿蒙系统4.0社保卡读卡器开发包适配

最近更新换代的项目终端设备都要求国产系统,大家都知道现在所谓的国产系统,桌面式一般就是麒麟和统信两家,如果是嵌入式开发板之类的,则有鸿蒙可选,后面还有个星光麒麟(兼容安卓)可以不考虑先。

索性公司所有的身份证阅读器、社保卡读卡器、IC卡读写器、二维码扫码等产品都花时间弄了一套鸿蒙系统的SDK。

适配机型:EST-100、EST-100G、EST-J13X、EST-100GS等,支持USB免驱和串口两种方式。

鸿蒙测试版本:OpenHarmony 3.2 、4.0

demo开发语言:ArkTS,支持定制提供C语言调用的so库开发使用。

下面是鸿蒙的demo测试界面截图:

ArkTS代码如下:

  1. import CommonContants from '../common/CommonContants';
  2. import DonseeDevice from '@ohos/DonseeDevice/src/main/ets/model/DonseeDevice';
  3. import { IDCardInfor } from '@ohos/DonseeDevice/src/main/ets/model/IDCardInfor';
  4. import { SSCardInfor } from '@ohos/DonseeDevice/src/main/ets/model/SSCardInfor';
  5. import util from '@ohos.util';
  6. /**
  7. * Card content contains the information list.
  8. * 广东东信智能科技有限公司www.eastcoms.com
  9. * EST-100身份证阅读器、社保卡读卡器鸿蒙系统SDK开发包
  10. */
  11. @Component
  12. export struct SSCardComponent {
  13. @State tvResult: string = '';
  14. @State pKkey: string = '01020304050607080102030405060708||';
  15. @State slot : number = 1;//卡座 ,默认选中sam1
  16. private textInputController: TextInputController = new TextInputController();
  17. build() {
  18. Column() {
  19. Row() {
  20. Column() {
  21. Row() {
  22. Text("pkey:")
  23. .fontSize(18)
  24. TextInput({ controller: this.textInputController,text:'01020304050607080102030405060708||' })
  25. .type(InputType.Normal)
  26. .height(32)
  27. .margin({ left: $r('app.float.text_input_margin_left') })
  28. .layoutWeight(CommonContants.TEXTINPUT_LAYOUT_WEIGHT)
  29. .onChange(value => {
  30. this.pKkey = value
  31. })
  32. }
  33. Text(this.tvResult)
  34. .fontSize(18)
  35. Text("").layoutWeight(1)
  36. }
  37. .layoutWeight(1)
  38. .margin({left:10})
  39. .alignItems(HorizontalAlign.Start)
  40. Column() {
  41. Column() {
  42. Row() {
  43. Text('SAM卡座选择:')
  44. }.margin({ left: 10 })
  45. Row() {
  46. Radio({ value: "SCard", group: "3" })
  47. .checked(this.slot === 1 ? true : false)
  48. .height(20)
  49. .width(20)
  50. .onClick(() => {
  51. this.slot = 1;
  52. console.info("Radio onClick")
  53. })
  54. Text('SAM1')
  55. Radio({ value: "SCard", group: "3" })
  56. .checked(this.slot === 2 ? true : false)
  57. .height(20)
  58. .width(20)
  59. .onClick(() => {
  60. this.slot = 2;
  61. console.info("Radio onClick")
  62. }).margin({ left: 10 })
  63. Text('SAM2')
  64. }.margin({ left: 10 })
  65. Row() {
  66. Radio({ value: "SCard", group: "3" })
  67. .checked(this.slot === 3 ? true : false)
  68. .height(20)
  69. .width(20)
  70. .onClick(() => {
  71. this.slot = 3;
  72. console.info("Radio onClick")
  73. })
  74. Text('SAM3')
  75. Radio({ value: "SCard", group: "3" })
  76. .checked(this.slot === 4 ? true : false)
  77. .height(20)
  78. .width(20)
  79. .onClick(() => {
  80. this.slot = 4;
  81. console.info("Radio onClick")
  82. }).margin({ left: 10 })
  83. Text('SAM4')
  84. }.margin({ left: 10 })
  85. Row() {
  86. Radio({ value: "SCard", group: "3" })
  87. .checked(this.slot === 0 ? true : false)
  88. .height(20)
  89. .width(20)
  90. .onClick(() => {
  91. this.slot = 0;
  92. console.info("Radio onClick")
  93. }).margin({ left: 15 })
  94. Text('无').margin({ left: 10 })
  95. }
  96. }.justifyContent(FlexAlign.Start)
  97. .alignItems(HorizontalAlign.Start)
  98. Row() {
  99. Button("读取社保卡")
  100. .fontSize($r('app.float.submit_button_font_size'))
  101. .fontWeight(CommonContants.FONT_WEIGHT)
  102. .height(20)
  103. .width(95)
  104. .onClick(() => {
  105. //nType 1, 有SAM卡返回全部信息 2, 无SAM卡返回卡号
  106. var nType = 1
  107. if (this.slot == 0) {
  108. nType = 2
  109. }
  110. console.info("nType = " + nType)
  111. console.info("this.slot = " + this.slot)
  112. let ssCardInfor: SSCardInfor = DonseeDevice.Donsee_ReadSSCardPre(this.slot, nType)
  113. console.info("ssCardInfor.result = " + ssCardInfor.result)
  114. if (ssCardInfor.result == 0) {
  115. DonseeDevice.Donsee_Beep(50)
  116. // const str = new util.TextDecoder('gbk').decode(ssCardInfor.name)
  117. // let gbkDecoder = new util.TextDecoder("gbk",{ignoreBOM: true});
  118. console.info("ssCardInfor.name = " + ssCardInfor.nation)
  119. console.info("ssCardInfor.name = " + ssCardInfor.name)
  120. // this.tvResult = "姓 名:"+ ssCardInfor.name
  121. this.tvResult = "姓 名:" + ssCardInfor.name + "\n"
  122. + "性 别:" + ssCardInfor.sex + "\n"
  123. + "民 族:" + ssCardInfor.nation + "\n"
  124. + "出身日期:" + ssCardInfor.birthday + "\n"
  125. + "城市代码:" + ssCardInfor.city + "\n"
  126. + "身份证号:" + ssCardInfor.idnumber + "\n"
  127. + "社保卡号:" + ssCardInfor.cardnumber + "\n"
  128. + "开始有效期限:" + ssCardInfor.signdate + "\n"
  129. + "结束有效期限:" + ssCardInfor.validterm + "\n"
  130. + "社保版本:" + ssCardInfor.cardveVrsion + "\n"
  131. } else {
  132. this.tvResult = "读卡失败:" + ssCardInfor.result+"\n errMsg = "+ssCardInfor.errMsg.trim()
  133. }
  134. })
  135. Button("读基本信息")
  136. .fontSize($r('app.float.submit_button_font_size'))
  137. .fontWeight(CommonContants.FONT_WEIGHT)
  138. .height(20)
  139. .width(95)
  140. .onClick(() => {
  141. let [result, data] = DonseeDevice.Donsee_iReadCardBas(3)
  142. if (result == 0) {
  143. DonseeDevice.Donsee_Beep(50)
  144. this.tvResult = "读基本信息成功:" + data
  145. } else {
  146. this.tvResult = "读基本信息失败:" + result
  147. }
  148. })
  149. }.margin({ top: 10 })
  150. Row() {
  151. Button("加密步骤1")
  152. .fontSize($r('app.float.submit_button_font_size'))
  153. .fontWeight(CommonContants.FONT_WEIGHT)
  154. .height(20)
  155. .width(95)
  156. .onClick(() => {
  157. let [result, data] = DonseeDevice.Donsee_iReadCardBas_HSM_Step1(3)
  158. if (result == 0) {
  159. DonseeDevice.Donsee_Beep(50)
  160. this.tvResult = "读卡成功:" + data
  161. } else {
  162. this.tvResult = "读卡失败:" + result
  163. }
  164. })
  165. Button("加密步骤2")
  166. .fontSize($r('app.float.submit_button_font_size'))
  167. .fontWeight(CommonContants.FONT_WEIGHT)
  168. .height(20)
  169. .width(95)
  170. .onClick(() => {
  171. let [result, data] = DonseeDevice.Donsee_iReadCardBas_HSM_Step2(this.pKkey)
  172. if (result == 0) {
  173. DonseeDevice.Donsee_Beep(50)
  174. this.tvResult = "读卡成功:" + data
  175. } else {
  176. this.tvResult = "读卡失败:" + result
  177. }
  178. })
  179. } .margin({ top: 10 })
  180. }.justifyContent(FlexAlign.End)
  181. .margin({right:10})
  182. }.justifyContent(FlexAlign.Start)
  183. .width(CommonContants.FULL_PARENT)
  184. }.justifyContent(FlexAlign.Start)
  185. .backgroundColor($r('app.color.card_background'))
  186. .width(CommonContants.FULL_PARENT)
  187. .height(CommonContants.FULL_PARENT)
  188. }
  189. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/327730
推荐阅读
相关标签
  

闽ICP备14008679号