From 5d449a6a4c4bc22228a64c65990fb2e94892a0e5 Mon Sep 17 00:00:00 2001 From: xiaohei <11674173+xiaohei102908@user.noreply.gitee.com> Date: Wed, 29 Nov 2023 15:33:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC1.0.6=20=202023-11-29=20=20lj?= =?UTF-8?q?d=201=E3=80=81=E7=A7=9F=E5=AE=A2=E7=AB=AF=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=97=B6=E9=97=B4=EF=BC=8Cq=E7=B3=BB?= =?UTF-8?q?=E5=88=97=E9=94=81=E9=A1=B5=E9=9D=A2=E5=A2=9E=E5=8A=A0=E5=B8=B8?= =?UTF-8?q?=E5=BC=80=E5=B8=B8=E9=97=AD=E5=8A=9F=E8=83=BD=EF=BC=8Cz?= =?UTF-8?q?=E7=B3=BB=E5=88=97=E9=A1=B5=E9=9D=A2=E9=9A=90=E8=97=8F=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/userbluetoothUnlock/userbluetoothUnlock.js | 116 +++++++++++++++++---- pages/userbluetoothUnlock/userbluetoothUnlock.wxml | 24 +++-- utils/ICINPakage/ICINLocker.js | 1 + 3 files changed, 116 insertions(+), 25 deletions(-) diff --git a/pages/userbluetoothUnlock/userbluetoothUnlock.js b/pages/userbluetoothUnlock/userbluetoothUnlock.js index 3cc1822..cadcf9b 100644 --- a/pages/userbluetoothUnlock/userbluetoothUnlock.js +++ b/pages/userbluetoothUnlock/userbluetoothUnlock.js @@ -43,6 +43,7 @@ Page({ * 页面的初始数据 */ data: { + isUnloked: false, toSearch: true, isSearch: false, event: '', @@ -132,7 +133,7 @@ Page({ basecode = superAdminId console.log(basecode, "basecode"); } - if(deviceinfo.manufactureId==201||deviceinfo.manufactureId == 221){ + if(deviceinfo.manufactureId == 201||deviceinfo.manufactureId == 221){ var data3 = { code: "zg/bleRegisterInfo", signature:wx.getStorageSync('signature'), @@ -142,11 +143,13 @@ Page({ } } WXAPI.sendCommandOne(data3).then(res1 => { + console.log(res1); if (res1.success) { wx.setStorageSync('cgInfo', res1.data) this.setData({ cgInfo: res1.data }) + console.log(this.data.cgInfo); } else { } @@ -1032,6 +1035,11 @@ Page({ }) }) }, + changeLockUnlockState: function () { + var that = this + taskId = 101 + that.initBluetooth() + }, // 蓝牙初始化 btntest1(e) { var event = e.currentTarget.dataset.i @@ -1042,7 +1050,7 @@ Page({ remotePasswordStatus:false }) if (deviceinfo.manufactureId == 201||deviceinfo.manufactureId == 221) { - if (this.data.isSearch) { + if (app.globalData.zgBlueStatus) { if (event == 0) { this.openTheDoor() } else if (event == 1) { @@ -1059,7 +1067,10 @@ Page({ }) }else if (event == 12) { this.goPasswordList() + }else if(event == 17){ + this.synchronizationTime() } + wx.hideLoading() } else { that.goBlue() } @@ -1104,6 +1115,10 @@ Page({ this.goPasswordList() }else if(event == '1'){ this.addPincode() + }else if(event == 71){ + this.changeLockUnlockState() + }else if(event == 117){ + this.syncClock() } } else { this.searchDevicesMethods() @@ -1185,6 +1200,10 @@ Page({ that.configurewifj() }else if(that.data.event == '12'){ that.goPasswordList() + }else if(that.data.event == '71'){ + that.changeLockUnlockState() + }else if(that.data.event == '117'){ + that.syncClock() } wx.hideLoading({ success: (res) => {}, @@ -1371,6 +1390,15 @@ Page({ } } }, + onChangeLockUnlockState: function () { + var that = this + wx.showLoading({ + title: that.data.isUnloked ? '退出常开模式' : '进入常开模式', + }) + var bytes = plugin.setLockUnlockState(lockDevice.name, !that.data.isUnloked) + console.debug('bytes', bytes) + that.sendBytes(bytes) + }, onConfigurewifi() { var that = this var bytes = plugin.configureWifi(lockDevice.name, lockMac, that.data.wifiName, that.data.wifiPwd) @@ -2126,6 +2154,50 @@ Page({ }, }) }, + synchronizationTime() { + var time = parseInt(new Date().getTime() / 1000) + ICINLocker.getSignKey(this.data.cgInfo.lockerId, this.data.cgInfo.superId, this.data.cgInfo.superId, + (callback) => { + var signKey = callback.signKey + ICINLocker.getCommonKey(this.data.cgInfo.lockerId, this.data.cgInfo.superId, this.data.cgInfo.superId, signKey, (callback1) => { + var _commonKey = callback1.commonKey + ICINLocker.updateTime(this.data.cgInfo.lockerId, this.data.cgInfo.superId, time, '', _commonKey, callback2 => { + if (callback2.status == '00') { + wx.showToast({ + title: '同步时间成功', + duration: 2000, + icon: 'none' + }) + this.setData({ + showIP: false + }) + } else { + wx.showToast({ + title: '同步时间失败,错误码:' + callback2.status, + duration: 2000, + icon: 'none' + }) + } + }); + + }) + }) + }, + syncClock: function() { + var that = this + taskId = 42 + that.initBluetooth() + }, + onSyncClock: function() { + var that = this + wx.showLoading({ + title: '同步时钟中', + }) + console.log(lockDevice.name, basecode, util1.getLocalTime(8), '0000') + var bytes = plugin.syncClock(lockDevice.name, basecode, util1.getLocalTime(8)) + console.debug('bytes', bytes) + that.sendBytes(bytes) + }, LwjonOpenLock: function () { var that = this wx.showLoading({ @@ -2179,23 +2251,27 @@ Page({ icon: "none", duration: 2000 }) - if (this.data.event == 0) { - this.openTheDoor() - }else if(this.data.event == 1){ - this.addPassword() - } else if (this.data.event == 3) { - this.addFingerPrints() - } else if (this.data.event == 6) { - this.setData({ - show: true - }) - }else if(this.data.event == 11){ - this.setData({ - showOne: true - }) - }else if (event == 12) { - this.goPasswordList() - } + setTimeout(() => { + if (this.data.event == 0) { + this.openTheDoor() + }else if(this.data.event == 1){ + this.addPassword() + } else if (this.data.event == 3) { + this.addFingerPrints() + } else if (this.data.event == 6) { + this.setData({ + show: true + }) + }else if(this.data.event == 11){ + this.setData({ + showOne: true + }) + }else if (this.data.event == 12) { + this.goPasswordList() + }else if(this.data.event == 17){ + this.synchronizationTime() + } + },500) } else { wx.hideLoading() var msg = '' @@ -2235,6 +2311,8 @@ Page({ wx.hideLoading() } } + }else{ + wx.hideLoading() } }) }, diff --git a/pages/userbluetoothUnlock/userbluetoothUnlock.wxml b/pages/userbluetoothUnlock/userbluetoothUnlock.wxml index b5eac80..9c8d84b 100644 --- a/pages/userbluetoothUnlock/userbluetoothUnlock.wxml +++ b/pages/userbluetoothUnlock/userbluetoothUnlock.wxml @@ -47,18 +47,18 @@ 蓝牙开锁 - + + +