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.

892 lines
44 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. // pagesA/passwordList/passwordList.js
  2. const WXAPI = require('../../utils/request.js')
  3. import moment from '../../utils/moment'
  4. import ICINLocker from '../../utils/ICINPakage/ICINLocker.js'
  5. const bleall = require('../../utils/bleall')
  6. // import dayjs from 'dayjs'
  7. const app = getApp()
  8. import util from '../../utils/util'
  9. import {
  10. BLE
  11. } from '../../utils/btls/ble'
  12. import methods from '../../utils/methods'
  13. const emitter = app.globalData.emitter
  14. const ADD_NFC_MODE = 10
  15. Page({
  16. /**
  17. * 页面的初始数据
  18. */
  19. data: {
  20. voucherlist: [{
  21. id: 0,
  22. title: "卡管理"
  23. },
  24. {
  25. id: 1,
  26. title: "密码管理"
  27. },
  28. {
  29. id: 2,
  30. title: "指纹管理"
  31. }
  32. ],
  33. active: 1,
  34. personLi: '',
  35. deviceInfo: '',
  36. cardlist: [],
  37. passwordlist: [],
  38. fingerlist: [],
  39. blecount: 0,
  40. cgInfo: '',
  41. userSignKey: ''
  42. },
  43. /**
  44. * 生命周期函数--监听页面加载
  45. */
  46. onLoad: function (options) {
  47. const personLi = wx.getStorageSync('deviceinfo')
  48. const deviceInfo = wx.getStorageSync('deviceinfo')
  49. const cgInfo = wx.getStorageSync('cgInfo')
  50. this.setData({
  51. personLi: personLi,
  52. deviceInfo: deviceInfo,
  53. cgInfo: cgInfo
  54. })
  55. this.getvoucher()
  56. },
  57. // 标签页切换
  58. onChange(e) {
  59. this.setData({
  60. active: e.detail.index
  61. })
  62. },
  63. // 获取凭证数据
  64. getvoucher() {
  65. var data = JSON.stringify({
  66. id: this.data.personLi.cardId,
  67. signature: wx.getStorageSync('signature')
  68. })
  69. WXAPI.tsGetCertificate(data).then(res => {
  70. console.log("72",res);
  71. res.data.map(li => {
  72. li.content = JSON.parse(li.content)
  73. li.content.passwordStartTime = moment(li.startTime*1000).format('YYYY-MM-DD HH:mm:ss')
  74. li.content.passwordEndTime = moment(li.endTime*1000).format('YYYY-MM-DD HH:mm:ss')
  75. })
  76. const list = res.data.filter(li => {
  77. return li.type == 3 && (li.status == 1 || li.status == 0);
  78. })
  79. const list1 = res.data.filter(li => {
  80. return li.type == 4 && (li.status == 1 || li.status == 0);
  81. })
  82. const list2 = res.data.filter(li => {
  83. return li.type == 1 && (li.status == 1 || li.status == 0);
  84. })
  85. this.setData({
  86. cardlist: list,
  87. passwordlist: list1,
  88. fingerlist: list2
  89. })
  90. })
  91. },
  92. // 蓝牙连接
  93. btnset() {
  94. wx.showLoading({
  95. title: '蓝牙连接中...',
  96. mask: true
  97. })
  98. if (this.data.blecount >= 10) {
  99. wx.hideLoading()
  100. wx.showToast({
  101. title: '蓝牙连接失败次数过多,请联系管理人员',
  102. icon: 'none',
  103. duration: 2000
  104. })
  105. } else {
  106. if (this.data.deviceInfo.manufactureId == 201 || this.data.deviceInfo.manufactureId == 221) {
  107. ICINLocker.scanDevices(this.data.deviceInfo.deviceNum).then(res => {
  108. if (res.status == 0) {
  109. app.globalData.blueDeviceId = res.blueDeviceId
  110. ICINLocker.connect(res.deviceId).then(res1 => {
  111. console.log(res1)
  112. if (res1.status == 0) {
  113. wx.hideLoading()
  114. app.globalData.bleStatus = true
  115. wx.showToast({
  116. title: '蓝牙连接成功',
  117. icon: 'none',
  118. duration: 2000
  119. })
  120. this.setData({
  121. blecount: 0
  122. })
  123. } else {
  124. wx.hideLoading()
  125. wx.showToast({
  126. title: '蓝牙连接失败',
  127. duration: 2000,
  128. icon: 'none'
  129. })
  130. this.setData({
  131. blecount: this.data.blecount++
  132. })
  133. }
  134. }).catch(err => {
  135. console.log(err,'err')
  136. if(err.status === 1 && err.statusReason == 'createBLEConnection:fail:already connect'){
  137. wx.hideLoading()
  138. app.globalData.bleStatus = true
  139. wx.showToast({
  140. title: '蓝牙连接成功',
  141. icon: 'none',
  142. duration: 2000
  143. })
  144. this.setData({
  145. blecount: 0
  146. })
  147. }else{
  148. wx.hideLoading()
  149. wx.showToast({
  150. title: err.statusReason,
  151. icon: 'none',
  152. duration: 2000
  153. })
  154. this.setData({
  155. blecount: this.data.blecount++
  156. })
  157. }
  158. })
  159. } else {
  160. wx.hideLoading()
  161. wx.showToast({
  162. title: '蓝牙连接失败',
  163. duration: 2000,
  164. icon: 'none'
  165. })
  166. this.setData({
  167. blecount: this.data.blecount++
  168. })
  169. }
  170. }).catch(err => {
  171. wx.hideLoading()
  172. wx.showToast({
  173. title: err.statusReason,
  174. icon: 'none',
  175. duration: 2000
  176. })
  177. this.setData({
  178. blecount: this.data.blecount++
  179. })
  180. })
  181. } else if (this.data.deviceInfo.manufactureId == 101) {
  182. const ble = new BLE(this.data.deviceInfo.deviceNum, emitter)
  183. app.globalData.ble = ble
  184. if (app.globalData.ble) {
  185. app.globalData.ble.listen(res => {
  186. console.log('1', res)
  187. if (res.type == 'connect') {
  188. if (res.data == '未打开适配器') {
  189. wx.hideLoading()
  190. wx.showToast({
  191. title: '请检查手机蓝牙和定位功能是否打开?',
  192. icon: 'none',
  193. duration: 3000
  194. })
  195. } else {
  196. if (res.data == '蓝牙已连接') {
  197. app.globalData.bleStatus = true
  198. wx.hideLoading()
  199. wx.showToast({
  200. title: '蓝牙连接成功',
  201. icon: 'none',
  202. duration: 2000
  203. })
  204. this.setData({
  205. blecount: 0
  206. })
  207. } else if (res.data == '蓝牙已断开') {
  208. app.globalData.bleStatus = false
  209. }
  210. }
  211. } else {
  212. this.setData({
  213. blecount: this.data.blecount++
  214. })
  215. }
  216. })
  217. app.globalData.ble.init()
  218. } else {
  219. wx.hideLoading()
  220. wx.showToast({
  221. title: '蓝牙连接失败',
  222. icon: 'none',
  223. duration: 2000
  224. })
  225. this.setData({
  226. blecount: this.data.blecount++
  227. })
  228. }
  229. }
  230. }
  231. },
  232. // 删除凭证
  233. deletevoucher(e) {
  234. var index = e.currentTarget.dataset.index
  235. var that = this
  236. if (app.globalData.bleStatus) {
  237. wx.showModal({
  238. title: '确定删除该凭证?',
  239. success(res) {
  240. if (res.confirm) {
  241. if (that.data.active == 0) {
  242. that.delNFC(index)
  243. } else if (that.data.active == 1) {
  244. that.delPwd(index)
  245. } else if (that.data.active == 2) {
  246. that.delFin(index)
  247. }
  248. }
  249. }
  250. })
  251. } else {
  252. this.btnset()
  253. }
  254. },
  255. // 删除NFC
  256. delNFC(index) {
  257. wx.showLoading({
  258. title: '删除NFC中...',
  259. mask: true
  260. })
  261. if (this.data.deviceInfo.manufactureId == 201) {
  262. var cgInfo = this.data.cgInfo
  263. var personLi = this.data.cardlist[index]
  264. var deviceinfo = this.data.deviceInfo
  265. var info = personLi.content
  266. var userSignKey = this.data.userSignKey
  267. var personInfo = JSON.parse(this.data.personLi.info)
  268. var _this = this
  269. var dataPasswod = {
  270. code: "zg/cardOperate",
  271. data: {
  272. lockerId: deviceinfo.deviceNum,
  273. imei: deviceinfo.imei,
  274. lockerUserId: personInfo.userId,
  275. keyId: personInfo.userId,
  276. action: 2,
  277. taskStatus: 1,
  278. cardType: 50,
  279. cardNo: info.password,
  280. startTime: personLi.startTime,
  281. endTime: personLi.endTime,
  282. order: 6212,
  283. type: 12,
  284. roomName: _this.data.deviceInfo.roomName,
  285. cardName: _this.data.personLi.name + info.pzname,
  286. },
  287. signature: wx.getStorageSync('signature'),
  288. cardId: _this.data.deviceInfo.cardId,
  289. }
  290. WXAPI.sendCommandOne(dataPasswod).then(res => {
  291. console.log('获取索引', res)
  292. if (res.success) {
  293. var cardIndex = res.data.index
  294. var serialNumber = res.data.serialNumber
  295. var cardNo = cardIndex.toString(16)
  296. if (cardNo < 10) {
  297. cardNo = '0' + cardNo
  298. } else {
  299. cardNo = cardNo
  300. }
  301. if (_this.data.userSignKey == '') {
  302. console.log('数据', cgInfo.lockerId, cgInfo.superId, personInfo.userId, cgInfo.superId, cgInfo.authKey, '01')
  303. ICINLocker.getUserSignKey(cgInfo.lockerId, cgInfo.superId, personInfo.userId, cgInfo.superId, cgInfo.authKey, '01', callback11 => {
  304. console.log('1', callback11)
  305. if (callback11.status == '00') {
  306. _this.setData({
  307. userSignKey: callback11.userSignKey
  308. })
  309. // ICINLocker.getCommonKey(cgInfo.lockerId, personInfo.userId, personInfo.userId, callback11.userSignKey, callback22 => {
  310. // console.log('2', callback22)
  311. // if (callback22.status == '00') {
  312. var startTime = personLi.startTime.toString(16).toUpperCase()
  313. var endTime = personLi.endTime.toString(16).toUpperCase()
  314. console.log('数据3', cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, cardNo.toUpperCase(), '', '01', callback11.userSignKey, startTime, endTime, callback11.userCommonKey)
  315. ICINLocker.modifyRFCard(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, cardNo.toUpperCase(), '', '01', callback11.userSignKey, startTime, endTime, callback11.userCommonKey,callback33 => {
  316. console.log('3', callback33)
  317. if (callback33.status == '00') {
  318. var datacom = {
  319. code: "zg/bleSendVoucherReply",
  320. data: {
  321. lockerId: deviceinfo.deviceNum,
  322. serialNumber: serialNumber,
  323. index: cardIndex,
  324. type: 12,
  325. result: 1
  326. },
  327. cardId: deviceinfo.cardId,
  328. signature: wx.getStorageSync('signature')
  329. }
  330. WXAPI.sendCommandOne(datacom).then(res1 => {
  331. console.log('成功', res1)
  332. })
  333. var data = {
  334. id: passwordLi.id,
  335. signature: wx.getStorageSync('signature'),
  336. status: 0
  337. }
  338. WXAPI.editCertificate(data).then(res2 => {
  339. console.log('4', res2)
  340. if (res2.success) {
  341. _this.getvoucher()
  342. wx.hideLoading()
  343. wx.showToast({
  344. title: '删除NFC成功',
  345. icon: 'none',
  346. duration: 2000
  347. })
  348. } else {
  349. wx.hideLoading()
  350. wx.showToast({
  351. title: '删除NFC失败',
  352. icon: 'none',
  353. duration: 2000
  354. })
  355. }
  356. })
  357. } else {
  358. wx.hideLoading()
  359. wx.showToast({
  360. title: '删除NFC失败',
  361. icon: 'none',
  362. duration: 2000
  363. })
  364. }
  365. })
  366. // } else {
  367. // wx.hideLoading()
  368. // wx.showToast({
  369. // title: '删除NFC失败',
  370. // icon: 'none',
  371. // duration: 2000
  372. // })
  373. // }
  374. // })
  375. } else {
  376. wx.hideLoading()
  377. wx.showToast({
  378. title: '删除NFC失败',
  379. icon: 'none',
  380. duration: 2000
  381. })
  382. }
  383. })
  384. } else {
  385. ICINLocker.getCommonKey(cgInfo.lockerId, personInfo.userId, personInfo.userId, userSignKey, callback22 => {
  386. console.log('2', callback22)
  387. if (callback22.status == '00') {
  388. var startTime = personLi.startTime.toString(16).toUpperCase()
  389. var endTime = personLi.endTime.toString(16).toUpperCase()
  390. console.log('数据3', cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, cardNo.toUpperCase(), '', '01', userSignKey, startTime, endTime, callback22.commonKey, )
  391. ICINLocker.modifyRFCard(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, cardNo.toUpperCase(), '', '01', userSignKey, startTime, endTime, callback22.commonKey, callback33 => {
  392. console.log('3', callback33)
  393. if (callback33.status == '00') {
  394. var datacom = {
  395. code: "zg/bleSendVoucherReply",
  396. data: {
  397. lockerId: deviceinfo.deviceNum,
  398. serialNumber: serialNumber,
  399. index: cardIndex,
  400. type: 12,
  401. result: 1
  402. },
  403. cardId: deviceinfo.cardId,
  404. signature: wx.getStorageSync('signature')
  405. }
  406. WXAPI.sendCommandOne(datacom).then(res1 => {
  407. console.log('成功', res1)
  408. })
  409. var data = {
  410. id: passwordLi.id,
  411. signature: wx.getStorageSync('signature'),
  412. status: 0
  413. }
  414. WXAPI.editCertificate(data).then(res2 => {
  415. console.log('4', res2)
  416. if (res2.success) {
  417. _this.getvoucher()
  418. wx.hideLoading()
  419. wx.showToast({
  420. title: '删除NFC成功',
  421. icon: 'none',
  422. duration: 2000
  423. })
  424. } else {
  425. wx.hideLoading()
  426. wx.showToast({
  427. title: '删除NFC失败',
  428. icon: 'none',
  429. duration: 2000
  430. })
  431. }
  432. })
  433. } else {
  434. wx.hideLoading()
  435. wx.showToast({
  436. title: '删除NFC失败',
  437. icon: 'none',
  438. duration: 2000
  439. })
  440. }
  441. })
  442. } else {
  443. wx.hideLoading()
  444. wx.showToast({
  445. title: '删除NFC失败',
  446. icon: 'none',
  447. duration: 2000
  448. })
  449. }
  450. })
  451. }
  452. } else {
  453. wx.hideLoading()
  454. wx.showToast({
  455. title: '删除NFC失败',
  456. icon: 'none',
  457. duration: 2000
  458. })
  459. }
  460. })
  461. }
  462. },
  463. // 删除密码
  464. delPwd(index) {
  465. if (this.data.deviceInfo.manufactureId == 201 || this.data.deviceinfo.manufactureId == 221) {
  466. var _this = this
  467. var deviceinfo = this.data.deviceInfo
  468. var passwordLi = this.data.passwordlist[index]
  469. var info = passwordLi.content
  470. var personInfo = JSON.parse(this.data.personLi.info)
  471. var cgInfo = this.data.cgInfo
  472. var userSignKey = this.data.userSignKey
  473. var dataPassword = {
  474. code: "zg/tempPassword",
  475. data: {
  476. lockerId: deviceinfo.deviceNum,
  477. imei: deviceinfo.imei,
  478. passwordCount: 255,
  479. lockerUserId: personInfo.userId,
  480. keyId: personInfo.userId,
  481. passwordStartTime: passwordLi.startTime,
  482. passwordEndTime: passwordLi.endTime,
  483. order: 6209,
  484. action: 2,
  485. password: info.password,
  486. type: 1,
  487. cardName: _this.data.personLi.name,
  488. roomName: deviceinfo.roomName
  489. },
  490. signature: wx.getStorageSync('signature'),
  491. cardId: deviceinfo.cardId,
  492. }
  493. WXAPI.sendCommandOne(dataPassword).then(res => {
  494. console.log('获取索引', res)
  495. if (res.success) {
  496. var pwdNo = res.data.index.toString(16)
  497. var passwordIndex = res.data.index
  498. console.log("500",pwdNo);
  499. if (pwdNo < 9) {
  500. pwdNo = '0' + pwdNo
  501. } else {
  502. pwdNo = pwdNo
  503. }
  504. if (_this.data.userSignKey == '') {
  505. console.log('数据', cgInfo.lockerId, cgInfo.superId, personInfo.userId, cgInfo.superId, cgInfo.authKey, '01')
  506. ICINLocker.getUserSignKey(cgInfo.lockerId, cgInfo.superId, personInfo.userId, cgInfo.superId, cgInfo.authKey, '01', callback => {
  507. console.log('1', callback)
  508. if (callback.status == '00') {
  509. _this.setData({
  510. userSignKey: callback.userSignKey
  511. })
  512. // ICINLocker.getCommonKey(cgInfo.lockerId, personInfo.userId, personInfo.userId, callback.userSignKey, callback1 => {
  513. // console.log('2', callback1)
  514. // if (callback1.status == '00') {
  515. var startTime = passwordLi.startTime.toString(16).toUpperCase()
  516. var endTime = passwordLi.endTime.toString(16).toUpperCase()
  517. console.log('3数据', deviceinfo.deviceNum, "---", cgInfo.superId, "---", personInfo.userId, "---", info.password, "---", pwdNo, "---", cgInfo.superId, "---", cgInfo.authKey, "---", '', "---", startTime, "---", endTime, "---", 0, "---", callback.userCommonKey)
  518. ICINLocker.handlePwd(deviceinfo.deviceNum, cgInfo.superId, personInfo.userId, info.password, pwdNo, cgInfo.superId, cgInfo.authKey, '', startTime, endTime, 0, callback.userCommonKey, callback2 => {
  519. console.log('3', callback2)
  520. if (callback2.status == '00') {
  521. var datacom = {
  522. code: "zg/bleSendVoucherReply",
  523. data: {
  524. lockerId: deviceinfo.deviceNum,
  525. serialNumber: res.data.serialNumber,
  526. index: passwordIndex,
  527. type: 9,
  528. result: 1
  529. },
  530. cardId: deviceinfo.cardId,
  531. signature: wx.getStorageSync('signature')
  532. }
  533. WXAPI.sendCommandOne(datacom).then(res1 => {
  534. console.log('4', res1)
  535. })
  536. var data = {
  537. id: passwordLi.id,
  538. signature: wx.getStorageSync('signature'),
  539. // cardId: deviceinfo.cardId,
  540. status: 703
  541. }
  542. WXAPI.editCertificate(data).then(res2 => {
  543. console.log('5', res2)
  544. if (res2.success) {
  545. _this.getvoucher()
  546. wx.hideLoading()
  547. wx.showToast({
  548. title: '删除成功',
  549. duration: 2000,
  550. icon: 'none'
  551. })
  552. } else {
  553. wx.hideLoading()
  554. wx.showToast({
  555. title: '删除失败',
  556. duration: 2000,
  557. icon: ' none'
  558. })
  559. }
  560. })
  561. } else {
  562. wx.hideLoading()
  563. wx.showToast({
  564. title: '删除失败',
  565. duration: 2000,
  566. icon: ' none'
  567. })
  568. var datacom = {
  569. code: "zg/bleSendVoucherReply",
  570. data: {
  571. lockerId: deviceinfo.deviceNum,
  572. serialNumber: res.data.serialNumber,
  573. index: res.data.index,
  574. type: 9,
  575. result: 0
  576. },
  577. cardId: deviceinfo.cardId,
  578. signature: wx.getStorageSync('signature')
  579. }
  580. WXAPI.sendCommandOne(datacom).then(res1 => {
  581. console.log('7 失败', res1)
  582. })
  583. }
  584. })
  585. // } else {
  586. // wx.hideLoading()
  587. // wx.showToast({
  588. // title: '删除失败',
  589. // icon: 'none',
  590. // duration: 2000
  591. // })
  592. // }
  593. // })
  594. } else {
  595. wx.hideLoading()
  596. wx.showToast({
  597. title: '删除失败',
  598. icon: 'none',
  599. duration: 2000
  600. })
  601. }
  602. })
  603. } else {
  604. ICINLocker.getCommonKey(cgInfo.lockerId, personInfo.userId, personInfo.userId, userSignKey, callback1 => {
  605. console.log('2', callback1)
  606. if (callback1.status == '00') {
  607. var startTime = passwordLi.startTime.toString(16).toUpperCase()
  608. var endTime = passwordLi.endTime.toString(16).toUpperCase()
  609. console.log('3数据', deviceinfo.deviceNum, "---", cgInfo.superId, "---", personInfo.userId, "---", info.password, "---", pwdNo, "---", cgInfo.superId, "---", cgInfo.authKey, "---", '', "---", startTime, "---", endTime, "---", 0, "---", callback1.commonKey)
  610. ICINLocker.handlePwd(deviceinfo.deviceNum, cgInfo.superId, personInfo.userId, info.password, pwdNo, cgInfo.superId, cgInfo.authKey, '', startTime, endTime, 0, callback1.commonKey, callback2 => {
  611. console.log('3', callback2)
  612. if (callback2.status == '00') {
  613. var datacom = {
  614. code: "zg/bleSendVoucherReply",
  615. data: {
  616. lockerId: deviceinfo.deviceNum,
  617. serialNumber: res.data.serialNumber,
  618. index: passwordIndex,
  619. type: 9,
  620. result: 1
  621. },
  622. cardId: deviceinfo.cardId,
  623. signature: wx.getStorageSync('signature')
  624. }
  625. WXAPI.sendCommandOne(datacom).then(res1 => {
  626. console.log('4', res1)
  627. })
  628. var data = {
  629. id: passwordLi.id,
  630. signature: wx.getStorageSync('signature'),
  631. // cardId: deviceinfo.cardId,
  632. status: 703
  633. }
  634. WXAPI.editCertificate(data).then(res2 => {
  635. console.log('5', res2)
  636. if (res2.success) {
  637. _this.getvoucher()
  638. wx.hideLoading()
  639. wx.showToast({
  640. title: '删除成功',
  641. duration: 2000,
  642. icon: 'none'
  643. })
  644. } else {
  645. wx.hideLoading()
  646. wx.showToast({
  647. title: '删除失败',
  648. duration: 2000,
  649. icon: ' none'
  650. })
  651. }
  652. })
  653. } else {
  654. wx.hideLoading()
  655. wx.showToast({
  656. title: '删除失败',
  657. duration: 2000,
  658. icon: ' none'
  659. })
  660. var datacom = {
  661. code: "zg/bleSendVoucherReply",
  662. data: {
  663. lockerId: deviceinfo.deviceNum,
  664. serialNumber: res.data.serialNumber,
  665. index: res.data.index,
  666. type: 9,
  667. result: 0
  668. },
  669. cardId: deviceinfo.cardId,
  670. signature: wx.getStorageSync('signature')
  671. }
  672. WXAPI.sendCommandOne(datacom).then(res1 => {
  673. console.log('7 失败', res1)
  674. })
  675. }
  676. })
  677. } else {
  678. wx.hideLoading()
  679. wx.showToast({
  680. title: '删除失败',
  681. icon: 'none',
  682. duration: 2000
  683. })
  684. }
  685. })
  686. }
  687. } else {
  688. wx.hideLoading()
  689. wx.showToast({
  690. title: res.msg,
  691. icon: 'none',
  692. duration: 2000
  693. })
  694. }
  695. })
  696. }
  697. },
  698. // 删除指纹
  699. delFin(index) {
  700. // return
  701. wx.showLoading({
  702. title: '删除指纹中...',
  703. mask: true
  704. })
  705. var cgInfo = this.data.cgInfo
  706. var personLi = this.data.fingerlist[index]
  707. var deviceinfo = this.data.deviceInfo
  708. var info = personLi.content
  709. var personInfo = JSON.parse(this.data.personLi.info)
  710. var _this = this
  711. var dataPassword = {
  712. code: "zg/fpOperate",
  713. data: {
  714. lockerId: deviceinfo.deviceNum,
  715. imei: deviceinfo.imei,
  716. lockerUserId: personInfo.userId,
  717. keyId: personInfo.userId,
  718. fingerType: '0',
  719. fingerId: '',
  720. startTime: personLi.startTime,
  721. endTime: personLi.endTime,
  722. order: 6218,
  723. action: 2,
  724. type: 1,
  725. roomName: _this.data.deviceInfo.roomName,
  726. cardName: _this.data.personLi.name,
  727. },
  728. cardId: deviceinfo.cardId,
  729. signature: wx.getStorageSync('signature')
  730. }
  731. WXAPI.sendCommandOne(dataPassword).then(res => {
  732. console.log('获取索引', res)
  733. if (res.success) {
  734. var Fgindex = res.data.index
  735. var fingerNo = Fgindex.toString(16)
  736. if (fingerNo < 10) {
  737. fingerNo = '000' + fingerNo
  738. } else {
  739. fingerNo = '00' + fingerNo
  740. }
  741. ICINLocker.getUserSignKey(cgInfo.lockerId, cgInfo.superId, personInfo.userId, cgInfo.superId, cgInfo.authKey, '01', callbackfp => {
  742. console.log('1', callbackfp)
  743. if (callbackfp.status == '00') {
  744. ICINLocker.getCommonKey(cgInfo.lockerId, personInfo.userId, personInfo.userId, callbackfp.userSignKey, callbcakfp1 => {
  745. console.log('2', callbackfp1)
  746. if (callbcakfp1.status == '00') {
  747. var startTime = personLi.startTime.toString(16).toUpperCase()
  748. var endTime = personLi.endTime.toString(16).toUpperCase()
  749. ICINLocker.modifyFingerPrints(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, '01', fingerNo, '', '00', startTime, endTime, callbcakfp1.commonKey, callbackfp2 => {
  750. console.log('3', callbackfp2)
  751. if (callbackfp2.status == '00') {
  752. var datacom = {
  753. code: "zg/bleSendVoucherReply",
  754. data: {
  755. lockerId: deviceinfo.deviceNum,
  756. serialNumber: res.data.serialNumber,
  757. index: Fgindex,
  758. type: 18,
  759. result: 1
  760. },
  761. cardId: deviceinfo.cardId,
  762. signature: wx.getStorageSync('signature')
  763. }
  764. WXAPI.sendCommandOne(datacom).then(res1 => {
  765. console.log('成功', res1)
  766. })
  767. var data = {
  768. id: passwordLi.id,
  769. signature: wx.getStorageSync('signature'),
  770. status: 0
  771. }
  772. WXAPI.editCertificate(data).then(res2 => {
  773. console.log('4', res2)
  774. if (res2.success) {
  775. _this.getvoucher()
  776. wx.hideLoading()
  777. wx.showToast({
  778. title: '删除指纹成功',
  779. icon: 'none',
  780. duration: 2000
  781. })
  782. } else {
  783. wx.hideLoading()
  784. wx.showToast({
  785. title: '删除指纹失败',
  786. icon: 'none',
  787. duration: 2000
  788. })
  789. }
  790. })
  791. } else {
  792. wx.hideLoading()
  793. wx.showToast({
  794. title: '删除指纹失败',
  795. icon: 'none',
  796. duration: 2000
  797. })
  798. }
  799. })
  800. } else {
  801. wx.hideLoading()
  802. wx.showToast({
  803. title: '删除指纹失败',
  804. icon: 'none',
  805. duration: 2000
  806. })
  807. }
  808. })
  809. } else {
  810. wx.hideLoading()
  811. wx.showToast({
  812. title: '删除指纹失败',
  813. icon: 'none',
  814. duration: 2000
  815. })
  816. }
  817. })
  818. } else {
  819. wx.hideLoading()
  820. wx.showToast({
  821. title: '删除指纹失败',
  822. icon: 'none',
  823. duration: 2000
  824. })
  825. }
  826. })
  827. },
  828. /**
  829. * 生命周期函数--监听页面初次渲染完成
  830. */
  831. onReady: function () {
  832. },
  833. /**
  834. * 生命周期函数--监听页面显示
  835. */
  836. onShow: function () {
  837. },
  838. /**
  839. * 生命周期函数--监听页面隐藏
  840. */
  841. onHide: function () {
  842. },
  843. closeblue() {
  844. app.globalData.ble.close()
  845. app.globalData.bleStatus = false
  846. },
  847. closeblue1() {
  848. ICINLocker.disConnect(this.data.deviceInfo.deviceNum).then(res => {}).catch(err => {})
  849. app.globalData.bleStatus = false
  850. },
  851. onUnload: function () {
  852. if (this.data.deviceInfo.manufactureId == 201) {
  853. this.closeblue1()
  854. } else if (this.data.deviceInfo.manufactureId == 101) {
  855. this.closeblue()
  856. }
  857. },
  858. /**
  859. * 页面相关事件处理函数--监听用户下拉动作
  860. */
  861. onPullDownRefresh: function () {
  862. },
  863. /**
  864. * 页面上拉触底事件的处理函数
  865. */
  866. onReachBottom: function () {
  867. },
  868. /**
  869. * 用户点击右上角分享
  870. */
  871. onShareAppMessage: function () {
  872. }
  873. })