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.

894 lines
44 KiB

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