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.

1775 lines
81 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. // pagesA/facepeople/facepeople.js
  2. import moment from '../../utils/moment'
  3. function CurentTime() {
  4. var now = new Date();
  5. var year = now.getFullYear(); //年
  6. var month = now.getMonth() + 1; //月
  7. var day = now.getDate(); //日
  8. var hh = now.getHours(); //时
  9. var mm = now.getMinutes(); //分
  10. var clock = year + "-";
  11. if (month < 10)
  12. clock += "0";
  13. clock += month + "-";
  14. if (day < 10)
  15. clock += "0";
  16. clock += day + " ";
  17. // if (hh < 10)
  18. // clock += "0";
  19. // clock += '00' + ":";
  20. // // if (mm < 10) clock += '0';
  21. clock += '00:00:00';
  22. return (clock);
  23. }
  24. function CurentTime1() {
  25. var now = new Date();
  26. var year = now.getFullYear() + 3; //年
  27. var month = now.getMonth() + 1; //月
  28. var day = now.getDate(); //日
  29. var hh = now.getHours(); //时
  30. var mm = now.getMinutes(); //分
  31. var clock = year + "-";
  32. if (month < 10)
  33. clock += "0";
  34. clock += month + "-";
  35. if (day < 10)
  36. clock += "0";
  37. clock += day + " ";
  38. // if (hh < 10)
  39. // clock += "0";
  40. // clock += hh + ":";
  41. // if (mm < 10) clock += '0';
  42. // clock += mm;
  43. clock += '23:59:59';
  44. return (clock);
  45. }
  46. const app = getApp()
  47. const WXAPI = require("../../utils/request")
  48. const util = require("../../utils/util")
  49. const plugin = requirePlugin("myPlugin")
  50. var methods = require('../../utils/methods');
  51. var md5 = require('../../utils/md5.js');
  52. var bleall = require('../../utils/bleall');
  53. var util1 = require('../../utils/util1');
  54. const config = require('../../config')
  55. const ADD_NFC_MODE = 10
  56. var date = new Date()
  57. var isConnected = false
  58. var connectedDeviceId = ''
  59. var basecode = 29283991
  60. var lockId = 1
  61. var lockManagerId = 1
  62. var lockMac = ''
  63. var isInitReady = false
  64. var lockModel
  65. var lockDevice
  66. var taskId = 0
  67. var pincode = -1
  68. var pincodeIndex = -1
  69. var rfCardId = -1
  70. var rfCardIndex = -1
  71. var fingerprintIndex = -1
  72. var passwordLiAll = {
  73. id: ''
  74. }
  75. var faceaddIndex = -1
  76. var isLockLogin = false
  77. var serialNumber = ''
  78. Page({
  79. /**
  80. * 页面的初始数据
  81. */
  82. data: {
  83. date: moment().format('YYYY-MM-DD HH:mm:ss'),
  84. show: false,
  85. value: '',
  86. show2: false,
  87. facename: '',
  88. minDate: '',
  89. minDate1: '',
  90. endtime: '',
  91. starttime: '',
  92. datetimerange: [CurentTime(), CurentTime1()],
  93. chooseface: false,
  94. avatarPath: "", // 上传的图片数据
  95. facepic: "", // 上传的图片的base64格式
  96. isSearch: app.globalData.isSearch,
  97. cgInfo: {},
  98. deviceinfo: {},
  99. personLi: {},
  100. faceList: [],
  101. facemessage: {}, // 删除人的信息
  102. },
  103. /**
  104. * 生命周期函数--监听页面加载
  105. */
  106. onLoad: function (options) {
  107. var cgInfo = wx.getStorageSync('cgInfo')
  108. var deviceinfo = wx.getStorageSync('deviceinfo')
  109. var personLi = wx.getStorageSync('personLi')
  110. let minDate = wx.getStorageSync('minDate')
  111. let minDate1 = wx.getStorageSync('minDate1')
  112. console.log(cgInfo, deviceinfo, personLi, minDate, minDate1);
  113. this.setData({
  114. isSearch: false,
  115. cgInfo: cgInfo,
  116. minDate,
  117. minDate1,
  118. starttime: minDate,
  119. endtime: minDate1,
  120. deviceinfo: deviceinfo,
  121. personLi: personLi,
  122. })
  123. if (this.data.avatarPath) {
  124. this.setData({
  125. show2: true
  126. })
  127. }
  128. this.getFace()
  129. },
  130. // 获取已录入人脸数据
  131. getFace() {
  132. var data = {
  133. pageNum: 0,
  134. pageSize: 0,
  135. q: JSON.stringify({
  136. // cardId: this.data.personLi.cardId,
  137. deviceNum: this.data.deviceinfo.deviceNum,
  138. types: "0",
  139. inStatus: '0,1,702'
  140. })
  141. }
  142. WXAPI.getCertificates(data).then(res => {
  143. var dataOne = util.zlib_unzip(res.data)
  144. console.log("人脸", res, dataOne);
  145. if (res.success) {
  146. dataOne.map(li => {
  147. let content = JSON.parse(li.content)
  148. li['pzname'] = content.pzname
  149. li['password'] = ''
  150. li['facepic'] = content.faceData
  151. li['startTime'] = moment(li['startTime'] * 1000).format('YYYY-MM-DD')
  152. li['endTime'] = moment(li['endTime'] * 1000).format('YYYY-MM-DD')
  153. })
  154. console.log(dataOne);
  155. this.setData({
  156. faceList: dataOne
  157. })
  158. }
  159. })
  160. },
  161. CurentTime() {
  162. var now = new Date();
  163. var year = now.getFullYear(); //年
  164. var month = now.getMonth() + 1; //月
  165. var day = now.getDate(); //日
  166. var hh = now.getHours(); //时
  167. var mm = now.getMinutes(); //分
  168. var clock = year + "-";
  169. if (month < 10)
  170. clock += "0";
  171. clock += month + "-";
  172. if (day < 10)
  173. clock += "0";
  174. clock += day + " ";
  175. // if (hh < 10)
  176. // clock += "0";
  177. // clock += '00' + ":";
  178. // // if (mm < 10) clock += '0';
  179. clock += '00:00:00';
  180. return (clock);
  181. },
  182. changeshow2() {
  183. this.setData({
  184. show2: true
  185. })
  186. },
  187. onChange2(e) {
  188. this.setData({
  189. facename: e.detail
  190. })
  191. },
  192. bindDateChange: function (e) {
  193. var str = e.detail.value + " 00:00:00"
  194. this.data.datetimerange[0] = str
  195. this.setData({
  196. starttime: str,
  197. })
  198. },
  199. bindDateChange1: function (e) {
  200. var str = e.detail.value + " 23:59:59"
  201. this.data.datetimerange[1] = str
  202. this.setData({
  203. endtime: str
  204. })
  205. },
  206. onSearch() {
  207. },
  208. onCancel() {
  209. },
  210. // 新增人脸
  211. addFace() {
  212. // wx.chooseImage({
  213. // count: 1,
  214. // sizeType: ['original', 'compressed'],
  215. // success: function (res) {
  216. // console.log(res)
  217. // wx.getImageInfo({
  218. // src: res.tempFilePaths[0],
  219. // success(res) {
  220. // wx.navigateTo({
  221. // url: '/pagesA/selectFace/selectFace?data=' + JSON.stringify(res)
  222. // })
  223. // }
  224. // })
  225. // }
  226. // });
  227. wx.navigateTo({
  228. url: '/pagesA/selectFace/selectFace',
  229. })
  230. },
  231. // 弹出框
  232. changeshow(e) {
  233. this.setData({
  234. show: true,
  235. facemessage: e.currentTarget.dataset.item
  236. })
  237. },
  238. onClose() {
  239. this.setData({
  240. show: false,
  241. show2: false
  242. })
  243. },
  244. // 跳转详情页
  245. gotoinfo() {
  246. wx.navigateTo({
  247. url: '/pagesA/faceinfo/faceinfo',
  248. })
  249. },
  250. // 增加人脸
  251. sendface() {
  252. var time3 = new Date(this.data.datetimerange[0].replace(/-/g, '/'))
  253. var time4 = new Date(this.data.datetimerange[1].replace(/-/g, '/'))
  254. var passwordStartTimecontrast = time3.getTime() / 1000
  255. var passwordEndTimecontrast = time4.getTime() / 1000
  256. if (passwordStartTimecontrast > passwordEndTimecontrast) {
  257. wx.showToast({
  258. title: '开始时间不能大于结束时间',
  259. duration: 2000,
  260. mask: true,
  261. icon: 'none'
  262. })
  263. return
  264. }
  265. wx.showLoading({
  266. title: '正在添加人脸',
  267. mask: true
  268. })
  269. var _this = this
  270. var deviceinfo = this.data.deviceinfo
  271. var info = JSON.parse(this.data.personLi.info)
  272. if (deviceinfo.manufactureId == 1241) {
  273. var time1 = new Date(_this.data.datetimerange[0].replace(/-/g, '/'))
  274. var time2 = new Date(_this.data.datetimerange[1].replace(/-/g, '/'))
  275. var passwordStartTime = time1.getTime() / 1000
  276. var passwordEndTime = time2.getTime() / 1000
  277. var facename
  278. if(_this.data.facename == ''){
  279. facename = "人脸" + _this.data.faceList.length
  280. }else {
  281. facename = _this.data.facename
  282. }
  283. // let facepicture = wx.getFileSystemManager().readFileSync(_this.data.avatarPath, "base64")
  284. // facepic = `data:image/jpg;base64, ${facepicture}`
  285. var dataface = {
  286. code: "lwj/faceOperate",
  287. data: {
  288. action: 1,
  289. endTime: passwordEndTime,
  290. faceData: _this.data.facepic,
  291. lockerId: deviceinfo.deviceNum,
  292. lockerUserId: info.userPassword,
  293. startTime: passwordStartTime,
  294. }
  295. }
  296. var str = {
  297. // cardId: this.personInfo.cardId,
  298. imei: _this.data.deviceinfo.imei || "",
  299. pzname: facename,
  300. password: '',
  301. faceData: _this.data.avatarPath,
  302. userTelephone: JSON.parse(_this.data.personLi.info).userTelephone,
  303. operateMode: '',
  304. userPassword: JSON.parse(_this.data.personLi.info).userPassword,
  305. passwordStartTime: passwordStartTime,
  306. passwordEndTime: passwordEndTime,
  307. is: false,
  308. pass: true
  309. }
  310. console.log(_this.data.avatarPath, dataface);
  311. WXAPI.sendCommand(dataface).then(res => {
  312. console.log(res);
  313. if (res.success) {
  314. faceaddIndex = res.data.index
  315. serialNumber = res.data.serialNumber
  316. var datalist = {
  317. cardId: _this.data.personLi.cardId,
  318. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  319. type: 10,
  320. startTime: passwordStartTime,
  321. endTime: passwordEndTime
  322. };
  323. WXAPI.addCertificates(datalist).then(res6 => {
  324. console.log("res6", res6);
  325. })
  326. var data1 = {
  327. cardId: _this.data.personLi.cardId,
  328. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  329. deviceNum: _this.data.deviceinfo.deviceNum,
  330. type: 0,
  331. imei: _this.data.deviceinfo.imei,
  332. serial: serialNumber,
  333. startTime: passwordStartTime,
  334. endTime: passwordEndTime,
  335. }
  336. WXAPI.addCertificates(data1).then(res2 => {
  337. console.log("res2", res2);
  338. var updatedata = {
  339. id: res2.data,
  340. status: 1
  341. };
  342. WXAPI.updateCertificates(updatedata).then((res3) => {
  343. console.log("res3", res3);
  344. });
  345. })
  346. this.setData({
  347. show2: false
  348. })
  349. wx.showToast({
  350. title: '添加人脸成功',
  351. icon: 'none',
  352. duration: 2000
  353. })
  354. this.getFace()
  355. }else{
  356. this.setData({
  357. show2: false
  358. })
  359. wx.showToast({
  360. title: res.msg,
  361. icon: 'none',
  362. duration: 2000
  363. })
  364. this.getFace()
  365. }
  366. })
  367. }
  368. },
  369. // 删除人脸
  370. delFace() {
  371. wx.showModal({
  372. title: '提示',
  373. content: "此操作将删除该人脸信息,确定删除吗?",
  374. success(res) {
  375. if(res.confirm){
  376. let dataface = {
  377. }
  378. }else if(res.cancel) {
  379. wx.showToast({
  380. title: '取消删除该图像信息',
  381. icon: "none",
  382. duration: 2000
  383. })
  384. }
  385. }
  386. })
  387. },
  388. sendBytes(bytes) {
  389. setTimeout(() => {
  390. wx.writeBLECharacteristicValue({
  391. deviceId: lockDevice.deviceId,
  392. serviceId: config.uuid.serviceUuid.toUpperCase(),
  393. characteristicId: config.uuid.writeUuid.toUpperCase(),
  394. value: bytes,
  395. success: function (res) {
  396. },
  397. })
  398. }, 50)
  399. },
  400. searchDevicesMethods() {
  401. var that = this;
  402. wx.showLoading({
  403. title: '正在搜索',
  404. // mask: true
  405. })
  406. this.setData({
  407. searchClick: false
  408. })
  409. wx.openBluetoothAdapter({
  410. success: function (res) {
  411. wx.startBluetoothDevicesDiscovery({
  412. success: function (res) {
  413. wx.getBluetoothDevices({
  414. success: function (res) {
  415. res.devices.map(it => {
  416. var status = it.name.indexOf('WSL_')
  417. if (status != -1) {
  418. if (it.RSSI != 127) {
  419. if (it.advertisData != null) {
  420. it.adData = util1.ab2hex(it.advertisData)
  421. if (it.adData.length > 10) {
  422. var macStr = it.adData.substring(4, 16).toUpperCase()
  423. //console.log('macStr', macStr)
  424. 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)
  425. if (it.adData.substring(1, 2) == '1') {
  426. it.isLightOn = true
  427. it.textColor = 'green'
  428. } else {
  429. it.isLightOn = false
  430. it.textColor = 'black'
  431. }
  432. if (it.adData.substring(3, 4) == '1') {
  433. it.textColor = 'pink'
  434. it.isBind = true
  435. } else {
  436. it.isBind = false
  437. }
  438. }
  439. } else {
  440. it.textColor = 'black'
  441. }
  442. lockModel = util1.getLockModel(it.name)
  443. it.lockType = util1.getLockType(lockModel)
  444. if (it.name == that.data.deviceinfo.deviceNum) {
  445. app.addDeviceWithDevName(it.name, it)
  446. lockDevice = it
  447. connectedDeviceId = it.deviceId
  448. that.setData({
  449. isSearch: true
  450. })
  451. that.initBluetooth()
  452. }
  453. }
  454. }
  455. })
  456. if (!that.data.isSearch) {
  457. that.searchDevicesMethods()
  458. }
  459. }
  460. })
  461. },
  462. fail: function (res) {
  463. wx.hideLoading({
  464. success: (res) => {
  465. wx.showToast({
  466. title: res.errMsg,
  467. duration: 2000,
  468. icon: 'none'
  469. })
  470. },
  471. })
  472. }
  473. })
  474. },
  475. fail: function (res) {
  476. console.log('请打开蓝牙和定位功能')
  477. wx.hideLoading({
  478. success: (res) => {
  479. wx.showToast({
  480. title: '请打开蓝牙和定位功能',
  481. duration: 2000,
  482. icon: 'none'
  483. })
  484. },
  485. })
  486. }
  487. })
  488. },
  489. initBluetooth: function () {
  490. var that = this
  491. wx.getConnectedBluetoothDevices({
  492. services: [config.uuid.serviceUuid],
  493. success: function (res) {
  494. res.devices.map(function (it) {
  495. if (it.deviceId == connectedDeviceId || it.name == that.data.deviceinfo.deviceNum) {
  496. isConnected = true
  497. }
  498. })
  499. that.setData({
  500. isConnected: isConnected
  501. })
  502. console.log(isInitReady, 'isConnected', isConnected)
  503. if (isConnected) {
  504. console.log("2144");
  505. if (isInitReady) {
  506. console.log("2146");
  507. that.doWork()
  508. } else {
  509. that.setupConnection()
  510. }
  511. } else {
  512. that.connectTo()
  513. }
  514. },
  515. })
  516. },
  517. connectTo: function () {
  518. var that = this
  519. wx.showLoading({
  520. title: '连接中',
  521. })
  522. wx.createBLEConnection({
  523. deviceId: lockDevice.deviceId,
  524. timeout: config.ble.connectTimeOut,
  525. success: function (res) {
  526. console.log('connectTo', res)
  527. isConnected = true
  528. // app.globalData.isConnected = true
  529. wx.hideLoading()
  530. setTimeout(function () {
  531. that.setupConnection()
  532. }, 500)
  533. },
  534. fail: function (e) {
  535. console.debug('connectTo', e)
  536. wx.hideLoading()
  537. switch (e.errCode) {
  538. case 10003: {
  539. wx.showModal({
  540. title: '连接失败',
  541. content: '是否重新连接?',
  542. success: function (res) {
  543. if (res.confirm) {
  544. that.connectTo()
  545. }
  546. }
  547. })
  548. break
  549. }
  550. case 10012: {
  551. wx.showModal({
  552. title: '连接失败',
  553. content: '蓝牙连接超时',
  554. showCancel: false
  555. })
  556. break
  557. }
  558. case 10002: {
  559. wx.showModal({
  560. title: '连接失败',
  561. content: '没有找到指定设备',
  562. showCancel: false
  563. })
  564. break
  565. }
  566. }
  567. }
  568. })
  569. },
  570. setupConnection: function () {
  571. var that = this
  572. wx.showLoading({
  573. title: '初始化连接中',
  574. })
  575. wx.getBLEDeviceServices({
  576. deviceId: lockDevice.deviceId,
  577. success: function (res) {
  578. console.log('Services', res)
  579. wx.getBLEDeviceCharacteristics({
  580. deviceId: lockDevice.deviceId,
  581. serviceId: config.uuid.serviceUuid.toUpperCase(),
  582. success: function (res) {
  583. console.log('Characteristics', res)
  584. wx.showToast({
  585. title: '连接成功',
  586. duration: 1000,
  587. icon: 'none'
  588. })
  589. wx.onBLECharacteristicValueChange(function (res) {
  590. console.log(res, 'reslllllll')
  591. var bytes = new Uint8Array(res.value)
  592. console.log('bytes', bytes)
  593. var data = plugin.parseBytes(lockDevice.name, basecode, bytes)
  594. console.log('data', data)
  595. switch (data.cmd) {
  596. case 'reportLockBattery': {
  597. if (data.data.battery < 10) {
  598. wx.showModal({
  599. title: '电量报警',
  600. content: `门锁当前电量${data.data.battery}%!\n电量严重不足,请立即更换电池!`,
  601. showCancel: false
  602. })
  603. } else if (data.data.battery < 30) {
  604. wx.showModal({
  605. title: '电量预警',
  606. content: `门锁当前电量${data.data.battery}%!\n请及时更换电池!`,
  607. showCancel: false
  608. })
  609. }
  610. break
  611. }
  612. case 'reportRfCardResult': {
  613. if (taskId == 61) {
  614. wx.showModal({
  615. title: '检测到新卡',
  616. content: `是否添加此房卡,卡号:${data.data.cardId}`,
  617. success: function (res) {
  618. if (res.confirm) {
  619. console.log(data.data, 'rfCardIdrfCardId')
  620. // rfCardId = randomMethods()//data.data.cardId
  621. that.onAddRfCard()
  622. }
  623. }
  624. })
  625. } else {
  626. if (lockModel > 70) {
  627. if (data.data.isValid) {
  628. wx.showModal({
  629. title: '提示',
  630. content: `房卡开锁成功,序号:${data.data.index}`,
  631. showCancel: false
  632. })
  633. } else {
  634. wx.showModal({
  635. title: '提示',
  636. content: `多次刷房卡开锁失败!`,
  637. showCancel: false
  638. })
  639. }
  640. } else {
  641. if (data.data.isValid) {
  642. wx.showModal({
  643. title: '提示',
  644. content: `房卡开锁成功,卡号:${data.data.cardId}`,
  645. showCancel: false
  646. })
  647. } else {
  648. wx.showModal({
  649. title: '提示',
  650. content: `房卡未授权,卡号:${data.data.cardId}`,
  651. showCancel: false
  652. })
  653. }
  654. }
  655. }
  656. break
  657. }
  658. case 'reportPincodeResult': {
  659. if (lockModel > 70) {
  660. if (data.data.isValid) {
  661. wx.showModal({
  662. title: '提示',
  663. content: `密码开锁成功,序号:${data.data.index}`,
  664. showCancel: false
  665. })
  666. } else {
  667. wx.showModal({
  668. title: '提示',
  669. content: `多次密码开锁失败!`,
  670. showCancel: false
  671. })
  672. }
  673. } else {
  674. if (data.data.isValid) {
  675. wx.showModal({
  676. title: '提示',
  677. content: `密码:${data.data.pincode}开锁成功!`,
  678. showCancel: false
  679. })
  680. } else {
  681. wx.showModal({
  682. title: '提示',
  683. content: `密码:${data.data.pincode}未授权!`,
  684. showCancel: false
  685. })
  686. }
  687. }
  688. break
  689. }
  690. case 'reportFingerprintResult': {
  691. if (data.data.isValid) {
  692. wx.showModal({
  693. title: '提示',
  694. content: `指纹开锁成功,序号:${data.data.index}`,
  695. showCancel: false
  696. })
  697. } else {
  698. wx.showModal({
  699. title: '提示',
  700. content: `多次指纹开锁失败!`,
  701. showCancel: false
  702. })
  703. }
  704. break
  705. }
  706. case 'queryLockState': {
  707. wx.hideLoading()
  708. if (data.code != 200) {
  709. wx.showModal({
  710. title: '提示',
  711. content: '查询失败!',
  712. showCancel: false,
  713. success: function (res) {}
  714. })
  715. break
  716. }
  717. that.setData({
  718. lock: {
  719. mac: data.data.mac,
  720. lockType: util1.getLockType(lockModel),
  721. },
  722. isBindLock: data.data.isBind
  723. })
  724. lockMac = data.data.mac
  725. if (taskId > 0) {
  726. if (data.data.isBind) {
  727. // wx.showModal({
  728. // title: data.data.mac,
  729. // content: '此设备已经硬件绑定!',
  730. // showCancel: false,
  731. // success: function (res) {}
  732. // })
  733. } else {
  734. wx.showModal({
  735. title: data.data.mac,
  736. content: '此设备硬件未绑定!',
  737. showCancel: false,
  738. success: function (res) {}
  739. })
  740. }
  741. }
  742. taskId = 0
  743. break
  744. }
  745. case 'queryLockBattery': {
  746. wx.hideLoading()
  747. if (data.code != 200) {
  748. wx.showModal({
  749. title: '提示',
  750. content: '查询失败!',
  751. showCancel: false,
  752. success: function (res) {}
  753. })
  754. break
  755. }
  756. taskId = 0
  757. wx.showModal({
  758. title: '提示',
  759. content: `此门锁电量为${data.data.battery}%`,
  760. showCancel: false,
  761. success: function (res) {}
  762. })
  763. break
  764. }
  765. case 'queryNbImei': {
  766. wx.hideLoading()
  767. if (data.code != 200) {
  768. wx.showModal({
  769. title: '提示',
  770. content: '查询失败!',
  771. showCancel: false,
  772. success: function (res) {}
  773. })
  774. break
  775. }
  776. taskId = 0
  777. wx.showModal({
  778. title: '提示',
  779. content: `此NB设备IMEI为${data.data.imei}`,
  780. showCancel: false,
  781. success: function (res) {}
  782. })
  783. break
  784. }
  785. case 'setNbFun': {
  786. wx.hideLoading()
  787. if (data.code != 200) {
  788. wx.showModal({
  789. title: '提示',
  790. content: '设置Nb功能失败!',
  791. showCancel: false,
  792. success: function (res) {}
  793. })
  794. break
  795. }
  796. taskId = 0
  797. wx.showModal({
  798. title: '提示',
  799. content: that.data.isNbEnable ? 'NB功能已禁用' : 'NB功能已打开',
  800. showCancel: false,
  801. })
  802. that.setData({
  803. isNbEnable: !that.data.isNbEnable
  804. })
  805. break
  806. }
  807. case 'sendBindLock': {
  808. wx.hideLoading()
  809. if (data.code != 200) {
  810. wx.showModal({
  811. title: '提示',
  812. content: '绑定失败!',
  813. showCancel: false,
  814. success: function (res) {}
  815. })
  816. break
  817. }
  818. taskId = 0
  819. that.setData({
  820. isBindLock: data.data.isBind
  821. })
  822. if (data.data.isBind) {
  823. wx.showToast({
  824. title: '绑定成功!',
  825. })
  826. } else {
  827. wx.showToast({
  828. title: '绑定失败!',
  829. })
  830. }
  831. break
  832. }
  833. case 'sendUnbindLock': {
  834. wx.hideLoading()
  835. if (data.code != 200) {
  836. wx.showModal({
  837. title: '提示',
  838. content: '解绑失败!',
  839. showCancel: false,
  840. success: function (res) {}
  841. })
  842. break
  843. }
  844. taskId = 0
  845. that.setData({
  846. isBindLock: data.data.isBind
  847. })
  848. if (data.data.isBind) {
  849. wx.showToast({
  850. title: '解绑失败!',
  851. })
  852. } else {
  853. wx.showToast({
  854. title: '解绑成功!',
  855. })
  856. }
  857. break
  858. }
  859. case 'login1':
  860. case 'sendOpenLockP1': {
  861. if (data.code != 200) {
  862. wx.hideLoading()
  863. if (taskId == 41) {
  864. wx.showModal({
  865. title: '提示',
  866. content: that.data.isJack ? '上电失败!' : '解锁失败!',
  867. showCancel: false,
  868. success: function (res) {}
  869. })
  870. } else if (taskId == 32) {
  871. wx.showModal({
  872. title: '提示',
  873. content: '登录失败!',
  874. showCancel: false,
  875. success: function (res) {}
  876. })
  877. }
  878. break
  879. }
  880. if (taskId == 41) {
  881. var bytes = plugin.sendOpenLockP2(lockDevice.name, basecode, data.data.randomN)
  882. console.debug('bytes', bytes)
  883. that.sendBytes(bytes)
  884. } else if (taskId == 32) {
  885. var bytes = plugin.login2(lockDevice.name, basecode, data.data.randomN)
  886. console.debug('bytes', bytes)
  887. that.sendBytes(bytes)
  888. }
  889. break;
  890. }
  891. case 'login':
  892. case 'sendOpenLockP2': {
  893. wx.hideLoading()
  894. if (data.code != 200) {
  895. if (taskId == 41) {
  896. wx.showModal({
  897. title: '提示',
  898. content: that.data.isJack ? '上电失败!' : '解锁失败!',
  899. showCancel: false,
  900. success: function (res) {}
  901. })
  902. } else if (taskId == 32) {
  903. wx.showModal({
  904. title: '提示',
  905. content: '登录失败!',
  906. showCancel: false,
  907. success: function (res) {}
  908. })
  909. }
  910. break
  911. }
  912. isLockLogin = true
  913. if (taskId == 41) {
  914. // var data = {
  915. // code: "zg/bleUnlockRecord",
  916. // data: {
  917. // lockerId: that.data.deviceinfo.deviceNum,
  918. // roomId:that.data.deviceinfo.roomId,
  919. // roomName:that.data.deviceinfo.roomName,
  920. // cardName:that.data.userInfo.username
  921. // }
  922. // }
  923. var data = {
  924. code: "ble/bleUnlockRecord",
  925. data: {
  926. deviceNum: that.data.deviceinfo.deviceNum,
  927. roomId: that.data.deviceinfo.roomId,
  928. roomName: that.data.deviceinfo.roomName,
  929. cardName: that.data.userInfo.username,
  930. productId: that.data.deviceinfo.manufactureId,
  931. userId: '29283991'
  932. }
  933. }
  934. WXAPI.sendCommand(data).then(res => {
  935. console.log(res)
  936. })
  937. wx.showToast({
  938. title: that.data.isJack ? '上电成功!' : '解锁成功!',
  939. })
  940. } else if (taskId == 32) {
  941. wx.showToast({
  942. title: '登录成功!',
  943. })
  944. }
  945. taskId = 0
  946. break;
  947. }
  948. case 'syncClock': {
  949. wx.hideLoading()
  950. if (data.code != 200) {
  951. wx.showModal({
  952. title: '提示',
  953. content: '同步时间失败!' + data.data.msg,
  954. showCancel: false,
  955. success: function (res) {}
  956. })
  957. break
  958. }
  959. taskId = 0
  960. wx.showModal({
  961. title: '提示',
  962. content: '时间更新成功!',
  963. showCancel: false
  964. })
  965. break;
  966. }
  967. case 'addPincode': {
  968. // console.log(data.data,'data.data')
  969. // wx.hideLoading()
  970. let data2 = {
  971. "code": "ble/bleSendVoucherReply",
  972. "data": {
  973. "deviceNum": that.data.deviceinfo.deviceNum,
  974. "serialNumber": serialNumber,
  975. "index": pincodeIndex,
  976. "type": 7,
  977. "result": 1,
  978. "productId": that.data.deviceinfo.manufactureId
  979. }
  980. }
  981. if (data.code != 200) {
  982. data2 = {
  983. "code": "ble/bleSendVoucherReply",
  984. "data": {
  985. "deviceNum": that.data.deviceinfo.deviceNum,
  986. "serialNumber": serialNumber,
  987. "index": pincodeIndex,
  988. "type": 7,
  989. "result": 0,
  990. "productId": that.data.deviceinfo.manufactureId
  991. }
  992. }
  993. WXAPI.sendCommand(data2).then(res => {
  994. })
  995. wx.showModal({
  996. title: '提示',
  997. content: '添加密码失败!' + data.data.msg,
  998. showCancel: false,
  999. success: function (res) {}
  1000. })
  1001. break
  1002. }
  1003. var time1 = new Date(that.data.starttime.replace(/-/g, '/'))
  1004. var time2 = new Date(that.data.endtime.replace(/-/g, '/'))
  1005. var passwordStartTime = time1.getTime() / 1000
  1006. var passwordEndTime = time2.getTime() / 1000
  1007. var pzname = '',
  1008. cardName = '';
  1009. pzname = '蓝牙-密码' + (that.data.passwordList.length + 1)
  1010. cardName = that.data.personLi.name + '-蓝牙-密码' + (that.data.passwordList.length + 1)
  1011. var str = {
  1012. // cardId: this.personInfo.cardId,
  1013. imei: that.data.deviceinfo.imei,
  1014. pzname: pzname,
  1015. password: that.data.password.toString(),
  1016. userTelephone: JSON.parse(that.data.personLi.info).userTelephone,
  1017. operateMode: 7,
  1018. userPassword: JSON.parse(that.data.personLi.info).userPassword,
  1019. passwordStartTime: passwordStartTime,
  1020. passwordEndTime: passwordEndTime,
  1021. index: pincodeIndex,
  1022. is: false,
  1023. pass: true
  1024. }
  1025. var data1 = {
  1026. cardId: that.data.personLi.cardId,
  1027. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  1028. deviceNum: that.data.deviceinfo.deviceNum,
  1029. type: 4,
  1030. imei: that.data.deviceinfo.imei,
  1031. serial: serialNumber,
  1032. startTime: passwordStartTime,
  1033. endTime: passwordEndTime,
  1034. };
  1035. var datalist = {
  1036. cardId: that.data.personLi.cardId,
  1037. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  1038. type: 14,
  1039. startTime: passwordStartTime,
  1040. endTime: passwordEndTime,
  1041. };
  1042. WXAPI.addCertificates(datalist).then(res6 => {
  1043. console.log(datalist, '密码22', res6)
  1044. })
  1045. WXAPI.addCertificates(data1).then(res3 => {
  1046. if (res3.success) {
  1047. var updatedata = {
  1048. id: res3.data,
  1049. status: 1
  1050. };
  1051. WXAPI.updateCertificates(updatedata).then((res2) => {});
  1052. WXAPI.sendCommand(data2).then(res => {
  1053. })
  1054. that.getPassword()
  1055. that.setData({
  1056. show: false
  1057. })
  1058. wx.hideLoading()
  1059. wx.showToast({
  1060. title: '添加成功',
  1061. mask: true,
  1062. icon: 'none',
  1063. duration: 2000
  1064. })
  1065. } else {
  1066. wx.hideLoading()
  1067. wx.showToast({
  1068. title: '添加失败',
  1069. mask: true,
  1070. icon: 'none',
  1071. duration: 2000
  1072. })
  1073. }
  1074. })
  1075. taskId = 0
  1076. that.setData({
  1077. isPincodeAdd: true,
  1078. show: false
  1079. })
  1080. wx.showModal({
  1081. title: '提示',
  1082. content: `添加密码${pincode}成功!`,
  1083. showCancel: false
  1084. })
  1085. break
  1086. }
  1087. case 'delPincode': {
  1088. wx.hideLoading()
  1089. if (data.code != 200) {
  1090. var datacom = {
  1091. code: "lwj/passwordOperate",
  1092. data: {
  1093. lockerId: that.data.deviceinfo.deviceNum,
  1094. serialNumber: serialNumber,
  1095. index: pincodeIndex,
  1096. action: 2,
  1097. type: 9,
  1098. result: 0
  1099. }
  1100. }
  1101. WXAPI.sendCommand(datacom).then(res2 => {
  1102. console.log(res2, '失败')
  1103. })
  1104. wx.showModal({
  1105. title: '提示',
  1106. content: '删除密码失败!',
  1107. showCancel: false,
  1108. success: function (res) {}
  1109. })
  1110. break
  1111. }
  1112. taskId = 0
  1113. wx.showModal({
  1114. title: '提示',
  1115. content: `删除密码成功!`,
  1116. showCancel: false,
  1117. })
  1118. var datacom = {
  1119. code: "lwj/passwordOperate",
  1120. data: {
  1121. lockerId: that.data.deviceinfo.deviceNum,
  1122. serialNumber: serialNumber,
  1123. index: pincodeIndex,
  1124. action: 2,
  1125. type: 9,
  1126. result: 1
  1127. }
  1128. }
  1129. WXAPI.sendCommand(datacom).then(res2 => {
  1130. if (res2.success) {}
  1131. })
  1132. var data = {
  1133. ids: [passwordLiAll.id]
  1134. }
  1135. WXAPI.deleteCertificates(data).then(res1 => {
  1136. if (res1.success) {
  1137. that.getPassword()
  1138. wx.hideLoading()
  1139. wx.showToast({
  1140. title: '删除成功',
  1141. mask: true,
  1142. icon: 'none',
  1143. duration: 2000
  1144. })
  1145. } else {
  1146. wx.hideLoading()
  1147. wx.showToast({
  1148. title: '删除失败',
  1149. mask: true,
  1150. icon: 'none',
  1151. duration: 2000
  1152. })
  1153. }
  1154. })
  1155. that.setData({
  1156. isPincodeAdd: false
  1157. })
  1158. pincode = -1
  1159. pincodeIndex = -1
  1160. break
  1161. }
  1162. case 'addRfCard': {
  1163. wx.hideLoading()
  1164. if (data.code == 100) {
  1165. wx.showLoading({
  1166. title: data.data.msg,
  1167. })
  1168. break
  1169. } else if (data.code != 200) {
  1170. var datacom = {
  1171. code: "ble/bleSendVoucherReply",
  1172. data: {
  1173. deviceNum: that.data.deviceinfo.deviceNum,
  1174. serialNumber: serialNumber,
  1175. index: rfCardIndex,
  1176. type: ADD_NFC_MODE,
  1177. cardNo: '',
  1178. result: 0,
  1179. productId: that.data.deviceinfo.manufactureId
  1180. }
  1181. }
  1182. WXAPI.sendCommand(datacom).then(res2 => {})
  1183. wx.showModal({
  1184. title: '提示',
  1185. content: '添加房卡失败!' + data.data.msg,
  1186. showCancel: false,
  1187. success: function (res) {}
  1188. })
  1189. break
  1190. }
  1191. taskId = 0
  1192. that.setData({
  1193. isRfCardAdd: true
  1194. })
  1195. if (lockModel > 70) {
  1196. console.log(data.data, 'rfCardIndexrfCardIndex')
  1197. // rfCardId = randomMethods()
  1198. wx.showModal({
  1199. title: '提示',
  1200. content: `添加房卡成功,序号${rfCardIndex}`,
  1201. showCancel: false
  1202. })
  1203. that.addRfcardCertificates()
  1204. } else {
  1205. console.log(data.data, 'rfCardIndexrfCardIndex1')
  1206. // rfCardId = randomMethods()
  1207. wx.showModal({
  1208. title: '提示',
  1209. content: `添加房卡成功,卡号${rfCardId}`,
  1210. showCancel: false
  1211. })
  1212. that.addRfcardCertificates()
  1213. }
  1214. break
  1215. }
  1216. case 'delRfCard': {
  1217. wx.hideLoading()
  1218. if (data.code != 200) {
  1219. var datacom = {
  1220. code: "lwj/c",
  1221. data: {
  1222. lockerId: that.data.deviceinfo.deviceNum,
  1223. serialNumber: serialNumber,
  1224. index: rfCardIndex,
  1225. action: 2,
  1226. type: 12,
  1227. result: 0
  1228. }
  1229. }
  1230. WXAPI.sendCommand(datacom).then(res2 => {
  1231. console.log(res2, '失败')
  1232. })
  1233. wx.showModal({
  1234. title: '提示',
  1235. content: '删除房卡失败!',
  1236. showCancel: false,
  1237. success: function (res) {}
  1238. })
  1239. break
  1240. }
  1241. taskId = 0
  1242. that.setData({
  1243. isRfCardAdd: false
  1244. })
  1245. if (lockModel > 70) {
  1246. wx.showModal({
  1247. title: '提示',
  1248. content: `删除房卡成功,序号${rfCardIndex}`,
  1249. showCancel: false,
  1250. })
  1251. } else {
  1252. wx.showModal({
  1253. title: '提示',
  1254. content: `删除房卡成功,卡号${rfCardId}`,
  1255. showCancel: false,
  1256. })
  1257. }
  1258. var datacom = {
  1259. code: "lwj/c",
  1260. data: {
  1261. lockerId: that.data.deviceinfo.deviceNum,
  1262. serialNumber: serialNumber,
  1263. index: rfCardIndex,
  1264. action: 2,
  1265. type: 12,
  1266. result: 1
  1267. }
  1268. }
  1269. WXAPI.sendCommand(datacom).then(res2 => {
  1270. console.log(res2, '失败')
  1271. })
  1272. var data = {
  1273. ids: [passwordLiAll.id]
  1274. }
  1275. WXAPI.deleteCertificates(data).then(res1 => {
  1276. console.log(res1, '2936');
  1277. if (res1.success) {
  1278. that.getNfc()
  1279. wx.showToast({
  1280. title: '删除成功',
  1281. mask: true,
  1282. icon: 'none',
  1283. duration: 2000
  1284. })
  1285. } else {
  1286. wx.showToast({
  1287. title: '删除失败',
  1288. mask: true,
  1289. icon: 'none',
  1290. duration: 2000
  1291. })
  1292. }
  1293. })
  1294. rfCardId = -1
  1295. rfCardIndex = -1
  1296. break
  1297. }
  1298. case 'addFingerprint': {
  1299. wx.hideLoading()
  1300. if (data.code == 100) {
  1301. wx.showLoading({
  1302. title: data.data.msg,
  1303. })
  1304. break
  1305. } else if (data.code != 200) {
  1306. wx.showModal({
  1307. title: '提示',
  1308. content: '添加指纹失败!' + data.data.msg,
  1309. showCancel: false,
  1310. success: function (res) {}
  1311. })
  1312. var datacom = {
  1313. code: "ble/bleSendVoucherReply",
  1314. data: {
  1315. deviceNum: that.data.deviceinfo.deviceNum,
  1316. serialNumber: serialNumber,
  1317. index: 0,
  1318. type: 16,
  1319. result: 0,
  1320. productId: that.data.deviceinfo.manufactureId
  1321. }
  1322. }
  1323. WXAPI.sendCommand(datacom).then(res2 => {
  1324. if (res2.success) {}
  1325. })
  1326. break
  1327. }
  1328. taskId = 0
  1329. that.setData({
  1330. isFingerprintAdd: true
  1331. })
  1332. wx.showModal({
  1333. title: '提示',
  1334. content: `添加指纹成功,序号${fingerprintIndex}`,
  1335. showCancel: false
  1336. })
  1337. var time1 = new Date(that.data.starttime.replace(/-/g, '/'))
  1338. var time2 = new Date(that.data.endtime.replace(/-/g, '/'))
  1339. var passwordStartTime = time1.getTime() / 1000
  1340. var passwordEndTime = time2.getTime() / 1000
  1341. var cardName = '',
  1342. pzname = ''
  1343. if (that.data.pzname) {
  1344. cardName = that.data.personLi.name + '-蓝牙-' + that.data.pzname
  1345. pzname = '蓝牙-' + that.data.pzname
  1346. } else {
  1347. cardName = that.data.personLi.name + '-蓝牙-指纹' + (that.data.FpList.length + 1)
  1348. pzname = '蓝牙-指纹' + (that.data.FpList.length + 1)
  1349. }
  1350. var str = {
  1351. // cardId: this.personInfo.cardId,
  1352. imei: that.data.deviceinfo.imei,
  1353. pzname: pzname,
  1354. password: '',
  1355. fingerprintAlias: that.data.radioDetil,
  1356. userTelephone: JSON.parse(that.data.personLi.info).userTelephone,
  1357. operateMode: 16,
  1358. userPassword: JSON.parse(that.data.personLi.info).userPassword,
  1359. passwordStartTime: passwordStartTime,
  1360. passwordEndTime: passwordEndTime,
  1361. index: fingerprintIndex,
  1362. is: false,
  1363. pass: true
  1364. }
  1365. var data2 = {
  1366. cardId: that.data.personLi.cardId,
  1367. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  1368. deviceNum: that.data.deviceinfo.deviceNum,
  1369. type: 1,
  1370. imei: that.data.deviceinfo.imei,
  1371. serial: serialNumber,
  1372. startTime: passwordStartTime,
  1373. endTime: passwordEndTime,
  1374. status: 1
  1375. };
  1376. var datalist = {
  1377. cardId: that.data.personLi.cardId,
  1378. content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1
  1379. type: 11,
  1380. startTime: passwordStartTime,
  1381. endTime: passwordEndTime
  1382. };
  1383. var datacom = {
  1384. code: "ble/bleSendVoucherReply",
  1385. data: {
  1386. deviceNum: that.data.deviceinfo.deviceNum,
  1387. serialNumber: serialNumber,
  1388. index: fingerprintIndex,
  1389. type: 16,
  1390. result: 1,
  1391. productId: that.data.deviceinfo.manufactureId
  1392. }
  1393. }
  1394. WXAPI.addCertificates(datalist).then(res6 => {})
  1395. console.log(data, '添加凭证')
  1396. WXAPI.addCertificates(data2).then(res3 => {
  1397. if (res3.success) {
  1398. var updatedata = {
  1399. id: res3.data,
  1400. status: 1
  1401. };
  1402. WXAPI.updateCertificates(updatedata).then((res2) => {});
  1403. WXAPI.sendCommand(datacom).then(res2 => {
  1404. if (res2.success) {}
  1405. })
  1406. console.log(res3, '添加凭证成功')
  1407. that.getFp()
  1408. that.setData({
  1409. show: false
  1410. })
  1411. wx.hideLoading()
  1412. wx.showToast({
  1413. title: '添加成功',
  1414. mask: true,
  1415. icon: 'none',
  1416. duration: 2000
  1417. })
  1418. } else {
  1419. wx.hideLoading()
  1420. wx.showToast({
  1421. title: '添加失败',
  1422. mask: true,
  1423. icon: 'none',
  1424. duration: 2000
  1425. })
  1426. }
  1427. })
  1428. break
  1429. }
  1430. case 'delFingerprint': {
  1431. wx.hideLoading()
  1432. if (data.code != 200) {
  1433. wx.showModal({
  1434. title: '提示',
  1435. content: '删除指纹失败!',
  1436. showCancel: false,
  1437. success: function (res) {}
  1438. })
  1439. break
  1440. }
  1441. taskId = 0
  1442. wx.showModal({
  1443. title: '提示',
  1444. content: `删除指纹成功,序号${fingerprintIndex}`,
  1445. showCancel: false,
  1446. })
  1447. that.setData({
  1448. isFingerprintAdd: false
  1449. })
  1450. fingerprintIndex = -1
  1451. break
  1452. }
  1453. case 'changeAdminPincode': {
  1454. wx.hideLoading()
  1455. if (data.code != 200) {
  1456. wx.showModal({
  1457. title: '提示',
  1458. content: '修改管理密码失败!',
  1459. showCancel: false,
  1460. success: function (res) {}
  1461. })
  1462. break
  1463. }
  1464. taskId = 0
  1465. wx.showToast({
  1466. title: '修改管理密码成功!',
  1467. })
  1468. }
  1469. case 'queryLockSlotState': {
  1470. wx.hideLoading()
  1471. if (data.code != 200) {
  1472. wx.showModal({
  1473. title: '提示',
  1474. content: '查询失败!',
  1475. showCancel: false,
  1476. success: function (res) {}
  1477. })
  1478. break
  1479. }
  1480. taskId = 0
  1481. wx.showModal({
  1482. title: '提示',
  1483. content: data.data.state == 0 ? '此门锁方舌关闭' : '此门锁方舌打开',
  1484. showCancel: false,
  1485. success: function (res) {}
  1486. })
  1487. break
  1488. }
  1489. case 'queryLockUnlockState': {
  1490. wx.hideLoading()
  1491. if (data.code != 200) {
  1492. wx.showModal({
  1493. title: '提示',
  1494. content: '查询失败!',
  1495. showCancel: false,
  1496. success: function (res) {}
  1497. })
  1498. break
  1499. }
  1500. taskId = 0
  1501. wx.showModal({
  1502. title: '提示',
  1503. content: data.data.state == 0 ? '此门锁已关闭' : '此门锁已打开',
  1504. showCancel: false,
  1505. success: function (res) {}
  1506. })
  1507. break
  1508. }
  1509. case 'setLockUnlockState': {
  1510. wx.hideLoading()
  1511. if (data.code != 200) {
  1512. wx.showModal({
  1513. title: '提示',
  1514. content: '设置常开指令失败!',
  1515. showCancel: false,
  1516. success: function (res) {}
  1517. })
  1518. break
  1519. }
  1520. taskId = 0
  1521. wx.showModal({
  1522. title: '提示',
  1523. content: data.data.state == 0 ? '常开模式已退出' : '常开模式已开启',
  1524. showCancel: false,
  1525. })
  1526. that.setData({
  1527. isUnloked: data.data.state == 1
  1528. })
  1529. break
  1530. }
  1531. case 'setLockMuteState': {
  1532. wx.hideLoading()
  1533. if (data.code != 200) {
  1534. wx.showModal({
  1535. title: '提示',
  1536. content: '设置静音指令失败!',
  1537. showCancel: false,
  1538. success: function (res) {}
  1539. })
  1540. break
  1541. }
  1542. taskId = 0
  1543. wx.showModal({
  1544. title: '提示',
  1545. content: data.data.state == 1 ? '静音模式已退出' : '静音模式已开启',
  1546. showCancel: false,
  1547. })
  1548. that.setData({
  1549. isMuted: data.data.state == 0
  1550. })
  1551. break
  1552. }
  1553. }
  1554. })
  1555. wx.notifyBLECharacteristicValueChange({
  1556. deviceId: lockDevice.deviceId,
  1557. serviceId: config.uuid.serviceUuid.toUpperCase(),
  1558. characteristicId: config.uuid.notifyUuid.toUpperCase(),
  1559. state: true,
  1560. success: function (res) {
  1561. console.log('setupNotify', res)
  1562. isInitReady = true
  1563. setTimeout(function () {
  1564. wx.hideLoading()
  1565. // that.onQueryBindState()
  1566. that.login()
  1567. }, 500)
  1568. },
  1569. })
  1570. },
  1571. })
  1572. },
  1573. })
  1574. },
  1575. doWork: function () {
  1576. var that = this
  1577. console.log(taskId);
  1578. switch (taskId) {
  1579. case 11: {
  1580. that.onBindLock()
  1581. break
  1582. }
  1583. case 12: {
  1584. that.onUnbindLock()
  1585. break
  1586. }
  1587. case 21: {
  1588. that.onQueryBindState()
  1589. break
  1590. }
  1591. case 22: {
  1592. that.onQueryBattery()
  1593. break
  1594. }
  1595. case 31: {
  1596. that.onQueryNbImei()
  1597. break
  1598. }
  1599. case 32: {
  1600. that.onLogin()
  1601. break
  1602. }
  1603. case 41: {
  1604. that.LwjonOpenLock()
  1605. break
  1606. }
  1607. case 42: {
  1608. that.onSyncClock()
  1609. break
  1610. }
  1611. case 51: {
  1612. that.onAddPincode()
  1613. break
  1614. }
  1615. case 52: {
  1616. that.onDelPincode()
  1617. break
  1618. }
  1619. case 61: {
  1620. // that.onAddRfCard()
  1621. // if (lockModel > 70) {
  1622. that.sendAddRfcard()
  1623. // } else {
  1624. // wx.showModal({
  1625. // title: '提示',
  1626. // content: '请刷卡!',
  1627. // showCancel: false
  1628. // })
  1629. // }
  1630. break
  1631. }
  1632. case 62: {
  1633. that.onDelRfCard()
  1634. break
  1635. }
  1636. case 71: {
  1637. that.onAddFingerprint()
  1638. break
  1639. }
  1640. case 72: {
  1641. that.onDelFingerprint()
  1642. break
  1643. }
  1644. case 81: {
  1645. that.onChangeAdminPincode()
  1646. break
  1647. }
  1648. case 91: {
  1649. that.onQueryLockSlotState()
  1650. break
  1651. }
  1652. case 92: {
  1653. that.onQueryLockUnlockState()
  1654. break
  1655. }
  1656. case 101: {
  1657. that.onChangeLockUnlockState()
  1658. break
  1659. }
  1660. case 102: {
  1661. that.onChangeLockMutedState()
  1662. break
  1663. }
  1664. case 111: {
  1665. this.onChangeLockNbState()
  1666. }
  1667. default: {
  1668. }
  1669. }
  1670. },
  1671. login: function () {
  1672. var that = this
  1673. taskId = 32
  1674. that.initBluetooth()
  1675. },
  1676. onLogin: function () {
  1677. var that = this
  1678. wx.showLoading({
  1679. title: '登录中',
  1680. })
  1681. var bytes = plugin.login1(lockDevice.name, basecode)
  1682. console.debug('bytes', bytes)
  1683. that.sendBytes(bytes)
  1684. },
  1685. /**
  1686. * 生命周期函数--监听页面初次渲染完成
  1687. */
  1688. onReady: function () {
  1689. },
  1690. /**
  1691. * 生命周期函数--监听页面显示
  1692. */
  1693. onShow: function () {
  1694. },
  1695. /**
  1696. * 生命周期函数--监听页面隐藏
  1697. */
  1698. onHide: function () {
  1699. },
  1700. /**
  1701. * 生命周期函数--监听页面卸载
  1702. */
  1703. onUnload: function () {
  1704. },
  1705. /**
  1706. * 页面相关事件处理函数--监听用户下拉动作
  1707. */
  1708. onPullDownRefresh: function () {
  1709. },
  1710. /**
  1711. * 页面上拉触底事件的处理函数
  1712. */
  1713. onReachBottom: function () {
  1714. },
  1715. /**
  1716. * 用户点击右上角分享
  1717. */
  1718. onShareAppMessage: function () {
  1719. }
  1720. })