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.

890 lines
43 KiB

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