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.

4423 lines
144 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. // pages/addperson/addperson.js
  2. const app = getApp()
  3. const WXAPI = require('../../utils/request')
  4. import ICINLocker from "../../utils/ICINPakage/ICINLocker"
  5. var util = require('../../utils/util');
  6. var util1 = require('../../utils/util1');
  7. const config = require('../../config')
  8. const plugin = requirePlugin("myPlugin")
  9. var methods = require('../../utils/methods');
  10. var md5 = require('../../utils/md5.js');
  11. var bleall = require('../../utils/bleall');
  12. import moment from "../../utils/moment"
  13. import {
  14. BLE
  15. } from "../../utils/btls/ble";
  16. const emitter = app.globalData.emitter
  17. const ADD_NFC_MODE = 10
  18. // ArrayBuffer转16进度字符串示例
  19. function ab2hex(buffer) {
  20. var hexArr = Array.prototype.map.call(
  21. new Uint8Array(buffer),
  22. function (bit) {
  23. return ('00' + bit.toString(16)).slice(-2)
  24. }
  25. )
  26. return hexArr.join(',');
  27. }
  28. function CurentTime() {
  29. var now = new Date();
  30. var year = now.getFullYear(); //年
  31. var month = now.getMonth() + 1; //月
  32. var day = now.getDate(); //日
  33. var hh = now.getHours(); //时
  34. var mm = now.getMinutes(); //分
  35. var clock = year + "-";
  36. if (month < 10)
  37. clock += "0";
  38. clock += month + "-";
  39. if (day < 10)
  40. clock += "0";
  41. clock += day + " ";
  42. // if (hh < 10)
  43. // clock += "0";
  44. // clock += '00' + ":";
  45. // // if (mm < 10) clock += '0';
  46. clock += '00:00:00';
  47. return (clock);
  48. }
  49. function CurentTime1() {
  50. var now = new Date();
  51. var year = now.getFullYear() + 3; //年
  52. var month = now.getMonth() + 1; //月
  53. var day = now.getDate(); //日
  54. var hh = now.getHours(); //时
  55. var mm = now.getMinutes(); //分
  56. var clock = year + "-";
  57. if (month < 10)
  58. clock += "0";
  59. clock += month + "-";
  60. if (day < 10)
  61. clock += "0";
  62. clock += day + " ";
  63. // if (hh < 10)
  64. // clock += "0";
  65. // clock += hh + ":";
  66. // if (mm < 10) clock += '0';
  67. // clock += mm;
  68. clock += '23:59:59';
  69. return (clock);
  70. }
  71. var date = new Date()
  72. var isConnected = false
  73. var connectedDeviceId = ''
  74. var basecode = 29283991
  75. var lockId = 1
  76. var lockManagerId = 1
  77. var lockMac = ''
  78. var isInitReady = false
  79. var lockModel
  80. var lockDevice
  81. var taskId = 0
  82. var pincode = -1
  83. var pincodeIndex = -1
  84. var rfCardId = -1
  85. var rfCardIndex = -1
  86. var fingerprintIndex = -1
  87. var passwordLiAll = {
  88. id: ''
  89. }
  90. var isLockLogin = false
  91. var serialNumber = ''
  92. let letterRandom = [
  93. "0",
  94. "1",
  95. "2",
  96. "3",
  97. "4",
  98. "5",
  99. "6",
  100. "7",
  101. "8",
  102. "9",
  103. "a",
  104. "b",
  105. "c",
  106. "d",
  107. "e",
  108. "f",
  109. "g",
  110. "h",
  111. "i",
  112. "j",
  113. "k",
  114. "l",
  115. "m",
  116. "n",
  117. "o",
  118. "p",
  119. "q",
  120. "r",
  121. "s",
  122. "t",
  123. "u",
  124. "v",
  125. "w",
  126. "x",
  127. "y",
  128. "z",
  129. "A",
  130. "B",
  131. "C",
  132. "D",
  133. "E",
  134. "F",
  135. "G",
  136. "H",
  137. "I",
  138. "J",
  139. "K",
  140. "L",
  141. "M",
  142. "N",
  143. "O",
  144. "P",
  145. "Q",
  146. "R",
  147. "S",
  148. "T",
  149. "U",
  150. "V",
  151. "W",
  152. "X",
  153. "Y",
  154. "Z",
  155. ];
  156. function randomMethods() {
  157. let str = ''
  158. for (let i = 0; i < 8; i++) {
  159. str +=
  160. letterRandom[Math.round(Math.random() * (letterRandom.length - 1))];
  161. }
  162. return str
  163. }
  164. Page({
  165. /**
  166. * 页面的初始数据
  167. */
  168. data: {
  169. isBindLock: false,
  170. isPincodeAdd: false,
  171. isRfCardAdd: false,
  172. isFingerprintAdd: false,
  173. isUnloked: false,
  174. isMuted: false,
  175. isNbEnable: true,
  176. lockModel: 0,
  177. lock: {},
  178. isSearch: app.globalData.isSearch,
  179. activeKey: 0,
  180. NfcList: [],
  181. FpList: [],
  182. passwordList: [],
  183. show: false,
  184. datetimerange: [CurentTime(), CurentTime1()],
  185. minDate: '',
  186. minDate1: '',
  187. endtime: '',
  188. starttime: '',
  189. addIndex: 0,
  190. pzname: '',
  191. current: '',
  192. currentIndex: '',
  193. fingerprintId: '',
  194. backstatus: false,
  195. radioDetil: '',
  196. passwordStatus: true,
  197. items: [{
  198. value: '0',
  199. name: '左手大拇指',
  200. checked: false
  201. },
  202. {
  203. value: '1',
  204. name: '左手食指',
  205. checked: false
  206. },
  207. {
  208. value: '2',
  209. name: '右手大拇指',
  210. checked: false
  211. },
  212. {
  213. value: '3',
  214. name: '右手食指',
  215. checked: false
  216. }
  217. ],
  218. showLoading: false,
  219. requestSatatus: true,
  220. password: ''
  221. },
  222. /**
  223. * 生命周期函数--监听页面加载
  224. */
  225. onLoad: function (options) {
  226. var cgInfo = wx.getStorageSync('cgInfo')
  227. var deviceinfo = wx.getStorageSync('deviceinfo')
  228. var personLi = wx.getStorageSync('personLi')
  229. let minDate = wx.getStorageSync('minDate')
  230. let minDate1 = wx.getStorageSync('minDate1')
  231. this.setData({
  232. cgInfo: cgInfo,
  233. minDate,
  234. minDate1,
  235. starttime: minDate,
  236. endtime: minDate1,
  237. deviceinfo: deviceinfo,
  238. personLi: personLi,
  239. isSearch: false
  240. })
  241. this.getPassword()
  242. this.getNfc()
  243. this.getCarId()
  244. this.getFp()
  245. if (deviceinfo.manufactureId == 1201) {
  246. this.searchDevicesMethods()
  247. } else if (deviceinfo.manufactureId == 101) {
  248. app.watch(this.getcartcount, 'backdata')
  249. app.watch(this.fingerprintFun, 'fingerprintId')
  250. }
  251. if(deviceinfo.bluetoothMac){
  252. let superAdmin = []
  253. var superAdminIdlist = deviceinfo.bluetoothMac.slice(deviceinfo.bluetoothMac.length - 11, deviceinfo.bluetoothMac.length).split(":").join("")
  254. for (let i = 0; i < superAdminIdlist.length; i++) {
  255. if (superAdminIdlist[i] >= 0 && superAdminIdlist[i] <= 9) {
  256. superAdmin.push(superAdminIdlist[i])
  257. } else {
  258. let adminid = superAdminIdlist.charCodeAt(i)
  259. superAdmin.push(adminid)
  260. }
  261. }
  262. let superAdminId = superAdmin.join('').slice(superAdmin.length - 8, superAdmin.length)
  263. basecode = superAdminId
  264. console.log(basecode, "basecode");
  265. }
  266. },
  267. // 指纹选择
  268. radioChange(e) {
  269. var personLi = wx.getStorageSync('personLi')
  270. var pzname = ''
  271. if (e.detail.value == 0) {
  272. pzname = "左手大拇指"
  273. } else if (e.detail.value == 1) {
  274. pzname = "左手食指"
  275. } else if (e.detail.value == 2) {
  276. pzname = "右手大拇指"
  277. } else if (e.detail.value == 3) {
  278. pzname = "右手食指"
  279. }
  280. this.setData({
  281. radioDetil: pzname
  282. })
  283. this.getfingerprintMrhods(pzname, personLi.cardId, 11)
  284. },
  285. getfingerprintMrhods(pzname, id, type) {
  286. var that = this
  287. var items = [{
  288. value: '0',
  289. name: '左手大拇指',
  290. checked: false
  291. },
  292. {
  293. value: '1',
  294. name: '左手食指',
  295. checked: false
  296. },
  297. {
  298. value: '2',
  299. name: '右手大拇指',
  300. checked: false
  301. },
  302. {
  303. value: '3',
  304. name: '右手食指',
  305. checked: false
  306. }
  307. ]
  308. var data = {
  309. pageNum: 0,
  310. pageSize: 0,
  311. orderBy: "create_at desc",
  312. q: {
  313. cardId: id,
  314. types: type,
  315. deviceNum: this.data.deviceinfo.deviceNum,
  316. inStatus: '0,1,702'
  317. },
  318. };
  319. WXAPI.getCertificates(data).then(res => {
  320. var dataOne = util.zlib_unzip(res.data)
  321. if (res.success) {
  322. dataOne.map(li => {
  323. var content = JSON.parse(li.content)
  324. if (content.fingerprintAlias == pzname) {
  325. wx.showModal({
  326. title: '提示',
  327. content: '该指纹已存在,请选择其他',
  328. success(res1) {
  329. if (res1.confirm) {
  330. console.log('用户点击确定')
  331. that.setData({
  332. items,
  333. radioDetil: ''
  334. })
  335. } else if (res1.cancel) {
  336. console.log('用户点击取消')
  337. that.setData({
  338. items,
  339. radioDetil: ''
  340. })
  341. }
  342. }
  343. })
  344. }
  345. })
  346. } else {
  347. wx.showToast({
  348. title: '获取失败',
  349. mask: true,
  350. duration: '2000',
  351. icon: 'none'
  352. })
  353. }
  354. })
  355. },
  356. fingerprintFun() {
  357. this.data.fingerprintId = app.globalData.fingerprintId
  358. },
  359. getcartcount(val) {
  360. var that = this
  361. var _this = this
  362. let deviceNum = that.data.deviceinfo.deviceNum
  363. var timestamp = moment().format("x")
  364. wx.showLoading({
  365. title: '添加指纹中',
  366. mask: true
  367. })
  368. if (app.globalData.backdata == 3 && this.data.backstatus) {
  369. bleall.startFp_29(deviceNum, 0x02, timestamp, function (res) {})
  370. } else if (app.globalData.backdata == 2 && this.data.backstatus) {
  371. bleall.startFp_29(deviceNum, 0x01, timestamp, function (res) {})
  372. } else if (app.globalData.backdata == 1 && this.data.backstatus) {
  373. console.log(app.globalData.backdata, this.data.backstatus, 'app.globalData.backdata, this.data.backstatus', this.data.fingerprintId)
  374. if (this.data.fingerprintId != 255) {
  375. var info = JSON.parse(this.data.personLi.info)
  376. var time1 = moment(this.data.datetimerange[0]).format("YYYYMMDDHHmmss")
  377. var time2 = moment(this.data.datetimerange[1]).format("YYYYMMDDHHmmss")
  378. var time3 = new Date(this.data.datetimerange[0].replace(/-/g, '/'))
  379. var time4 = new Date(this.data.datetimerange[1].replace(/-/g, '/'))
  380. var passwordStartTime = time3.getTime() / 1000
  381. var passwordEndTime = time4.getTime() / 1000
  382. var data = {
  383. managerTelephone: "18270949468",
  384. managerPassword: "202108",
  385. userTelephone: info.userTelephone,
  386. userPassword: info.userPassword,
  387. startTime: time1,
  388. endTime: time2
  389. }
  390. console.log(data, this.data.fingerprintId)
  391. // if(app.globalData.fingerprintId != -1){
  392. // setTimeout(() => {
  393. // app.globalData.backdata = -1
  394. this.setData({
  395. backstatus: false
  396. })
  397. let fingerprintId = ''
  398. console.log(_this.data.fingerprintId, typeof (_this.data.fingerprintId))
  399. if (Number(_this.data.fingerprintId) < 9) {
  400. fingerprintId = '0' + _this.data.fingerprintId.toString(16)
  401. } else {
  402. fingerprintId = _this.data.fingerprintId.toString(16)
  403. }
  404. let deviceinfo = that.data.deviceinfo
  405. bleall.startFp_63(data.managerTelephone, data.managerPassword, data.userTelephone, data.userPassword,
  406. data.startTime, data.endTime, 16, this.data.fingerprintId, timestamp,
  407. function (res) {
  408. console.log(res, 'resres')
  409. if (res.success) {
  410. wx.hideLoading()
  411. var cardName = '',
  412. pzname = ''
  413. if (that.data.pzname) {
  414. cardName = that.data.personLi.name + '-蓝牙-' + that.data.pzname
  415. pzname = '蓝牙-' + that.data.pzname
  416. } else {
  417. cardName = that.data.personLi.name + '-蓝牙-指纹' + that.data.FpList.length + 1
  418. pzname = '蓝牙-指纹' + that.data.FpList.length + 1
  419. }
  420. var str = {
  421. // cardId: this.personInfo.cardId,
  422. imei: _this.data.deviceinfo.imei,
  423. pzname: pzname,
  424. password: '',
  425. userTelephone: info.userTelephone,
  426. operateMode: 16,
  427. fingerprintAlias: _this.data.radioDetil,
  428. userPassword: info.userPassword,
  429. passwordStartTime: time1,
  430. passwordEndTime: time2,
  431. is: false,
  432. pass: true
  433. }
  434. var data3 = {
  435. code: "ble/operateUserInfo",
  436. data: {
  437. deviceNum: deviceinfo.deviceNum,
  438. imei: deviceinfo.imei,
  439. userTelephone: info.userTelephone,
  440. userPassword: info.userPassword,
  441. password: fingerprintId,
  442. userStartTime: time1,
  443. userEndTime: time2,
  444. passwordStartTime: time1,
  445. passwordEndTime: time2,
  446. operateMode: 16,
  447. order: 6216,
  448. timestamp: timestamp,
  449. managerTelephone: '18270949468',
  450. managerPassword: '202108',
  451. passwordLength: 10,
  452. permission: 4294967295,
  453. times: 255,
  454. recycleTime: "65535",
  455. roomName: _this.data.deviceinfo.roomName,
  456. cardName: cardName,
  457. }
  458. }
  459. console.log(data3, 'pppppp')
  460. WXAPI.sendCommand(data3).then(res3 => {
  461. console.log(res3, 'resres3')
  462. if (res3.success) {
  463. var data4 = {
  464. result: 1,
  465. serial: res3.data.serialNumber
  466. }
  467. WXAPI.updatePush(data4).then(res4 => {
  468. })
  469. var data6 = {
  470. result: 1,
  471. serial: res3.data.serialNumber,
  472. face: fingerprintId
  473. }
  474. WXAPI.editPushBySerial(data6).then(res4 => {
  475. })
  476. var data = {
  477. cardId: _this.data.personLi.cardId,
  478. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  479. deviceNum: _this.data.deviceinfo.deviceNum,
  480. type: 1,
  481. imei: _this.data.deviceinfo.imei,
  482. serial: res3.data.serialNumber,
  483. startTime: passwordStartTime,
  484. endTime: passwordEndTime,
  485. };
  486. var datalist = {
  487. cardId: _this.data.personLi.cardId,
  488. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  489. type: 11,
  490. startTime: passwordStartTime,
  491. endTime: passwordEndTime,
  492. };
  493. WXAPI.addCertificates(datalist).then(res6 => {})
  494. console.log(data, '添加凭证')
  495. WXAPI.addCertificates(data).then(res4 => {
  496. if (res4.success) {
  497. var updatedata = {
  498. id: res4.data,
  499. status: 1
  500. };
  501. WXAPI.updateCertificates(updatedata).then((res2) => {});
  502. console.log(res3, '添加凭证成功')
  503. _this.getFp()
  504. _this.setData({
  505. show: false
  506. })
  507. wx.hideLoading()
  508. wx.showToast({
  509. title: '添加成功',
  510. icon: 'none',
  511. mask: true,
  512. duration: 2000
  513. })
  514. } else {
  515. wx.hideLoading()
  516. wx.showToast({
  517. title: '添加失败',
  518. mask: true,
  519. icon: 'none',
  520. duration: 2000
  521. })
  522. }
  523. })
  524. } else {
  525. wx.hideLoading()
  526. wx.showToast({
  527. title: res3.msg,
  528. mask: true,
  529. icon: 'none',
  530. duration: 2000
  531. })
  532. }
  533. })
  534. } else {
  535. wx.hideLoading()
  536. wx.showToast({
  537. title: '添加失败',
  538. duration: 2000,
  539. icon: 'none'
  540. })
  541. }
  542. if (res.data == "蓝牙功能暂不支持") {
  543. _this.startconnect()
  544. }
  545. })
  546. // }, 200)
  547. // }
  548. } else {
  549. wx.hideLoading()
  550. wx.showToast({
  551. title: '添加失败',
  552. mask: true,
  553. duration: 2000,
  554. icon: 'none'
  555. })
  556. }
  557. }
  558. },
  559. // 删除开锁方式
  560. delMode(e) {
  561. var current = e.currentTarget.dataset.current
  562. var index = e.currentTarget.dataset.index
  563. var cgInfo = this.data.cgInfo
  564. var deviceinfo = this.data.deviceinfo
  565. this.setData({
  566. current: current,
  567. currentIndex: index
  568. })
  569. if (deviceinfo.manufactureId == 101) {
  570. if (current == 1) {
  571. this.delPassword1(index)
  572. } else if (current == 2) {
  573. this.delNfc1(index)
  574. } else if (current == 3) {
  575. this.delFp1(index)
  576. }
  577. } else if (deviceinfo.manufactureId == 201 || deviceinfo.manufactureId == 221) {
  578. if (current == 1) {
  579. this.delPassword(index)
  580. } else if (current == 2) {
  581. this.delNfc1(index)
  582. } else if (current == 3) {
  583. this.delFp(index)
  584. }
  585. } else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) {
  586. if (this.data.isSearch) {
  587. if (current == 1) {
  588. this.delPasswordLwj(index)
  589. } else if (current == 2) {
  590. this.delNfcLwj(index)
  591. } else if (current == 3) {
  592. this.delFpLwj(index)
  593. }
  594. }else{
  595. this.searchDevicesMethods()
  596. }
  597. }
  598. },
  599. getNFCIndexLwj(index, callback) {
  600. var data = {
  601. q: JSON.stringify({
  602. cardId: this.data.personLi.cardId,
  603. inStatus: "1",
  604. types: '3',
  605. deviceNum: this.data.NfcList[index].deviceNum,
  606. // this.data.NfcList[index].serial,
  607. // result:1
  608. }),
  609. pageNum: 1,
  610. pageSize: 10,
  611. orderBy: "create_at desc"
  612. };
  613. WXAPI.getCertificates(data).then(res => {
  614. if (res.success) {
  615. var dataOne = util.zlib_unzip(res.data)
  616. console.log(dataOne, 'ddd')
  617. callback(dataOne)
  618. } else {
  619. wx.showToast({
  620. title: '获取失败',
  621. mask: true,
  622. duration: 2000,
  623. icon: 'none'
  624. })
  625. }
  626. })
  627. },
  628. getNFCIndex(index, callback) {
  629. var data = {
  630. q: JSON.stringify({
  631. serial: this.data.NfcList[index].serial,
  632. result: 1
  633. }),
  634. pageNum: 1,
  635. pageSize: 10,
  636. };
  637. WXAPI.getDeviceResult(data).then(res => {
  638. if (res.success) {
  639. var dataOne = util.zlib_unzip(res.data)
  640. console.log(dataOne, 'ddd')
  641. callback(dataOne)
  642. } else {
  643. wx.showToast({
  644. title: '获取失败',
  645. mask: true,
  646. duration: 2000,
  647. icon: 'none'
  648. })
  649. }
  650. })
  651. },
  652. getFpIndex(index, callback) {
  653. var data = {
  654. q: JSON.stringify({
  655. serial: this.data.FpList[index].serial,
  656. }),
  657. pageNum: 1,
  658. pageSize: 10,
  659. };
  660. WXAPI.getDeviceResult(data).then(res => {
  661. if (res.success) {
  662. var dataOne = util.zlib_unzip(res.data)
  663. console.log(dataOne, 'ddd')
  664. callback(dataOne)
  665. } else {
  666. wx.showToast({
  667. title: '获取失败',
  668. duration: 2000,
  669. mask: true,
  670. icon: 'none'
  671. })
  672. }
  673. })
  674. },
  675. addPassword(e) {
  676. this.setData({
  677. show: true,
  678. current: e.currentTarget.dataset.current,
  679. addIndex: e.currentTarget.dataset.addindex
  680. })
  681. },
  682. onChange1(event) {
  683. // event.detail 为当前输入的值
  684. this.setData({
  685. password: event.detail
  686. })
  687. },
  688. onChange2(event) {
  689. // event.detail 为当前输入的值
  690. this.setData({
  691. pzname: event.detail
  692. })
  693. },
  694. bindDateChange: function (e) {
  695. var str = e.detail.value + " 00:00:00"
  696. this.data.datetimerange[0] = str
  697. this.setData({
  698. starttime: str,
  699. })
  700. },
  701. bindDateChange1: function (e) {
  702. var str = e.detail.value + " 23:59:59"
  703. this.data.datetimerange[1] = str
  704. this.setData({
  705. endtime: str
  706. })
  707. },
  708. delNfc1(index) {
  709. wx.showLoading({
  710. title: '正在删除',
  711. mask: true
  712. })
  713. var cgInfo = this.data.cgInfo
  714. var personLi = this.data.NfcList[index]
  715. var deviceinfo = this.data.deviceinfo
  716. var info = JSON.parse(personLi.content)
  717. var personInfo = JSON.parse(this.data.personLi.info)
  718. var _this = this
  719. this.getNFCIndex(index, function (data) {
  720. console.log(data, 'datatdatata', data[0])
  721. if (data.length > 0 && data[0].face != null) {
  722. var FPindex = data[0].face
  723. var dataPasswod = {
  724. code: "zg/cardOperate",
  725. data: {
  726. lockerId: deviceinfo.deviceNum,
  727. imei: deviceinfo.imei,
  728. lockerUserId: personInfo.userId,
  729. keyId: personInfo.userId,
  730. action: 2,
  731. taskStatus: 1,
  732. cardType: 50,
  733. cardNo: info.password,
  734. cardIndex: FPindex,
  735. startTime: personLi.startTime,
  736. endTime: personLi.endTime,
  737. order: 6212,
  738. type: 12,
  739. roomName: _this.data.deviceinfo.roomName,
  740. cardName: _this.data.personLi.name + personLi.pzname,
  741. }
  742. }
  743. WXAPI.sendCommand(dataPasswod).then(res => {
  744. console.log(res, '获取索引', FPindex)
  745. if (res.success) {
  746. var serialNumber = res.data.serialNumber
  747. var fingerNo = FPindex.toString(16)
  748. if (fingerNo.length == 1) {
  749. fingerNo = '0' + fingerNo
  750. } else {
  751. fingerNo = fingerNo
  752. }
  753. ICINLocker.getSignKey(cgInfo.lockerId, cgInfo.superId, cgInfo.superId,
  754. (callback) => {
  755. console.log(callback, fingerNo)
  756. if (callback.status == '00') {
  757. ICINLocker.getCommonKey(cgInfo.lockerId, cgInfo.superId, cgInfo.superId, callback.signKey, (callback1) => {
  758. console.log(callback1)
  759. if (callback1.status == '00') {
  760. var startTime = personLi.startTime.toString(16).toUpperCase()
  761. var endTime = personLi.endTime.toString(16).toUpperCase()
  762. console.log(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, fingerNo.toUpperCase(), '--', '01', callback.signKey, startTime, endTime, callback1.commonKey)
  763. ICINLocker.modifyRFCard(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, fingerNo.toUpperCase(), '', '01', callback.signKey, startTime, endTime, callback1.commonKey, (
  764. callback2) => {
  765. console.log(callback2)
  766. if (callback2.status == '00') {
  767. var datacom = {
  768. code: "zg/bleSendVoucherReply",
  769. data: {
  770. lockerId: deviceinfo.deviceNum,
  771. serialNumber: serialNumber,
  772. index: FPindex,
  773. type: 12,
  774. result: 1
  775. }
  776. }
  777. WXAPI.sendCommand(datacom).then(res2 => {
  778. console.log(res2, '成功----')
  779. })
  780. wx.showToast({
  781. title: '下发成功',
  782. mask: true,
  783. icon: 'none',
  784. duration: 2000
  785. })
  786. var data = {
  787. ids: [personLi.id]
  788. }
  789. wx.hideLoading()
  790. WXAPI.deleteCertificates(data).then(res1 => {
  791. if (res1.success) {
  792. _this.getNfc()
  793. wx.showToast({
  794. title: '删除成功',
  795. mask: true,
  796. icon: 'none',
  797. duration: 2000
  798. })
  799. } else {
  800. wx.showToast({
  801. title: '删除失败',
  802. mask: true,
  803. icon: 'none',
  804. duration: 2000
  805. })
  806. }
  807. })
  808. } else {
  809. wx.hideLoading()
  810. wx.showToast({
  811. title: '删除失败',
  812. mask: true,
  813. icon: 'none',
  814. duration: 2000
  815. })
  816. var datacom = {
  817. code: "zg/bleSendVoucherReply",
  818. data: {
  819. lockerId: deviceinfo.deviceNum,
  820. serialNumber: serialNumber,
  821. index: FPindex,
  822. type: 12,
  823. result: 0
  824. }
  825. }
  826. WXAPI.sendCommand(datacom).then(res2 => {
  827. console.log(res2, '失败')
  828. })
  829. }
  830. })
  831. } else {
  832. wx.hideLoading()
  833. wx.showToast({
  834. title: '删除失败',
  835. mask: true,
  836. icon: 'none',
  837. duration: 2000
  838. })
  839. var datacom = {
  840. code: "zg/bleSendVoucherReply",
  841. data: {
  842. lockerId: deviceinfo.deviceNum,
  843. serialNumber: serialNumber,
  844. index: FPindex,
  845. type: 12,
  846. result: 0
  847. }
  848. }
  849. WXAPI.sendCommand(datacom).then(res2 => {
  850. console.log(res2, '失败')
  851. })
  852. }
  853. })
  854. } else {
  855. wx.hideLoading()
  856. wx.showToast({
  857. title: '删除失败',
  858. mask: true,
  859. icon: 'none',
  860. duration: 2000
  861. })
  862. var datacom = {
  863. code: "zg/bleSendVoucherReply",
  864. data: {
  865. lockerId: deviceinfo.deviceNum,
  866. serialNumber: serialNumber,
  867. index: FPindex,
  868. type: 12,
  869. result: 0
  870. }
  871. }
  872. WXAPI.sendCommand(datacom).then(res2 => {
  873. console.log(res2, '失败')
  874. })
  875. }
  876. })
  877. } else {
  878. wx.showToast({
  879. title: res.msg,
  880. mask: true,
  881. icon: 'none',
  882. duration: 2000
  883. })
  884. }
  885. })
  886. } else {
  887. wx.hideLoading()
  888. wx.showToast({
  889. title: '删除失败',
  890. mask: true,
  891. duration: 2000,
  892. icon: 'none'
  893. })
  894. }
  895. })
  896. },
  897. delNfcLwj(index) {
  898. wx.showLoading({
  899. title: '正在删除',
  900. mask: true
  901. })
  902. var personLi = this.data.NfcList[index]
  903. passwordLiAll = personLi
  904. var deviceinfo = this.data.deviceinfo
  905. var info = JSON.parse(personLi.content)
  906. var personInfo = JSON.parse(this.data.personLi.info)
  907. var _this = this
  908. this.getNFCIndexLwj(index, function (data) {
  909. if (data.length > 0) {
  910. let passwordIndex = info.index
  911. var dataPasswod = {
  912. code: "lwj/cardOperate",
  913. data: {
  914. lockerId: deviceinfo.deviceNum,
  915. lockerUserId: personInfo.userId,
  916. startTime: personLi.startTime,
  917. endTime: personLi.endTime,
  918. order: 6212,
  919. operateMode: 12,
  920. action: 2,
  921. // cardNo: info.password,
  922. passwordIndex: passwordIndex,
  923. type: 12,
  924. cardName: _this.data.personLi.name,
  925. roomName: deviceinfo.roomName
  926. }
  927. }
  928. console.log(dataPasswod, 'dataPasswod', info)
  929. WXAPI.sendCommand(dataPasswod).then(res => {
  930. console.log(res, '获取索引')
  931. if (res.success) {
  932. rfCardIndex = res.data.index
  933. serialNumber = res.data.serialNumber
  934. rfCardId = info.password
  935. taskId = 62
  936. _this.initBluetooth()
  937. } else {
  938. wx.hideLoading()
  939. wx.showToast({
  940. title: res.msg,
  941. mask: true,
  942. icon: 'none',
  943. duration: 2000
  944. })
  945. }
  946. })
  947. } else {
  948. wx.hideLoading()
  949. wx.showToast({
  950. title: '删除失败',
  951. mask: true,
  952. duration: 2000,
  953. icon: 'none'
  954. })
  955. }
  956. })
  957. },
  958. delFp1(index) {
  959. wx.showLoading({
  960. title: '正在删除',
  961. mask: true
  962. })
  963. var cgInfo = this.data.cgInfo
  964. var personLi = this.data.FpList[index]
  965. var deviceinfo = this.data.deviceinfo
  966. var info = JSON.parse(personLi.content)
  967. var person = this.data.personLi
  968. var _this = this
  969. this.getFpIndex(index, function (data) {
  970. if (data.length > 0) {
  971. var FPindex = data[0].face
  972. var timestamp = moment().format("x")
  973. var fingerprintId = ''
  974. if (Number(FPindex) < 9) {
  975. fingerprintId = '0' + FPindex.toString(16)
  976. } else {
  977. fingerprintId = FPindex.toString(16)
  978. }
  979. var data1 = {
  980. managerTelephone: "18270949468",
  981. managerPassword: '202108',
  982. userTelephone: info.userTelephone,
  983. userPassword: info.userPassword,
  984. password: fingerprintId,
  985. startTime: "20210813010101",
  986. endTime: "20680813010101"
  987. }
  988. bleall.startFp1_63(data1.managerTelephone, data1.managerPassword, data1.userTelephone,
  989. data1.userPassword, data1.password, data1.startTime, data1.endTime, 18, timestamp,
  990. function (res) {
  991. if (res.success) {
  992. var dataPasswod = {
  993. code: "ble/operateUserInfo",
  994. data: {
  995. deviceNum: deviceinfo.deviceNum,
  996. imei: deviceinfo.imei,
  997. userTelephone: info.userTelephone,
  998. userPassword: info.userPassword,
  999. password: fingerprintId,
  1000. userStartTime: info.passwordStartTime,
  1001. userEndTime: info.passwordEndTime,
  1002. passwordStartTime: info.passwordStartTime,
  1003. passwordEndTime: info.passwordEndTime,
  1004. operateMode: 18,
  1005. order: 6218,
  1006. timestamp: timestamp,
  1007. managerTelephone: '18270949468',
  1008. managerPassword: '202108',
  1009. passwordLength: 10,
  1010. permission: 4294967295,
  1011. times: 255,
  1012. recycleTime: "65535",
  1013. roomName: _this.data.deviceinfo.roomName,
  1014. cardName: _this.data.personLi.name,
  1015. }
  1016. }
  1017. var data = {
  1018. ids: [personLi.id]
  1019. }
  1020. wx.hideLoading()
  1021. WXAPI.deleteCertificates(data).then(res1 => {
  1022. if (res1.success) {
  1023. _this.getFp()
  1024. wx.showToast({
  1025. title: '删除成功',
  1026. mask: true,
  1027. icon: 'none',
  1028. duration: 2000
  1029. })
  1030. } else {
  1031. wx.showToast({
  1032. title: '删除失败',
  1033. mask: true,
  1034. icon: 'none',
  1035. duration: 2000
  1036. })
  1037. }
  1038. })
  1039. WXAPI.sendCommand(dataPasswod).then(res1 => {
  1040. console.log(res1, '获取索引')
  1041. if (res1.success) {
  1042. var data4 = {
  1043. result: 1,
  1044. serial: res1.data.serialNumber
  1045. }
  1046. WXAPI.updatePush(data4).then(res4 => {
  1047. })
  1048. } else {
  1049. wx.showToast({
  1050. title: res1.msg,
  1051. mask: true,
  1052. icon: 'none',
  1053. duration: 2000
  1054. })
  1055. }
  1056. })
  1057. } else {
  1058. wx.hideLoading()
  1059. }
  1060. })
  1061. } else {
  1062. wx.hideLoading()
  1063. wx.showToast({
  1064. title: '获取指纹ID失败',
  1065. mask: true,
  1066. duration: 2000,
  1067. icon: 'none'
  1068. })
  1069. }
  1070. })
  1071. },
  1072. delFpLwj(index) {
  1073. console.log("删除指纹");
  1074. wx.showLoading({
  1075. title: '正在删除',
  1076. mask: true
  1077. })
  1078. var cgInfo = this.data.cgInfo
  1079. var personLi = this.data.FpList[index]
  1080. var deviceinfo = this.data.deviceinfo
  1081. var info = JSON.parse(personLi.content)
  1082. var person = this.data.personLi
  1083. var _this = this
  1084. console.log(personLi, "personLi");
  1085. this.getFpIndex(index, function (data) {
  1086. if (data.length > 0) {
  1087. var FPindex = data[0].face
  1088. // 删除
  1089. var dataFP = {
  1090. code: "",
  1091. data: {
  1092. fpIndex: info.index,
  1093. lockerId: deviceinfo.deviceNum,
  1094. imei: deviceinfo.imei,
  1095. lockerUserId: info.userPassword,
  1096. keyId: info.userPassword,
  1097. operateMode: 18,
  1098. order: 6218,
  1099. roomName: deviceinfo.roomName,
  1100. cardName: cardName,
  1101. startTime: passwordStartTime,
  1102. endTime: passwordEndTime,
  1103. action: 2
  1104. }
  1105. }
  1106. } else {
  1107. wx.hideLoading()
  1108. wx.showToast({
  1109. title: '获取指纹ID失败',
  1110. mask: true,
  1111. duration: 2000,
  1112. icon: 'none'
  1113. })
  1114. }
  1115. })
  1116. },
  1117. delFp(index) {
  1118. wx.showLoading({
  1119. title: '正在删除',
  1120. mask: true
  1121. })
  1122. var cgInfo = this.data.cgInfo
  1123. var personLi = this.data.FpList[index]
  1124. var deviceinfo = this.data.deviceinfo
  1125. var info = JSON.parse(personLi.content)
  1126. var personInfo = JSON.parse(this.data.personLi.info)
  1127. var _this = this
  1128. this.getFpIndex(index, function (data) {
  1129. if (data.length > 0) {
  1130. var FPindex = data[0].face
  1131. var dataPasswod = {
  1132. code: "zg/fpOperate",
  1133. data: {
  1134. lockerId: deviceinfo.deviceNum,
  1135. imei: deviceinfo.imei,
  1136. lockerUserId: personInfo.userId,
  1137. keyId: personInfo.userId,
  1138. fingerId: FPindex,
  1139. fingerType: '0',
  1140. startTime: personLi.startTime,
  1141. endTime: personLi.endTime,
  1142. order: 6218,
  1143. action: 2,
  1144. type: 1,
  1145. roomName: _this.data.deviceinfo.roomName,
  1146. cardName: _this.data.personLi.name,
  1147. }
  1148. }
  1149. WXAPI.sendCommand(dataPasswod).then(res => {
  1150. console.log(res, '获取索引')
  1151. if (res.success) {
  1152. var fingerNo = FPindex.toString(16)
  1153. if (fingerNo < 10) {
  1154. fingerNo = '000' + fingerNo
  1155. } else {
  1156. fingerNo = '00' + fingerNo
  1157. }
  1158. ICINLocker.getSignKey(cgInfo.lockerId, cgInfo.superId, cgInfo.superId,
  1159. (callback) => {
  1160. console.log(callback)
  1161. if (callback.status == '00') {
  1162. ICINLocker.getCommonKey(cgInfo.lockerId, cgInfo.superId, cgInfo.superId, callback.signKey, (callback1) => {
  1163. console.log(callback1)
  1164. if (callback1.status == '00') {
  1165. var startTime = personLi.startTime.toString(16).toUpperCase()
  1166. var endTime = personLi.endTime.toString(16).toUpperCase()
  1167. console.log(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, '01', fingerNo, '', callback.signKey, '00', startTime, endTime, callback1.commonKey, '-----')
  1168. ICINLocker.modifyFingerPrints(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, '01', fingerNo, '', callback.signKey, '00', startTime, endTime, callback1.commonKey, (
  1169. callback2) => {
  1170. console.log(callback2)
  1171. if (callback2.status == '00') {
  1172. var datacom = {
  1173. code: "zg/bleSendVoucherReply",
  1174. data: {
  1175. lockerId: deviceinfo.deviceNum,
  1176. serialNumber: res.data.serialNumber,
  1177. index: FPindex,
  1178. type: 18,
  1179. result: 1
  1180. }
  1181. }
  1182. WXAPI.sendCommand(datacom).then(res2 => {
  1183. console.log(res2, '成功----')
  1184. })
  1185. wx.showToast({
  1186. title: '下发成功',
  1187. mask: true,
  1188. icon: 'none',
  1189. duration: 2000
  1190. })
  1191. var data = {
  1192. ids: [personLi.id]
  1193. }
  1194. wx.hideLoading()
  1195. WXAPI.deleteCertificates(data).then(res1 => {
  1196. if (res1.success) {
  1197. _this.getFp()
  1198. wx.showToast({
  1199. title: '删除成功',
  1200. mask: true,
  1201. icon: 'none',
  1202. duration: 2000
  1203. })
  1204. } else {
  1205. wx.showToast({
  1206. title: '删除失败',
  1207. mask: true,
  1208. icon: 'none',
  1209. duration: 2000
  1210. })
  1211. }
  1212. })
  1213. } else {
  1214. wx.hideLoading()
  1215. wx.showToast({
  1216. title: '删除失败',
  1217. mask: true,
  1218. icon: 'none',
  1219. duration: 2000
  1220. })
  1221. var datacom = {
  1222. code: "zg/bleSendVoucherReply",
  1223. data: {
  1224. lockerId: deviceinfo.deviceNum,
  1225. serialNumber: res.data.serialNumber,
  1226. index: FPindex,
  1227. type: 18,
  1228. result: 0
  1229. }
  1230. }
  1231. WXAPI.sendCommand(datacom).then(res2 => {
  1232. console.log(res2, '失败')
  1233. })
  1234. }
  1235. })
  1236. } else {
  1237. wx.hideLoading()
  1238. wx.showToast({
  1239. title: '删除失败',
  1240. mask: true,
  1241. icon: 'none',
  1242. duration: 2000
  1243. })
  1244. var datacom = {
  1245. code: "zg/bleSendVoucherReply",
  1246. data: {
  1247. lockerId: deviceinfo.deviceNum,
  1248. serialNumber: res.data.serialNumber,
  1249. index: FPindex,
  1250. type: 18,
  1251. result: 0
  1252. }
  1253. }
  1254. WXAPI.sendCommand(datacom).then(res2 => {
  1255. console.log(res2, '失败')
  1256. })
  1257. }
  1258. })
  1259. } else {
  1260. wx.hideLoading()
  1261. wx.showToast({
  1262. title: '删除失败',
  1263. mask: true,
  1264. icon: 'none',
  1265. duration: 2000
  1266. })
  1267. var datacom = {
  1268. code: "zg/bleSendVoucherReply",
  1269. data: {
  1270. lockerId: deviceinfo.deviceNum,
  1271. serialNumber: res.data.serialNumber,
  1272. index: FPindex,
  1273. type: 18,
  1274. result: 0
  1275. }
  1276. }
  1277. WXAPI.sendCommand(datacom).then(res2 => {
  1278. console.log(res2, '失败')
  1279. })
  1280. }
  1281. })
  1282. } else {
  1283. var datacom = {
  1284. code: "zg/bleSendVoucherReply",
  1285. data: {
  1286. lockerId: deviceinfo.deviceNum,
  1287. serialNumber: res.data.serialNumber,
  1288. index: FPindex,
  1289. type: 18,
  1290. result: 0
  1291. }
  1292. }
  1293. WXAPI.sendCommand(datacom).then(res2 => {
  1294. console.log(res2, '失败')
  1295. })
  1296. var data = {
  1297. ids: [personLi.id]
  1298. }
  1299. wx.hideLoading()
  1300. WXAPI.deleteCertificates(data).then(res1 => {
  1301. if (res1.success) {
  1302. _this.getFp()
  1303. }
  1304. })
  1305. wx.hideLoading()
  1306. wx.showToast({
  1307. title: res.msg,
  1308. mask: true,
  1309. icon: 'none',
  1310. duration: 2000
  1311. })
  1312. }
  1313. })
  1314. } else {
  1315. wx.hideLoading()
  1316. wx.showToast({
  1317. title: '获取失败',
  1318. mask: true,
  1319. duration: 2000,
  1320. icon: 'none'
  1321. })
  1322. }
  1323. })
  1324. },
  1325. delPassword1(index) {
  1326. wx.showLoading({
  1327. title: '正在删除',
  1328. mask: true
  1329. })
  1330. var _this = this
  1331. var deviceinfo = this.data.deviceinfo
  1332. var passwordLi = this.data.passwordList[index]
  1333. passwordLiAll = passwordLi
  1334. var info = JSON.parse(passwordLi.content)
  1335. var data = {
  1336. managerTelephone: "18270949468",
  1337. managerPassword: "202108",
  1338. userTelephone: info.userTelephone,
  1339. userPassword: info.userPassword,
  1340. password: info.password,
  1341. startTime: info.passwordStartTime,
  1342. endTime: info.passwordEndTime
  1343. }
  1344. console.log(data)
  1345. var timestamp = moment().format("x")
  1346. bleall.startFp1_63(data.managerTelephone, data.managerPassword, data.userTelephone,
  1347. data.userPassword, data.password, data.startTime, data.endTime, 9, timestamp,
  1348. function (res) {
  1349. if (res.success) {
  1350. var data = {
  1351. ids: [passwordLi.id]
  1352. }
  1353. WXAPI.deleteCertificates(data).then(res1 => {
  1354. if (res1.success) {
  1355. var data3 = {
  1356. code: "ble/operateUserInfo",
  1357. data: {
  1358. deviceNum: deviceinfo.deviceNum,
  1359. imei: deviceinfo.imei,
  1360. userTelephone: info.userTelephone,
  1361. userPassword: info.userPassword,
  1362. password: info.password,
  1363. userStartTime: info.passwordStartTime,
  1364. userEndTime: info.passwordEndTime,
  1365. passwordStartTime: info.passwordStartTime,
  1366. passwordEndTime: info.passwordEndTime,
  1367. operateMode: 9,
  1368. order: 6209,
  1369. timestamp: timestamp,
  1370. managerTelephone: '18270949468',
  1371. managerPassword: '202108',
  1372. passwordLength: 10,
  1373. permission: 4294967295,
  1374. times: 255,
  1375. recycleTime: "65535",
  1376. roomName: _this.data.deviceinfo.roomName,
  1377. cardName: _this.data.personLi.name,
  1378. }
  1379. }
  1380. WXAPI.sendCommand(data3).then(res => {
  1381. if (res.success) {
  1382. var data4 = {
  1383. result: 1,
  1384. serial: res.data.serialNumber
  1385. }
  1386. WXAPI.updatePush(data4).then(res4 => {
  1387. })
  1388. }
  1389. })
  1390. _this.getPassword()
  1391. wx.hideLoading()
  1392. wx.showToast({
  1393. title: '删除成功',
  1394. icon: 'none',
  1395. mask: true,
  1396. duration: 2000
  1397. })
  1398. } else {
  1399. wx.hideLoading()
  1400. wx.showToast({
  1401. title: '删除失败',
  1402. icon: 'none',
  1403. mask: true,
  1404. duration: 2000
  1405. })
  1406. }
  1407. })
  1408. }
  1409. if (res.data == "蓝牙功能暂不支持") {
  1410. // wx.hideLoading()
  1411. // wx.showLoading({
  1412. // title: '重新连接蓝牙中'
  1413. // })
  1414. _this.startconnect()
  1415. }
  1416. })
  1417. },
  1418. startconnect() {
  1419. wx.showLoading({
  1420. title: "连接蓝牙中",
  1421. mask: true
  1422. })
  1423. this.setData({
  1424. showLoading: true
  1425. })
  1426. // this.setData({
  1427. // showLoading:true
  1428. // })
  1429. var deviceinfo = this.data.deviceinfo
  1430. const ble = new BLE(this.data.deviceinfo.deviceNum, emitter)
  1431. app.globalData.ble = ble
  1432. this.watchBLE()
  1433. app.globalData.ble.init()
  1434. // }
  1435. },
  1436. watchBLE() {
  1437. var that = this
  1438. if (app.globalData.ble) {
  1439. app.globalData.ble.listen(res => {
  1440. if (res.type == 'connect') {
  1441. if (res.data == "未打开适配器") {
  1442. this.setData({
  1443. showLoading: false
  1444. })
  1445. wx.hideLoading()
  1446. wx.showModal({
  1447. title: "提示",
  1448. content: "请检查手机蓝牙和定位功能是否打开?",
  1449. showCancel: false,
  1450. confirmText: "确定",
  1451. success(res) {}
  1452. });
  1453. } else {
  1454. if (res.data == '蓝牙已连接') {
  1455. app.globalData.bleStatus = res.data
  1456. this.setData({
  1457. showLoading: false
  1458. })
  1459. if (this.data.current == 0) {
  1460. this.sendPassword()
  1461. } else if (that.data.current == 1) {
  1462. this.delPassword1(this.data.currentIndex)
  1463. } else if (that.data.current == 2) {
  1464. this.sendFp()
  1465. }
  1466. }
  1467. }
  1468. }
  1469. })
  1470. }
  1471. },
  1472. delPasswordLwj(index) {
  1473. wx.showLoading({
  1474. title: '正在删除',
  1475. mask: true
  1476. })
  1477. var _this = this
  1478. var deviceinfo = this.data.deviceinfo
  1479. var passwordLi = this.data.passwordList[index]
  1480. passwordLiAll = passwordLi
  1481. var info = JSON.parse(passwordLi.content)
  1482. var personInfo = JSON.parse(this.data.personLi.info)
  1483. var cgInfo = this.data.cgInfo
  1484. var dataPasswod = {
  1485. code: "lwj/passwordOperate",
  1486. data: {
  1487. lockerId: deviceinfo.deviceNum,
  1488. lockerUserId: personInfo.userId,
  1489. startTime: passwordLi.startTime,
  1490. endTime: passwordLi.endTime,
  1491. order: 6209,
  1492. operateMode: 9,
  1493. action: 2,
  1494. password: info.password,
  1495. type: 9,
  1496. cardName: _this.data.personLi.name,
  1497. roomName: deviceinfo.roomName
  1498. }
  1499. }
  1500. console.log(dataPasswod, 'dataPasswod', info)
  1501. WXAPI.sendCommand(dataPasswod).then(res => {
  1502. console.log(res, '获取索引')
  1503. if (res.success) {
  1504. pincodeIndex = res.data.index
  1505. serialNumber = res.data.serialNumber
  1506. taskId = 52
  1507. _this.initBluetooth()
  1508. } else {
  1509. wx.hideLoading()
  1510. wx.showToast({
  1511. title: res.msg,
  1512. mask: true,
  1513. icon: 'none',
  1514. duration: 2000
  1515. })
  1516. }
  1517. })
  1518. },
  1519. onDelRfCard: function () {
  1520. var that = this
  1521. wx.showLoading({
  1522. title: '删除房卡中',
  1523. })
  1524. var bytes = plugin.delRfCard(lockDevice.name, basecode, 0, rfCardIndex)
  1525. console.debug('bytes', bytes)
  1526. that.sendBytes(bytes)
  1527. },
  1528. onDelPincode: function () {
  1529. var that = this
  1530. wx.showLoading({
  1531. title: '删除密码中',
  1532. })
  1533. var bytes = plugin.delPincode(lockDevice.name, basecode, pincode, pincodeIndex)
  1534. console.debug('bytes', bytes)
  1535. that.sendBytes(bytes)
  1536. },
  1537. delPassword(index) {
  1538. wx.showLoading({
  1539. title: '正在删除',
  1540. mask: true
  1541. })
  1542. var _this = this
  1543. var deviceinfo = this.data.deviceinfo
  1544. var passwordLi = this.data.passwordList[index]
  1545. passwordLiAll = passwordLi
  1546. var info = JSON.parse(passwordLi.content)
  1547. var personInfo = JSON.parse(this.data.personLi.info)
  1548. var cgInfo = this.data.cgInfo
  1549. var dataPasswod = {
  1550. code: "zg/tempPassword",
  1551. data: {
  1552. lockerId: deviceinfo.deviceNum,
  1553. imei: deviceinfo.imei,
  1554. passwordCount: 255,
  1555. lockerUserId: personInfo.userId,
  1556. keyId: personInfo.userId,
  1557. passwordStartTime: passwordLi.startTime,
  1558. passwordEndTime: passwordLi.endTime,
  1559. order: 6209,
  1560. action: 2,
  1561. password: info.password,
  1562. type: 1,
  1563. cardName: _this.data.personLi.name,
  1564. roomName: deviceinfo.roomName
  1565. }
  1566. }
  1567. console.log(dataPasswod, 'dataPasswod', info)
  1568. WXAPI.sendCommand(dataPasswod).then(res => {
  1569. console.log(res, '获取索引')
  1570. if (res.success) {
  1571. var pwdNo = res.data.index.toString(16)
  1572. var passwordIndex = res.data.index
  1573. if (pwdNo < 9) {
  1574. pwdNo = '0' + pwdNo
  1575. } else {
  1576. pwdNo = pwdNo
  1577. }
  1578. ICINLocker.getUserSignKey(cgInfo.lockerId, cgInfo.superId, personInfo.userId, cgInfo.superId, cgInfo.authKey, '01', (callback) => {
  1579. console.log(callback)
  1580. if (callback.status == '00') {
  1581. var userSignKey = callback.userSignKey
  1582. ICINLocker.getCommonKey(cgInfo.lockerId, personInfo.userId, personInfo.userId, userSignKey, (callback) => {
  1583. if (callback.status == '00') {
  1584. console.log(callback, 'commonKey')
  1585. var commonKey = callback.commonKey
  1586. var startTime = passwordLi.startTime.toString(16).toUpperCase()
  1587. var endTime = passwordLi.endTime.toString(16).toUpperCase()
  1588. ICINLocker.handlePwd(deviceinfo.deviceNum, cgInfo.superId, personInfo.userId, info.password, pwdNo, cgInfo.superId, cgInfo.authKey, '', startTime, endTime, 0, commonKey, (callback) => {
  1589. console.log(callback)
  1590. if (callback.status == '00') {
  1591. var datacom = {
  1592. code: "zg/bleSendVoucherReply",
  1593. data: {
  1594. lockerId: deviceinfo.deviceNum,
  1595. serialNumber: res.data.serialNumber,
  1596. index: passwordIndex,
  1597. type: 9,
  1598. result: 1
  1599. }
  1600. }
  1601. WXAPI.sendCommand(datacom).then(res2 => {
  1602. if (res2.success) {}
  1603. })
  1604. var data = {
  1605. ids: [passwordLiAll.id]
  1606. }
  1607. WXAPI.deleteCertificates(data).then(res1 => {
  1608. if (res1.success) {
  1609. _this.getPassword()
  1610. wx.hideLoading()
  1611. wx.showToast({
  1612. title: '删除成功',
  1613. mask: true,
  1614. icon: 'none',
  1615. duration: 2000
  1616. })
  1617. } else {
  1618. wx.hideLoading()
  1619. wx.showToast({
  1620. title: '删除失败',
  1621. mask: true,
  1622. icon: 'none',
  1623. duration: 2000
  1624. })
  1625. }
  1626. })
  1627. } else {
  1628. wx.hideLoading()
  1629. wx.showToast({
  1630. title: '删除失败',
  1631. mask: true,
  1632. icon: 'none',
  1633. duration: 2000
  1634. })
  1635. var datacom = {
  1636. code: "zg/bleSendVoucherReply",
  1637. data: {
  1638. lockerId: deviceinfo.deviceNum,
  1639. serialNumber: res.data.serialNumber,
  1640. index: res.data.index,
  1641. type: 9,
  1642. result: 0
  1643. }
  1644. }
  1645. WXAPI.sendCommand(datacom).then(res2 => {
  1646. console.log(res2, '失败')
  1647. })
  1648. }
  1649. })
  1650. } else {
  1651. wx.hideLoading()
  1652. wx.showToast({
  1653. title: '删除失败',
  1654. mask: true,
  1655. icon: 'none',
  1656. duration: 2000
  1657. })
  1658. }
  1659. })
  1660. } else {
  1661. wx.hideLoading()
  1662. wx.showToast({
  1663. title: '删除失败',
  1664. mask: true,
  1665. icon: 'none',
  1666. duration: 2000
  1667. })
  1668. }
  1669. })
  1670. } else {
  1671. wx.hideLoading()
  1672. wx.showToast({
  1673. title: res.msg,
  1674. mask: true,
  1675. icon: 'none',
  1676. duration: 2000
  1677. })
  1678. }
  1679. })
  1680. },
  1681. getPassWordMehods(content, id, type) {
  1682. var that = this
  1683. var data = {
  1684. pageNum: 0,
  1685. pageSize: 0,
  1686. orderBy: "create_at desc",
  1687. q: {
  1688. cardId: id,
  1689. password: content,
  1690. deviceNum: this.data.deviceinfo.deviceNum,
  1691. types: type,
  1692. inStatus: '0,1,702'
  1693. },
  1694. };
  1695. WXAPI.getCertificates(data).then(res => {
  1696. if (res.success) {
  1697. var dataOne = util.zlib_unzip(res.data)
  1698. if (dataOne.length > 0) {
  1699. wx.showModal({
  1700. title: '提示',
  1701. content: '该密码已存在,不能重复添加',
  1702. success(res1) {
  1703. if (res1.confirm) {
  1704. console.log('用户点击确定')
  1705. that.setData({
  1706. password: '',
  1707. passwordStatus: false
  1708. })
  1709. } else if (res1.cancel) {
  1710. console.log('用户点击取消')
  1711. that.setData({
  1712. password: '',
  1713. passwordStatus: false
  1714. })
  1715. }
  1716. }
  1717. })
  1718. } else {
  1719. this.setData({
  1720. passwordStatus: true
  1721. })
  1722. }
  1723. } else {
  1724. wx.showToast({
  1725. title: '获取失败',
  1726. duration: '2000',
  1727. mask: true,
  1728. icon: 'none'
  1729. })
  1730. }
  1731. })
  1732. },
  1733. sendPassword() {
  1734. let passwordLength = this.data.password.toString()
  1735. if (passwordLength.length != 6) {
  1736. wx.showToast({
  1737. title: '格式错误,密码为6位数字!',
  1738. icon: 'none'
  1739. })
  1740. return false;
  1741. }
  1742. wx.showLoading({
  1743. title: '正在添加',
  1744. mask: true,
  1745. })
  1746. var time3 = new Date(this.data.datetimerange[0].replace(/-/g, '/'))
  1747. var time4 = new Date(this.data.datetimerange[1].replace(/-/g, '/'))
  1748. var passwordStartTimecontrast = time3.getTime() / 1000
  1749. var passwordEndTimecontrast = time4.getTime() / 1000
  1750. this.getPassWordMehods(this.data.password, this.data.personLi.cardId, 14)
  1751. if (this.data.password == '') {
  1752. wx.showToast({
  1753. title: '密码不能为空',
  1754. mask: true,
  1755. duration: 2000,
  1756. icon: 'none'
  1757. })
  1758. return
  1759. }
  1760. if (!this.data.passwordStatus) {
  1761. wx.showToast({
  1762. title: '已存在该密码,请重输',
  1763. duration: 2000,
  1764. mask: true,
  1765. icon: 'none'
  1766. })
  1767. return
  1768. }
  1769. if (passwordStartTimecontrast > passwordEndTimecontrast) {
  1770. wx.showToast({
  1771. title: '开始时间不能大于结束时间',
  1772. duration: 2000,
  1773. mask: true,
  1774. icon: 'none'
  1775. })
  1776. return
  1777. }
  1778. wx.showLoading({
  1779. title: '正在添加',
  1780. mask: true
  1781. })
  1782. var _this = this
  1783. var deviceinfo = this.data.deviceinfo
  1784. var info = JSON.parse(this.data.personLi.info)
  1785. if (deviceinfo.manufactureId == 101) {
  1786. var time1 = moment(this.data.datetimerange[0]).format("YYYYMMDDHHmmss")
  1787. var time2 = moment(this.data.datetimerange[1]).format("YYYYMMDDHHmmss")
  1788. var time3 = new Date(_this.data.datetimerange[0].replace(/-/g, '/'))
  1789. var time4 = new Date(_this.data.datetimerange[1].replace(/-/g, '/'))
  1790. var passwordStartTime = time3.getTime() / 1000
  1791. var passwordEndTime = time4.getTime() / 1000
  1792. var data1 = {
  1793. managerTelephone: "18270949468",
  1794. managerPassword: '202108',
  1795. userTelephone: info.userTelephone,
  1796. userPassword: info.userPassword,
  1797. password: this.data.password,
  1798. startTime: time1,
  1799. endTime: time2
  1800. }
  1801. var timestamp = moment().format("x")
  1802. bleall.startFp1_63(data1.managerTelephone, data1.managerPassword, data1.userTelephone,
  1803. data1.userPassword, data1.password, data1.startTime, data1.endTime, 7, timestamp,
  1804. function (res) {
  1805. console.log(res)
  1806. if (res.success) {
  1807. var pzname = '',
  1808. cardName = ''
  1809. pzname = '蓝牙-密码' + (_this.data.passwordList.length + 1)
  1810. cardName = _this.data.personLi.name + '-蓝牙-密码' + (_this.data.passwordList.length + 1)
  1811. var str = {
  1812. // cardId: this.personInfo.cardId,
  1813. pzname: pzname,
  1814. imei: _this.data.deviceinfo.imei,
  1815. password: _this.data.password.toString(),
  1816. userTelephone: JSON.parse(_this.data.personLi.info).userTelephone,
  1817. operateMode: 7,
  1818. userPassword: JSON.parse(_this.data.personLi.info).userPassword,
  1819. passwordStartTime: time1,
  1820. passwordEndTime: time2,
  1821. is: false,
  1822. pass: true
  1823. }
  1824. var data3 = {
  1825. code: "ble/operateUserInfo",
  1826. data: {
  1827. deviceNum: _this.data.deviceinfo.deviceNum,
  1828. imei: _this.data.deviceinfo.imei,
  1829. userTelephone: info.userTelephone,
  1830. userPassword: info.userPassword,
  1831. password: _this.data.password,
  1832. userStartTime: time1,
  1833. userEndTime: time2,
  1834. passwordStartTime: time1,
  1835. passwordEndTime: time2,
  1836. operateMode: 7,
  1837. order: 6207,
  1838. timestamp: timestamp,
  1839. managerTelephone: '18270949468',
  1840. managerPassword: '202108',
  1841. passwordLength: 10,
  1842. permission: 4294967295,
  1843. times: 255,
  1844. recycleTime: "65535",
  1845. roomName: _this.data.deviceinfo.roomName,
  1846. cardName: cardName,
  1847. }
  1848. }
  1849. WXAPI.sendCommand(data3).then(res3 => {
  1850. if (res3.success) {
  1851. var data4 = {
  1852. result: 1,
  1853. serial: res3.data.serialNumber
  1854. }
  1855. WXAPI.updatePush(data4).then(res4 => {
  1856. })
  1857. var data = {
  1858. cardId: _this.data.personLi.cardId,
  1859. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  1860. deviceNum: _this.data.deviceinfo.deviceNum,
  1861. type: 4,
  1862. imei: _this.data.deviceinfo.imei,
  1863. serial: res3.data.serialNumber,
  1864. startTime: passwordStartTime,
  1865. endTime: passwordEndTime,
  1866. };
  1867. var datalist = {
  1868. cardId: _this.data.personLi.cardId,
  1869. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  1870. type: 14,
  1871. startTime: passwordStartTime,
  1872. endTime: passwordEndTime,
  1873. };
  1874. console.log(datalist, '密码11')
  1875. WXAPI.addCertificates(datalist).then(res6 => {
  1876. console.log(datalist, '密码22')
  1877. })
  1878. WXAPI.addCertificates(data).then(res3 => {
  1879. if (res3.success) {
  1880. var updatedata = {
  1881. id: res3.data,
  1882. status: 1
  1883. };
  1884. WXAPI.updateCertificates(updatedata).then((res2) => {});
  1885. _this.getPassword()
  1886. _this.setData({
  1887. show: false
  1888. })
  1889. wx.hideLoading()
  1890. wx.showToast({
  1891. title: '添加成功',
  1892. icon: 'none',
  1893. mask: true,
  1894. duration: 2000
  1895. })
  1896. } else {
  1897. wx.hideLoading()
  1898. wx.showToast({
  1899. title: '添加失败',
  1900. mask: true,
  1901. icon: 'none',
  1902. duration: 2000
  1903. })
  1904. }
  1905. })
  1906. } else {
  1907. wx.showToast({
  1908. title: res3.msg,
  1909. mask: true,
  1910. icon: 'none',
  1911. duration: 2000
  1912. })
  1913. }
  1914. })
  1915. } else {
  1916. wx.hideLoading()
  1917. if (res.data == "蓝牙功能暂不支持") {
  1918. // wx.showToast({
  1919. // title: '重新连接蓝牙中',
  1920. // duration: 2000,
  1921. // icon: "none"
  1922. // })
  1923. _this.startconnect()
  1924. } else {
  1925. wx.showToast({
  1926. title: '下发失败',
  1927. mask: true,
  1928. duration: 2000,
  1929. icon: "none"
  1930. })
  1931. }
  1932. }
  1933. })
  1934. } else if (deviceinfo.manufactureId == 201 || deviceinfo.manufactureId == 221) {
  1935. var cgInfo = this.data.cgInfo
  1936. var time1 = new Date(_this.data.datetimerange[0].replace(/-/g, '/'))
  1937. var time2 = new Date(_this.data.datetimerange[1].replace(/-/g, '/'))
  1938. var passwordStartTime = time1.getTime() / 1000
  1939. var passwordEndTime = time2.getTime() / 1000
  1940. var pzname = '',
  1941. cardName = ''
  1942. pzname = '蓝牙-密码' + (_this.data.passwordList.length + 1)
  1943. cardName = _this.data.personLi.name + '-蓝牙-密码' + (_this.data.passwordList.length + 1)
  1944. var dataPasswod = {
  1945. code: "zg/tempPassword",
  1946. data: {
  1947. lockerId: deviceinfo.deviceNum,
  1948. imei: deviceinfo.imei,
  1949. passwordCount: 255,
  1950. lockerUserId: info.userId,
  1951. keyId: info.userId,
  1952. passwordStartTime: passwordStartTime,
  1953. passwordEndTime: passwordEndTime,
  1954. order: 6207,
  1955. action: 1,
  1956. password: this.data.password.toString(),
  1957. type: 1,
  1958. roomName: this.data.deviceinfo.roomName,
  1959. cardName: cardName,
  1960. }
  1961. }
  1962. WXAPI.sendCommand(dataPasswod).then(res => {
  1963. console.log(res, '获取索引')
  1964. if (res.success) {
  1965. var pwdNo = res.data.index
  1966. var passwordIndex = res.data.index
  1967. // var str = res.data.index
  1968. pwdNo = pwdNo.toString(16)
  1969. if (pwdNo.length < 2) {
  1970. pwdNo = '0' + pwdNo
  1971. }
  1972. var startTime = passwordStartTime.toString(16).toUpperCase()
  1973. var endTime = passwordEndTime.toString(16).toUpperCase()
  1974. info.startTime = startTime
  1975. info.endTime = endTime
  1976. info.pwdNo = pwdNo
  1977. info.password = this.data.password.toString()
  1978. methods.bluetoothOperation_ZH(cgInfo, info, 3).then(result => {
  1979. if (result.status == '00' || result.status == '0a') {
  1980. var datacom = {
  1981. code: "zg/bleSendVoucherReply",
  1982. data: {
  1983. lockerId: deviceinfo.deviceNum,
  1984. serialNumber: res.data.serialNumber,
  1985. index: passwordIndex,
  1986. type: 7,
  1987. result: 1
  1988. }
  1989. }
  1990. var str = {
  1991. // cardId: this.personInfo.cardId,
  1992. imei: _this.data.deviceinfo.imei,
  1993. pzname: pzname,
  1994. password: _this.data.password.toString(),
  1995. userTelephone: JSON.parse(_this.data.personLi.info).userTelephone,
  1996. operateMode: 7,
  1997. userPassword: JSON.parse(_this.data.personLi.info).userPassword,
  1998. passwordStartTime: passwordStartTime,
  1999. passwordEndTime: passwordEndTime,
  2000. is: false,
  2001. pass: true
  2002. }
  2003. var data = {
  2004. cardId: _this.data.personLi.cardId,
  2005. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  2006. deviceNum: _this.data.deviceinfo.deviceNum,
  2007. type: 4,
  2008. imei: _this.data.deviceinfo.imei,
  2009. serial: res.data.serialNumber,
  2010. startTime: passwordStartTime,
  2011. endTime: passwordEndTime,
  2012. };
  2013. var datalist = {
  2014. cardId: _this.data.personLi.cardId,
  2015. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  2016. type: 14,
  2017. startTime: passwordStartTime,
  2018. endTime: passwordEndTime,
  2019. };
  2020. console.log(datalist, '密码11')
  2021. WXAPI.addCertificates(datalist).then(res6 => {
  2022. console.log(datalist, '密码22', res6)
  2023. })
  2024. console.log(data, '添加凭证')
  2025. WXAPI.addCertificates(data).then(res3 => {
  2026. if (res3.success) {
  2027. var updatedata = {
  2028. id: res3.data,
  2029. status: 1
  2030. };
  2031. WXAPI.updateCertificates(updatedata).then((res2) => {});
  2032. WXAPI.sendCommand(datacom).then(res2 => {
  2033. if (res2.success) {}
  2034. })
  2035. console.log(res3, '添加凭证成功')
  2036. _this.getPassword()
  2037. _this.setData({
  2038. show: false
  2039. })
  2040. wx.hideLoading()
  2041. wx.showToast({
  2042. title: '添加成功',
  2043. mask: true,
  2044. icon: 'none',
  2045. duration: 2000
  2046. })
  2047. } else {
  2048. wx.hideLoading()
  2049. wx.showToast({
  2050. title: '添加失败',
  2051. mask: true,
  2052. icon: 'none',
  2053. duration: 2000
  2054. })
  2055. }
  2056. })
  2057. } else {
  2058. wx.showToast({
  2059. title: '添加失败',
  2060. mask: true,
  2061. icon: 'none',
  2062. duration: 2000
  2063. })
  2064. var datacom = {
  2065. code: "zg/bleSendVoucherReply",
  2066. data: {
  2067. lockerId: deviceinfo.deviceNum,
  2068. serialNumber: res.data.serialNumber,
  2069. index: res.data.index,
  2070. type: 7,
  2071. result: 0
  2072. }
  2073. }
  2074. WXAPI.sendCommand(datacom).then(res2 => {
  2075. console.log(res2, '失败')
  2076. _this.setData({
  2077. show: false
  2078. })
  2079. })
  2080. }
  2081. }).catch(err => {
  2082. wx.hideLoading()
  2083. wx.showToast({
  2084. title: '添加失败',
  2085. icon: 'none',
  2086. mask: true,
  2087. duration: 2000
  2088. })
  2089. var datacom = {
  2090. code: "zg/bleSendVoucherReply",
  2091. data: {
  2092. lockerId: deviceinfo.deviceNum,
  2093. serialNumber: res.data.serialNumber,
  2094. index: res.data.index,
  2095. type: 7,
  2096. result: 0
  2097. }
  2098. }
  2099. WXAPI.sendCommand(datacom).then(res2 => {
  2100. console.log(res2, '失败')
  2101. _this.setData({
  2102. show: false
  2103. })
  2104. })
  2105. })
  2106. } else {
  2107. wx.showToast({
  2108. title: res.msg,
  2109. duration: 2000,
  2110. mask: true,
  2111. icon: 'none'
  2112. })
  2113. }
  2114. })
  2115. } else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) {
  2116. console.log(this.data.isSearch);
  2117. if (this.data.isSearch) {
  2118. wx.hideLoading()
  2119. this.addPincode()
  2120. } else {
  2121. this.searchDevicesMethods()
  2122. }
  2123. }
  2124. },
  2125. onAddPincode: function () {
  2126. console.log("2073123");
  2127. var that = this
  2128. wx.showLoading({
  2129. title: '添加密码中',
  2130. })
  2131. var info = JSON.parse(this.data.personLi.info)
  2132. let deviceinfo = this.data.deviceinfo
  2133. var time1 = new Date(that.data.starttime.replace(/-/g, '/'))
  2134. var time2 = new Date(that.data.endtime.replace(/-/g, '/'))
  2135. var passwordStartTime = time1.getTime() / 1000
  2136. var passwordEndTime = time2.getTime() / 1000
  2137. var pzname = '',
  2138. cardName = ''
  2139. pzname = '蓝牙-密码' + (that.data.passwordList.length + 1)
  2140. cardName = that.data.personLi.name + '-蓝牙-密码' + (that.data.passwordList.length + 1)
  2141. var dataPasswod = {
  2142. code: "lwj/passwordOperate",
  2143. data: {
  2144. lockerId: deviceinfo.deviceNum,
  2145. lockerUserId: info.userId,
  2146. startTime: passwordStartTime,
  2147. endTime: passwordEndTime,
  2148. order: 6207,
  2149. operateMode: 7,
  2150. action: 1,
  2151. password: this.data.password.toString(),
  2152. type: 7,
  2153. roomName: this.data.deviceinfo.roomName,
  2154. cardName: cardName,
  2155. }
  2156. }
  2157. console.log(dataPasswod);
  2158. WXAPI.sendCommand(dataPasswod).then(res => {
  2159. console.log(res, '获取索引')
  2160. if (res.success) {
  2161. var pwdNo = res.data.index
  2162. serialNumber = res.data.serialNumber
  2163. pincodeIndex = pwdNo
  2164. that.sendAddPincode()
  2165. }
  2166. })
  2167. // var startTime = util1.getLocalTime(8)
  2168. // var endTime = new Date(startTime.getTime() + 5 * 60 * 1000) //有效期5分钟
  2169. },
  2170. sendAddPincode() {
  2171. var that = this
  2172. var startTime = new Date(Number(moment(that.data.starttime).format('x')))
  2173. var endTime = new Date(Number(moment(that.data.endtime).format('x')))
  2174. pincode = this.data.password
  2175. console.log(lockDevice.name, basecode, pincode, pincodeIndex, startTime, endTime)
  2176. let bytes = plugin.addPincode(lockDevice.name, basecode, pincode, pincodeIndex, startTime, endTime)
  2177. console.log('bytes', bytes)
  2178. that.sendBytes(bytes)
  2179. },
  2180. addPincode: function () {
  2181. console.log("2124");
  2182. var that = this
  2183. taskId = 51
  2184. that.initBluetooth()
  2185. },
  2186. initBluetooth: function () {
  2187. var that = this
  2188. wx.getConnectedBluetoothDevices({
  2189. services: [config.uuid.serviceUuid],
  2190. success: function (res) {
  2191. res.devices.map(function (it) {
  2192. if (it.deviceId == connectedDeviceId || it.name == that.data.deviceinfo.deviceNum) {
  2193. isConnected = true
  2194. }
  2195. })
  2196. that.setData({
  2197. isConnected: isConnected
  2198. })
  2199. console.log(isInitReady, 'isConnected', isConnected)
  2200. if (isConnected) {
  2201. console.log("2144");
  2202. if (isInitReady) {
  2203. console.log("2146");
  2204. that.doWork()
  2205. } else {
  2206. that.setupConnection()
  2207. }
  2208. } else {
  2209. that.connectTo()
  2210. }
  2211. },
  2212. })
  2213. },
  2214. setupConnection: function () {
  2215. var that = this
  2216. wx.showLoading({
  2217. title: '初始化连接中',
  2218. })
  2219. wx.getBLEDeviceServices({
  2220. deviceId: lockDevice.deviceId,
  2221. success: function (res) {
  2222. console.log('Services', res)
  2223. wx.getBLEDeviceCharacteristics({
  2224. deviceId: lockDevice.deviceId,
  2225. serviceId: config.uuid.serviceUuid.toUpperCase(),
  2226. success: function (res) {
  2227. console.log('Characteristics', res)
  2228. wx.showToast({
  2229. title: '连接成功',
  2230. duration: 1000,
  2231. icon: 'none'
  2232. })
  2233. wx.onBLECharacteristicValueChange(function (res) {
  2234. console.log(res, 'reslllllll')
  2235. var bytes = new Uint8Array(res.value)
  2236. console.log('bytes', bytes)
  2237. var data = plugin.parseBytes(lockDevice.name, basecode, bytes)
  2238. console.log('data', data)
  2239. switch (data.cmd) {
  2240. case 'reportLockBattery': {
  2241. if (data.data.battery < 10) {
  2242. wx.showModal({
  2243. title: '电量报警',
  2244. content: `门锁当前电量${data.data.battery}%!\n电量严重不足,请立即更换电池!`,
  2245. showCancel: false
  2246. })
  2247. } else if (data.data.battery < 30) {
  2248. wx.showModal({
  2249. title: '电量预警',
  2250. content: `门锁当前电量${data.data.battery}%!\n请及时更换电池!`,
  2251. showCancel: false
  2252. })
  2253. }
  2254. break
  2255. }
  2256. case 'reportRfCardResult': {
  2257. if (taskId == 61) {
  2258. wx.showModal({
  2259. title: '检测到新卡',
  2260. content: `是否添加此房卡,卡号:${data.data.cardId}`,
  2261. success: function (res) {
  2262. if (res.confirm) {
  2263. console.log(data.data, 'rfCardIdrfCardId')
  2264. // rfCardId = randomMethods()//data.data.cardId
  2265. that.onAddRfCard()
  2266. }
  2267. }
  2268. })
  2269. } else {
  2270. if (lockModel > 70) {
  2271. if (data.data.isValid) {
  2272. wx.showModal({
  2273. title: '提示',
  2274. content: `房卡开锁成功,序号:${data.data.index}`,
  2275. showCancel: false
  2276. })
  2277. } else {
  2278. wx.showModal({
  2279. title: '提示',
  2280. content: `多次刷房卡开锁失败!`,
  2281. showCancel: false
  2282. })
  2283. }
  2284. } else {
  2285. if (data.data.isValid) {
  2286. wx.showModal({
  2287. title: '提示',
  2288. content: `房卡开锁成功,卡号:${data.data.cardId}`,
  2289. showCancel: false
  2290. })
  2291. } else {
  2292. wx.showModal({
  2293. title: '提示',
  2294. content: `房卡未授权,卡号:${data.data.cardId}`,
  2295. showCancel: false
  2296. })
  2297. }
  2298. }
  2299. }
  2300. break
  2301. }
  2302. case 'reportPincodeResult': {
  2303. if (lockModel > 70) {
  2304. if (data.data.isValid) {
  2305. wx.showModal({
  2306. title: '提示',
  2307. content: `密码开锁成功,序号:${data.data.index}`,
  2308. showCancel: false
  2309. })
  2310. } else {
  2311. wx.showModal({
  2312. title: '提示',
  2313. content: `多次密码开锁失败!`,
  2314. showCancel: false
  2315. })
  2316. }
  2317. } else {
  2318. if (data.data.isValid) {
  2319. wx.showModal({
  2320. title: '提示',
  2321. content: `密码:${data.data.pincode}开锁成功!`,
  2322. showCancel: false
  2323. })
  2324. } else {
  2325. wx.showModal({
  2326. title: '提示',
  2327. content: `密码:${data.data.pincode}未授权!`,
  2328. showCancel: false
  2329. })
  2330. }
  2331. }
  2332. break
  2333. }
  2334. case 'reportFingerprintResult': {
  2335. if (data.data.isValid) {
  2336. wx.showModal({
  2337. title: '提示',
  2338. content: `指纹开锁成功,序号:${data.data.index}`,
  2339. showCancel: false
  2340. })
  2341. } else {
  2342. wx.showModal({
  2343. title: '提示',
  2344. content: `多次指纹开锁失败!`,
  2345. showCancel: false
  2346. })
  2347. }
  2348. break
  2349. }
  2350. case 'queryLockState': {
  2351. wx.hideLoading()
  2352. if (data.code != 200) {
  2353. wx.showModal({
  2354. title: '提示',
  2355. content: '查询失败!',
  2356. showCancel: false,
  2357. success: function (res) {}
  2358. })
  2359. break
  2360. }
  2361. that.setData({
  2362. lock: {
  2363. mac: data.data.mac,
  2364. lockType: util1.getLockType(lockModel),
  2365. },
  2366. isBindLock: data.data.isBind
  2367. })
  2368. lockMac = data.data.mac
  2369. if (taskId > 0) {
  2370. if (data.data.isBind) {
  2371. // wx.showModal({
  2372. // title: data.data.mac,
  2373. // content: '此设备已经硬件绑定!',
  2374. // showCancel: false,
  2375. // success: function (res) {}
  2376. // })
  2377. } else {
  2378. wx.showModal({
  2379. title: data.data.mac,
  2380. content: '此设备硬件未绑定!',
  2381. showCancel: false,
  2382. success: function (res) {}
  2383. })
  2384. }
  2385. }
  2386. taskId = 0
  2387. break
  2388. }
  2389. case 'queryLockBattery': {
  2390. wx.hideLoading()
  2391. if (data.code != 200) {
  2392. wx.showModal({
  2393. title: '提示',
  2394. content: '查询失败!',
  2395. showCancel: false,
  2396. success: function (res) {}
  2397. })
  2398. break
  2399. }
  2400. taskId = 0
  2401. wx.showModal({
  2402. title: '提示',
  2403. content: `此门锁电量为${data.data.battery}%`,
  2404. showCancel: false,
  2405. success: function (res) {}
  2406. })
  2407. break
  2408. }
  2409. case 'queryNbImei': {
  2410. wx.hideLoading()
  2411. if (data.code != 200) {
  2412. wx.showModal({
  2413. title: '提示',
  2414. content: '查询失败!',
  2415. showCancel: false,
  2416. success: function (res) {}
  2417. })
  2418. break
  2419. }
  2420. taskId = 0
  2421. wx.showModal({
  2422. title: '提示',
  2423. content: `此NB设备IMEI为${data.data.imei}`,
  2424. showCancel: false,
  2425. success: function (res) {}
  2426. })
  2427. break
  2428. }
  2429. case 'setNbFun': {
  2430. wx.hideLoading()
  2431. if (data.code != 200) {
  2432. wx.showModal({
  2433. title: '提示',
  2434. content: '设置Nb功能失败!',
  2435. showCancel: false,
  2436. success: function (res) {}
  2437. })
  2438. break
  2439. }
  2440. taskId = 0
  2441. wx.showModal({
  2442. title: '提示',
  2443. content: that.data.isNbEnable ? 'NB功能已禁用' : 'NB功能已打开',
  2444. showCancel: false,
  2445. })
  2446. that.setData({
  2447. isNbEnable: !that.data.isNbEnable
  2448. })
  2449. break
  2450. }
  2451. case 'sendBindLock': {
  2452. wx.hideLoading()
  2453. if (data.code != 200) {
  2454. wx.showModal({
  2455. title: '提示',
  2456. content: '绑定失败!',
  2457. showCancel: false,
  2458. success: function (res) {}
  2459. })
  2460. break
  2461. }
  2462. taskId = 0
  2463. that.setData({
  2464. isBindLock: data.data.isBind
  2465. })
  2466. if (data.data.isBind) {
  2467. wx.showToast({
  2468. title: '绑定成功!',
  2469. })
  2470. } else {
  2471. wx.showToast({
  2472. title: '绑定失败!',
  2473. })
  2474. }
  2475. break
  2476. }
  2477. case 'sendUnbindLock': {
  2478. wx.hideLoading()
  2479. if (data.code != 200) {
  2480. wx.showModal({
  2481. title: '提示',
  2482. content: '解绑失败!',
  2483. showCancel: false,
  2484. success: function (res) {}
  2485. })
  2486. break
  2487. }
  2488. taskId = 0
  2489. that.setData({
  2490. isBindLock: data.data.isBind
  2491. })
  2492. if (data.data.isBind) {
  2493. wx.showToast({
  2494. title: '解绑失败!',
  2495. })
  2496. } else {
  2497. wx.showToast({
  2498. title: '解绑成功!',
  2499. })
  2500. }
  2501. break
  2502. }
  2503. case 'login1':
  2504. case 'sendOpenLockP1': {
  2505. if (data.code != 200) {
  2506. wx.hideLoading()
  2507. if (taskId == 41) {
  2508. wx.showModal({
  2509. title: '提示',
  2510. content: that.data.isJack ? '上电失败!' : '解锁失败!',
  2511. showCancel: false,
  2512. success: function (res) {}
  2513. })
  2514. } else if (taskId == 32) {
  2515. wx.showModal({
  2516. title: '提示',
  2517. content: '登录失败!',
  2518. showCancel: false,
  2519. success: function (res) {}
  2520. })
  2521. }
  2522. break
  2523. }
  2524. if (taskId == 41) {
  2525. var bytes = plugin.sendOpenLockP2(lockDevice.name, basecode, data.data.randomN)
  2526. console.debug('bytes', bytes)
  2527. that.sendBytes(bytes)
  2528. } else if (taskId == 32) {
  2529. var bytes = plugin.login2(lockDevice.name, basecode, data.data.randomN)
  2530. console.debug('bytes', bytes)
  2531. that.sendBytes(bytes)
  2532. }
  2533. break;
  2534. }
  2535. case 'login':
  2536. case 'sendOpenLockP2': {
  2537. wx.hideLoading()
  2538. if (data.code != 200) {
  2539. if (taskId == 41) {
  2540. wx.showModal({
  2541. title: '提示',
  2542. content: that.data.isJack ? '上电失败!' : '解锁失败!',
  2543. showCancel: false,
  2544. success: function (res) {}
  2545. })
  2546. } else if (taskId == 32) {
  2547. wx.showModal({
  2548. title: '提示',
  2549. content: '登录失败!',
  2550. showCancel: false,
  2551. success: function (res) {}
  2552. })
  2553. }
  2554. break
  2555. }
  2556. isLockLogin = true
  2557. if (taskId == 41) {
  2558. // var data = {
  2559. // code: "zg/bleUnlockRecord",
  2560. // data: {
  2561. // lockerId: that.data.deviceinfo.deviceNum,
  2562. // roomId:that.data.deviceinfo.roomId,
  2563. // roomName:that.data.deviceinfo.roomName,
  2564. // cardName:that.data.userInfo.username
  2565. // }
  2566. // }
  2567. var data = {
  2568. code: "ble/bleUnlockRecord",
  2569. data: {
  2570. deviceNum: that.data.deviceinfo.deviceNum,
  2571. roomId: that.data.deviceinfo.roomId,
  2572. roomName: that.data.deviceinfo.roomName,
  2573. cardName: that.data.userInfo.username,
  2574. productId: that.data.deviceinfo.manufactureId,
  2575. userId: '29283991'
  2576. }
  2577. }
  2578. WXAPI.sendCommand(data).then(res => {
  2579. console.log(res)
  2580. })
  2581. wx.showToast({
  2582. title: that.data.isJack ? '上电成功!' : '解锁成功!',
  2583. })
  2584. } else if (taskId == 32) {
  2585. wx.showToast({
  2586. title: '登录成功!',
  2587. })
  2588. }
  2589. taskId = 0
  2590. break;
  2591. }
  2592. case 'syncClock': {
  2593. wx.hideLoading()
  2594. if (data.code != 200) {
  2595. wx.showModal({
  2596. title: '提示',
  2597. content: '同步时间失败!' + data.data.msg,
  2598. showCancel: false,
  2599. success: function (res) {}
  2600. })
  2601. break
  2602. }
  2603. taskId = 0
  2604. wx.showModal({
  2605. title: '提示',
  2606. content: '时间更新成功!',
  2607. showCancel: false
  2608. })
  2609. break;
  2610. }
  2611. case 'addPincode': {
  2612. // console.log(data.data,'data.data')
  2613. // wx.hideLoading()
  2614. let data2 = {
  2615. "code": "ble/bleSendVoucherReply",
  2616. "data": {
  2617. "deviceNum": that.data.deviceinfo.deviceNum,
  2618. "serialNumber": serialNumber,
  2619. "index": pincodeIndex,
  2620. "type": 7,
  2621. "result": 1,
  2622. "productId": that.data.deviceinfo.manufactureId
  2623. }
  2624. }
  2625. if (data.code != 200) {
  2626. data2 = {
  2627. "code": "ble/bleSendVoucherReply",
  2628. "data": {
  2629. "deviceNum": that.data.deviceinfo.deviceNum,
  2630. "serialNumber": serialNumber,
  2631. "index": pincodeIndex,
  2632. "type": 7,
  2633. "result": 0,
  2634. "productId": that.data.deviceinfo.manufactureId
  2635. }
  2636. }
  2637. WXAPI.sendCommand(data2).then(res => {
  2638. })
  2639. wx.showModal({
  2640. title: '提示',
  2641. content: '添加密码失败!' + data.data.msg,
  2642. showCancel: false,
  2643. success: function (res) {}
  2644. })
  2645. break
  2646. }
  2647. var time1 = new Date(that.data.starttime.replace(/-/g, '/'))
  2648. var time2 = new Date(that.data.endtime.replace(/-/g, '/'))
  2649. var passwordStartTime = time1.getTime() / 1000
  2650. var passwordEndTime = time2.getTime() / 1000
  2651. var pzname = '',
  2652. cardName = '';
  2653. pzname = '蓝牙-密码' + (that.data.passwordList.length + 1)
  2654. cardName = that.data.personLi.name + '-蓝牙-密码' + (that.data.passwordList.length + 1)
  2655. var str = {
  2656. // cardId: this.personInfo.cardId,
  2657. imei: that.data.deviceinfo.imei,
  2658. pzname: pzname,
  2659. password: that.data.password.toString(),
  2660. userTelephone: JSON.parse(that.data.personLi.info).userTelephone,
  2661. operateMode: 7,
  2662. userPassword: JSON.parse(that.data.personLi.info).userPassword,
  2663. passwordStartTime: passwordStartTime,
  2664. passwordEndTime: passwordEndTime,
  2665. index: pincodeIndex,
  2666. is: false,
  2667. pass: true
  2668. }
  2669. var data1 = {
  2670. cardId: that.data.personLi.cardId,
  2671. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  2672. deviceNum: that.data.deviceinfo.deviceNum,
  2673. type: 4,
  2674. imei: that.data.deviceinfo.imei,
  2675. serial: serialNumber,
  2676. startTime: passwordStartTime,
  2677. endTime: passwordEndTime,
  2678. };
  2679. var datalist = {
  2680. cardId: that.data.personLi.cardId,
  2681. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  2682. type: 14,
  2683. startTime: passwordStartTime,
  2684. endTime: passwordEndTime,
  2685. };
  2686. WXAPI.addCertificates(datalist).then(res6 => {
  2687. console.log(datalist, '密码22', res6)
  2688. })
  2689. WXAPI.addCertificates(data1).then(res3 => {
  2690. if (res3.success) {
  2691. var updatedata = {
  2692. id: res3.data,
  2693. status: 1
  2694. };
  2695. WXAPI.updateCertificates(updatedata).then((res2) => {});
  2696. WXAPI.sendCommand(data2).then(res => {
  2697. })
  2698. that.getPassword()
  2699. that.setData({
  2700. show: false
  2701. })
  2702. wx.hideLoading()
  2703. wx.showToast({
  2704. title: '添加成功',
  2705. mask: true,
  2706. icon: 'none',
  2707. duration: 2000
  2708. })
  2709. } else {
  2710. wx.hideLoading()
  2711. wx.showToast({
  2712. title: '添加失败',
  2713. mask: true,
  2714. icon: 'none',
  2715. duration: 2000
  2716. })
  2717. }
  2718. })
  2719. taskId = 0
  2720. that.setData({
  2721. isPincodeAdd: true,
  2722. show: false
  2723. })
  2724. wx.showModal({
  2725. title: '提示',
  2726. content: `添加密码${pincode}成功!`,
  2727. showCancel: false
  2728. })
  2729. break
  2730. }
  2731. case 'delPincode': {
  2732. wx.hideLoading()
  2733. if (data.code != 200) {
  2734. var datacom = {
  2735. code: "lwj/passwordOperate",
  2736. data: {
  2737. lockerId: that.data.deviceinfo.deviceNum,
  2738. serialNumber: serialNumber,
  2739. index: pincodeIndex,
  2740. action: 2,
  2741. type: 9,
  2742. result: 0
  2743. }
  2744. }
  2745. WXAPI.sendCommand(datacom).then(res2 => {
  2746. console.log(res2, '失败')
  2747. })
  2748. wx.showModal({
  2749. title: '提示',
  2750. content: '删除密码失败!',
  2751. showCancel: false,
  2752. success: function (res) {}
  2753. })
  2754. break
  2755. }
  2756. taskId = 0
  2757. wx.showModal({
  2758. title: '提示',
  2759. content: `删除密码成功!`,
  2760. showCancel: false,
  2761. })
  2762. var datacom = {
  2763. code: "lwj/passwordOperate",
  2764. data: {
  2765. lockerId: that.data.deviceinfo.deviceNum,
  2766. serialNumber: serialNumber,
  2767. index: pincodeIndex,
  2768. action: 2,
  2769. type: 9,
  2770. result: 1
  2771. }
  2772. }
  2773. WXAPI.sendCommand(datacom).then(res2 => {
  2774. if (res2.success) {}
  2775. })
  2776. var data = {
  2777. ids: [passwordLiAll.id]
  2778. }
  2779. WXAPI.deleteCertificates(data).then(res1 => {
  2780. if (res1.success) {
  2781. that.getPassword()
  2782. wx.hideLoading()
  2783. wx.showToast({
  2784. title: '删除成功',
  2785. mask: true,
  2786. icon: 'none',
  2787. duration: 2000
  2788. })
  2789. } else {
  2790. wx.hideLoading()
  2791. wx.showToast({
  2792. title: '删除失败',
  2793. mask: true,
  2794. icon: 'none',
  2795. duration: 2000
  2796. })
  2797. }
  2798. })
  2799. that.setData({
  2800. isPincodeAdd: false
  2801. })
  2802. pincode = -1
  2803. pincodeIndex = -1
  2804. break
  2805. }
  2806. case 'addRfCard': {
  2807. wx.hideLoading()
  2808. if (data.code == 100) {
  2809. wx.showLoading({
  2810. title: data.data.msg,
  2811. })
  2812. break
  2813. } else if (data.code != 200) {
  2814. var datacom = {
  2815. code: "ble/bleSendVoucherReply",
  2816. data: {
  2817. deviceNum: that.data.deviceinfo.deviceNum,
  2818. serialNumber: serialNumber,
  2819. index: rfCardIndex,
  2820. type: ADD_NFC_MODE,
  2821. cardNo: '',
  2822. result: 0,
  2823. productId: that.data.deviceinfo.manufactureId
  2824. }
  2825. }
  2826. WXAPI.sendCommand(datacom).then(res2 => {})
  2827. wx.showModal({
  2828. title: '提示',
  2829. content: '添加房卡失败!' + data.data.msg,
  2830. showCancel: false,
  2831. success: function (res) {}
  2832. })
  2833. break
  2834. }
  2835. taskId = 0
  2836. that.setData({
  2837. isRfCardAdd: true
  2838. })
  2839. if (lockModel > 70) {
  2840. console.log(data.data, 'rfCardIndexrfCardIndex')
  2841. // rfCardId = randomMethods()
  2842. wx.showModal({
  2843. title: '提示',
  2844. content: `添加房卡成功,序号${rfCardIndex}`,
  2845. showCancel: false
  2846. })
  2847. that.addRfcardCertificates()
  2848. } else {
  2849. console.log(data.data, 'rfCardIndexrfCardIndex1')
  2850. // rfCardId = randomMethods()
  2851. wx.showModal({
  2852. title: '提示',
  2853. content: `添加房卡成功,卡号${rfCardId}`,
  2854. showCancel: false
  2855. })
  2856. that.addRfcardCertificates()
  2857. }
  2858. break
  2859. }
  2860. case 'delRfCard': {
  2861. wx.hideLoading()
  2862. if (data.code != 200) {
  2863. var datacom = {
  2864. code: "lwj/c",
  2865. data: {
  2866. lockerId: that.data.deviceinfo.deviceNum,
  2867. serialNumber: serialNumber,
  2868. index: rfCardIndex,
  2869. action: 2,
  2870. type: 12,
  2871. result: 0
  2872. }
  2873. }
  2874. WXAPI.sendCommand(datacom).then(res2 => {
  2875. console.log(res2, '失败')
  2876. })
  2877. wx.showModal({
  2878. title: '提示',
  2879. content: '删除房卡失败!',
  2880. showCancel: false,
  2881. success: function (res) {}
  2882. })
  2883. break
  2884. }
  2885. taskId = 0
  2886. that.setData({
  2887. isRfCardAdd: false
  2888. })
  2889. if (lockModel > 70) {
  2890. wx.showModal({
  2891. title: '提示',
  2892. content: `删除房卡成功,序号${rfCardIndex}`,
  2893. showCancel: false,
  2894. })
  2895. } else {
  2896. wx.showModal({
  2897. title: '提示',
  2898. content: `删除房卡成功,卡号${rfCardId}`,
  2899. showCancel: false,
  2900. })
  2901. }
  2902. var datacom = {
  2903. code: "lwj/c",
  2904. data: {
  2905. lockerId: that.data.deviceinfo.deviceNum,
  2906. serialNumber: serialNumber,
  2907. index: rfCardIndex,
  2908. action: 2,
  2909. type: 12,
  2910. result: 1
  2911. }
  2912. }
  2913. WXAPI.sendCommand(datacom).then(res2 => {
  2914. console.log(res2, '失败')
  2915. })
  2916. var data = {
  2917. ids: [passwordLiAll.id]
  2918. }
  2919. WXAPI.deleteCertificates(data).then(res1 => {
  2920. console.log(res1, '2936');
  2921. if (res1.success) {
  2922. that.getNfc()
  2923. wx.showToast({
  2924. title: '删除成功',
  2925. mask: true,
  2926. icon: 'none',
  2927. duration: 2000
  2928. })
  2929. } else {
  2930. wx.showToast({
  2931. title: '删除失败',
  2932. mask: true,
  2933. icon: 'none',
  2934. duration: 2000
  2935. })
  2936. }
  2937. })
  2938. rfCardId = -1
  2939. rfCardIndex = -1
  2940. break
  2941. }
  2942. case 'addFingerprint': {
  2943. wx.hideLoading()
  2944. if (data.code == 100) {
  2945. wx.showLoading({
  2946. title: data.data.msg,
  2947. })
  2948. break
  2949. } else if (data.code != 200) {
  2950. wx.showModal({
  2951. title: '提示',
  2952. content: '添加指纹失败!' + data.data.msg,
  2953. showCancel: false,
  2954. success: function (res) {}
  2955. })
  2956. var datacom = {
  2957. code: "ble/bleSendVoucherReply",
  2958. data: {
  2959. deviceNum: that.data.deviceinfo.deviceNum,
  2960. serialNumber: serialNumber,
  2961. index: 0,
  2962. type: 16,
  2963. result: 0,
  2964. productId: that.data.deviceinfo.manufactureId
  2965. }
  2966. }
  2967. WXAPI.sendCommand(datacom).then(res2 => {
  2968. if (res2.success) {}
  2969. })
  2970. break
  2971. }
  2972. taskId = 0
  2973. that.setData({
  2974. isFingerprintAdd: true
  2975. })
  2976. wx.showModal({
  2977. title: '提示',
  2978. content: `添加指纹成功,序号${fingerprintIndex}`,
  2979. showCancel: false
  2980. })
  2981. var time1 = new Date(that.data.starttime.replace(/-/g, '/'))
  2982. var time2 = new Date(that.data.endtime.replace(/-/g, '/'))
  2983. var passwordStartTime = time1.getTime() / 1000
  2984. var passwordEndTime = time2.getTime() / 1000
  2985. var cardName = '',
  2986. pzname = ''
  2987. if (that.data.pzname) {
  2988. cardName = that.data.personLi.name + '-蓝牙-' + that.data.pzname
  2989. pzname = '蓝牙-' + that.data.pzname
  2990. } else {
  2991. cardName = that.data.personLi.name + '-蓝牙-指纹' + (that.data.FpList.length + 1)
  2992. pzname = '蓝牙-指纹' + (that.data.FpList.length + 1)
  2993. }
  2994. var str = {
  2995. // cardId: this.personInfo.cardId,
  2996. imei: that.data.deviceinfo.imei,
  2997. pzname: pzname,
  2998. password: '',
  2999. fingerprintAlias: that.data.radioDetil,
  3000. userTelephone: JSON.parse(that.data.personLi.info).userTelephone,
  3001. operateMode: 16,
  3002. userPassword: JSON.parse(that.data.personLi.info).userPassword,
  3003. passwordStartTime: passwordStartTime,
  3004. passwordEndTime: passwordEndTime,
  3005. index: fingerprintIndex,
  3006. is: false,
  3007. pass: true
  3008. }
  3009. var data2 = {
  3010. cardId: that.data.personLi.cardId,
  3011. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  3012. deviceNum: that.data.deviceinfo.deviceNum,
  3013. type: 1,
  3014. imei: that.data.deviceinfo.imei,
  3015. serial: serialNumber,
  3016. startTime: passwordStartTime,
  3017. endTime: passwordEndTime,
  3018. status: 1
  3019. };
  3020. var datalist = {
  3021. cardId: that.data.personLi.cardId,
  3022. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  3023. type: 11,
  3024. startTime: passwordStartTime,
  3025. endTime: passwordEndTime
  3026. };
  3027. var datacom = {
  3028. code: "ble/bleSendVoucherReply",
  3029. data: {
  3030. deviceNum: that.data.deviceinfo.deviceNum,
  3031. serialNumber: serialNumber,
  3032. index: fingerprintIndex,
  3033. type: 16,
  3034. result: 1,
  3035. productId: that.data.deviceinfo.manufactureId
  3036. }
  3037. }
  3038. WXAPI.addCertificates(datalist).then(res6 => {})
  3039. console.log(data, '添加凭证')
  3040. WXAPI.addCertificates(data2).then(res3 => {
  3041. if (res3.success) {
  3042. var updatedata = {
  3043. id: res3.data,
  3044. status: 1
  3045. };
  3046. WXAPI.updateCertificates(updatedata).then((res2) => {});
  3047. WXAPI.sendCommand(datacom).then(res2 => {
  3048. if (res2.success) {}
  3049. })
  3050. console.log(res3, '添加凭证成功')
  3051. that.getFp()
  3052. that.setData({
  3053. show: false
  3054. })
  3055. wx.hideLoading()
  3056. wx.showToast({
  3057. title: '添加成功',
  3058. mask: true,
  3059. icon: 'none',
  3060. duration: 2000
  3061. })
  3062. } else {
  3063. wx.hideLoading()
  3064. wx.showToast({
  3065. title: '添加失败',
  3066. mask: true,
  3067. icon: 'none',
  3068. duration: 2000
  3069. })
  3070. }
  3071. })
  3072. break
  3073. }
  3074. case 'delFingerprint': {
  3075. wx.hideLoading()
  3076. if (data.code != 200) {
  3077. wx.showModal({
  3078. title: '提示',
  3079. content: '删除指纹失败!',
  3080. showCancel: false,
  3081. success: function (res) {}
  3082. })
  3083. break
  3084. }
  3085. taskId = 0
  3086. wx.showModal({
  3087. title: '提示',
  3088. content: `删除指纹成功,序号${fingerprintIndex}`,
  3089. showCancel: false,
  3090. })
  3091. that.setData({
  3092. isFingerprintAdd: false
  3093. })
  3094. fingerprintIndex = -1
  3095. break
  3096. }
  3097. case 'changeAdminPincode': {
  3098. wx.hideLoading()
  3099. if (data.code != 200) {
  3100. wx.showModal({
  3101. title: '提示',
  3102. content: '修改管理密码失败!',
  3103. showCancel: false,
  3104. success: function (res) {}
  3105. })
  3106. break
  3107. }
  3108. taskId = 0
  3109. wx.showToast({
  3110. title: '修改管理密码成功!',
  3111. })
  3112. }
  3113. case 'queryLockSlotState': {
  3114. wx.hideLoading()
  3115. if (data.code != 200) {
  3116. wx.showModal({
  3117. title: '提示',
  3118. content: '查询失败!',
  3119. showCancel: false,
  3120. success: function (res) {}
  3121. })
  3122. break
  3123. }
  3124. taskId = 0
  3125. wx.showModal({
  3126. title: '提示',
  3127. content: data.data.state == 0 ? '此门锁方舌关闭' : '此门锁方舌打开',
  3128. showCancel: false,
  3129. success: function (res) {}
  3130. })
  3131. break
  3132. }
  3133. case 'queryLockUnlockState': {
  3134. wx.hideLoading()
  3135. if (data.code != 200) {
  3136. wx.showModal({
  3137. title: '提示',
  3138. content: '查询失败!',
  3139. showCancel: false,
  3140. success: function (res) {}
  3141. })
  3142. break
  3143. }
  3144. taskId = 0
  3145. wx.showModal({
  3146. title: '提示',
  3147. content: data.data.state == 0 ? '此门锁已关闭' : '此门锁已打开',
  3148. showCancel: false,
  3149. success: function (res) {}
  3150. })
  3151. break
  3152. }
  3153. case 'setLockUnlockState': {
  3154. wx.hideLoading()
  3155. if (data.code != 200) {
  3156. wx.showModal({
  3157. title: '提示',
  3158. content: '设置常开指令失败!',
  3159. showCancel: false,
  3160. success: function (res) {}
  3161. })
  3162. break
  3163. }
  3164. taskId = 0
  3165. wx.showModal({
  3166. title: '提示',
  3167. content: data.data.state == 0 ? '常开模式已退出' : '常开模式已开启',
  3168. showCancel: false,
  3169. })
  3170. that.setData({
  3171. isUnloked: data.data.state == 1
  3172. })
  3173. break
  3174. }
  3175. case 'setLockMuteState': {
  3176. wx.hideLoading()
  3177. if (data.code != 200) {
  3178. wx.showModal({
  3179. title: '提示',
  3180. content: '设置静音指令失败!',
  3181. showCancel: false,
  3182. success: function (res) {}
  3183. })
  3184. break
  3185. }
  3186. taskId = 0
  3187. wx.showModal({
  3188. title: '提示',
  3189. content: data.data.state == 1 ? '静音模式已退出' : '静音模式已开启',
  3190. showCancel: false,
  3191. })
  3192. that.setData({
  3193. isMuted: data.data.state == 0
  3194. })
  3195. break
  3196. }
  3197. }
  3198. })
  3199. wx.notifyBLECharacteristicValueChange({
  3200. deviceId: lockDevice.deviceId,
  3201. serviceId: config.uuid.serviceUuid.toUpperCase(),
  3202. characteristicId: config.uuid.notifyUuid.toUpperCase(),
  3203. state: true,
  3204. success: function (res) {
  3205. console.log('setupNotify', res)
  3206. isInitReady = true
  3207. setTimeout(function () {
  3208. wx.hideLoading()
  3209. // that.onQueryBindState()
  3210. that.login()
  3211. }, 500)
  3212. },
  3213. })
  3214. },
  3215. })
  3216. },
  3217. })
  3218. },
  3219. onQueryBindState: function () {
  3220. var that = this
  3221. wx.showLoading({
  3222. title: '查询中',
  3223. })
  3224. var bytes = plugin.queryLockState(lockDevice.name)
  3225. console.debug('bytes', bytes)
  3226. that.sendBytes(bytes)
  3227. },
  3228. queryBindState: function () {
  3229. var that = this
  3230. taskId = 21
  3231. that.initBluetooth()
  3232. },
  3233. doWork: function () {
  3234. var that = this
  3235. console.log(taskId);
  3236. switch (taskId) {
  3237. case 11: {
  3238. that.onBindLock()
  3239. break
  3240. }
  3241. case 12: {
  3242. that.onUnbindLock()
  3243. break
  3244. }
  3245. case 21: {
  3246. that.onQueryBindState()
  3247. break
  3248. }
  3249. case 22: {
  3250. that.onQueryBattery()
  3251. break
  3252. }
  3253. case 31: {
  3254. that.onQueryNbImei()
  3255. break
  3256. }
  3257. case 32: {
  3258. that.onLogin()
  3259. break
  3260. }
  3261. case 41: {
  3262. that.LwjonOpenLock()
  3263. break
  3264. }
  3265. case 42: {
  3266. that.onSyncClock()
  3267. break
  3268. }
  3269. case 51: {
  3270. that.onAddPincode()
  3271. break
  3272. }
  3273. case 52: {
  3274. that.onDelPincode()
  3275. break
  3276. }
  3277. case 61: {
  3278. // that.onAddRfCard()
  3279. // if (lockModel > 70) {
  3280. that.sendAddRfcard()
  3281. // } else {
  3282. // wx.showModal({
  3283. // title: '提示',
  3284. // content: '请刷卡!',
  3285. // showCancel: false
  3286. // })
  3287. // }
  3288. break
  3289. }
  3290. case 62: {
  3291. that.onDelRfCard()
  3292. break
  3293. }
  3294. case 71: {
  3295. that.onAddFingerprint()
  3296. break
  3297. }
  3298. case 72: {
  3299. that.onDelFingerprint()
  3300. break
  3301. }
  3302. case 81: {
  3303. that.onChangeAdminPincode()
  3304. break
  3305. }
  3306. case 91: {
  3307. that.onQueryLockSlotState()
  3308. break
  3309. }
  3310. case 92: {
  3311. that.onQueryLockUnlockState()
  3312. break
  3313. }
  3314. case 101: {
  3315. that.onChangeLockUnlockState()
  3316. break
  3317. }
  3318. case 102: {
  3319. that.onChangeLockMutedState()
  3320. break
  3321. }
  3322. case 111: {
  3323. this.onChangeLockNbState()
  3324. }
  3325. default: {
  3326. }
  3327. }
  3328. },
  3329. connectTo: function () {
  3330. var that = this
  3331. wx.showLoading({
  3332. title: '连接中',
  3333. })
  3334. wx.createBLEConnection({
  3335. deviceId: lockDevice.deviceId,
  3336. timeout: config.ble.connectTimeOut,
  3337. success: function (res) {
  3338. console.log('connectTo', res)
  3339. isConnected = true
  3340. // app.globalData.isConnected = true
  3341. wx.hideLoading()
  3342. setTimeout(function () {
  3343. that.setupConnection()
  3344. }, 500)
  3345. },
  3346. fail: function (e) {
  3347. console.debug('connectTo', e)
  3348. wx.hideLoading()
  3349. switch (e.errCode) {
  3350. case 10003: {
  3351. wx.showModal({
  3352. title: '连接失败',
  3353. content: '是否重新连接?',
  3354. success: function (res) {
  3355. if (res.confirm) {
  3356. that.connectTo()
  3357. }
  3358. }
  3359. })
  3360. break
  3361. }
  3362. case 10012: {
  3363. wx.showModal({
  3364. title: '连接失败',
  3365. content: '蓝牙连接超时',
  3366. showCancel: false
  3367. })
  3368. break
  3369. }
  3370. case 10002: {
  3371. wx.showModal({
  3372. title: '连接失败',
  3373. content: '没有找到指定设备',
  3374. showCancel: false
  3375. })
  3376. break
  3377. }
  3378. }
  3379. }
  3380. })
  3381. },
  3382. searchDevicesMethods() {
  3383. var that = this;
  3384. wx.showLoading({
  3385. title: '正在搜索',
  3386. // mask: true
  3387. })
  3388. this.setData({
  3389. searchClick: false
  3390. })
  3391. wx.openBluetoothAdapter({
  3392. success: function (res) {
  3393. wx.startBluetoothDevicesDiscovery({
  3394. success: function (res) {
  3395. wx.getBluetoothDevices({
  3396. success: function (res) {
  3397. res.devices.map(it => {
  3398. var status = it.name.indexOf('WSL_')
  3399. if (status != -1) {
  3400. if (it.RSSI != 127) {
  3401. if (it.advertisData != null) {
  3402. it.adData = util1.ab2hex(it.advertisData)
  3403. if (it.adData.length > 10) {
  3404. var macStr = it.adData.substring(4, 16).toUpperCase()
  3405. //console.log('macStr', macStr)
  3406. it.mac = macStr.substr(10, 2) + ':' + macStr.substr(8, 2) + ':' + macStr.substr(6, 2) + ':' + macStr.substr(4, 2) + ':' + macStr.substr(2, 2) + ':' + macStr.substr(0, 2)
  3407. if (it.adData.substring(1, 2) == '1') {
  3408. it.isLightOn = true
  3409. it.textColor = 'green'
  3410. } else {
  3411. it.isLightOn = false
  3412. it.textColor = 'black'
  3413. }
  3414. if (it.adData.substring(3, 4) == '1') {
  3415. it.textColor = 'pink'
  3416. it.isBind = true
  3417. } else {
  3418. it.isBind = false
  3419. }
  3420. }
  3421. } else {
  3422. it.textColor = 'black'
  3423. }
  3424. lockModel = util1.getLockModel(it.name)
  3425. it.lockType = util1.getLockType(lockModel)
  3426. if (it.name == that.data.deviceinfo.deviceNum) {
  3427. app.addDeviceWithDevName(it.name, it)
  3428. lockDevice = it
  3429. connectedDeviceId = it.deviceId
  3430. that.setData({
  3431. isSearch: true
  3432. })
  3433. that.initBluetooth()
  3434. }
  3435. }
  3436. }
  3437. })
  3438. if (!that.data.isSearch) {
  3439. that.searchDevicesMethods()
  3440. }
  3441. }
  3442. })
  3443. },
  3444. fail: function (res) {
  3445. wx.hideLoading({
  3446. success: (res) => {
  3447. wx.showToast({
  3448. title: res.errMsg,
  3449. duration: 2000,
  3450. icon: 'none'
  3451. })
  3452. },
  3453. })
  3454. }
  3455. })
  3456. },
  3457. fail: function (res) {
  3458. console.log('请打开蓝牙和定位功能')
  3459. wx.hideLoading({
  3460. success: (res) => {
  3461. wx.showToast({
  3462. title: '请打开蓝牙和定位功能',
  3463. duration: 2000,
  3464. icon: 'none'
  3465. })
  3466. },
  3467. })
  3468. }
  3469. })
  3470. },
  3471. LwjonOpenLock: function () {
  3472. var that = this
  3473. wx.showLoading({
  3474. title: that.data.isJack ? '上电中' : '解锁中',
  3475. })
  3476. console.log(lockDevice.name, 'lockDevice.name0')
  3477. var bytes = plugin.sendOpenLockP1(lockDevice.name, basecode)
  3478. console.debug('bytes', bytes)
  3479. that.sendBytes(bytes)
  3480. },
  3481. openLock: function () {
  3482. var that = this
  3483. taskId = 41
  3484. that.initBluetooth()
  3485. },
  3486. sendBytes(bytes) {
  3487. setTimeout(() => {
  3488. wx.writeBLECharacteristicValue({
  3489. deviceId: lockDevice.deviceId,
  3490. serviceId: config.uuid.serviceUuid.toUpperCase(),
  3491. characteristicId: config.uuid.writeUuid.toUpperCase(),
  3492. value: bytes,
  3493. success: function (res) {
  3494. },
  3495. })
  3496. }, 50)
  3497. },
  3498. sendNfc() {
  3499. var time3 = new Date(this.data.datetimerange[0].replace(/-/g, '/'))
  3500. var time4 = new Date(this.data.datetimerange[1].replace(/-/g, '/'))
  3501. var passwordStartTimecontrast = time3.getTime() / 1000
  3502. var passwordEndTimecontrast = time4.getTime() / 1000
  3503. if (passwordStartTimecontrast > passwordEndTimecontrast) {
  3504. wx.showToast({
  3505. title: '开始时间不能大于结束时间',
  3506. duration: 2000,
  3507. mask: true,
  3508. icon: 'none'
  3509. })
  3510. return
  3511. }
  3512. wx.showLoading({
  3513. title: '正在添加',
  3514. mask: true
  3515. })
  3516. var _this = this
  3517. var deviceinfo = this.data.deviceinfo
  3518. var info = JSON.parse(this.data.personLi.info)
  3519. if (deviceinfo.manufactureId == 101) {
  3520. } else if (deviceinfo.manufactureId == 201 || deviceinfo.manufactureId == 221) {
  3521. var cgInfo = this.data.cgInfo
  3522. var time1 = new Date(_this.data.datetimerange[0].replace(/-/g, '/'))
  3523. var time2 = new Date(_this.data.datetimerange[1].replace(/-/g, '/'))
  3524. var passwordStartTime = time1.getTime() / 1000
  3525. var passwordEndTime = time2.getTime() / 1000
  3526. var pzname = _this.data.pzname,
  3527. cardName = ''
  3528. if (pzname == "") {
  3529. pzname = '蓝牙-NFC' + (_this.data.NfcList.length + 1)
  3530. cardName = _this.data.personLi.name + '-蓝牙-NFC' + (_this.data.NfcList.length + 1)
  3531. } else {
  3532. pzname = '蓝牙-' + pzname
  3533. cardName = _this.data.personLi.name + '-蓝牙-' + pzname
  3534. }
  3535. var dataPasswod = {
  3536. code: "zg/cardOperate",
  3537. data: {
  3538. lockerId: deviceinfo.deviceNum,
  3539. imei: deviceinfo.imei,
  3540. lockerUserId: info.userId,
  3541. keyId: info.userId,
  3542. action: 1,
  3543. taskStatus: 1,
  3544. order: 6210,
  3545. startTime: passwordStartTime,
  3546. endTime: passwordEndTime,
  3547. cardType: 50,
  3548. type: ADD_NFC_MODE,
  3549. roomName: this.data.deviceinfo.roomName,
  3550. cardName: cardName,
  3551. }
  3552. }
  3553. console.log(dataPasswod, 'dataPasswod')
  3554. WXAPI.sendCommand(dataPasswod).then(res => {
  3555. console.log(res, 'resres')
  3556. if (res.success) {
  3557. var pwdNo = res.data.index
  3558. var passwordIndex = res.data.index
  3559. var serialNumber = res.data.serialNumber
  3560. pwdNo = pwdNo.toString(16)
  3561. if (pwdNo.length < 2) {
  3562. pwdNo = '0' + pwdNo
  3563. }
  3564. var startTime = passwordStartTime.toString(16).toUpperCase()
  3565. var endTime = passwordEndTime.toString(16).toUpperCase()
  3566. info.startTime = startTime
  3567. info.endTime = endTime
  3568. info.pwdNo = pwdNo
  3569. methods.bluetoothOperation_ZH(cgInfo, info, 7).then(result => {
  3570. if (result.status == '00') {
  3571. let carNoId = this.processCardNumber(result.cardNo)
  3572. var datacom = {
  3573. code: "zg/bleSendVoucherReply",
  3574. data: {
  3575. lockerId: deviceinfo.deviceNum,
  3576. serialNumber: serialNumber,
  3577. index: passwordIndex,
  3578. type: ADD_NFC_MODE,
  3579. cardNo: carNoId.toUpperCase(),
  3580. result: 1
  3581. }
  3582. }
  3583. WXAPI.sendCommand(datacom).then(res2 => {
  3584. if (res2.success) {
  3585. var str = {
  3586. // cardId: this.personInfo.cardId,
  3587. pzname: pzname,
  3588. imei: _this.data.deviceinfo.imei,
  3589. password: carNoId.toUpperCase(),
  3590. blueCardNo: result.cardNo,
  3591. userTelephone: JSON.parse(_this.data.personLi.info).userTelephone,
  3592. operateMode: 10,
  3593. userPassword: JSON.parse(_this.data.personLi.info).userPassword,
  3594. passwordStartTime: passwordStartTime,
  3595. passwordEndTime: passwordEndTime,
  3596. is: false,
  3597. roomName: _this.data.deviceinfo.roomName,
  3598. }
  3599. var data = {
  3600. cardId: _this.data.personLi.cardId,
  3601. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  3602. deviceNum: _this.data.deviceinfo.deviceNum,
  3603. type: 3,
  3604. blueCardNo: result.cardNo,
  3605. imei: _this.data.deviceinfo.imei,
  3606. serial: serialNumber,
  3607. startTime: passwordStartTime,
  3608. endTime: passwordEndTime,
  3609. };
  3610. console.log(data, '添加凭证')
  3611. var datalist = {
  3612. cardId: _this.data.personLi.cardId,
  3613. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  3614. type: 13,
  3615. startTime: passwordStartTime,
  3616. endTime: passwordEndTime,
  3617. };
  3618. WXAPI.addCertificates(datalist).then(res6 => {
  3619. console.log(datalist, 'NFC', res6)
  3620. })
  3621. WXAPI.addCertificates(data).then(res3 => {
  3622. if (res3.success) {
  3623. var updatedata = {
  3624. id: res3.data,
  3625. status: 1
  3626. };
  3627. WXAPI.updateCertificates(updatedata).then((res2) => {});
  3628. console.log(res3, '添加凭证成功')
  3629. _this.getNfc()
  3630. _this.setData({
  3631. show: false
  3632. })
  3633. wx.hideLoading()
  3634. wx.showToast({
  3635. title: '添加成功',
  3636. mask: true,
  3637. icon: 'none',
  3638. duration: 2000
  3639. })
  3640. } else {
  3641. wx.hideLoading()
  3642. wx.showToast({
  3643. title: '添加失败',
  3644. mask: true,
  3645. icon: 'none',
  3646. duration: 2000
  3647. })
  3648. }
  3649. })
  3650. }
  3651. })
  3652. } else {
  3653. wx.hideLoading()
  3654. wx.showToast({
  3655. title: '添加失败',
  3656. mask: true,
  3657. icon: 'none',
  3658. duration: 2000
  3659. })
  3660. var datacom = {
  3661. code: "zg/bleSendVoucherReply",
  3662. data: {
  3663. lockerId: deviceinfo.deviceNum,
  3664. serialNumber: serialNumber,
  3665. index: passwordIndex,
  3666. type: ADD_NFC_MODE,
  3667. result: 0
  3668. }
  3669. }
  3670. WXAPI.sendCommand(datacom).then(res2 => {
  3671. console.log(res2, '失败')
  3672. _this.setData({
  3673. show: false
  3674. })
  3675. })
  3676. }
  3677. }).catch(err => {
  3678. var datacom = {
  3679. code: "zg/bleSendVoucherReply",
  3680. data: {
  3681. lockerId: deviceinfo.deviceNum,
  3682. serialNumber: serialNumber,
  3683. index: passwordIndex,
  3684. type: ADD_NFC_MODE,
  3685. result: 0
  3686. }
  3687. }
  3688. WXAPI.sendCommand(datacom).then(res2 => {
  3689. _this.setData({
  3690. show: false
  3691. })
  3692. })
  3693. wx.showToast({
  3694. title: '添加失败',
  3695. mask: true,
  3696. icon: 'none',
  3697. duration: 2000
  3698. })
  3699. })
  3700. } else {
  3701. wx.showToast({
  3702. title: res.msg,
  3703. duration: 2000,
  3704. mask: true,
  3705. icon: 'none'
  3706. })
  3707. }
  3708. })
  3709. } else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) {
  3710. if (this.data.isSearch) {
  3711. wx.hideLoading()
  3712. this.addRfCard()
  3713. } else {
  3714. this.searchDevicesMethods()
  3715. }
  3716. }
  3717. },
  3718. addRfCard: function () {
  3719. console.log("3691NFC");
  3720. var that = this
  3721. taskId = 61
  3722. that.initBluetooth()
  3723. },
  3724. onAddRfCard: function () {
  3725. var that = this
  3726. wx.showLoading({
  3727. title: '添加房卡中',
  3728. })
  3729. var startTime = new Date(Number(moment(that.data.starttime).format('x')))
  3730. var endTime = new Date(Number(moment(that.data.endtime).format('x')))
  3731. console.log("锁", lockDevice.name, basecode, 0, rfCardIndex, startTime, endTime);
  3732. var bytes = plugin.addRfCard(lockDevice.name, basecode, 0, rfCardIndex, startTime, endTime)
  3733. console.debug('bytes', bytes)
  3734. that.sendBytes(bytes)
  3735. },
  3736. addRfcardCertificates() {
  3737. var that = this
  3738. var time1 = new Date(that.data.starttime.replace(/-/g, '/'))
  3739. var time2 = new Date(that.data.endtime.replace(/-/g, '/'))
  3740. var passwordStartTime = time1.getTime() / 1000
  3741. var passwordEndTime = time2.getTime() / 1000
  3742. var pzname = '',
  3743. cardName = '';
  3744. pzname = '蓝牙-NFC' + (that.data.passwordList.length + 1)
  3745. cardName = that.data.personLi.name + '-蓝牙-NFC' + (that.data.passwordList.length + 1)
  3746. let carNoId = rfCardId
  3747. var datacom = {
  3748. code: "ble/bleSendVoucherReply",
  3749. data: {
  3750. deviceNum: that.data.deviceinfo.deviceNum,
  3751. serialNumber: serialNumber,
  3752. index: rfCardIndex,
  3753. type: ADD_NFC_MODE,
  3754. cardNo: rfCardId.toUpperCase(),
  3755. result: 1,
  3756. productId: that.data.deviceinfo.manufactureId
  3757. }
  3758. }
  3759. WXAPI.sendCommand(datacom).then(res2 => {
  3760. if (res2.success) {
  3761. var str = {
  3762. // cardId: this.personInfo.cardId,
  3763. pzname: pzname,
  3764. imei: that.data.deviceinfo.imei,
  3765. password: carNoId.toUpperCase(),
  3766. blueCardNo: rfCardIndex,
  3767. userTelephone: JSON.parse(that.data.personLi.info).userTelephone,
  3768. operateMode: 10,
  3769. userPassword: JSON.parse(that.data.personLi.info).userPassword,
  3770. passwordStartTime: passwordStartTime,
  3771. passwordEndTime: passwordEndTime,
  3772. is: false,
  3773. index: rfCardIndex,
  3774. roomName: that.data.deviceinfo.roomName,
  3775. }
  3776. var data2 = {
  3777. cardId: that.data.personLi.cardId,
  3778. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  3779. deviceNum: that.data.deviceinfo.deviceNum,
  3780. type: 3,
  3781. blueCardNo: carNoId,
  3782. imei: that.data.deviceinfo.imei,
  3783. serial: serialNumber,
  3784. startTime: passwordStartTime,
  3785. endTime: passwordEndTime,
  3786. };
  3787. console.log(data2, '添加凭证')
  3788. var datalist = {
  3789. cardId: that.data.personLi.cardId,
  3790. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  3791. type: 13,
  3792. startTime: passwordStartTime,
  3793. endTime: passwordEndTime,
  3794. };
  3795. WXAPI.addCertificates(datalist).then(res6 => {
  3796. console.log(datalist, 'NFC', res6)
  3797. })
  3798. WXAPI.addCertificates(data2).then(res3 => {
  3799. if (res3.success) {
  3800. var updatedata = {
  3801. id: res3.data,
  3802. status: 1
  3803. };
  3804. WXAPI.updateCertificates(updatedata).then((res2) => {});
  3805. console.log(res3, '添加凭证成功')
  3806. that.getNfc()
  3807. that.setData({
  3808. show: false
  3809. })
  3810. wx.hideLoading()
  3811. wx.showToast({
  3812. title: '添加成功',
  3813. mask: true,
  3814. icon: 'none',
  3815. duration: 2000
  3816. })
  3817. } else {
  3818. wx.hideLoading()
  3819. wx.showToast({
  3820. title: '添加失败',
  3821. mask: true,
  3822. icon: 'none',
  3823. duration: 2000
  3824. })
  3825. }
  3826. })
  3827. } else {
  3828. wx.showToast({
  3829. title: res2.message,
  3830. duration: 2000,
  3831. icon: 'none'
  3832. })
  3833. }
  3834. })
  3835. },
  3836. sendAddRfcard() {
  3837. var that = this
  3838. var info = JSON.parse(this.data.personLi.info)
  3839. let deviceinfo = this.data.deviceinfo
  3840. var time1 = new Date(that.data.starttime.replace(/-/g, '/'))
  3841. var time2 = new Date(that.data.endtime.replace(/-/g, '/'))
  3842. var passwordStartTime = time1.getTime() / 1000
  3843. var passwordEndTime = time2.getTime() / 1000
  3844. var pzname = '',
  3845. cardName = ''
  3846. if(that.data.pzname == ''){
  3847. pzname = '蓝牙-NFC' + (that.data.NfcList.length + 1)
  3848. }else{
  3849. pzname = '蓝牙-NFC' + that.data.pzname
  3850. }
  3851. cardName = that.data.personLi.name + '-蓝牙-NFC' + (that.data.NfcList.length + 1)
  3852. rfCardId = randomMethods()
  3853. var dataPasswod = {
  3854. code: "lwj/cardOperate",
  3855. data: {
  3856. lockerId: deviceinfo.deviceNum,
  3857. lockerUserId: info.userId,
  3858. startTime: passwordStartTime,
  3859. endTime: passwordEndTime,
  3860. order: 6210,
  3861. operateMode: 10,
  3862. action: 1,
  3863. cardNo: rfCardId,
  3864. type: 10,
  3865. roomName: this.data.deviceinfo.roomName,
  3866. cardName: cardName,
  3867. }
  3868. }
  3869. console.log("平台", dataPasswod);
  3870. WXAPI.sendCommand(dataPasswod).then(res => {
  3871. console.log(res, '获取索引')
  3872. if (res.success) {
  3873. var pwdNo = res.data.index
  3874. serialNumber = res.data.serialNumber
  3875. rfCardIndex = pwdNo
  3876. setTimeout(() => {
  3877. that.onAddRfCard()
  3878. }, 500)
  3879. }
  3880. })
  3881. },
  3882. processCardNumber(cardNo) {
  3883. var str1 = cardNo.substr(0, 8)
  3884. var str2 = cardNo.substr(8, 8)
  3885. var num = str2.split("")
  3886. var status = num.every(item => item == 0)
  3887. console.log(status, num, 'numnum', str1, str2)
  3888. if (status) {
  3889. var bbb = str1.split("")
  3890. var a, b;
  3891. var aIndex = 0;
  3892. var bIndex = 1;
  3893. var arr = [];
  3894. bbb.forEach((str, index) => {
  3895. if (index % 2 === 0) {
  3896. a = str;
  3897. aIndex += 1
  3898. } else {
  3899. b = str
  3900. bIndex += 1
  3901. }
  3902. if (a && b && (bIndex - aIndex === 1)) {
  3903. arr.push(a + b)
  3904. }
  3905. });
  3906. console.log(arr)
  3907. return arr.join("")
  3908. } else {
  3909. var ll = str1 + str2
  3910. return ll
  3911. }
  3912. },
  3913. sendFp() {
  3914. var time3 = new Date(this.data.datetimerange[0].replace(/-/g, '/'))
  3915. var time4 = new Date(this.data.datetimerange[1].replace(/-/g, '/'))
  3916. var passwordStartTimecontrast = time3.getTime() / 1000
  3917. var passwordEndTimecontrast = time4.getTime() / 1000
  3918. if (passwordStartTimecontrast > passwordEndTimecontrast) {
  3919. wx.showToast({
  3920. title: '开始时间不能大于结束时间',
  3921. duration: 2000,
  3922. mask: true,
  3923. icon: 'none'
  3924. })
  3925. return
  3926. }
  3927. if (this.data.radioDetil == '') {
  3928. wx.showToast({
  3929. title: '请选择是那个指纹?',
  3930. mask: true,
  3931. duration: 2000,
  3932. icon: 'none'
  3933. })
  3934. return
  3935. }
  3936. wx.showLoading({
  3937. title: '正在添加指纹',
  3938. mask: true
  3939. })
  3940. var _this = this
  3941. var deviceinfo = this.data.deviceinfo
  3942. var info = JSON.parse(this.data.personLi.info)
  3943. if (deviceinfo.manufactureId == 101) {
  3944. let deviceNum = deviceinfo.deviceNum
  3945. this.setData({
  3946. backstatus: true
  3947. })
  3948. var timestamp = moment().format("x")
  3949. var time1 = moment(this.data.datetimerange[0]).format("YYYYMMDDHHmmss")
  3950. var time2 = moment(this.data.datetimerange[1]).format("YYYYMMDDHHmmss")
  3951. bleall.startFp_29(deviceNum, 0x03, timestamp, function (res) {
  3952. console.log(res, 'resresres')
  3953. if (res.success) {
  3954. wx.showLoading({
  3955. title: '正在添加指纹',
  3956. mask: true
  3957. })
  3958. }
  3959. if (res.data == "蓝牙功能暂不支持") {
  3960. wx.hideLoading()
  3961. _this.startconnect()
  3962. }
  3963. })
  3964. } else if (deviceinfo.manufactureId == 201 || deviceinfo.manufactureId == 221) {
  3965. var cgInfo = this.data.cgInfo
  3966. var time1 = new Date(_this.data.datetimerange[0].replace(/-/g, '/'))
  3967. var time2 = new Date(_this.data.datetimerange[1].replace(/-/g, '/'))
  3968. var passwordStartTime = time1.getTime() / 1000
  3969. var passwordEndTime = time2.getTime() / 1000
  3970. var cardName = '',
  3971. pzname = ''
  3972. if (this.data.pzname) {
  3973. cardName = _this.data.personLi.name + '-蓝牙-' + _this.data.pzname
  3974. pzname = '蓝牙-' + _this.data.pzname
  3975. } else {
  3976. cardName = _this.data.personLi.name + '-蓝牙-指纹' + (_this.data.FpList.length + 1)
  3977. pzname = '蓝牙-指纹' + (_this.data.FpList.length + 1)
  3978. }
  3979. var dataPasswod = {
  3980. code: "zg/addFingerPrint",
  3981. data: {
  3982. lockerId: deviceinfo.deviceNum,
  3983. imei: deviceinfo.imei,
  3984. lockerUserId: info.userPassword,
  3985. keyId: info.userPassword,
  3986. fingerType: 0,
  3987. order: 6216,
  3988. fingerId: '',
  3989. roomName: deviceinfo.roomName,
  3990. cardName: cardName,
  3991. startTime: passwordStartTime,
  3992. endTime: passwordEndTime,
  3993. file: '',
  3994. type: 1
  3995. }
  3996. }
  3997. WXAPI.sendCommand(dataPasswod).then(res => {
  3998. console.log(res, '获取索引')
  3999. if (res.success) {
  4000. var startTime = passwordStartTime.toString(16).toUpperCase()
  4001. var endTime = passwordEndTime.toString(16).toUpperCase()
  4002. info.startTime = startTime
  4003. info.endTime = endTime
  4004. methods.bluetoothOperation_ZH(cgInfo, info, 5).then(result => {
  4005. if (result.status == '00' && result.completeFlag == '01') {
  4006. console.log(result, 'callback2callback2')
  4007. var datacom = {
  4008. code: "zg/bleSendVoucherReply",
  4009. data: {
  4010. lockerId: deviceinfo.deviceNum,
  4011. serialNumber: res.data.serialNumber,
  4012. index: result.fingerprintNo,
  4013. type: 16,
  4014. result: 1
  4015. }
  4016. }
  4017. console.log(datacom)
  4018. var str = {
  4019. // cardId: this.personInfo.cardId,
  4020. imei: _this.data.deviceinfo.imei,
  4021. pzname: pzname,
  4022. password: '',
  4023. fingerprintAlias: _this.data.radioDetil,
  4024. userTelephone: JSON.parse(_this.data.personLi.info).userTelephone,
  4025. operateMode: 16,
  4026. userPassword: JSON.parse(_this.data.personLi.info).userPassword,
  4027. passwordStartTime: passwordStartTime,
  4028. passwordEndTime: passwordEndTime,
  4029. is: false,
  4030. pass: true
  4031. }
  4032. var data = {
  4033. cardId: _this.data.personLi.cardId,
  4034. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  4035. deviceNum: _this.data.deviceinfo.deviceNum,
  4036. type: 1,
  4037. imei: _this.data.deviceinfo.imei,
  4038. serial: res.data.serialNumber,
  4039. startTime: passwordStartTime,
  4040. endTime: passwordEndTime,
  4041. status: 1
  4042. };
  4043. var datalist = {
  4044. cardId: _this.data.personLi.cardId,
  4045. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  4046. type: 11,
  4047. startTime: passwordStartTime,
  4048. endTime: passwordEndTime
  4049. };
  4050. WXAPI.addCertificates(datalist).then(res6 => {})
  4051. console.log(data, '添加凭证')
  4052. WXAPI.addCertificates(data).then(res3 => {
  4053. if (res3.success) {
  4054. var updatedata = {
  4055. id: res3.data,
  4056. status: 1
  4057. };
  4058. WXAPI.updateCertificates(updatedata).then((res2) => {});
  4059. WXAPI.sendCommand(datacom).then(res2 => {
  4060. if (res2.success) {}
  4061. })
  4062. console.log(res3, '添加凭证成功')
  4063. _this.getFp()
  4064. _this.setData({
  4065. show: false
  4066. })
  4067. wx.hideLoading()
  4068. wx.showToast({
  4069. title: '添加成功',
  4070. mask: true,
  4071. icon: 'none',
  4072. duration: 2000
  4073. })
  4074. } else {
  4075. wx.hideLoading()
  4076. wx.showToast({
  4077. title: '添加失败',
  4078. mask: true,
  4079. icon: 'none',
  4080. duration: 2000
  4081. })
  4082. }
  4083. })
  4084. }
  4085. }).catch(err => {
  4086. var datacom = {
  4087. code: "zg/bleSendVoucherReply",
  4088. data: {
  4089. lockerId: deviceinfo.deviceNum,
  4090. serialNumber: res.data.serialNumber,
  4091. index: 0,
  4092. type: 16,
  4093. result: 0
  4094. }
  4095. }
  4096. WXAPI.sendCommand(datacom).then(res2 => {
  4097. if (res2.success) {}
  4098. })
  4099. })
  4100. } else {
  4101. var datacom = {
  4102. code: "zg/bleSendVoucherReply",
  4103. data: {
  4104. lockerId: deviceinfo.deviceNum,
  4105. serialNumber: res.data.serialNumber,
  4106. index: 0,
  4107. type: 16,
  4108. result: 0
  4109. }
  4110. }
  4111. WXAPI.sendCommand(datacom).then(res2 => {
  4112. if (res2.success) {}
  4113. })
  4114. wx.showToast({
  4115. title: res.msg,
  4116. duration: 2000,
  4117. mask: true,
  4118. icon: 'none'
  4119. })
  4120. }
  4121. })
  4122. } else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) {
  4123. if (this.data.isSearch) {
  4124. // fingerprintIndex = 1
  4125. // serialNumber = 1686309639840
  4126. // this.onAddFingerprint()
  4127. // return
  4128. var time1 = new Date(_this.data.datetimerange[0].replace(/-/g, '/'))
  4129. var time2 = new Date(_this.data.datetimerange[1].replace(/-/g, '/'))
  4130. var passwordStartTime = time1.getTime() / 1000
  4131. var passwordEndTime = time2.getTime() / 1000
  4132. var cardName = '',
  4133. pzname = ''
  4134. if (this.data.pzname) {
  4135. cardName = _this.data.personLi.name + '-蓝牙-' + _this.data.pzname
  4136. pzname = '蓝牙-' + _this.data.pzname
  4137. } else {
  4138. cardName = _this.data.personLi.name + '-蓝牙-指纹' + (_this.data.FpList.length + 1)
  4139. pzname = '蓝牙-指纹' + (_this.data.FpList.length + 1)
  4140. }
  4141. var dataPasswod = {
  4142. code: "lwj/fpOperate",
  4143. data: {
  4144. lockerId: deviceinfo.deviceNum,
  4145. action: 1,
  4146. lockerUserId: info.userPassword,
  4147. fpData: '',
  4148. operateMode: 16,
  4149. order: 6216,
  4150. roomName: deviceinfo.roomName,
  4151. cardName: cardName,
  4152. startTime: passwordStartTime,
  4153. endTime: passwordEndTime,
  4154. type: 1
  4155. }
  4156. }
  4157. console.log(dataPasswod);
  4158. WXAPI.sendCommand(dataPasswod).then(res => {
  4159. console.log(res);
  4160. if (res.success) {
  4161. fingerprintIndex = res.data.index
  4162. serialNumber = res.data.serialNumber
  4163. this.onAddFingerprint()
  4164. }
  4165. })
  4166. } else {
  4167. this.searchDevicesMethods()
  4168. }
  4169. }
  4170. },
  4171. login: function () {
  4172. var that = this
  4173. taskId = 32
  4174. that.initBluetooth()
  4175. },
  4176. onLogin: function () {
  4177. var that = this
  4178. wx.showLoading({
  4179. title: '登录中',
  4180. })
  4181. var bytes = plugin.login1(lockDevice.name, basecode)
  4182. console.debug('bytes', bytes)
  4183. that.sendBytes(bytes)
  4184. },
  4185. onAddFingerprint: function () {
  4186. var that = this
  4187. wx.showLoading({
  4188. title: '添加指纹中',
  4189. })
  4190. // var startTime = util1.getLocalTime(8)
  4191. // var endTime = new Date(startTime.getTime() + 5 * 60 * 1000) //有效期5分钟
  4192. var startTime = new Date(Number(moment(that.data.starttime).format('x')))
  4193. var endTime = new Date(Number(moment(that.data.endtime).format('x')))
  4194. // fingerprintIndex = Math.floor(Math.random() * 100)
  4195. var bytes = plugin.addFingerprint(lockDevice.name, basecode, fingerprintIndex, startTime, endTime)
  4196. console.debug('bytes', bytes)
  4197. that.sendBytes(bytes)
  4198. },
  4199. // 关闭添加人员弹窗
  4200. onClose() {
  4201. this.setData({
  4202. show: false
  4203. });
  4204. },
  4205. onChange(event) {
  4206. console.log(event.detail)
  4207. this.setData({
  4208. activeKey: event.detail
  4209. })
  4210. },
  4211. getPassword() {
  4212. var data = {
  4213. pageNum: 0,
  4214. pageSize: 0,
  4215. q: JSON.stringify({
  4216. cardId: this.data.personLi.cardId,
  4217. deviceNum: this.data.deviceinfo.deviceNum,
  4218. types: "4",
  4219. inStatus: '0,1,702'
  4220. })
  4221. }
  4222. console.log(data)
  4223. WXAPI.getCertificates(data).then(res => {
  4224. var dataOne = util.zlib_unzip(res.data)
  4225. if (res.success) {
  4226. dataOne.map(li => {
  4227. li['pzname'] = JSON.parse(li.content).pzname
  4228. li['password'] = util.plusXing(JSON.parse(li.content).password, 2, 2, '*')
  4229. })
  4230. this.setData({
  4231. passwordList: dataOne
  4232. })
  4233. }
  4234. })
  4235. },
  4236. getNfc() {
  4237. var data = {
  4238. pageNum: 0,
  4239. pageSize: 0,
  4240. q: JSON.stringify({
  4241. cardId: this.data.personLi.cardId,
  4242. deviceNum: this.data.deviceinfo.deviceNum,
  4243. types: "3",
  4244. inStatus: '0,1,702'
  4245. })
  4246. }
  4247. WXAPI.getCertificates(data).then(res => {
  4248. console.log(res)
  4249. var dataOne = util.zlib_unzip(res.data)
  4250. console.log(dataOne)
  4251. if (res.success) {
  4252. dataOne.map(li => {
  4253. li['pzname'] = JSON.parse(li.content).pzname
  4254. li['password'] = util.plusXing(JSON.parse(li.content).password, 2, 2, '*')
  4255. })
  4256. this.setData({
  4257. NfcList: dataOne
  4258. })
  4259. }
  4260. })
  4261. },
  4262. getFp() {
  4263. var data = {
  4264. pageNum: 0,
  4265. pageSize: 0,
  4266. q: JSON.stringify({
  4267. cardId: this.data.personLi.cardId,
  4268. deviceNum: this.data.deviceinfo.deviceNum,
  4269. types: "1",
  4270. inStatus: '0,1,702'
  4271. })
  4272. }
  4273. WXAPI.getCertificates(data).then(res => {
  4274. var dataOne = util.zlib_unzip(res.data)
  4275. if (res.success) {
  4276. dataOne.map(li => {
  4277. li['pzname'] = JSON.parse(li.content).pzname
  4278. li['password'] = ''
  4279. li['fingerprintAlias'] = JSON.parse(li.content).fingerprintAlias || ''
  4280. })
  4281. this.setData({
  4282. FpList: dataOne
  4283. })
  4284. }
  4285. })
  4286. },
  4287. getCarId() {
  4288. var data = {
  4289. pageNum: 0,
  4290. pageSize: 0,
  4291. q: JSON.stringify({
  4292. cardId: this.data.personLi.cardId,
  4293. deviceNum: this.data.deviceinfo.deviceNum,
  4294. types: "2",
  4295. inStatus: '0,1,702'
  4296. })
  4297. }
  4298. WXAPI.getCertificates(data).then(res => {
  4299. var dataOne = util.zlib_unzip(res.data)
  4300. if (res.success) {
  4301. dataOne.map(li => {
  4302. li['pzname'] = JSON.parse(li.content).pzname
  4303. li['password'] = util.plusXing(JSON.parse(li.content).password, 2, 2, '*')
  4304. })
  4305. this.setData({
  4306. CarIdList: dataOne
  4307. })
  4308. }
  4309. })
  4310. },
  4311. /**
  4312. * 生命周期函数--监听页面初次渲染完成
  4313. */
  4314. onReady: function () {
  4315. },
  4316. /**
  4317. * 生命周期函数--监听页面显示
  4318. */
  4319. onShow: function () {
  4320. },
  4321. /**
  4322. * 生命周期函数--监听页面隐藏
  4323. */
  4324. onHide: function () {
  4325. },
  4326. /**
  4327. * 生命周期函数--监听页面卸载
  4328. */
  4329. onUnload: function () {
  4330. if (isConnected) {
  4331. console.log(connectedDeviceId, 'connectedDeviceId')
  4332. wx.closeBLEConnection({
  4333. deviceId: connectedDeviceId,
  4334. success: function (res) {
  4335. isConnected = false
  4336. app.globalData.isConnected = false
  4337. },
  4338. })
  4339. }
  4340. },
  4341. /**
  4342. * 页面相关事件处理函数--监听用户下拉动作
  4343. */
  4344. onPullDownRefresh: function () {
  4345. },
  4346. /**
  4347. * 页面上拉触底事件的处理函数
  4348. */
  4349. onReachBottom: function () {
  4350. },
  4351. /**
  4352. * 用户点击右上角分享
  4353. */
  4354. onShareAppMessage: function () {
  4355. }
  4356. })