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 @@
蓝牙开锁
-
+
+
+