index.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. const app = getApp()
  2. Page({
  3. data: {
  4. // 是否显示信息
  5. showSystemInfo: false,
  6. //系统信息
  7. systemInfo: null,
  8. //系统信息字符串展示
  9. systemInfoStr: null,
  10. //是否是K8容器中运行的小程序
  11. isKEightDevice: false,
  12. /**
  13. * 初始化刷脸服务
  14. */
  15. //入参打印
  16. initObj: null,
  17. //结果
  18. initResult: null,
  19. //初始化入参
  20. initParams: {},
  21. /**
  22. * 调用1:N刷脸
  23. */
  24. //入参打印
  25. oneVNObj: null,
  26. //结果
  27. oneVNResult: null,
  28. //调用服务入参
  29. oneVNParams: {},
  30. //服务编码
  31. oneVNServiceCode: "",
  32. /**
  33. * 调用订阅授权服务
  34. */
  35. //入参打印
  36. authObj: null,
  37. //结果
  38. authResult: null,
  39. //调用服务入参
  40. authParams: {},
  41. //服务编码
  42. authServiceCode: "",
  43. /**
  44. * ampe通道调用参数
  45. */
  46. ampe_params: [
  47. {
  48. name: '隐藏导航栏(仅本次运⾏有效)',
  49. aromeCode: "",
  50. number: "I1",
  51. initParams: {
  52. "action": "deviceConfig",
  53. "event": "open",
  54. "params": {
  55. "deviceConfig": {
  56. "hideNavigationBar": 1
  57. }
  58. }
  59. }
  60. },
  61. {
  62. name: '开启导航栏(仅本次运⾏有效)',
  63. aromeCode: "",
  64. number: "I2",
  65. initParams: {
  66. "action": "deviceConfig",
  67. "event": "open",
  68. "params": {
  69. "deviceConfig": {
  70. "hideNavigationBar": 2
  71. }
  72. }
  73. }
  74. },
  75. {
  76. name: '隐藏通知栏(仅本次运⾏有效)',
  77. aromeCode: "",
  78. number: "I1",
  79. initParams: {
  80. "action": "deviceConfig",
  81. "event": "open",
  82. "params": {
  83. "deviceConfig": {
  84. "hideNotificationBar": 1
  85. }
  86. }
  87. }
  88. },
  89. {
  90. name: '开启通知栏(仅本次运⾏有效)',
  91. aromeCode: "",
  92. number: "I2",
  93. initParams: {
  94. "action": "deviceConfig",
  95. "event": "open",
  96. "params": {
  97. "deviceConfig": {
  98. "hideNotificationBar": 2
  99. }
  100. }
  101. }
  102. },
  103. {
  104. name: '关闭⼩程序',
  105. aromeCode: "",
  106. number: "I1",
  107. initParams: {
  108. "action": "deviceConfig",
  109. "event": "open",
  110. "params": {
  111. "deviceConfig": {
  112. "exitApplet": 1
  113. }
  114. }
  115. }
  116. },
  117. {
  118. name: "刷脸初始化请求",
  119. number: "A",
  120. aromeCode: "",
  121. initParams: {
  122. "action": "initFace",
  123. "event": "open",
  124. "taskId": "5",
  125. "params": {
  126. "serviceId": "",
  127. "query": "",
  128. "scope": ""
  129. }
  130. }
  131. },
  132. {
  133. name: '调用刷脸(老年食堂)',
  134. aromeCode: "",
  135. number: "H1",
  136. initParams: {
  137. "action": "doStorageFaceInfo",
  138. "params": {
  139. "appid": "2021003181682188",
  140. "orgOutId": "hanghuijingquTest3",
  141. "componentOutId": "day_label_sign_online",
  142. "isvPid": "2088721034139660"
  143. }
  144. // "params": {
  145. // "appId":"2021004147600083",
  146. // "orgOutId":"huanggangzhangzheshitang",
  147. // "componentOutId":"day_label_sign_online",
  148. // "isvPid":"2088741779695636"
  149. // }
  150. }
  151. },
  152. {
  153. name: '调用刷证/输证入库(老年食堂)',
  154. aromeCode: "",
  155. number: "H1",
  156. initParams: {
  157. "action": "doStorageFaceInfo",
  158. "params": {
  159. "uniqueId": "2021003181682188",
  160. "name": "刘琳琳",
  161. "certNo": "430822199903010465",
  162. "phone": "15674931071"
  163. }
  164. }
  165. },
  166. {
  167. name: '启动NFC轮询',
  168. aromeCode: "",
  169. number: "G1",
  170. initParams: {
  171. "action": "startCPUCardLoopRead",
  172. "params": {
  173. "intervalTime": "5000",
  174. }
  175. }
  176. },
  177. {
  178. name: '启动NFC轮询2',
  179. aromeCode: "",
  180. number: "G9",
  181. initParams: {
  182. "action": "startCPUCardLoopRead",
  183. "params": {
  184. "intervalTime": "5000",
  185. "isComeBackFailed": true
  186. }
  187. }
  188. },
  189. {
  190. name: '停止NFC轮询',
  191. aromeCode: "",
  192. number: "G2",
  193. initParams: {
  194. "action": "stopCPUCardLoopRead",
  195. }
  196. },
  197. {
  198. name: 'NFC监听',
  199. aromeCode: "CPUCardListener",
  200. number: "G3",
  201. initParams: {
  202. }
  203. },
  204. {
  205. name: '单次读取NFC',
  206. aromeCode: "",
  207. number: "G4",
  208. initParams: {
  209. "action": "readOnceCPUCardInfo",
  210. }
  211. },
  212. {
  213. name: '发送NFC-apdu命令',
  214. aromeCode: "",
  215. number: "G5",
  216. initParams: {
  217. "action": "sendCPUCardCommand",
  218. "params": {
  219. "commandApdu": "0084000008",
  220. "isPsamCommand": false,
  221. }
  222. }
  223. },
  224. {
  225. name: '启动蜂鸣器',
  226. aromeCode: "",
  227. number: "G6",
  228. initParams: {
  229. "action": "startBuzzer",
  230. "params": {
  231. "beep": "50",
  232. }
  233. }
  234. },
  235. {
  236. name: '冷复位',
  237. aromeCode: "",
  238. number: "G7",
  239. initParams: {
  240. "action": "psamCardColdReset",
  241. }
  242. },
  243. {
  244. name: 'CPU',
  245. aromeCode: "",
  246. number: "G8",
  247. initParams: {
  248. "action": "sendCPUCardApduCommands",
  249. "event": "open",
  250. "params": {
  251. "commandApdus": ["0084000008", "0084000008", "0084000008"],
  252. "type": "1",
  253. "slot": "1"
  254. }
  255. }
  256. },
  257. {
  258. name: '社保卡单次读取',
  259. aromeCode: "",
  260. number: "F1",
  261. initParams: {
  262. "action": "getSocialSecurityCardInfo",
  263. }
  264. },
  265. {
  266. name: '社保卡持续推送接受',
  267. aromeCode: "socialSecurityCardListener",
  268. number: "F2",
  269. initParams: {
  270. }
  271. },
  272. {
  273. name: '社保卡持续推送注册',
  274. aromeCode: "",
  275. number: "F1",
  276. initParams: {
  277. "action": "socialSecurityCardConfig",
  278. }
  279. },
  280. {
  281. name: "授权弹框",
  282. aromeCode: "",
  283. number: "Z1",
  284. initParams: {}
  285. },
  286. {
  287. name: "开始超时监听",
  288. aromeCode: "ampeStartOperationWatcher",
  289. number: "Z1",
  290. initParams: {}
  291. },
  292. {
  293. name: "超时监听",
  294. aromeCode: "ampeOperationTimeout",
  295. number: "Z1",
  296. initParams: {}
  297. },
  298. // {
  299. // name: "刷脸初始化请求",
  300. // number: "A",
  301. // aromeCode: "",
  302. // initParams: {
  303. // "action": "initFace",
  304. // "event": "open",
  305. // "taskId": "5",
  306. // "params": {
  307. // "serviceId": "",
  308. // "query": "",
  309. // "scope": ""
  310. // }
  311. // }
  312. // },
  313. {
  314. name: "刷脸请求1:1",
  315. number: "B1",
  316. aromeCode: "",
  317. initParams: {
  318. "action": "getFaceInfoPersonCard",
  319. "event": "open",
  320. "taskId": "7",
  321. "params": {
  322. "certName": "",
  323. "certNo": "",
  324. "certPhotoBase64Str": ""
  325. }
  326. }
  327. },
  328. {
  329. name: "刷脸请求1:N",
  330. number: "B2",
  331. aromeCode: "",
  332. initParams: {
  333. "action": "getFaceInfo",
  334. "event": "open",
  335. "taskId": "2"
  336. }
  337. },
  338. {
  339. name: "开启刷⼆维码(单次)",
  340. number: "C1",
  341. aromeCode: "",
  342. initParams: {
  343. "action": "getQRCode",
  344. "event": "open",
  345. "taskId": "1"
  346. }
  347. },
  348. {
  349. name: "二维码持续监听",
  350. aromeCode: "initQRListener",
  351. number: "Z1",
  352. initParams: {}
  353. },
  354. {
  355. name: "开启刷身份证(单次)",
  356. number: "D1",
  357. aromeCode: '',
  358. initParams: {
  359. "action": "getIDCardInfo",
  360. "event": "open",
  361. "taskId": "3",
  362. "params": {
  363. "infoType": "base,photo,other"
  364. }
  365. }
  366. },
  367. {
  368. name: "身份证持续监听",
  369. aromeCode: "initIDCardListener",
  370. number: "Z2",
  371. initParams: {}
  372. },
  373. {
  374. name: "⼿输身份证号",
  375. aromeCode: "",
  376. number: "D2",
  377. initParams: {
  378. "action": "enterIDNumber",
  379. "event": "open",
  380. "taskId": "9"
  381. }
  382. },
  383. {
  384. name: "设备信息请求",
  385. aromeCode: "",
  386. number: "E",
  387. initParams: {
  388. "action": "getDeviceInfo",
  389. "event": "open",
  390. "taskId": "4"
  391. }
  392. },
  393. {
  394. name: "语⾳播报请求",
  395. aromeCode: "",
  396. number: "F",
  397. initParams: {
  398. "action": "speech",
  399. "event": "open",
  400. "taskId": "8",
  401. "params": {
  402. "text": "要播报的⽂字内容",
  403. "pitch": 1.0,
  404. "rate": 1.0
  405. }
  406. }
  407. },
  408. {
  409. name: "⼩票打印机⼩程序",
  410. number: "G",
  411. aromeCode: "",
  412. initParams: {
  413. "action": "receiptPrinting",
  414. "event": "open",
  415. "taskId": "10",
  416. "params": {
  417. "printList": [{
  418. "text": "测试⽂字打印",
  419. "textSize": 26,
  420. "bold": false,
  421. "algin": "left"
  422. }, {
  423. "imageBase64": "测试图⽚打印,实际传⼊base64图⽚值/9j/4AAQSkZJRgABAgAAAQABABntRS5Sj//",
  424. "width": 376,
  425. "height": 376
  426. }]
  427. }
  428. }
  429. },
  430. ]
  431. },
  432. //切换系统信息的显示
  433. changeMsg() {
  434. let { showSystemInfo } = this.data;
  435. this.setData({
  436. showSystemInfo: !showSystemInfo
  437. })
  438. },
  439. //初始化接口
  440. doInit() {
  441. let that = this
  442. let params = JSON.parse(JSON.stringify(that.data.initParams))
  443. this.setData({
  444. initObj: JSON.stringify(params)
  445. })
  446. my.call("aromeInitBpaasService", params, (res) => {
  447. that.setData({
  448. initResult: JSON.stringify(res)
  449. })
  450. })
  451. },
  452. //调用刷脸
  453. doOneVN() {
  454. let that = this
  455. let params = JSON.parse(JSON.stringify(that.data.oneVNParams))
  456. that.setData({
  457. oneVNObj: JSON.stringify(params) + "----服务编码: " + that.data.oneVNServiceCode
  458. })
  459. console.log(JSON.stringify(params) + "----服务编码: " + that.data.oneVNServiceCode)
  460. my.call('aromeStartBpaasService', {
  461. serviceCode: that.data.oneVNServiceCode,
  462. params: params,
  463. taskId: parseInt(Math.random() * 1000000 + 1)
  464. }, (res) => {
  465. that.setData({
  466. oneVNResult: JSON.stringify(res)
  467. })
  468. app.data.authParams.user_id = res.alipayUid || ""
  469. app.data.authParams.ftoken = res.ftoken || ""
  470. })
  471. },
  472. //调用授权服务
  473. doAuth() {
  474. let that = this
  475. let params = JSON.parse(JSON.stringify(that.data.authParams))
  476. that.setData({
  477. authObj: JSON.stringify(params) + "----服务编码: " + that.data.authServiceCode
  478. })
  479. my.call('aromeStartBpaasService', {
  480. serviceCode: that.data.authServiceCode,
  481. params: params,
  482. taskId: parseInt(Math.random() * 1000000 + 1)
  483. }, (res) => {
  484. that.setData({
  485. authResult: JSON.stringify(res)
  486. })
  487. })
  488. },
  489. //关闭结果
  490. close(e) {
  491. let type = e.currentTarget.dataset.type
  492. switch (type) {
  493. case "init":
  494. this.setData({
  495. initResult: null,
  496. initObj: null
  497. })
  498. break;
  499. case "oneVN":
  500. this.setData({
  501. oneVNResult: null,
  502. oneVNObj: null
  503. })
  504. break;
  505. case "auth":
  506. this.setData({
  507. authObj: null,
  508. authResult: null
  509. })
  510. break;
  511. default:
  512. break;
  513. }
  514. },
  515. //进入设置页
  516. doSetting(e) {
  517. let route = {
  518. init: "/pages/setInit/setInit",
  519. oneVN: "/pages/setOneVN/setOneVN",
  520. auth: "/pages/setAuth/setAuth"
  521. }
  522. let type = e.currentTarget.dataset.type
  523. my.navigateTo({
  524. url: route[type]
  525. })
  526. },
  527. //更新配置信息
  528. updateConfig() {
  529. this.data.initParams = app.data.initParams;
  530. this.data.oneVNParams = app.data.oneVNParams;
  531. this.data.oneVNServiceCode = app.data.oneVNServiceCode;
  532. this.data.authParams = app.data.authParams;
  533. this.data.authServiceCode = app.data.authServiceCode;
  534. },
  535. onLoad(query) {
  536. },
  537. onReady() {
  538. // 页面加载完成
  539. },
  540. onShow() {
  541. this.setData({
  542. systemInfo: app.data.systemInfo,
  543. systemInfoStr: JSON.stringify(app.data.systemInfo),
  544. isKEightDevice: app.data.isKEightDevice,
  545. initObj: null,
  546. initResult: null,
  547. oneVNObj: null,
  548. oneVNResult: null,
  549. authObj: null,
  550. authResult: null
  551. });
  552. this.updateConfig();
  553. },
  554. onHide() {
  555. // 页面隐藏
  556. },
  557. onUnload() {
  558. // 页面被关闭
  559. },
  560. onTitleClick() {
  561. // 标题被点击
  562. },
  563. onPullDownRefresh() {
  564. // 页面被下拉
  565. },
  566. onReachBottom() {
  567. // 页面被拉到底部
  568. },
  569. onShareAppMessage() {
  570. // 返回自定义分享信息
  571. },
  572. });