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.

4504 lines
147 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 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. type: 12,
  923. cardName: _this.data.personLi.name,
  924. roomName: deviceinfo.roomName,
  925. cardIndex: info.index
  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. passwordLiAll = personLi
  1081. var deviceinfo = this.data.deviceinfo
  1082. var info = JSON.parse(personLi.content)
  1083. var person = this.data.personLi
  1084. var _this = this
  1085. console.log(personLi, "personLi");
  1086. this.getFpIndex(index, function (data) {
  1087. if (data.length > 0) {
  1088. // 删除
  1089. var dataFP = {
  1090. code: "lwj/fpOperate",
  1091. data: {
  1092. fpIndex: info.index,
  1093. lockerId: deviceinfo.deviceNum,
  1094. lockerUserId: info.userPassword,
  1095. keyId: info.userPassword,
  1096. operateMode: 18,
  1097. order: 6218,
  1098. roomName: deviceinfo.roomName,
  1099. startTime: personLi.startTime,
  1100. endTime: personLi.endTime,
  1101. action: 2,
  1102. cardName: personLi.name
  1103. }
  1104. }
  1105. console.log(dataFP);
  1106. WXAPI.sendCommand(dataFP).then(res => {
  1107. console.log(res, "获取索引");
  1108. if(res.success){
  1109. // fingerprintIndex = res.data.index
  1110. fingerprintIndex = JSON.parse(personLi.content).index
  1111. serialNumber = res.data.serialNumber
  1112. taskId = 72
  1113. _this.initBluetooth()
  1114. }else{
  1115. wx.hideLoading()
  1116. wx.showToast({
  1117. title: res.msg,
  1118. mask: true,
  1119. icon: 'none',
  1120. duration: 2000
  1121. })
  1122. }
  1123. })
  1124. } else {
  1125. wx.hideLoading()
  1126. wx.showToast({
  1127. title: '获取指纹ID失败',
  1128. mask: true,
  1129. duration: 2000,
  1130. icon: 'none'
  1131. })
  1132. }
  1133. })
  1134. },
  1135. delFp(index) {
  1136. wx.showLoading({
  1137. title: '正在删除',
  1138. mask: true
  1139. })
  1140. var cgInfo = this.data.cgInfo
  1141. var personLi = this.data.FpList[index]
  1142. var deviceinfo = this.data.deviceinfo
  1143. var info = JSON.parse(personLi.content)
  1144. var personInfo = JSON.parse(this.data.personLi.info)
  1145. var _this = this
  1146. this.getFpIndex(index, function (data) {
  1147. if (data.length > 0) {
  1148. var FPindex = data[0].face
  1149. var dataPasswod = {
  1150. code: "zg/fpOperate",
  1151. data: {
  1152. lockerId: deviceinfo.deviceNum,
  1153. imei: deviceinfo.imei,
  1154. lockerUserId: personInfo.userId,
  1155. keyId: personInfo.userId,
  1156. fingerId: FPindex,
  1157. fingerType: '0',
  1158. startTime: personLi.startTime,
  1159. endTime: personLi.endTime,
  1160. order: 6218,
  1161. action: 2,
  1162. type: 1,
  1163. roomName: _this.data.deviceinfo.roomName,
  1164. cardName: _this.data.personLi.name,
  1165. }
  1166. }
  1167. WXAPI.sendCommand(dataPasswod).then(res => {
  1168. console.log(res, '获取索引')
  1169. if (res.success) {
  1170. var fingerNo = FPindex.toString(16)
  1171. if (fingerNo < 10) {
  1172. fingerNo = '000' + fingerNo
  1173. } else {
  1174. fingerNo = '00' + fingerNo
  1175. }
  1176. ICINLocker.getSignKey(cgInfo.lockerId, cgInfo.superId, cgInfo.superId,
  1177. (callback) => {
  1178. console.log(callback)
  1179. if (callback.status == '00') {
  1180. ICINLocker.getCommonKey(cgInfo.lockerId, cgInfo.superId, cgInfo.superId, callback.signKey, (callback1) => {
  1181. console.log(callback1)
  1182. if (callback1.status == '00') {
  1183. var startTime = personLi.startTime.toString(16).toUpperCase()
  1184. var endTime = personLi.endTime.toString(16).toUpperCase()
  1185. console.log(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, '01', fingerNo, '', callback.signKey, '00', startTime, endTime, callback1.commonKey, '-----')
  1186. ICINLocker.modifyFingerPrints(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, '01', fingerNo, '', callback.signKey, '00', startTime, endTime, callback1.commonKey, (
  1187. callback2) => {
  1188. console.log(callback2)
  1189. if (callback2.status == '00') {
  1190. var datacom = {
  1191. code: "zg/bleSendVoucherReply",
  1192. data: {
  1193. lockerId: deviceinfo.deviceNum,
  1194. serialNumber: res.data.serialNumber,
  1195. index: FPindex,
  1196. type: 18,
  1197. result: 1
  1198. }
  1199. }
  1200. WXAPI.sendCommand(datacom).then(res2 => {
  1201. console.log(res2, '成功----')
  1202. })
  1203. wx.showToast({
  1204. title: '下发成功',
  1205. mask: true,
  1206. icon: 'none',
  1207. duration: 2000
  1208. })
  1209. var data = {
  1210. ids: [personLi.id]
  1211. }
  1212. wx.hideLoading()
  1213. WXAPI.deleteCertificates(data).then(res1 => {
  1214. if (res1.success) {
  1215. _this.getFp()
  1216. wx.showToast({
  1217. title: '删除成功',
  1218. mask: true,
  1219. icon: 'none',
  1220. duration: 2000
  1221. })
  1222. } else {
  1223. wx.showToast({
  1224. title: '删除失败',
  1225. mask: true,
  1226. icon: 'none',
  1227. duration: 2000
  1228. })
  1229. }
  1230. })
  1231. } else {
  1232. wx.hideLoading()
  1233. wx.showToast({
  1234. title: '删除失败',
  1235. mask: true,
  1236. icon: 'none',
  1237. duration: 2000
  1238. })
  1239. var datacom = {
  1240. code: "zg/bleSendVoucherReply",
  1241. data: {
  1242. lockerId: deviceinfo.deviceNum,
  1243. serialNumber: res.data.serialNumber,
  1244. index: FPindex,
  1245. type: 18,
  1246. result: 0
  1247. }
  1248. }
  1249. WXAPI.sendCommand(datacom).then(res2 => {
  1250. console.log(res2, '失败')
  1251. })
  1252. }
  1253. })
  1254. } else {
  1255. wx.hideLoading()
  1256. wx.showToast({
  1257. title: '删除失败',
  1258. mask: true,
  1259. icon: 'none',
  1260. duration: 2000
  1261. })
  1262. var datacom = {
  1263. code: "zg/bleSendVoucherReply",
  1264. data: {
  1265. lockerId: deviceinfo.deviceNum,
  1266. serialNumber: res.data.serialNumber,
  1267. index: FPindex,
  1268. type: 18,
  1269. result: 0
  1270. }
  1271. }
  1272. WXAPI.sendCommand(datacom).then(res2 => {
  1273. console.log(res2, '失败')
  1274. })
  1275. }
  1276. })
  1277. } else {
  1278. wx.hideLoading()
  1279. wx.showToast({
  1280. title: '删除失败',
  1281. mask: true,
  1282. icon: 'none',
  1283. duration: 2000
  1284. })
  1285. var datacom = {
  1286. code: "zg/bleSendVoucherReply",
  1287. data: {
  1288. lockerId: deviceinfo.deviceNum,
  1289. serialNumber: res.data.serialNumber,
  1290. index: FPindex,
  1291. type: 18,
  1292. result: 0
  1293. }
  1294. }
  1295. WXAPI.sendCommand(datacom).then(res2 => {
  1296. console.log(res2, '失败')
  1297. })
  1298. }
  1299. })
  1300. } else {
  1301. var datacom = {
  1302. code: "zg/bleSendVoucherReply",
  1303. data: {
  1304. lockerId: deviceinfo.deviceNum,
  1305. serialNumber: res.data.serialNumber,
  1306. index: FPindex,
  1307. type: 18,
  1308. result: 0
  1309. }
  1310. }
  1311. WXAPI.sendCommand(datacom).then(res2 => {
  1312. console.log(res2, '失败')
  1313. })
  1314. var data = {
  1315. ids: [personLi.id]
  1316. }
  1317. wx.hideLoading()
  1318. WXAPI.deleteCertificates(data).then(res1 => {
  1319. if (res1.success) {
  1320. _this.getFp()
  1321. }
  1322. })
  1323. wx.hideLoading()
  1324. wx.showToast({
  1325. title: res.msg,
  1326. mask: true,
  1327. icon: 'none',
  1328. duration: 2000
  1329. })
  1330. }
  1331. })
  1332. } else {
  1333. wx.hideLoading()
  1334. wx.showToast({
  1335. title: '获取失败',
  1336. mask: true,
  1337. duration: 2000,
  1338. icon: 'none'
  1339. })
  1340. }
  1341. })
  1342. },
  1343. delPassword1(index) {
  1344. wx.showLoading({
  1345. title: '正在删除',
  1346. mask: true
  1347. })
  1348. var _this = this
  1349. var deviceinfo = this.data.deviceinfo
  1350. var passwordLi = this.data.passwordList[index]
  1351. passwordLiAll = passwordLi
  1352. var info = JSON.parse(passwordLi.content)
  1353. var data = {
  1354. managerTelephone: "18270949468",
  1355. managerPassword: "202108",
  1356. userTelephone: info.userTelephone,
  1357. userPassword: info.userPassword,
  1358. password: info.password,
  1359. startTime: info.passwordStartTime,
  1360. endTime: info.passwordEndTime
  1361. }
  1362. console.log(data)
  1363. var timestamp = moment().format("x")
  1364. bleall.startFp1_63(data.managerTelephone, data.managerPassword, data.userTelephone,
  1365. data.userPassword, data.password, data.startTime, data.endTime, 9, timestamp,
  1366. function (res) {
  1367. if (res.success) {
  1368. var data = {
  1369. ids: [passwordLi.id]
  1370. }
  1371. WXAPI.deleteCertificates(data).then(res1 => {
  1372. if (res1.success) {
  1373. var data3 = {
  1374. code: "ble/operateUserInfo",
  1375. data: {
  1376. deviceNum: deviceinfo.deviceNum,
  1377. imei: deviceinfo.imei,
  1378. userTelephone: info.userTelephone,
  1379. userPassword: info.userPassword,
  1380. password: info.password,
  1381. userStartTime: info.passwordStartTime,
  1382. userEndTime: info.passwordEndTime,
  1383. passwordStartTime: info.passwordStartTime,
  1384. passwordEndTime: info.passwordEndTime,
  1385. operateMode: 9,
  1386. order: 6209,
  1387. timestamp: timestamp,
  1388. managerTelephone: '18270949468',
  1389. managerPassword: '202108',
  1390. passwordLength: 10,
  1391. permission: 4294967295,
  1392. times: 255,
  1393. recycleTime: "65535",
  1394. roomName: _this.data.deviceinfo.roomName,
  1395. cardName: _this.data.personLi.name,
  1396. }
  1397. }
  1398. WXAPI.sendCommand(data3).then(res => {
  1399. if (res.success) {
  1400. var data4 = {
  1401. result: 1,
  1402. serial: res.data.serialNumber
  1403. }
  1404. WXAPI.updatePush(data4).then(res4 => {
  1405. })
  1406. }
  1407. })
  1408. _this.getPassword()
  1409. wx.hideLoading()
  1410. wx.showToast({
  1411. title: '删除成功',
  1412. icon: 'none',
  1413. mask: true,
  1414. duration: 2000
  1415. })
  1416. } else {
  1417. wx.hideLoading()
  1418. wx.showToast({
  1419. title: '删除失败',
  1420. icon: 'none',
  1421. mask: true,
  1422. duration: 2000
  1423. })
  1424. }
  1425. })
  1426. }
  1427. if (res.data == "蓝牙功能暂不支持") {
  1428. // wx.hideLoading()
  1429. // wx.showLoading({
  1430. // title: '重新连接蓝牙中'
  1431. // })
  1432. _this.startconnect()
  1433. }
  1434. })
  1435. },
  1436. startconnect() {
  1437. wx.showLoading({
  1438. title: "连接蓝牙中",
  1439. mask: true
  1440. })
  1441. this.setData({
  1442. showLoading: true
  1443. })
  1444. // this.setData({
  1445. // showLoading:true
  1446. // })
  1447. var deviceinfo = this.data.deviceinfo
  1448. const ble = new BLE(this.data.deviceinfo.deviceNum, emitter)
  1449. app.globalData.ble = ble
  1450. this.watchBLE()
  1451. app.globalData.ble.init()
  1452. // }
  1453. },
  1454. watchBLE() {
  1455. var that = this
  1456. if (app.globalData.ble) {
  1457. app.globalData.ble.listen(res => {
  1458. if (res.type == 'connect') {
  1459. if (res.data == "未打开适配器") {
  1460. this.setData({
  1461. showLoading: false
  1462. })
  1463. wx.hideLoading()
  1464. wx.showModal({
  1465. title: "提示",
  1466. content: "请检查手机蓝牙和定位功能是否打开?",
  1467. showCancel: false,
  1468. confirmText: "确定",
  1469. success(res) {}
  1470. });
  1471. } else {
  1472. if (res.data == '蓝牙已连接') {
  1473. app.globalData.bleStatus = res.data
  1474. this.setData({
  1475. showLoading: false
  1476. })
  1477. if (this.data.current == 0) {
  1478. this.sendPassword()
  1479. } else if (that.data.current == 1) {
  1480. this.delPassword1(this.data.currentIndex)
  1481. } else if (that.data.current == 2) {
  1482. this.sendFp()
  1483. }
  1484. }
  1485. }
  1486. }
  1487. })
  1488. }
  1489. },
  1490. delPasswordLwj(index) {
  1491. wx.showLoading({
  1492. title: '正在删除',
  1493. mask: true
  1494. })
  1495. var _this = this
  1496. var deviceinfo = this.data.deviceinfo
  1497. var passwordLi = this.data.passwordList[index]
  1498. passwordLiAll = passwordLi
  1499. var info = JSON.parse(passwordLi.content)
  1500. var personInfo = JSON.parse(this.data.personLi.info)
  1501. var cgInfo = this.data.cgInfo
  1502. var dataPasswod = {
  1503. code: "lwj/passwordOperate",
  1504. data: {
  1505. lockerId: deviceinfo.deviceNum,
  1506. lockerUserId: personInfo.userId,
  1507. startTime: passwordLi.startTime,
  1508. endTime: passwordLi.endTime,
  1509. order: 6209,
  1510. operateMode: 9,
  1511. action: 2,
  1512. password: info.password,
  1513. type: 9,
  1514. cardName: _this.data.personLi.name,
  1515. roomName: deviceinfo.roomName
  1516. }
  1517. }
  1518. console.log(dataPasswod, 'dataPasswod', info)
  1519. WXAPI.sendCommand(dataPasswod).then(res => {
  1520. console.log(res, '获取索引')
  1521. if (res.success) {
  1522. pincodeIndex = res.data.index
  1523. serialNumber = res.data.serialNumber
  1524. taskId = 52
  1525. _this.initBluetooth()
  1526. } else {
  1527. wx.hideLoading()
  1528. wx.showToast({
  1529. title: res.msg,
  1530. mask: true,
  1531. icon: 'none',
  1532. duration: 2000
  1533. })
  1534. }
  1535. })
  1536. },
  1537. onDelRfCard: function () {
  1538. var that = this
  1539. wx.showLoading({
  1540. title: '删除房卡中',
  1541. })
  1542. var bytes = plugin.delRfCard(lockDevice.name, basecode, 0, rfCardIndex)
  1543. console.debug('bytes', bytes)
  1544. that.sendBytes(bytes)
  1545. },
  1546. onDelFingerprint: function() {
  1547. var that = this
  1548. wx.showLoading({
  1549. title: '删除指纹中',
  1550. })
  1551. var bytes = plugin.delFingerprint(lockDevice.name, basecode, fingerprintIndex)
  1552. console.debug('bytes', bytes);
  1553. that.sendBytes(bytes)
  1554. },
  1555. onDelPincode: function () {
  1556. var that = this
  1557. wx.showLoading({
  1558. title: '删除密码中',
  1559. })
  1560. var bytes = plugin.delPincode(lockDevice.name, basecode, pincode, pincodeIndex)
  1561. console.debug('bytes', bytes)
  1562. that.sendBytes(bytes)
  1563. },
  1564. delPassword(index) {
  1565. wx.showLoading({
  1566. title: '正在删除',
  1567. mask: true
  1568. })
  1569. var _this = this
  1570. var deviceinfo = this.data.deviceinfo
  1571. var passwordLi = this.data.passwordList[index]
  1572. passwordLiAll = passwordLi
  1573. var info = JSON.parse(passwordLi.content)
  1574. var personInfo = JSON.parse(this.data.personLi.info)
  1575. var cgInfo = this.data.cgInfo
  1576. var dataPasswod = {
  1577. code: "zg/tempPassword",
  1578. data: {
  1579. lockerId: deviceinfo.deviceNum,
  1580. imei: deviceinfo.imei,
  1581. passwordCount: 255,
  1582. lockerUserId: personInfo.userId,
  1583. keyId: personInfo.userId,
  1584. passwordStartTime: passwordLi.startTime,
  1585. passwordEndTime: passwordLi.endTime,
  1586. order: 6209,
  1587. action: 2,
  1588. password: info.password,
  1589. type: 1,
  1590. cardName: _this.data.personLi.name,
  1591. roomName: deviceinfo.roomName
  1592. }
  1593. }
  1594. console.log(dataPasswod, 'dataPasswod', info)
  1595. WXAPI.sendCommand(dataPasswod).then(res => {
  1596. console.log(res, '获取索引')
  1597. if (res.success) {
  1598. var pwdNo = res.data.index.toString(16)
  1599. var passwordIndex = res.data.index
  1600. if (pwdNo < 9) {
  1601. pwdNo = '0' + pwdNo
  1602. } else {
  1603. pwdNo = pwdNo
  1604. }
  1605. ICINLocker.getUserSignKey(cgInfo.lockerId, cgInfo.superId, personInfo.userId, cgInfo.superId, cgInfo.authKey, '01', (callback) => {
  1606. console.log(callback)
  1607. if (callback.status == '00') {
  1608. var userSignKey = callback.userSignKey
  1609. ICINLocker.getCommonKey(cgInfo.lockerId, personInfo.userId, personInfo.userId, userSignKey, (callback) => {
  1610. if (callback.status == '00') {
  1611. console.log(callback, 'commonKey')
  1612. var commonKey = callback.commonKey
  1613. var startTime = passwordLi.startTime.toString(16).toUpperCase()
  1614. var endTime = passwordLi.endTime.toString(16).toUpperCase()
  1615. ICINLocker.handlePwd(deviceinfo.deviceNum, cgInfo.superId, personInfo.userId, info.password, pwdNo, cgInfo.superId, cgInfo.authKey, '', startTime, endTime, 0, commonKey, (callback) => {
  1616. console.log(callback)
  1617. if (callback.status == '00') {
  1618. var datacom = {
  1619. code: "zg/bleSendVoucherReply",
  1620. data: {
  1621. lockerId: deviceinfo.deviceNum,
  1622. serialNumber: res.data.serialNumber,
  1623. index: passwordIndex,
  1624. type: 9,
  1625. result: 1
  1626. }
  1627. }
  1628. WXAPI.sendCommand(datacom).then(res2 => {
  1629. if (res2.success) {}
  1630. })
  1631. var data = {
  1632. ids: [passwordLiAll.id]
  1633. }
  1634. WXAPI.deleteCertificates(data).then(res1 => {
  1635. if (res1.success) {
  1636. _this.getPassword()
  1637. wx.hideLoading()
  1638. wx.showToast({
  1639. title: '删除成功',
  1640. mask: true,
  1641. icon: 'none',
  1642. duration: 2000
  1643. })
  1644. } else {
  1645. wx.hideLoading()
  1646. wx.showToast({
  1647. title: '删除失败',
  1648. mask: true,
  1649. icon: 'none',
  1650. duration: 2000
  1651. })
  1652. }
  1653. })
  1654. } else {
  1655. wx.hideLoading()
  1656. wx.showToast({
  1657. title: '删除失败',
  1658. mask: true,
  1659. icon: 'none',
  1660. duration: 2000
  1661. })
  1662. var datacom = {
  1663. code: "zg/bleSendVoucherReply",
  1664. data: {
  1665. lockerId: deviceinfo.deviceNum,
  1666. serialNumber: res.data.serialNumber,
  1667. index: res.data.index,
  1668. type: 9,
  1669. result: 0
  1670. }
  1671. }
  1672. WXAPI.sendCommand(datacom).then(res2 => {
  1673. console.log(res2, '失败')
  1674. })
  1675. }
  1676. })
  1677. } else {
  1678. wx.hideLoading()
  1679. wx.showToast({
  1680. title: '删除失败',
  1681. mask: true,
  1682. icon: 'none',
  1683. duration: 2000
  1684. })
  1685. }
  1686. })
  1687. } else {
  1688. wx.hideLoading()
  1689. wx.showToast({
  1690. title: '删除失败',
  1691. mask: true,
  1692. icon: 'none',
  1693. duration: 2000
  1694. })
  1695. }
  1696. })
  1697. } else {
  1698. wx.hideLoading()
  1699. wx.showToast({
  1700. title: res.msg,
  1701. mask: true,
  1702. icon: 'none',
  1703. duration: 2000
  1704. })
  1705. }
  1706. })
  1707. },
  1708. getPassWordMehods(content, id, type) {
  1709. var that = this
  1710. var data = {
  1711. pageNum: 0,
  1712. pageSize: 0,
  1713. orderBy: "create_at desc",
  1714. q: {
  1715. cardId: id,
  1716. password: content,
  1717. deviceNum: this.data.deviceinfo.deviceNum,
  1718. types: type,
  1719. inStatus: '0,1,702'
  1720. },
  1721. };
  1722. WXAPI.getCertificates(data).then(res => {
  1723. if (res.success) {
  1724. var dataOne = util.zlib_unzip(res.data)
  1725. if (dataOne.length > 0) {
  1726. wx.showModal({
  1727. title: '提示',
  1728. content: '该密码已存在,不能重复添加',
  1729. success(res1) {
  1730. if (res1.confirm) {
  1731. console.log('用户点击确定')
  1732. that.setData({
  1733. password: '',
  1734. passwordStatus: false
  1735. })
  1736. } else if (res1.cancel) {
  1737. console.log('用户点击取消')
  1738. that.setData({
  1739. password: '',
  1740. passwordStatus: false
  1741. })
  1742. }
  1743. }
  1744. })
  1745. } else {
  1746. this.setData({
  1747. passwordStatus: true
  1748. })
  1749. }
  1750. } else {
  1751. wx.showToast({
  1752. title: '获取失败',
  1753. duration: '2000',
  1754. mask: true,
  1755. icon: 'none'
  1756. })
  1757. }
  1758. })
  1759. },
  1760. sendPassword() {
  1761. let passwordLength = this.data.password.toString()
  1762. if (passwordLength.length != 6) {
  1763. wx.showToast({
  1764. title: '格式错误,密码为6位数字!',
  1765. icon: 'none'
  1766. })
  1767. return false;
  1768. }
  1769. wx.showLoading({
  1770. title: '正在添加',
  1771. mask: true,
  1772. })
  1773. var time3 = new Date(this.data.datetimerange[0].replace(/-/g, '/'))
  1774. var time4 = new Date(this.data.datetimerange[1].replace(/-/g, '/'))
  1775. var passwordStartTimecontrast = time3.getTime() / 1000
  1776. var passwordEndTimecontrast = time4.getTime() / 1000
  1777. this.getPassWordMehods(this.data.password, this.data.personLi.cardId, 14)
  1778. if (this.data.password == '') {
  1779. wx.showToast({
  1780. title: '密码不能为空',
  1781. mask: true,
  1782. duration: 2000,
  1783. icon: 'none'
  1784. })
  1785. return
  1786. }
  1787. if (!this.data.passwordStatus) {
  1788. wx.showToast({
  1789. title: '已存在该密码,请重输',
  1790. duration: 2000,
  1791. mask: true,
  1792. icon: 'none'
  1793. })
  1794. return
  1795. }
  1796. if (passwordStartTimecontrast > passwordEndTimecontrast) {
  1797. wx.showToast({
  1798. title: '开始时间不能大于结束时间',
  1799. duration: 2000,
  1800. mask: true,
  1801. icon: 'none'
  1802. })
  1803. return
  1804. }
  1805. wx.showLoading({
  1806. title: '正在添加',
  1807. mask: true
  1808. })
  1809. var _this = this
  1810. var deviceinfo = this.data.deviceinfo
  1811. var info = JSON.parse(this.data.personLi.info)
  1812. if (deviceinfo.manufactureId == 101) {
  1813. var time1 = moment(this.data.datetimerange[0]).format("YYYYMMDDHHmmss")
  1814. var time2 = moment(this.data.datetimerange[1]).format("YYYYMMDDHHmmss")
  1815. var time3 = new Date(_this.data.datetimerange[0].replace(/-/g, '/'))
  1816. var time4 = new Date(_this.data.datetimerange[1].replace(/-/g, '/'))
  1817. var passwordStartTime = time3.getTime() / 1000
  1818. var passwordEndTime = time4.getTime() / 1000
  1819. var data1 = {
  1820. managerTelephone: "18270949468",
  1821. managerPassword: '202108',
  1822. userTelephone: info.userTelephone,
  1823. userPassword: info.userPassword,
  1824. password: this.data.password,
  1825. startTime: time1,
  1826. endTime: time2
  1827. }
  1828. var timestamp = moment().format("x")
  1829. bleall.startFp1_63(data1.managerTelephone, data1.managerPassword, data1.userTelephone,
  1830. data1.userPassword, data1.password, data1.startTime, data1.endTime, 7, timestamp,
  1831. function (res) {
  1832. console.log(res)
  1833. if (res.success) {
  1834. var pzname = '',
  1835. cardName = ''
  1836. pzname = '蓝牙-密码' + (_this.data.passwordList.length + 1)
  1837. cardName = _this.data.personLi.name + '-蓝牙-密码' + (_this.data.passwordList.length + 1)
  1838. var str = {
  1839. // cardId: this.personInfo.cardId,
  1840. pzname: pzname,
  1841. imei: _this.data.deviceinfo.imei,
  1842. password: _this.data.password.toString(),
  1843. userTelephone: JSON.parse(_this.data.personLi.info).userTelephone,
  1844. operateMode: 7,
  1845. userPassword: JSON.parse(_this.data.personLi.info).userPassword,
  1846. passwordStartTime: time1,
  1847. passwordEndTime: time2,
  1848. is: false,
  1849. pass: true
  1850. }
  1851. var data3 = {
  1852. code: "ble/operateUserInfo",
  1853. data: {
  1854. deviceNum: _this.data.deviceinfo.deviceNum,
  1855. imei: _this.data.deviceinfo.imei,
  1856. userTelephone: info.userTelephone,
  1857. userPassword: info.userPassword,
  1858. password: _this.data.password,
  1859. userStartTime: time1,
  1860. userEndTime: time2,
  1861. passwordStartTime: time1,
  1862. passwordEndTime: time2,
  1863. operateMode: 7,
  1864. order: 6207,
  1865. timestamp: timestamp,
  1866. managerTelephone: '18270949468',
  1867. managerPassword: '202108',
  1868. passwordLength: 10,
  1869. permission: 4294967295,
  1870. times: 255,
  1871. recycleTime: "65535",
  1872. roomName: _this.data.deviceinfo.roomName,
  1873. cardName: cardName,
  1874. }
  1875. }
  1876. WXAPI.sendCommand(data3).then(res3 => {
  1877. if (res3.success) {
  1878. var data4 = {
  1879. result: 1,
  1880. serial: res3.data.serialNumber
  1881. }
  1882. WXAPI.updatePush(data4).then(res4 => {
  1883. })
  1884. var data = {
  1885. cardId: _this.data.personLi.cardId,
  1886. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  1887. deviceNum: _this.data.deviceinfo.deviceNum,
  1888. type: 4,
  1889. imei: _this.data.deviceinfo.imei,
  1890. serial: res3.data.serialNumber,
  1891. startTime: passwordStartTime,
  1892. endTime: passwordEndTime,
  1893. };
  1894. var datalist = {
  1895. cardId: _this.data.personLi.cardId,
  1896. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  1897. type: 14,
  1898. startTime: passwordStartTime,
  1899. endTime: passwordEndTime,
  1900. };
  1901. console.log(datalist, '密码11')
  1902. WXAPI.addCertificates(datalist).then(res6 => {
  1903. console.log(datalist, '密码22')
  1904. })
  1905. WXAPI.addCertificates(data).then(res3 => {
  1906. if (res3.success) {
  1907. var updatedata = {
  1908. id: res3.data,
  1909. status: 1
  1910. };
  1911. WXAPI.updateCertificates(updatedata).then((res2) => {});
  1912. _this.getPassword()
  1913. _this.setData({
  1914. show: false
  1915. })
  1916. wx.hideLoading()
  1917. wx.showToast({
  1918. title: '添加成功',
  1919. icon: 'none',
  1920. mask: true,
  1921. duration: 2000
  1922. })
  1923. } else {
  1924. wx.hideLoading()
  1925. wx.showToast({
  1926. title: '添加失败',
  1927. mask: true,
  1928. icon: 'none',
  1929. duration: 2000
  1930. })
  1931. }
  1932. })
  1933. } else {
  1934. wx.showToast({
  1935. title: res3.msg,
  1936. mask: true,
  1937. icon: 'none',
  1938. duration: 2000
  1939. })
  1940. }
  1941. })
  1942. } else {
  1943. wx.hideLoading()
  1944. if (res.data == "蓝牙功能暂不支持") {
  1945. // wx.showToast({
  1946. // title: '重新连接蓝牙中',
  1947. // duration: 2000,
  1948. // icon: "none"
  1949. // })
  1950. _this.startconnect()
  1951. } else {
  1952. wx.showToast({
  1953. title: '下发失败',
  1954. mask: true,
  1955. duration: 2000,
  1956. icon: "none"
  1957. })
  1958. }
  1959. }
  1960. })
  1961. } else if (deviceinfo.manufactureId == 201 || deviceinfo.manufactureId == 221) {
  1962. var cgInfo = this.data.cgInfo
  1963. var time1 = new Date(_this.data.datetimerange[0].replace(/-/g, '/'))
  1964. var time2 = new Date(_this.data.datetimerange[1].replace(/-/g, '/'))
  1965. var passwordStartTime = time1.getTime() / 1000
  1966. var passwordEndTime = time2.getTime() / 1000
  1967. var pzname = '',
  1968. cardName = ''
  1969. pzname = '蓝牙-密码' + (_this.data.passwordList.length + 1)
  1970. cardName = _this.data.personLi.name + '-蓝牙-密码' + (_this.data.passwordList.length + 1)
  1971. var dataPasswod = {
  1972. code: "zg/tempPassword",
  1973. data: {
  1974. lockerId: deviceinfo.deviceNum,
  1975. imei: deviceinfo.imei,
  1976. passwordCount: 255,
  1977. lockerUserId: info.userId,
  1978. keyId: info.userId,
  1979. passwordStartTime: passwordStartTime,
  1980. passwordEndTime: passwordEndTime,
  1981. order: 6207,
  1982. action: 1,
  1983. password: this.data.password.toString(),
  1984. type: 1,
  1985. roomName: this.data.deviceinfo.roomName,
  1986. cardName: cardName,
  1987. }
  1988. }
  1989. WXAPI.sendCommand(dataPasswod).then(res => {
  1990. console.log(res, '获取索引')
  1991. if (res.success) {
  1992. var pwdNo = res.data.index
  1993. var passwordIndex = res.data.index
  1994. // var str = res.data.index
  1995. pwdNo = pwdNo.toString(16)
  1996. if (pwdNo.length < 2) {
  1997. pwdNo = '0' + pwdNo
  1998. }
  1999. var startTime = passwordStartTime.toString(16).toUpperCase()
  2000. var endTime = passwordEndTime.toString(16).toUpperCase()
  2001. info.startTime = startTime
  2002. info.endTime = endTime
  2003. info.pwdNo = pwdNo
  2004. info.password = this.data.password.toString()
  2005. methods.bluetoothOperation_ZH(cgInfo, info, 3).then(result => {
  2006. if (result.status == '00' || result.status == '0a') {
  2007. var datacom = {
  2008. code: "zg/bleSendVoucherReply",
  2009. data: {
  2010. lockerId: deviceinfo.deviceNum,
  2011. serialNumber: res.data.serialNumber,
  2012. index: passwordIndex,
  2013. type: 7,
  2014. result: 1
  2015. }
  2016. }
  2017. var str = {
  2018. // cardId: this.personInfo.cardId,
  2019. imei: _this.data.deviceinfo.imei,
  2020. pzname: pzname,
  2021. password: _this.data.password.toString(),
  2022. userTelephone: JSON.parse(_this.data.personLi.info).userTelephone,
  2023. operateMode: 7,
  2024. userPassword: JSON.parse(_this.data.personLi.info).userPassword,
  2025. passwordStartTime: passwordStartTime,
  2026. passwordEndTime: passwordEndTime,
  2027. is: false,
  2028. pass: true
  2029. }
  2030. var data = {
  2031. cardId: _this.data.personLi.cardId,
  2032. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  2033. deviceNum: _this.data.deviceinfo.deviceNum,
  2034. type: 4,
  2035. imei: _this.data.deviceinfo.imei,
  2036. serial: res.data.serialNumber,
  2037. startTime: passwordStartTime,
  2038. endTime: passwordEndTime,
  2039. };
  2040. var datalist = {
  2041. cardId: _this.data.personLi.cardId,
  2042. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  2043. type: 14,
  2044. startTime: passwordStartTime,
  2045. endTime: passwordEndTime,
  2046. };
  2047. console.log(datalist, '密码11')
  2048. WXAPI.addCertificates(datalist).then(res6 => {
  2049. console.log(datalist, '密码22', res6)
  2050. })
  2051. console.log(data, '添加凭证')
  2052. WXAPI.addCertificates(data).then(res3 => {
  2053. if (res3.success) {
  2054. var updatedata = {
  2055. id: res3.data,
  2056. status: 1
  2057. };
  2058. WXAPI.updateCertificates(updatedata).then((res2) => {});
  2059. WXAPI.sendCommand(datacom).then(res2 => {
  2060. if (res2.success) {}
  2061. })
  2062. console.log(res3, '添加凭证成功')
  2063. _this.getPassword()
  2064. _this.setData({
  2065. show: false
  2066. })
  2067. wx.hideLoading()
  2068. wx.showToast({
  2069. title: '添加成功',
  2070. mask: true,
  2071. icon: 'none',
  2072. duration: 2000
  2073. })
  2074. } else {
  2075. wx.hideLoading()
  2076. wx.showToast({
  2077. title: '添加失败',
  2078. mask: true,
  2079. icon: 'none',
  2080. duration: 2000
  2081. })
  2082. }
  2083. })
  2084. } else {
  2085. wx.showToast({
  2086. title: '添加失败',
  2087. mask: true,
  2088. icon: 'none',
  2089. duration: 2000
  2090. })
  2091. var datacom = {
  2092. code: "zg/bleSendVoucherReply",
  2093. data: {
  2094. lockerId: deviceinfo.deviceNum,
  2095. serialNumber: res.data.serialNumber,
  2096. index: res.data.index,
  2097. type: 7,
  2098. result: 0
  2099. }
  2100. }
  2101. WXAPI.sendCommand(datacom).then(res2 => {
  2102. console.log(res2, '失败')
  2103. _this.setData({
  2104. show: false
  2105. })
  2106. })
  2107. }
  2108. }).catch(err => {
  2109. wx.hideLoading()
  2110. wx.showToast({
  2111. title: '添加失败',
  2112. icon: 'none',
  2113. mask: true,
  2114. duration: 2000
  2115. })
  2116. var datacom = {
  2117. code: "zg/bleSendVoucherReply",
  2118. data: {
  2119. lockerId: deviceinfo.deviceNum,
  2120. serialNumber: res.data.serialNumber,
  2121. index: res.data.index,
  2122. type: 7,
  2123. result: 0
  2124. }
  2125. }
  2126. WXAPI.sendCommand(datacom).then(res2 => {
  2127. console.log(res2, '失败')
  2128. _this.setData({
  2129. show: false
  2130. })
  2131. })
  2132. })
  2133. } else {
  2134. wx.showToast({
  2135. title: res.msg,
  2136. duration: 2000,
  2137. mask: true,
  2138. icon: 'none'
  2139. })
  2140. }
  2141. })
  2142. } else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) {
  2143. console.log(this.data.isSearch);
  2144. if (this.data.isSearch) {
  2145. wx.hideLoading()
  2146. this.addPincode()
  2147. } else {
  2148. this.searchDevicesMethods()
  2149. }
  2150. }
  2151. },
  2152. onAddPincode: function () {
  2153. console.log("2073123");
  2154. var that = this
  2155. wx.showLoading({
  2156. title: '添加密码中',
  2157. })
  2158. var info = JSON.parse(this.data.personLi.info)
  2159. let deviceinfo = this.data.deviceinfo
  2160. var time1 = new Date(that.data.starttime.replace(/-/g, '/'))
  2161. var time2 = new Date(that.data.endtime.replace(/-/g, '/'))
  2162. var passwordStartTime = time1.getTime() / 1000
  2163. var passwordEndTime = time2.getTime() / 1000
  2164. var pzname = '',
  2165. cardName = ''
  2166. pzname = '蓝牙-密码' + (that.data.passwordList.length + 1)
  2167. cardName = that.data.personLi.name + '-蓝牙-密码' + (that.data.passwordList.length + 1)
  2168. var dataPasswod = {
  2169. code: "lwj/passwordOperate",
  2170. data: {
  2171. lockerId: deviceinfo.deviceNum,
  2172. lockerUserId: info.userId,
  2173. startTime: passwordStartTime,
  2174. endTime: passwordEndTime,
  2175. order: 6207,
  2176. operateMode: 7,
  2177. action: 1,
  2178. password: this.data.password.toString(),
  2179. type: 7,
  2180. roomName: this.data.deviceinfo.roomName,
  2181. cardName: cardName,
  2182. }
  2183. }
  2184. console.log(dataPasswod);
  2185. WXAPI.sendCommand(dataPasswod).then(res => {
  2186. console.log(res, '获取索引')
  2187. if (res.success) {
  2188. var pwdNo = res.data.index
  2189. serialNumber = res.data.serialNumber
  2190. pincodeIndex = pwdNo
  2191. that.sendAddPincode()
  2192. }
  2193. })
  2194. // var startTime = util1.getLocalTime(8)
  2195. // var endTime = new Date(startTime.getTime() + 5 * 60 * 1000) //有效期5分钟
  2196. },
  2197. sendAddPincode() {
  2198. var that = this
  2199. var startTime = new Date(Number(moment(that.data.starttime).format('x')))
  2200. var endTime = new Date(Number(moment(that.data.endtime).format('x')))
  2201. pincode = this.data.password
  2202. console.log(lockDevice.name, basecode, pincode, pincodeIndex, startTime, endTime)
  2203. let bytes = plugin.addPincode(lockDevice.name, basecode, pincode, pincodeIndex, startTime, endTime)
  2204. console.log('bytes', bytes)
  2205. that.sendBytes(bytes)
  2206. },
  2207. addPincode: function () {
  2208. console.log("2124");
  2209. var that = this
  2210. taskId = 51
  2211. that.initBluetooth()
  2212. },
  2213. initBluetooth: function () {
  2214. var that = this
  2215. wx.getConnectedBluetoothDevices({
  2216. services: [config.uuid.serviceUuid],
  2217. success: function (res) {
  2218. res.devices.map(function (it) {
  2219. if (it.deviceId == connectedDeviceId || it.name == that.data.deviceinfo.deviceNum) {
  2220. isConnected = true
  2221. }
  2222. })
  2223. that.setData({
  2224. isConnected: isConnected
  2225. })
  2226. console.log(isInitReady, 'isConnected', isConnected)
  2227. if (isConnected) {
  2228. console.log("2144");
  2229. if (isInitReady) {
  2230. console.log("2146");
  2231. that.doWork()
  2232. } else {
  2233. that.setupConnection()
  2234. }
  2235. } else {
  2236. that.connectTo()
  2237. }
  2238. },
  2239. })
  2240. },
  2241. setupConnection: function () {
  2242. var that = this
  2243. wx.showLoading({
  2244. title: '初始化连接中',
  2245. })
  2246. wx.getBLEDeviceServices({
  2247. deviceId: lockDevice.deviceId,
  2248. success: function (res) {
  2249. console.log('Services', res)
  2250. wx.getBLEDeviceCharacteristics({
  2251. deviceId: lockDevice.deviceId,
  2252. serviceId: config.uuid.serviceUuid.toUpperCase(),
  2253. success: function (res) {
  2254. console.log('Characteristics', res)
  2255. wx.showToast({
  2256. title: '连接成功',
  2257. duration: 1000,
  2258. icon: 'none'
  2259. })
  2260. wx.onBLECharacteristicValueChange(function (res) {
  2261. console.log(res, 'reslllllll')
  2262. var bytes = new Uint8Array(res.value)
  2263. console.log('bytes', bytes)
  2264. var data = plugin.parseBytes(lockDevice.name, basecode, bytes)
  2265. console.log('data', data)
  2266. switch (data.cmd) {
  2267. case 'reportLockBattery': {
  2268. if (data.data.battery < 10) {
  2269. wx.showModal({
  2270. title: '电量报警',
  2271. content: `门锁当前电量${data.data.battery}%!\n电量严重不足,请立即更换电池!`,
  2272. showCancel: false
  2273. })
  2274. } else if (data.data.battery < 30) {
  2275. wx.showModal({
  2276. title: '电量预警',
  2277. content: `门锁当前电量${data.data.battery}%!\n请及时更换电池!`,
  2278. showCancel: false
  2279. })
  2280. }
  2281. break
  2282. }
  2283. case 'reportRfCardResult': {
  2284. if (taskId == 61) {
  2285. wx.showModal({
  2286. title: '检测到新卡',
  2287. content: `是否添加此房卡,卡号:${data.data.cardId}`,
  2288. success: function (res) {
  2289. if (res.confirm) {
  2290. console.log(data.data, 'rfCardIdrfCardId')
  2291. // rfCardId = randomMethods()//data.data.cardId
  2292. that.onAddRfCard()
  2293. }
  2294. }
  2295. })
  2296. } else {
  2297. if (lockModel > 70) {
  2298. if (data.data.isValid) {
  2299. wx.showModal({
  2300. title: '提示',
  2301. content: `房卡开锁成功,序号:${data.data.index}`,
  2302. showCancel: false
  2303. })
  2304. } else {
  2305. wx.showModal({
  2306. title: '提示',
  2307. content: `多次刷房卡开锁失败!`,
  2308. showCancel: false
  2309. })
  2310. }
  2311. } else {
  2312. if (data.data.isValid) {
  2313. wx.showModal({
  2314. title: '提示',
  2315. content: `房卡开锁成功,卡号:${data.data.cardId}`,
  2316. showCancel: false
  2317. })
  2318. } else {
  2319. wx.showModal({
  2320. title: '提示',
  2321. content: `房卡未授权,卡号:${data.data.cardId}`,
  2322. showCancel: false
  2323. })
  2324. }
  2325. }
  2326. }
  2327. break
  2328. }
  2329. case 'reportPincodeResult': {
  2330. if (lockModel > 70) {
  2331. if (data.data.isValid) {
  2332. wx.showModal({
  2333. title: '提示',
  2334. content: `密码开锁成功,序号:${data.data.index}`,
  2335. showCancel: false
  2336. })
  2337. } else {
  2338. wx.showModal({
  2339. title: '提示',
  2340. content: `多次密码开锁失败!`,
  2341. showCancel: false
  2342. })
  2343. }
  2344. } else {
  2345. if (data.data.isValid) {
  2346. wx.showModal({
  2347. title: '提示',
  2348. content: `密码:${data.data.pincode}开锁成功!`,
  2349. showCancel: false
  2350. })
  2351. } else {
  2352. wx.showModal({
  2353. title: '提示',
  2354. content: `密码:${data.data.pincode}未授权!`,
  2355. showCancel: false
  2356. })
  2357. }
  2358. }
  2359. break
  2360. }
  2361. case 'reportFingerprintResult': {
  2362. if (data.data.isValid) {
  2363. wx.showModal({
  2364. title: '提示',
  2365. content: `指纹开锁成功,序号:${data.data.index}`,
  2366. showCancel: false
  2367. })
  2368. } else {
  2369. wx.showModal({
  2370. title: '提示',
  2371. content: `多次指纹开锁失败!`,
  2372. showCancel: false
  2373. })
  2374. }
  2375. break
  2376. }
  2377. case 'queryLockState': {
  2378. wx.hideLoading()
  2379. if (data.code != 200) {
  2380. wx.showModal({
  2381. title: '提示',
  2382. content: '查询失败!',
  2383. showCancel: false,
  2384. success: function (res) {}
  2385. })
  2386. break
  2387. }
  2388. that.setData({
  2389. lock: {
  2390. mac: data.data.mac,
  2391. lockType: util1.getLockType(lockModel),
  2392. },
  2393. isBindLock: data.data.isBind
  2394. })
  2395. lockMac = data.data.mac
  2396. if (taskId > 0) {
  2397. if (data.data.isBind) {
  2398. // wx.showModal({
  2399. // title: data.data.mac,
  2400. // content: '此设备已经硬件绑定!',
  2401. // showCancel: false,
  2402. // success: function (res) {}
  2403. // })
  2404. } else {
  2405. wx.showModal({
  2406. title: data.data.mac,
  2407. content: '此设备硬件未绑定!',
  2408. showCancel: false,
  2409. success: function (res) {}
  2410. })
  2411. }
  2412. }
  2413. taskId = 0
  2414. break
  2415. }
  2416. case 'queryLockBattery': {
  2417. wx.hideLoading()
  2418. if (data.code != 200) {
  2419. wx.showModal({
  2420. title: '提示',
  2421. content: '查询失败!',
  2422. showCancel: false,
  2423. success: function (res) {}
  2424. })
  2425. break
  2426. }
  2427. taskId = 0
  2428. wx.showModal({
  2429. title: '提示',
  2430. content: `此门锁电量为${data.data.battery}%`,
  2431. showCancel: false,
  2432. success: function (res) {}
  2433. })
  2434. break
  2435. }
  2436. case 'queryNbImei': {
  2437. wx.hideLoading()
  2438. if (data.code != 200) {
  2439. wx.showModal({
  2440. title: '提示',
  2441. content: '查询失败!',
  2442. showCancel: false,
  2443. success: function (res) {}
  2444. })
  2445. break
  2446. }
  2447. taskId = 0
  2448. wx.showModal({
  2449. title: '提示',
  2450. content: `此NB设备IMEI为${data.data.imei}`,
  2451. showCancel: false,
  2452. success: function (res) {}
  2453. })
  2454. break
  2455. }
  2456. case 'setNbFun': {
  2457. wx.hideLoading()
  2458. if (data.code != 200) {
  2459. wx.showModal({
  2460. title: '提示',
  2461. content: '设置Nb功能失败!',
  2462. showCancel: false,
  2463. success: function (res) {}
  2464. })
  2465. break
  2466. }
  2467. taskId = 0
  2468. wx.showModal({
  2469. title: '提示',
  2470. content: that.data.isNbEnable ? 'NB功能已禁用' : 'NB功能已打开',
  2471. showCancel: false,
  2472. })
  2473. that.setData({
  2474. isNbEnable: !that.data.isNbEnable
  2475. })
  2476. break
  2477. }
  2478. case 'sendBindLock': {
  2479. wx.hideLoading()
  2480. if (data.code != 200) {
  2481. wx.showModal({
  2482. title: '提示',
  2483. content: '绑定失败!',
  2484. showCancel: false,
  2485. success: function (res) {}
  2486. })
  2487. break
  2488. }
  2489. taskId = 0
  2490. that.setData({
  2491. isBindLock: data.data.isBind
  2492. })
  2493. if (data.data.isBind) {
  2494. wx.showToast({
  2495. title: '绑定成功!',
  2496. })
  2497. } else {
  2498. wx.showToast({
  2499. title: '绑定失败!',
  2500. })
  2501. }
  2502. break
  2503. }
  2504. case 'sendUnbindLock': {
  2505. wx.hideLoading()
  2506. if (data.code != 200) {
  2507. wx.showModal({
  2508. title: '提示',
  2509. content: '解绑失败!',
  2510. showCancel: false,
  2511. success: function (res) {}
  2512. })
  2513. break
  2514. }
  2515. taskId = 0
  2516. that.setData({
  2517. isBindLock: data.data.isBind
  2518. })
  2519. if (data.data.isBind) {
  2520. wx.showToast({
  2521. title: '解绑失败!',
  2522. })
  2523. } else {
  2524. wx.showToast({
  2525. title: '解绑成功!',
  2526. })
  2527. }
  2528. break
  2529. }
  2530. case 'login1':
  2531. case 'sendOpenLockP1': {
  2532. if (data.code != 200) {
  2533. wx.hideLoading()
  2534. if (taskId == 41) {
  2535. wx.showModal({
  2536. title: '提示',
  2537. content: that.data.isJack ? '上电失败!' : '解锁失败!',
  2538. showCancel: false,
  2539. success: function (res) {}
  2540. })
  2541. } else if (taskId == 32) {
  2542. wx.showModal({
  2543. title: '提示',
  2544. content: '登录失败!',
  2545. showCancel: false,
  2546. success: function (res) {}
  2547. })
  2548. }
  2549. break
  2550. }
  2551. if (taskId == 41) {
  2552. var bytes = plugin.sendOpenLockP2(lockDevice.name, basecode, data.data.randomN)
  2553. console.debug('bytes', bytes)
  2554. that.sendBytes(bytes)
  2555. } else if (taskId == 32) {
  2556. var bytes = plugin.login2(lockDevice.name, basecode, data.data.randomN)
  2557. console.debug('bytes', bytes)
  2558. that.sendBytes(bytes)
  2559. }
  2560. break;
  2561. }
  2562. case 'login':
  2563. case 'sendOpenLockP2': {
  2564. wx.hideLoading()
  2565. if (data.code != 200) {
  2566. if (taskId == 41) {
  2567. wx.showModal({
  2568. title: '提示',
  2569. content: that.data.isJack ? '上电失败!' : '解锁失败!',
  2570. showCancel: false,
  2571. success: function (res) {}
  2572. })
  2573. } else if (taskId == 32) {
  2574. wx.showModal({
  2575. title: '提示',
  2576. content: '登录失败!',
  2577. showCancel: false,
  2578. success: function (res) {}
  2579. })
  2580. }
  2581. break
  2582. }
  2583. isLockLogin = true
  2584. if (taskId == 41) {
  2585. // var data = {
  2586. // code: "zg/bleUnlockRecord",
  2587. // data: {
  2588. // lockerId: that.data.deviceinfo.deviceNum,
  2589. // roomId:that.data.deviceinfo.roomId,
  2590. // roomName:that.data.deviceinfo.roomName,
  2591. // cardName:that.data.userInfo.username
  2592. // }
  2593. // }
  2594. var data = {
  2595. code: "ble/bleUnlockRecord",
  2596. data: {
  2597. deviceNum: that.data.deviceinfo.deviceNum,
  2598. roomId: that.data.deviceinfo.roomId,
  2599. roomName: that.data.deviceinfo.roomName,
  2600. cardName: that.data.userInfo.username,
  2601. productId: that.data.deviceinfo.manufactureId,
  2602. userId: '29283991'
  2603. }
  2604. }
  2605. WXAPI.sendCommand(data).then(res => {
  2606. console.log(res)
  2607. })
  2608. wx.showToast({
  2609. title: that.data.isJack ? '上电成功!' : '解锁成功!',
  2610. })
  2611. } else if (taskId == 32) {
  2612. wx.showToast({
  2613. title: '登录成功!',
  2614. })
  2615. }
  2616. taskId = 0
  2617. break;
  2618. }
  2619. case 'syncClock': {
  2620. wx.hideLoading()
  2621. if (data.code != 200) {
  2622. wx.showModal({
  2623. title: '提示',
  2624. content: '同步时间失败!' + data.data.msg,
  2625. showCancel: false,
  2626. success: function (res) {}
  2627. })
  2628. break
  2629. }
  2630. taskId = 0
  2631. wx.showModal({
  2632. title: '提示',
  2633. content: '时间更新成功!',
  2634. showCancel: false
  2635. })
  2636. break;
  2637. }
  2638. case 'addPincode': {
  2639. // console.log(data.data,'data.data')
  2640. // wx.hideLoading()
  2641. let data2 = {
  2642. "code": "ble/bleSendVoucherReply",
  2643. "data": {
  2644. "deviceNum": that.data.deviceinfo.deviceNum,
  2645. "serialNumber": serialNumber,
  2646. "index": pincodeIndex,
  2647. "type": 7,
  2648. "result": 1,
  2649. "productId": that.data.deviceinfo.manufactureId
  2650. }
  2651. }
  2652. if (data.code != 200) {
  2653. data2 = {
  2654. "code": "ble/bleSendVoucherReply",
  2655. "data": {
  2656. "deviceNum": that.data.deviceinfo.deviceNum,
  2657. "serialNumber": serialNumber,
  2658. "index": pincodeIndex,
  2659. "type": 7,
  2660. "result": 0,
  2661. "productId": that.data.deviceinfo.manufactureId
  2662. }
  2663. }
  2664. WXAPI.sendCommand(data2).then(res => {
  2665. })
  2666. wx.showModal({
  2667. title: '提示',
  2668. content: '添加密码失败!' + data.data.msg,
  2669. showCancel: false,
  2670. success: function (res) {}
  2671. })
  2672. break
  2673. }
  2674. var time1 = new Date(that.data.starttime.replace(/-/g, '/'))
  2675. var time2 = new Date(that.data.endtime.replace(/-/g, '/'))
  2676. var passwordStartTime = time1.getTime() / 1000
  2677. var passwordEndTime = time2.getTime() / 1000
  2678. var pzname = '',
  2679. cardName = '';
  2680. pzname = '蓝牙-密码' + (that.data.passwordList.length + 1)
  2681. cardName = that.data.personLi.name + '-蓝牙-密码' + (that.data.passwordList.length + 1)
  2682. var str = {
  2683. // cardId: this.personInfo.cardId,
  2684. imei: that.data.deviceinfo.imei,
  2685. pzname: pzname,
  2686. password: that.data.password.toString(),
  2687. userTelephone: JSON.parse(that.data.personLi.info).userTelephone,
  2688. operateMode: 7,
  2689. userPassword: JSON.parse(that.data.personLi.info).userPassword,
  2690. passwordStartTime: passwordStartTime,
  2691. passwordEndTime: passwordEndTime,
  2692. index: pincodeIndex,
  2693. is: false,
  2694. pass: true
  2695. }
  2696. var data1 = {
  2697. cardId: that.data.personLi.cardId,
  2698. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  2699. deviceNum: that.data.deviceinfo.deviceNum,
  2700. type: 4,
  2701. imei: that.data.deviceinfo.imei,
  2702. serial: serialNumber,
  2703. startTime: passwordStartTime,
  2704. endTime: passwordEndTime,
  2705. };
  2706. var datalist = {
  2707. cardId: that.data.personLi.cardId,
  2708. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  2709. type: 14,
  2710. startTime: passwordStartTime,
  2711. endTime: passwordEndTime,
  2712. };
  2713. WXAPI.addCertificates(datalist).then(res6 => {
  2714. console.log(datalist, '密码22', res6)
  2715. })
  2716. WXAPI.addCertificates(data1).then(res3 => {
  2717. if (res3.success) {
  2718. var updatedata = {
  2719. id: res3.data,
  2720. status: 1
  2721. };
  2722. WXAPI.updateCertificates(updatedata).then((res2) => {});
  2723. WXAPI.sendCommand(data2).then(res => {
  2724. })
  2725. that.getPassword()
  2726. that.setData({
  2727. show: false
  2728. })
  2729. wx.hideLoading()
  2730. wx.showToast({
  2731. title: '添加成功',
  2732. mask: true,
  2733. icon: 'none',
  2734. duration: 2000
  2735. })
  2736. } else {
  2737. wx.hideLoading()
  2738. wx.showToast({
  2739. title: '添加失败',
  2740. mask: true,
  2741. icon: 'none',
  2742. duration: 2000
  2743. })
  2744. }
  2745. })
  2746. taskId = 0
  2747. that.setData({
  2748. isPincodeAdd: true,
  2749. show: false
  2750. })
  2751. wx.showModal({
  2752. title: '提示',
  2753. content: `添加密码${pincode}成功!`,
  2754. showCancel: false
  2755. })
  2756. break
  2757. }
  2758. case 'delPincode': {
  2759. wx.hideLoading()
  2760. if (data.code != 200) {
  2761. var datacom = {
  2762. code: "lwj/passwordOperate",
  2763. data: {
  2764. lockerId: that.data.deviceinfo.deviceNum,
  2765. serialNumber: serialNumber,
  2766. index: pincodeIndex,
  2767. action: 2,
  2768. type: 9,
  2769. result: 0
  2770. }
  2771. }
  2772. WXAPI.sendCommand(datacom).then(res2 => {
  2773. console.log(res2, '失败')
  2774. })
  2775. wx.showModal({
  2776. title: '提示',
  2777. content: '删除密码失败!',
  2778. showCancel: false,
  2779. success: function (res) {}
  2780. })
  2781. break
  2782. }
  2783. taskId = 0
  2784. wx.showModal({
  2785. title: '提示',
  2786. content: `删除密码成功!`,
  2787. showCancel: false,
  2788. })
  2789. var datacom = {
  2790. code: "lwj/passwordOperate",
  2791. data: {
  2792. lockerId: that.data.deviceinfo.deviceNum,
  2793. serialNumber: serialNumber,
  2794. index: pincodeIndex,
  2795. action: 2,
  2796. type: 9,
  2797. result: 1
  2798. }
  2799. }
  2800. WXAPI.sendCommand(datacom).then(res2 => {
  2801. if (res2.success) {}
  2802. })
  2803. var data = {
  2804. ids: [passwordLiAll.id]
  2805. }
  2806. WXAPI.deleteCertificates(data).then(res1 => {
  2807. if (res1.success) {
  2808. that.getPassword()
  2809. wx.hideLoading()
  2810. wx.showToast({
  2811. title: '删除成功',
  2812. mask: true,
  2813. icon: 'none',
  2814. duration: 2000
  2815. })
  2816. } else {
  2817. wx.hideLoading()
  2818. wx.showToast({
  2819. title: '删除失败',
  2820. mask: true,
  2821. icon: 'none',
  2822. duration: 2000
  2823. })
  2824. }
  2825. })
  2826. that.setData({
  2827. isPincodeAdd: false
  2828. })
  2829. pincode = -1
  2830. pincodeIndex = -1
  2831. break
  2832. }
  2833. case 'addRfCard': {
  2834. wx.hideLoading()
  2835. if (data.code == 100) {
  2836. wx.showLoading({
  2837. title: data.data.msg,
  2838. })
  2839. break
  2840. } else if (data.code != 200) {
  2841. var datacom = {
  2842. code: "ble/bleSendVoucherReply",
  2843. data: {
  2844. deviceNum: that.data.deviceinfo.deviceNum,
  2845. serialNumber: serialNumber,
  2846. index: rfCardIndex,
  2847. type: ADD_NFC_MODE,
  2848. cardNo: '',
  2849. result: 0,
  2850. productId: that.data.deviceinfo.manufactureId
  2851. }
  2852. }
  2853. WXAPI.sendCommand(datacom).then(res2 => {})
  2854. wx.showModal({
  2855. title: '提示',
  2856. content: '添加房卡失败!' + data.data.msg,
  2857. showCancel: false,
  2858. success: function (res) {}
  2859. })
  2860. break
  2861. }
  2862. taskId = 0
  2863. that.setData({
  2864. isRfCardAdd: true
  2865. })
  2866. if (lockModel > 70) {
  2867. console.log(data.data, 'rfCardIndexrfCardIndex')
  2868. // rfCardId = randomMethods()
  2869. wx.showModal({
  2870. title: '提示',
  2871. content: `添加房卡成功,序号${rfCardIndex}`,
  2872. showCancel: false
  2873. })
  2874. that.addRfcardCertificates()
  2875. } else {
  2876. console.log(data.data, 'rfCardIndexrfCardIndex1')
  2877. // rfCardId = randomMethods()
  2878. wx.showModal({
  2879. title: '提示',
  2880. content: `添加房卡成功,卡号${rfCardId}`,
  2881. showCancel: false
  2882. })
  2883. that.addRfcardCertificates()
  2884. }
  2885. break
  2886. }
  2887. case 'delRfCard': {
  2888. wx.hideLoading()
  2889. if (data.code != 200) {
  2890. var datacom = {
  2891. code: "lwj/cardOperate",
  2892. data: {
  2893. lockerId: that.data.deviceinfo.deviceNum,
  2894. serialNumber: serialNumber,
  2895. index: rfCardIndex,
  2896. action: 2,
  2897. type: 12,
  2898. result: 0
  2899. }
  2900. }
  2901. WXAPI.sendCommand(datacom).then(res2 => {
  2902. console.log(res2, '失败2933')
  2903. })
  2904. wx.showModal({
  2905. title: '提示',
  2906. content: '删除房卡失败!',
  2907. showCancel: false,
  2908. success: function (res) {}
  2909. })
  2910. break
  2911. }
  2912. taskId = 0
  2913. that.setData({
  2914. isRfCardAdd: false
  2915. })
  2916. if (lockModel > 70) {
  2917. wx.showModal({
  2918. title: '提示',
  2919. content: `删除房卡成功,序号${rfCardIndex}`,
  2920. showCancel: false,
  2921. })
  2922. } else {
  2923. wx.showModal({
  2924. title: '提示',
  2925. content: `删除房卡成功,卡号${rfCardId}`,
  2926. showCancel: false,
  2927. })
  2928. }
  2929. var datacom = {
  2930. code: "lwj/cardOperate",
  2931. data: {
  2932. lockerId: that.data.deviceinfo.deviceNum,
  2933. serialNumber: serialNumber,
  2934. index: rfCardIndex,
  2935. action: 2,
  2936. type: 12,
  2937. result: 1
  2938. }
  2939. }
  2940. WXAPI.sendCommand(datacom).then(res2 => {
  2941. console.log(res2, '失败')
  2942. })
  2943. var data = {
  2944. ids: [passwordLiAll.id]
  2945. }
  2946. WXAPI.deleteCertificates(data).then(res1 => {
  2947. console.log(res1, '2936');
  2948. if (res1.success) {
  2949. that.getNfc()
  2950. wx.showToast({
  2951. title: '删除成功',
  2952. mask: true,
  2953. icon: 'none',
  2954. duration: 2000
  2955. })
  2956. } else {
  2957. wx.showToast({
  2958. title: '删除失败',
  2959. mask: true,
  2960. icon: 'none',
  2961. duration: 2000
  2962. })
  2963. }
  2964. })
  2965. that.setData({
  2966. isRfCardAdd: false
  2967. })
  2968. rfCardId = -1
  2969. rfCardIndex = -1
  2970. break
  2971. }
  2972. case 'addFingerprint': {
  2973. wx.hideLoading()
  2974. if (data.code == 100) {
  2975. wx.showLoading({
  2976. title: data.data.msg,
  2977. })
  2978. break
  2979. } else if (data.code != 200) {
  2980. wx.showModal({
  2981. title: '提示',
  2982. content: '添加指纹失败!' + data.data.msg,
  2983. showCancel: false,
  2984. success: function (res) {}
  2985. })
  2986. var datacom = {
  2987. code: "ble/bleSendVoucherReply",
  2988. data: {
  2989. deviceNum: that.data.deviceinfo.deviceNum,
  2990. serialNumber: serialNumber,
  2991. index: 0,
  2992. type: 16,
  2993. result: 0,
  2994. productId: that.data.deviceinfo.manufactureId
  2995. }
  2996. }
  2997. WXAPI.sendCommand(datacom).then(res2 => {
  2998. if (res2.success) {}
  2999. })
  3000. break
  3001. }
  3002. taskId = 0
  3003. that.setData({
  3004. isFingerprintAdd: true
  3005. })
  3006. wx.showModal({
  3007. title: '提示',
  3008. content: `添加指纹成功,序号${fingerprintIndex}`,
  3009. showCancel: false
  3010. })
  3011. var time1 = new Date(that.data.starttime.replace(/-/g, '/'))
  3012. var time2 = new Date(that.data.endtime.replace(/-/g, '/'))
  3013. var passwordStartTime = time1.getTime() / 1000
  3014. var passwordEndTime = time2.getTime() / 1000
  3015. var cardName = '',
  3016. pzname = ''
  3017. if (that.data.pzname) {
  3018. cardName = that.data.personLi.name + '-蓝牙-' + that.data.pzname
  3019. pzname = '蓝牙-' + that.data.pzname
  3020. } else {
  3021. cardName = that.data.personLi.name + '-蓝牙-指纹' + (that.data.FpList.length + 1)
  3022. pzname = '蓝牙-指纹' + (that.data.FpList.length + 1)
  3023. }
  3024. var str = {
  3025. // cardId: this.personInfo.cardId,
  3026. imei: that.data.deviceinfo.imei,
  3027. pzname: pzname,
  3028. password: '',
  3029. fingerprintAlias: that.data.radioDetil,
  3030. userTelephone: JSON.parse(that.data.personLi.info).userTelephone,
  3031. operateMode: 16,
  3032. userPassword: JSON.parse(that.data.personLi.info).userPassword,
  3033. passwordStartTime: passwordStartTime,
  3034. passwordEndTime: passwordEndTime,
  3035. index: fingerprintIndex,
  3036. is: false,
  3037. pass: true
  3038. }
  3039. var data2 = {
  3040. cardId: that.data.personLi.cardId,
  3041. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  3042. deviceNum: that.data.deviceinfo.deviceNum,
  3043. type: 1,
  3044. imei: that.data.deviceinfo.imei,
  3045. serial: serialNumber,
  3046. startTime: passwordStartTime,
  3047. endTime: passwordEndTime,
  3048. status: 1
  3049. };
  3050. var datalist = {
  3051. cardId: that.data.personLi.cardId,
  3052. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  3053. type: 11,
  3054. startTime: passwordStartTime,
  3055. endTime: passwordEndTime
  3056. };
  3057. var datacom = {
  3058. code: "ble/bleSendVoucherReply",
  3059. data: {
  3060. deviceNum: that.data.deviceinfo.deviceNum,
  3061. serialNumber: serialNumber,
  3062. index: fingerprintIndex,
  3063. type: 16,
  3064. result: 1,
  3065. productId: that.data.deviceinfo.manufactureId
  3066. }
  3067. }
  3068. WXAPI.addCertificates(datalist).then(res6 => {})
  3069. console.log(data, '添加凭证')
  3070. WXAPI.addCertificates(data2).then(res3 => {
  3071. if (res3.success) {
  3072. var updatedata = {
  3073. id: res3.data,
  3074. status: 1
  3075. };
  3076. WXAPI.updateCertificates(updatedata).then((res2) => {});
  3077. WXAPI.sendCommand(datacom).then(res2 => {
  3078. if (res2.success) {}
  3079. })
  3080. console.log(res3, '添加凭证成功')
  3081. that.getFp()
  3082. that.setData({
  3083. show: false
  3084. })
  3085. wx.hideLoading()
  3086. wx.showToast({
  3087. title: '添加成功',
  3088. mask: true,
  3089. icon: 'none',
  3090. duration: 2000
  3091. })
  3092. } else {
  3093. wx.hideLoading()
  3094. wx.showToast({
  3095. title: '添加失败',
  3096. mask: true,
  3097. icon: 'none',
  3098. duration: 2000
  3099. })
  3100. }
  3101. })
  3102. break
  3103. }
  3104. case 'delFingerprint': {
  3105. wx.hideLoading()
  3106. if (data.code != 200) {
  3107. var datacom = {
  3108. code: "lwj/fpOperate",
  3109. data: {
  3110. lockerId: that.data.deviceinfo.deviceNum,
  3111. serialNumber: serialNumber,
  3112. index: fingerprintIndex,
  3113. action: 2,
  3114. type: 18,
  3115. result: 0
  3116. }
  3117. }
  3118. WXAPI.sendCommand(datacom).then(res2 => {
  3119. console.log(res2, '失败')
  3120. })
  3121. wx.showModal({
  3122. title: '提示',
  3123. content: '删除指纹失败!',
  3124. showCancel: false,
  3125. success: function (res) {}
  3126. })
  3127. break
  3128. }
  3129. taskId = 0
  3130. wx.showModal({
  3131. title: '提示',
  3132. content: `删除指纹成功,序号${fingerprintIndex}`,
  3133. showCancel: false,
  3134. })
  3135. var datacom = {
  3136. code: "lwj/fpOperate",
  3137. data: {
  3138. lockerId: that.data.deviceinfo.deviceNum,
  3139. serialNumber: serialNumber,
  3140. index: fingerprintIndex,
  3141. action: 2,
  3142. type: 18,
  3143. result: 1
  3144. }
  3145. }
  3146. WXAPI.sendCommand(datacom).then(res2 => {
  3147. if (res2.success) {}
  3148. })
  3149. var data = {
  3150. ids: [passwordLiAll.id]
  3151. }
  3152. WXAPI.deleteCertificates(data).then(res1 => {
  3153. if (res1.success) {
  3154. that.getFp()
  3155. wx.hideLoading()
  3156. wx.showToast({
  3157. title: '删除成功',
  3158. mask: true,
  3159. icon: 'none',
  3160. duration: 2000
  3161. })
  3162. } else {
  3163. wx.hideLoading()
  3164. wx.showToast({
  3165. title: '删除失败',
  3166. mask: true,
  3167. icon: 'none',
  3168. duration: 2000
  3169. })
  3170. }
  3171. })
  3172. that.setData({
  3173. isFingerprintAdd: false
  3174. })
  3175. fingerprintIndex = -1
  3176. break
  3177. }
  3178. case 'changeAdminPincode': {
  3179. wx.hideLoading()
  3180. if (data.code != 200) {
  3181. wx.showModal({
  3182. title: '提示',
  3183. content: '修改管理密码失败!',
  3184. showCancel: false,
  3185. success: function (res) {}
  3186. })
  3187. break
  3188. }
  3189. taskId = 0
  3190. wx.showToast({
  3191. title: '修改管理密码成功!',
  3192. })
  3193. }
  3194. case 'queryLockSlotState': {
  3195. wx.hideLoading()
  3196. if (data.code != 200) {
  3197. wx.showModal({
  3198. title: '提示',
  3199. content: '查询失败!',
  3200. showCancel: false,
  3201. success: function (res) {}
  3202. })
  3203. break
  3204. }
  3205. taskId = 0
  3206. wx.showModal({
  3207. title: '提示',
  3208. content: data.data.state == 0 ? '此门锁方舌关闭' : '此门锁方舌打开',
  3209. showCancel: false,
  3210. success: function (res) {}
  3211. })
  3212. break
  3213. }
  3214. case 'queryLockUnlockState': {
  3215. wx.hideLoading()
  3216. if (data.code != 200) {
  3217. wx.showModal({
  3218. title: '提示',
  3219. content: '查询失败!',
  3220. showCancel: false,
  3221. success: function (res) {}
  3222. })
  3223. break
  3224. }
  3225. taskId = 0
  3226. wx.showModal({
  3227. title: '提示',
  3228. content: data.data.state == 0 ? '此门锁已关闭' : '此门锁已打开',
  3229. showCancel: false,
  3230. success: function (res) {}
  3231. })
  3232. break
  3233. }
  3234. case 'setLockUnlockState': {
  3235. wx.hideLoading()
  3236. if (data.code != 200) {
  3237. wx.showModal({
  3238. title: '提示',
  3239. content: '设置常开指令失败!',
  3240. showCancel: false,
  3241. success: function (res) {}
  3242. })
  3243. break
  3244. }
  3245. taskId = 0
  3246. wx.showModal({
  3247. title: '提示',
  3248. content: data.data.state == 0 ? '常开模式已退出' : '常开模式已开启',
  3249. showCancel: false,
  3250. })
  3251. that.setData({
  3252. isUnloked: data.data.state == 1
  3253. })
  3254. break
  3255. }
  3256. case 'setLockMuteState': {
  3257. wx.hideLoading()
  3258. if (data.code != 200) {
  3259. wx.showModal({
  3260. title: '提示',
  3261. content: '设置静音指令失败!',
  3262. showCancel: false,
  3263. success: function (res) {}
  3264. })
  3265. break
  3266. }
  3267. taskId = 0
  3268. wx.showModal({
  3269. title: '提示',
  3270. content: data.data.state == 1 ? '静音模式已退出' : '静音模式已开启',
  3271. showCancel: false,
  3272. })
  3273. that.setData({
  3274. isMuted: data.data.state == 0
  3275. })
  3276. break
  3277. }
  3278. }
  3279. })
  3280. wx.notifyBLECharacteristicValueChange({
  3281. deviceId: lockDevice.deviceId,
  3282. serviceId: config.uuid.serviceUuid.toUpperCase(),
  3283. characteristicId: config.uuid.notifyUuid.toUpperCase(),
  3284. state: true,
  3285. success: function (res) {
  3286. console.log('setupNotify', res)
  3287. isInitReady = true
  3288. setTimeout(function () {
  3289. wx.hideLoading()
  3290. // that.onQueryBindState()
  3291. that.login()
  3292. }, 500)
  3293. },
  3294. })
  3295. },
  3296. })
  3297. },
  3298. })
  3299. },
  3300. onQueryBindState: function () {
  3301. var that = this
  3302. wx.showLoading({
  3303. title: '查询中',
  3304. })
  3305. var bytes = plugin.queryLockState(lockDevice.name)
  3306. console.debug('bytes', bytes)
  3307. that.sendBytes(bytes)
  3308. },
  3309. queryBindState: function () {
  3310. var that = this
  3311. taskId = 21
  3312. that.initBluetooth()
  3313. },
  3314. doWork: function () {
  3315. var that = this
  3316. console.log(taskId);
  3317. switch (taskId) {
  3318. case 11: {
  3319. that.onBindLock()
  3320. break
  3321. }
  3322. case 12: {
  3323. that.onUnbindLock()
  3324. break
  3325. }
  3326. case 21: {
  3327. that.onQueryBindState()
  3328. break
  3329. }
  3330. case 22: {
  3331. that.onQueryBattery()
  3332. break
  3333. }
  3334. case 31: {
  3335. that.onQueryNbImei()
  3336. break
  3337. }
  3338. case 32: {
  3339. that.onLogin()
  3340. break
  3341. }
  3342. case 41: {
  3343. that.LwjonOpenLock()
  3344. break
  3345. }
  3346. case 42: {
  3347. that.onSyncClock()
  3348. break
  3349. }
  3350. case 51: {
  3351. that.onAddPincode()
  3352. break
  3353. }
  3354. case 52: {
  3355. that.onDelPincode()
  3356. break
  3357. }
  3358. case 61: {
  3359. // that.onAddRfCard()
  3360. // if (lockModel > 70) {
  3361. that.sendAddRfcard()
  3362. // } else {
  3363. // wx.showModal({
  3364. // title: '提示',
  3365. // content: '请刷卡!',
  3366. // showCancel: false
  3367. // })
  3368. // }
  3369. break
  3370. }
  3371. case 62: {
  3372. that.onDelRfCard()
  3373. break
  3374. }
  3375. case 71: {
  3376. that.onAddFingerprint()
  3377. break
  3378. }
  3379. case 72: {
  3380. that.onDelFingerprint()
  3381. break
  3382. }
  3383. case 81: {
  3384. that.onChangeAdminPincode()
  3385. break
  3386. }
  3387. case 91: {
  3388. that.onQueryLockSlotState()
  3389. break
  3390. }
  3391. case 92: {
  3392. that.onQueryLockUnlockState()
  3393. break
  3394. }
  3395. case 101: {
  3396. that.onChangeLockUnlockState()
  3397. break
  3398. }
  3399. case 102: {
  3400. that.onChangeLockMutedState()
  3401. break
  3402. }
  3403. case 111: {
  3404. this.onChangeLockNbState()
  3405. }
  3406. default: {
  3407. }
  3408. }
  3409. },
  3410. connectTo: function () {
  3411. var that = this
  3412. wx.showLoading({
  3413. title: '连接中',
  3414. })
  3415. wx.createBLEConnection({
  3416. deviceId: lockDevice.deviceId,
  3417. timeout: config.ble.connectTimeOut,
  3418. success: function (res) {
  3419. console.log('connectTo', res)
  3420. isConnected = true
  3421. // app.globalData.isConnected = true
  3422. wx.hideLoading()
  3423. setTimeout(function () {
  3424. that.setupConnection()
  3425. }, 500)
  3426. },
  3427. fail: function (e) {
  3428. console.debug('connectTo', e)
  3429. wx.hideLoading()
  3430. switch (e.errCode) {
  3431. case 10003: {
  3432. wx.showModal({
  3433. title: '连接失败',
  3434. content: '是否重新连接?',
  3435. success: function (res) {
  3436. if (res.confirm) {
  3437. that.connectTo()
  3438. }
  3439. }
  3440. })
  3441. break
  3442. }
  3443. case 10012: {
  3444. wx.showModal({
  3445. title: '连接失败',
  3446. content: '蓝牙连接超时',
  3447. showCancel: false
  3448. })
  3449. break
  3450. }
  3451. case 10002: {
  3452. wx.showModal({
  3453. title: '连接失败',
  3454. content: '没有找到指定设备',
  3455. showCancel: false
  3456. })
  3457. break
  3458. }
  3459. }
  3460. }
  3461. })
  3462. },
  3463. searchDevicesMethods() {
  3464. var that = this;
  3465. wx.showLoading({
  3466. title: '正在搜索',
  3467. // mask: true
  3468. })
  3469. this.setData({
  3470. searchClick: false
  3471. })
  3472. wx.openBluetoothAdapter({
  3473. success: function (res) {
  3474. wx.startBluetoothDevicesDiscovery({
  3475. success: function (res) {
  3476. wx.getBluetoothDevices({
  3477. success: function (res) {
  3478. res.devices.map(it => {
  3479. var status = it.name.indexOf('WSL_')
  3480. if (status != -1) {
  3481. if (it.RSSI != 127) {
  3482. if (it.advertisData != null) {
  3483. it.adData = util1.ab2hex(it.advertisData)
  3484. if (it.adData.length > 10) {
  3485. var macStr = it.adData.substring(4, 16).toUpperCase()
  3486. //console.log('macStr', macStr)
  3487. 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)
  3488. if (it.adData.substring(1, 2) == '1') {
  3489. it.isLightOn = true
  3490. it.textColor = 'green'
  3491. } else {
  3492. it.isLightOn = false
  3493. it.textColor = 'black'
  3494. }
  3495. if (it.adData.substring(3, 4) == '1') {
  3496. it.textColor = 'pink'
  3497. it.isBind = true
  3498. } else {
  3499. it.isBind = false
  3500. }
  3501. }
  3502. } else {
  3503. it.textColor = 'black'
  3504. }
  3505. lockModel = util1.getLockModel(it.name)
  3506. it.lockType = util1.getLockType(lockModel)
  3507. if (it.name == that.data.deviceinfo.deviceNum) {
  3508. app.addDeviceWithDevName(it.name, it)
  3509. lockDevice = it
  3510. connectedDeviceId = it.deviceId
  3511. that.setData({
  3512. isSearch: true
  3513. })
  3514. that.initBluetooth()
  3515. }
  3516. }
  3517. }
  3518. })
  3519. if (!that.data.isSearch) {
  3520. that.searchDevicesMethods()
  3521. }
  3522. }
  3523. })
  3524. },
  3525. fail: function (res) {
  3526. wx.hideLoading({
  3527. success: (res) => {
  3528. wx.showToast({
  3529. title: res.errMsg,
  3530. duration: 2000,
  3531. icon: 'none'
  3532. })
  3533. },
  3534. })
  3535. }
  3536. })
  3537. },
  3538. fail: function (res) {
  3539. console.log('请打开蓝牙和定位功能')
  3540. wx.hideLoading({
  3541. success: (res) => {
  3542. wx.showToast({
  3543. title: '请打开蓝牙和定位功能',
  3544. duration: 2000,
  3545. icon: 'none'
  3546. })
  3547. },
  3548. })
  3549. }
  3550. })
  3551. },
  3552. LwjonOpenLock: function () {
  3553. var that = this
  3554. wx.showLoading({
  3555. title: that.data.isJack ? '上电中' : '解锁中',
  3556. })
  3557. console.log(lockDevice.name, 'lockDevice.name0')
  3558. var bytes = plugin.sendOpenLockP1(lockDevice.name, basecode)
  3559. console.debug('bytes', bytes)
  3560. that.sendBytes(bytes)
  3561. },
  3562. openLock: function () {
  3563. var that = this
  3564. taskId = 41
  3565. that.initBluetooth()
  3566. },
  3567. sendBytes(bytes) {
  3568. setTimeout(() => {
  3569. wx.writeBLECharacteristicValue({
  3570. deviceId: lockDevice.deviceId,
  3571. serviceId: config.uuid.serviceUuid.toUpperCase(),
  3572. characteristicId: config.uuid.writeUuid.toUpperCase(),
  3573. value: bytes,
  3574. success: function (res) {
  3575. },
  3576. })
  3577. }, 50)
  3578. },
  3579. sendNfc() {
  3580. var time3 = new Date(this.data.datetimerange[0].replace(/-/g, '/'))
  3581. var time4 = new Date(this.data.datetimerange[1].replace(/-/g, '/'))
  3582. var passwordStartTimecontrast = time3.getTime() / 1000
  3583. var passwordEndTimecontrast = time4.getTime() / 1000
  3584. if (passwordStartTimecontrast > passwordEndTimecontrast) {
  3585. wx.showToast({
  3586. title: '开始时间不能大于结束时间',
  3587. duration: 2000,
  3588. mask: true,
  3589. icon: 'none'
  3590. })
  3591. return
  3592. }
  3593. wx.showLoading({
  3594. title: '正在添加',
  3595. mask: true
  3596. })
  3597. var _this = this
  3598. var deviceinfo = this.data.deviceinfo
  3599. var info = JSON.parse(this.data.personLi.info)
  3600. if (deviceinfo.manufactureId == 101) {
  3601. } else if (deviceinfo.manufactureId == 201 || deviceinfo.manufactureId == 221) {
  3602. var cgInfo = this.data.cgInfo
  3603. var time1 = new Date(_this.data.datetimerange[0].replace(/-/g, '/'))
  3604. var time2 = new Date(_this.data.datetimerange[1].replace(/-/g, '/'))
  3605. var passwordStartTime = time1.getTime() / 1000
  3606. var passwordEndTime = time2.getTime() / 1000
  3607. var pzname = _this.data.pzname,
  3608. cardName = ''
  3609. if (pzname == "") {
  3610. pzname = '蓝牙-NFC' + (_this.data.NfcList.length + 1)
  3611. cardName = _this.data.personLi.name + '-蓝牙-NFC' + (_this.data.NfcList.length + 1)
  3612. } else {
  3613. pzname = '蓝牙-' + pzname
  3614. cardName = _this.data.personLi.name + '-蓝牙-' + pzname
  3615. }
  3616. var dataPasswod = {
  3617. code: "zg/cardOperate",
  3618. data: {
  3619. lockerId: deviceinfo.deviceNum,
  3620. imei: deviceinfo.imei,
  3621. lockerUserId: info.userId,
  3622. keyId: info.userId,
  3623. action: 1,
  3624. taskStatus: 1,
  3625. order: 6210,
  3626. startTime: passwordStartTime,
  3627. endTime: passwordEndTime,
  3628. cardType: 50,
  3629. type: ADD_NFC_MODE,
  3630. roomName: this.data.deviceinfo.roomName,
  3631. cardName: cardName,
  3632. }
  3633. }
  3634. console.log(dataPasswod, 'dataPasswod')
  3635. WXAPI.sendCommand(dataPasswod).then(res => {
  3636. console.log(res, 'resres')
  3637. if (res.success) {
  3638. var pwdNo = res.data.index
  3639. var passwordIndex = res.data.index
  3640. var serialNumber = res.data.serialNumber
  3641. pwdNo = pwdNo.toString(16)
  3642. if (pwdNo.length < 2) {
  3643. pwdNo = '0' + pwdNo
  3644. }
  3645. var startTime = passwordStartTime.toString(16).toUpperCase()
  3646. var endTime = passwordEndTime.toString(16).toUpperCase()
  3647. info.startTime = startTime
  3648. info.endTime = endTime
  3649. info.pwdNo = pwdNo
  3650. methods.bluetoothOperation_ZH(cgInfo, info, 7).then(result => {
  3651. if (result.status == '00') {
  3652. let carNoId = this.processCardNumber(result.cardNo)
  3653. var datacom = {
  3654. code: "zg/bleSendVoucherReply",
  3655. data: {
  3656. lockerId: deviceinfo.deviceNum,
  3657. serialNumber: serialNumber,
  3658. index: passwordIndex,
  3659. type: ADD_NFC_MODE,
  3660. cardNo: carNoId.toUpperCase(),
  3661. result: 1
  3662. }
  3663. }
  3664. WXAPI.sendCommand(datacom).then(res2 => {
  3665. if (res2.success) {
  3666. var str = {
  3667. // cardId: this.personInfo.cardId,
  3668. pzname: pzname,
  3669. imei: _this.data.deviceinfo.imei,
  3670. password: carNoId.toUpperCase(),
  3671. blueCardNo: result.cardNo,
  3672. userTelephone: JSON.parse(_this.data.personLi.info).userTelephone,
  3673. operateMode: 10,
  3674. userPassword: JSON.parse(_this.data.personLi.info).userPassword,
  3675. passwordStartTime: passwordStartTime,
  3676. passwordEndTime: passwordEndTime,
  3677. is: false,
  3678. roomName: _this.data.deviceinfo.roomName,
  3679. }
  3680. var data = {
  3681. cardId: _this.data.personLi.cardId,
  3682. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  3683. deviceNum: _this.data.deviceinfo.deviceNum,
  3684. type: 3,
  3685. blueCardNo: result.cardNo,
  3686. imei: _this.data.deviceinfo.imei,
  3687. serial: serialNumber,
  3688. startTime: passwordStartTime,
  3689. endTime: passwordEndTime,
  3690. };
  3691. console.log(data, '添加凭证')
  3692. var datalist = {
  3693. cardId: _this.data.personLi.cardId,
  3694. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  3695. type: 13,
  3696. startTime: passwordStartTime,
  3697. endTime: passwordEndTime,
  3698. };
  3699. WXAPI.addCertificates(datalist).then(res6 => {
  3700. console.log(datalist, 'NFC', res6)
  3701. })
  3702. WXAPI.addCertificates(data).then(res3 => {
  3703. if (res3.success) {
  3704. var updatedata = {
  3705. id: res3.data,
  3706. status: 1
  3707. };
  3708. WXAPI.updateCertificates(updatedata).then((res2) => {});
  3709. console.log(res3, '添加凭证成功')
  3710. _this.getNfc()
  3711. _this.setData({
  3712. show: false
  3713. })
  3714. wx.hideLoading()
  3715. wx.showToast({
  3716. title: '添加成功',
  3717. mask: true,
  3718. icon: 'none',
  3719. duration: 2000
  3720. })
  3721. } else {
  3722. wx.hideLoading()
  3723. wx.showToast({
  3724. title: '添加失败',
  3725. mask: true,
  3726. icon: 'none',
  3727. duration: 2000
  3728. })
  3729. }
  3730. })
  3731. }
  3732. })
  3733. } else {
  3734. wx.hideLoading()
  3735. wx.showToast({
  3736. title: '添加失败',
  3737. mask: true,
  3738. icon: 'none',
  3739. duration: 2000
  3740. })
  3741. var datacom = {
  3742. code: "zg/bleSendVoucherReply",
  3743. data: {
  3744. lockerId: deviceinfo.deviceNum,
  3745. serialNumber: serialNumber,
  3746. index: passwordIndex,
  3747. type: ADD_NFC_MODE,
  3748. result: 0
  3749. }
  3750. }
  3751. WXAPI.sendCommand(datacom).then(res2 => {
  3752. console.log(res2, '失败')
  3753. _this.setData({
  3754. show: false
  3755. })
  3756. })
  3757. }
  3758. }).catch(err => {
  3759. var datacom = {
  3760. code: "zg/bleSendVoucherReply",
  3761. data: {
  3762. lockerId: deviceinfo.deviceNum,
  3763. serialNumber: serialNumber,
  3764. index: passwordIndex,
  3765. type: ADD_NFC_MODE,
  3766. result: 0
  3767. }
  3768. }
  3769. WXAPI.sendCommand(datacom).then(res2 => {
  3770. _this.setData({
  3771. show: false
  3772. })
  3773. })
  3774. wx.showToast({
  3775. title: '添加失败',
  3776. mask: true,
  3777. icon: 'none',
  3778. duration: 2000
  3779. })
  3780. })
  3781. } else {
  3782. wx.showToast({
  3783. title: res.msg,
  3784. duration: 2000,
  3785. mask: true,
  3786. icon: 'none'
  3787. })
  3788. }
  3789. })
  3790. } else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) {
  3791. if (this.data.isSearch) {
  3792. wx.hideLoading()
  3793. this.addRfCard()
  3794. } else {
  3795. this.searchDevicesMethods()
  3796. }
  3797. }
  3798. },
  3799. addRfCard: function () {
  3800. console.log("3691NFC");
  3801. var that = this
  3802. taskId = 61
  3803. that.initBluetooth()
  3804. },
  3805. onAddRfCard: function () {
  3806. var that = this
  3807. wx.showLoading({
  3808. title: '添加房卡中',
  3809. })
  3810. var startTime = new Date(Number(moment(that.data.starttime).format('x')))
  3811. var endTime = new Date(Number(moment(that.data.endtime).format('x')))
  3812. console.log("锁", lockDevice.name, basecode, 0, rfCardIndex, startTime, endTime);
  3813. var bytes = plugin.addRfCard(lockDevice.name, basecode, 0, rfCardIndex, startTime, endTime)
  3814. console.debug('bytes', bytes)
  3815. that.sendBytes(bytes)
  3816. },
  3817. addRfcardCertificates() {
  3818. var that = this
  3819. var time1 = new Date(that.data.starttime.replace(/-/g, '/'))
  3820. var time2 = new Date(that.data.endtime.replace(/-/g, '/'))
  3821. var passwordStartTime = time1.getTime() / 1000
  3822. var passwordEndTime = time2.getTime() / 1000
  3823. var pzname = '',
  3824. cardName = '';
  3825. pzname = '蓝牙-NFC' + (that.data.passwordList.length + 1)
  3826. cardName = that.data.personLi.name + '-蓝牙-NFC' + (that.data.passwordList.length + 1)
  3827. let carNoId = rfCardId
  3828. var datacom = {
  3829. code: "ble/bleSendVoucherReply",
  3830. data: {
  3831. deviceNum: that.data.deviceinfo.deviceNum,
  3832. serialNumber: serialNumber,
  3833. index: rfCardIndex,
  3834. type: ADD_NFC_MODE,
  3835. cardNo: rfCardId.toUpperCase(),
  3836. result: 1,
  3837. productId: that.data.deviceinfo.manufactureId
  3838. }
  3839. }
  3840. WXAPI.sendCommand(datacom).then(res2 => {
  3841. if (res2.success) {
  3842. var str = {
  3843. // cardId: this.personInfo.cardId,
  3844. pzname: pzname,
  3845. imei: that.data.deviceinfo.imei,
  3846. password: carNoId.toUpperCase(),
  3847. blueCardNo: rfCardIndex,
  3848. userTelephone: JSON.parse(that.data.personLi.info).userTelephone,
  3849. operateMode: 10,
  3850. userPassword: JSON.parse(that.data.personLi.info).userPassword,
  3851. passwordStartTime: passwordStartTime,
  3852. passwordEndTime: passwordEndTime,
  3853. is: false,
  3854. index: rfCardIndex,
  3855. roomName: that.data.deviceinfo.roomName,
  3856. }
  3857. var data2 = {
  3858. cardId: that.data.personLi.cardId,
  3859. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  3860. deviceNum: that.data.deviceinfo.deviceNum,
  3861. type: 3,
  3862. blueCardNo: carNoId,
  3863. imei: that.data.deviceinfo.imei,
  3864. serial: serialNumber,
  3865. startTime: passwordStartTime,
  3866. endTime: passwordEndTime,
  3867. };
  3868. console.log(data2, '添加凭证')
  3869. var datalist = {
  3870. cardId: that.data.personLi.cardId,
  3871. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  3872. type: 13,
  3873. startTime: passwordStartTime,
  3874. endTime: passwordEndTime,
  3875. };
  3876. WXAPI.addCertificates(datalist).then(res6 => {
  3877. console.log(datalist, 'NFC', res6)
  3878. })
  3879. WXAPI.addCertificates(data2).then(res3 => {
  3880. if (res3.success) {
  3881. var updatedata = {
  3882. id: res3.data,
  3883. status: 1
  3884. };
  3885. WXAPI.updateCertificates(updatedata).then((res2) => {});
  3886. console.log(res3, '添加凭证成功')
  3887. that.getNfc()
  3888. that.setData({
  3889. show: false
  3890. })
  3891. wx.hideLoading()
  3892. wx.showToast({
  3893. title: '添加成功',
  3894. mask: true,
  3895. icon: 'none',
  3896. duration: 2000
  3897. })
  3898. } else {
  3899. wx.hideLoading()
  3900. wx.showToast({
  3901. title: '添加失败',
  3902. mask: true,
  3903. icon: 'none',
  3904. duration: 2000
  3905. })
  3906. }
  3907. })
  3908. } else {
  3909. wx.showToast({
  3910. title: res2.message,
  3911. duration: 2000,
  3912. icon: 'none'
  3913. })
  3914. }
  3915. })
  3916. },
  3917. sendAddRfcard() {
  3918. var that = this
  3919. var info = JSON.parse(this.data.personLi.info)
  3920. let deviceinfo = this.data.deviceinfo
  3921. var time1 = new Date(that.data.starttime.replace(/-/g, '/'))
  3922. var time2 = new Date(that.data.endtime.replace(/-/g, '/'))
  3923. var passwordStartTime = time1.getTime() / 1000
  3924. var passwordEndTime = time2.getTime() / 1000
  3925. var pzname = '',
  3926. cardName = ''
  3927. if(that.data.pzname == ''){
  3928. pzname = '蓝牙-NFC' + (that.data.NfcList.length + 1)
  3929. }else{
  3930. pzname = '蓝牙-NFC' + that.data.pzname
  3931. }
  3932. cardName = that.data.personLi.name + '-蓝牙-NFC' + (that.data.NfcList.length + 1)
  3933. rfCardId = randomMethods()
  3934. var dataPasswod = {
  3935. code: "lwj/cardOperate",
  3936. data: {
  3937. lockerId: deviceinfo.deviceNum,
  3938. lockerUserId: info.userId,
  3939. startTime: passwordStartTime,
  3940. endTime: passwordEndTime,
  3941. order: 6210,
  3942. operateMode: 10,
  3943. action: 1,
  3944. cardNo: rfCardId,
  3945. type: 10,
  3946. roomName: this.data.deviceinfo.roomName,
  3947. cardName: cardName,
  3948. }
  3949. }
  3950. console.log("平台", dataPasswod);
  3951. WXAPI.sendCommand(dataPasswod).then(res => {
  3952. console.log(res, '获取索引')
  3953. if (res.success) {
  3954. var pwdNo = res.data.index
  3955. serialNumber = res.data.serialNumber
  3956. rfCardIndex = pwdNo
  3957. setTimeout(() => {
  3958. that.onAddRfCard()
  3959. }, 500)
  3960. }
  3961. })
  3962. },
  3963. processCardNumber(cardNo) {
  3964. var str1 = cardNo.substr(0, 8)
  3965. var str2 = cardNo.substr(8, 8)
  3966. var num = str2.split("")
  3967. var status = num.every(item => item == 0)
  3968. console.log(status, num, 'numnum', str1, str2)
  3969. if (status) {
  3970. var bbb = str1.split("")
  3971. var a, b;
  3972. var aIndex = 0;
  3973. var bIndex = 1;
  3974. var arr = [];
  3975. bbb.forEach((str, index) => {
  3976. if (index % 2 === 0) {
  3977. a = str;
  3978. aIndex += 1
  3979. } else {
  3980. b = str
  3981. bIndex += 1
  3982. }
  3983. if (a && b && (bIndex - aIndex === 1)) {
  3984. arr.push(a + b)
  3985. }
  3986. });
  3987. console.log(arr)
  3988. return arr.join("")
  3989. } else {
  3990. var ll = str1 + str2
  3991. return ll
  3992. }
  3993. },
  3994. sendFp() {
  3995. var time3 = new Date(this.data.datetimerange[0].replace(/-/g, '/'))
  3996. var time4 = new Date(this.data.datetimerange[1].replace(/-/g, '/'))
  3997. var passwordStartTimecontrast = time3.getTime() / 1000
  3998. var passwordEndTimecontrast = time4.getTime() / 1000
  3999. if (passwordStartTimecontrast > passwordEndTimecontrast) {
  4000. wx.showToast({
  4001. title: '开始时间不能大于结束时间',
  4002. duration: 2000,
  4003. mask: true,
  4004. icon: 'none'
  4005. })
  4006. return
  4007. }
  4008. if (this.data.radioDetil == '') {
  4009. wx.showToast({
  4010. title: '请选择是那个指纹?',
  4011. mask: true,
  4012. duration: 2000,
  4013. icon: 'none'
  4014. })
  4015. return
  4016. }
  4017. wx.showLoading({
  4018. title: '正在添加指纹',
  4019. mask: true
  4020. })
  4021. var _this = this
  4022. var deviceinfo = this.data.deviceinfo
  4023. var info = JSON.parse(this.data.personLi.info)
  4024. if (deviceinfo.manufactureId == 101) {
  4025. let deviceNum = deviceinfo.deviceNum
  4026. this.setData({
  4027. backstatus: true
  4028. })
  4029. var timestamp = moment().format("x")
  4030. var time1 = moment(this.data.datetimerange[0]).format("YYYYMMDDHHmmss")
  4031. var time2 = moment(this.data.datetimerange[1]).format("YYYYMMDDHHmmss")
  4032. bleall.startFp_29(deviceNum, 0x03, timestamp, function (res) {
  4033. console.log(res, 'resresres')
  4034. if (res.success) {
  4035. wx.showLoading({
  4036. title: '正在添加指纹',
  4037. mask: true
  4038. })
  4039. }
  4040. if (res.data == "蓝牙功能暂不支持") {
  4041. wx.hideLoading()
  4042. _this.startconnect()
  4043. }
  4044. })
  4045. } else if (deviceinfo.manufactureId == 201 || deviceinfo.manufactureId == 221) {
  4046. var cgInfo = this.data.cgInfo
  4047. var time1 = new Date(_this.data.datetimerange[0].replace(/-/g, '/'))
  4048. var time2 = new Date(_this.data.datetimerange[1].replace(/-/g, '/'))
  4049. var passwordStartTime = time1.getTime() / 1000
  4050. var passwordEndTime = time2.getTime() / 1000
  4051. var cardName = '',
  4052. pzname = ''
  4053. if (this.data.pzname) {
  4054. cardName = _this.data.personLi.name + '-蓝牙-' + _this.data.pzname
  4055. pzname = '蓝牙-' + _this.data.pzname
  4056. } else {
  4057. cardName = _this.data.personLi.name + '-蓝牙-指纹' + (_this.data.FpList.length + 1)
  4058. pzname = '蓝牙-指纹' + (_this.data.FpList.length + 1)
  4059. }
  4060. var dataPasswod = {
  4061. code: "zg/addFingerPrint",
  4062. data: {
  4063. lockerId: deviceinfo.deviceNum,
  4064. imei: deviceinfo.imei,
  4065. lockerUserId: info.userPassword,
  4066. keyId: info.userPassword,
  4067. fingerType: 0,
  4068. order: 6216,
  4069. fingerId: '',
  4070. roomName: deviceinfo.roomName,
  4071. cardName: cardName,
  4072. startTime: passwordStartTime,
  4073. endTime: passwordEndTime,
  4074. file: '',
  4075. type: 1
  4076. }
  4077. }
  4078. WXAPI.sendCommand(dataPasswod).then(res => {
  4079. console.log(res, '获取索引')
  4080. if (res.success) {
  4081. var startTime = passwordStartTime.toString(16).toUpperCase()
  4082. var endTime = passwordEndTime.toString(16).toUpperCase()
  4083. info.startTime = startTime
  4084. info.endTime = endTime
  4085. methods.bluetoothOperation_ZH(cgInfo, info, 5).then(result => {
  4086. if (result.status == '00' && result.completeFlag == '01') {
  4087. console.log(result, 'callback2callback2')
  4088. var datacom = {
  4089. code: "zg/bleSendVoucherReply",
  4090. data: {
  4091. lockerId: deviceinfo.deviceNum,
  4092. serialNumber: res.data.serialNumber,
  4093. index: result.fingerprintNo,
  4094. type: 16,
  4095. result: 1
  4096. }
  4097. }
  4098. console.log(datacom)
  4099. var str = {
  4100. // cardId: this.personInfo.cardId,
  4101. imei: _this.data.deviceinfo.imei,
  4102. pzname: pzname,
  4103. password: '',
  4104. fingerprintAlias: _this.data.radioDetil,
  4105. userTelephone: JSON.parse(_this.data.personLi.info).userTelephone,
  4106. operateMode: 16,
  4107. userPassword: JSON.parse(_this.data.personLi.info).userPassword,
  4108. passwordStartTime: passwordStartTime,
  4109. passwordEndTime: passwordEndTime,
  4110. is: false,
  4111. pass: true
  4112. }
  4113. var data = {
  4114. cardId: _this.data.personLi.cardId,
  4115. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  4116. deviceNum: _this.data.deviceinfo.deviceNum,
  4117. type: 1,
  4118. imei: _this.data.deviceinfo.imei,
  4119. serial: res.data.serialNumber,
  4120. startTime: passwordStartTime,
  4121. endTime: passwordEndTime,
  4122. status: 1
  4123. };
  4124. var datalist = {
  4125. cardId: _this.data.personLi.cardId,
  4126. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  4127. type: 11,
  4128. startTime: passwordStartTime,
  4129. endTime: passwordEndTime
  4130. };
  4131. WXAPI.addCertificates(datalist).then(res6 => {})
  4132. console.log(data, '添加凭证')
  4133. WXAPI.addCertificates(data).then(res3 => {
  4134. if (res3.success) {
  4135. var updatedata = {
  4136. id: res3.data,
  4137. status: 1
  4138. };
  4139. WXAPI.updateCertificates(updatedata).then((res2) => {});
  4140. WXAPI.sendCommand(datacom).then(res2 => {
  4141. if (res2.success) {}
  4142. })
  4143. console.log(res3, '添加凭证成功')
  4144. _this.getFp()
  4145. _this.setData({
  4146. show: false
  4147. })
  4148. wx.hideLoading()
  4149. wx.showToast({
  4150. title: '添加成功',
  4151. mask: true,
  4152. icon: 'none',
  4153. duration: 2000
  4154. })
  4155. } else {
  4156. wx.hideLoading()
  4157. wx.showToast({
  4158. title: '添加失败',
  4159. mask: true,
  4160. icon: 'none',
  4161. duration: 2000
  4162. })
  4163. }
  4164. })
  4165. }
  4166. }).catch(err => {
  4167. var datacom = {
  4168. code: "zg/bleSendVoucherReply",
  4169. data: {
  4170. lockerId: deviceinfo.deviceNum,
  4171. serialNumber: res.data.serialNumber,
  4172. index: 0,
  4173. type: 16,
  4174. result: 0
  4175. }
  4176. }
  4177. WXAPI.sendCommand(datacom).then(res2 => {
  4178. if (res2.success) {}
  4179. })
  4180. })
  4181. } else {
  4182. var datacom = {
  4183. code: "zg/bleSendVoucherReply",
  4184. data: {
  4185. lockerId: deviceinfo.deviceNum,
  4186. serialNumber: res.data.serialNumber,
  4187. index: 0,
  4188. type: 16,
  4189. result: 0
  4190. }
  4191. }
  4192. WXAPI.sendCommand(datacom).then(res2 => {
  4193. if (res2.success) {}
  4194. })
  4195. wx.showToast({
  4196. title: res.msg,
  4197. duration: 2000,
  4198. mask: true,
  4199. icon: 'none'
  4200. })
  4201. }
  4202. })
  4203. } else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) {
  4204. if (this.data.isSearch) {
  4205. // fingerprintIndex = 1
  4206. // serialNumber = 1686309639840
  4207. // this.onAddFingerprint()
  4208. // return
  4209. var time1 = new Date(_this.data.datetimerange[0].replace(/-/g, '/'))
  4210. var time2 = new Date(_this.data.datetimerange[1].replace(/-/g, '/'))
  4211. var passwordStartTime = time1.getTime() / 1000
  4212. var passwordEndTime = time2.getTime() / 1000
  4213. var cardName = '',
  4214. pzname = ''
  4215. if (this.data.pzname) {
  4216. cardName = _this.data.personLi.name + '-蓝牙-' + _this.data.pzname
  4217. pzname = '蓝牙-' + _this.data.pzname
  4218. } else {
  4219. cardName = _this.data.personLi.name + '-蓝牙-指纹' + (_this.data.FpList.length + 1)
  4220. pzname = '蓝牙-指纹' + (_this.data.FpList.length + 1)
  4221. }
  4222. var dataPasswod = {
  4223. code: "lwj/fpOperate",
  4224. data: {
  4225. lockerId: deviceinfo.deviceNum,
  4226. action: 1,
  4227. lockerUserId: info.userPassword,
  4228. fpData: '',
  4229. operateMode: 16,
  4230. order: 6216,
  4231. roomName: deviceinfo.roomName,
  4232. cardName: cardName,
  4233. startTime: passwordStartTime,
  4234. endTime: passwordEndTime,
  4235. type: 1
  4236. }
  4237. }
  4238. console.log(dataPasswod);
  4239. WXAPI.sendCommand(dataPasswod).then(res => {
  4240. console.log(res);
  4241. if (res.success) {
  4242. fingerprintIndex = res.data.index
  4243. serialNumber = res.data.serialNumber
  4244. this.onAddFingerprint()
  4245. }
  4246. })
  4247. } else {
  4248. this.searchDevicesMethods()
  4249. }
  4250. }
  4251. },
  4252. login: function () {
  4253. var that = this
  4254. taskId = 32
  4255. that.initBluetooth()
  4256. },
  4257. onLogin: function () {
  4258. var that = this
  4259. wx.showLoading({
  4260. title: '登录中',
  4261. })
  4262. var bytes = plugin.login1(lockDevice.name, basecode)
  4263. console.debug('bytes', bytes)
  4264. that.sendBytes(bytes)
  4265. },
  4266. onAddFingerprint: function () {
  4267. var that = this
  4268. wx.showLoading({
  4269. title: '添加指纹中',
  4270. })
  4271. // var startTime = util1.getLocalTime(8)
  4272. // var endTime = new Date(startTime.getTime() + 5 * 60 * 1000) //有效期5分钟
  4273. var startTime = new Date(Number(moment(that.data.starttime).format('x')))
  4274. var endTime = new Date(Number(moment(that.data.endtime).format('x')))
  4275. // fingerprintIndex = Math.floor(Math.random() * 100)
  4276. var bytes = plugin.addFingerprint(lockDevice.name, basecode, fingerprintIndex, startTime, endTime)
  4277. console.debug('bytes', bytes)
  4278. that.sendBytes(bytes)
  4279. },
  4280. // 关闭添加人员弹窗
  4281. onClose() {
  4282. this.setData({
  4283. show: false
  4284. });
  4285. },
  4286. onChange(event) {
  4287. console.log(event.detail)
  4288. this.setData({
  4289. activeKey: event.detail
  4290. })
  4291. },
  4292. getPassword() {
  4293. var data = {
  4294. pageNum: 0,
  4295. pageSize: 0,
  4296. q: JSON.stringify({
  4297. cardId: this.data.personLi.cardId,
  4298. deviceNum: this.data.deviceinfo.deviceNum,
  4299. types: "4",
  4300. inStatus: '0,1,702'
  4301. })
  4302. }
  4303. console.log(data)
  4304. WXAPI.getCertificates(data).then(res => {
  4305. var dataOne = util.zlib_unzip(res.data)
  4306. if (res.success) {
  4307. dataOne.map(li => {
  4308. li['pzname'] = JSON.parse(li.content).pzname
  4309. li['password'] = util.plusXing(JSON.parse(li.content).password, 2, 2, '*')
  4310. })
  4311. this.setData({
  4312. passwordList: dataOne
  4313. })
  4314. }
  4315. })
  4316. },
  4317. getNfc() {
  4318. var data = {
  4319. pageNum: 0,
  4320. pageSize: 0,
  4321. q: JSON.stringify({
  4322. cardId: this.data.personLi.cardId,
  4323. deviceNum: this.data.deviceinfo.deviceNum,
  4324. types: "3",
  4325. inStatus: '0,1,702'
  4326. })
  4327. }
  4328. WXAPI.getCertificates(data).then(res => {
  4329. console.log(res)
  4330. var dataOne = util.zlib_unzip(res.data)
  4331. console.log(dataOne)
  4332. if (res.success) {
  4333. dataOne.map(li => {
  4334. li['pzname'] = JSON.parse(li.content).pzname
  4335. li['password'] = util.plusXing(JSON.parse(li.content).password, 2, 2, '*')
  4336. })
  4337. this.setData({
  4338. NfcList: dataOne
  4339. })
  4340. }
  4341. })
  4342. },
  4343. getFp() {
  4344. var data = {
  4345. pageNum: 0,
  4346. pageSize: 0,
  4347. q: JSON.stringify({
  4348. cardId: this.data.personLi.cardId,
  4349. deviceNum: this.data.deviceinfo.deviceNum,
  4350. types: "1",
  4351. inStatus: '0,1,702'
  4352. })
  4353. }
  4354. WXAPI.getCertificates(data).then(res => {
  4355. var dataOne = util.zlib_unzip(res.data)
  4356. if (res.success) {
  4357. dataOne.map(li => {
  4358. li['pzname'] = JSON.parse(li.content).pzname
  4359. li['password'] = ''
  4360. li['fingerprintAlias'] = JSON.parse(li.content).fingerprintAlias || ''
  4361. })
  4362. this.setData({
  4363. FpList: dataOne
  4364. })
  4365. }
  4366. })
  4367. },
  4368. getCarId() {
  4369. var data = {
  4370. pageNum: 0,
  4371. pageSize: 0,
  4372. q: JSON.stringify({
  4373. cardId: this.data.personLi.cardId,
  4374. deviceNum: this.data.deviceinfo.deviceNum,
  4375. types: "2",
  4376. inStatus: '0,1,702'
  4377. })
  4378. }
  4379. WXAPI.getCertificates(data).then(res => {
  4380. var dataOne = util.zlib_unzip(res.data)
  4381. if (res.success) {
  4382. dataOne.map(li => {
  4383. li['pzname'] = JSON.parse(li.content).pzname
  4384. li['password'] = util.plusXing(JSON.parse(li.content).password, 2, 2, '*')
  4385. })
  4386. this.setData({
  4387. CarIdList: dataOne
  4388. })
  4389. }
  4390. })
  4391. },
  4392. /**
  4393. * 生命周期函数--监听页面初次渲染完成
  4394. */
  4395. onReady: function () {
  4396. },
  4397. /**
  4398. * 生命周期函数--监听页面显示
  4399. */
  4400. onShow: function () {
  4401. },
  4402. /**
  4403. * 生命周期函数--监听页面隐藏
  4404. */
  4405. onHide: function () {
  4406. },
  4407. /**
  4408. * 生命周期函数--监听页面卸载
  4409. */
  4410. onUnload: function () {
  4411. if (isConnected) {
  4412. console.log(connectedDeviceId, 'connectedDeviceId')
  4413. wx.closeBLEConnection({
  4414. deviceId: connectedDeviceId,
  4415. success: function (res) {
  4416. isConnected = false
  4417. app.globalData.isConnected = false
  4418. },
  4419. })
  4420. }
  4421. },
  4422. /**
  4423. * 页面相关事件处理函数--监听用户下拉动作
  4424. */
  4425. onPullDownRefresh: function () {
  4426. },
  4427. /**
  4428. * 页面上拉触底事件的处理函数
  4429. */
  4430. onReachBottom: function () {
  4431. },
  4432. /**
  4433. * 用户点击右上角分享
  4434. */
  4435. onShareAppMessage: function () {
  4436. }
  4437. })