diff --git a/pages/Bluetooth/Bluetooth.js b/pages/Bluetooth/Bluetooth.js
index cae9792..bd24a1a 100644
--- a/pages/Bluetooth/Bluetooth.js
+++ b/pages/Bluetooth/Bluetooth.js
@@ -3166,6 +3166,16 @@ Page({
that.setData({
lock
})
+ let data1 = {
+ code: "lwj/resetDevice",
+ data: {
+ lockerId: that.data.deviceInfo.deviceNum,
+ type: 1
+ }
+ }
+ WXAPI.sendCommand(data1).then(res22 => {
+ console.log("3177",res22);
+ })
}
})
wx.showToast({
diff --git a/pages/userbluetoothUnlock/userbluetoothUnlock.js b/pages/userbluetoothUnlock/userbluetoothUnlock.js
index 423dbfb..7858f4d 100644
--- a/pages/userbluetoothUnlock/userbluetoothUnlock.js
+++ b/pages/userbluetoothUnlock/userbluetoothUnlock.js
@@ -3,6 +3,9 @@ const WXAPI = require('../../utils/request')
import ICINLocker from "../../utils/ICINPakage/ICINLocker"
var methods = require('../../utils/methods');
var util = require('../../utils/util');
+const config = require('../../config')
+const plugin = requirePlugin('myPlugin')
+const util1 = require('../../utils/util1.js')
import {
BLE
} from "../../utils/btls/ble";
@@ -13,6 +16,17 @@ const emitter = app.globalData.emitter
import moment from "../../utils/moment"
const ADD_NFC_MODE=10
var basecode = ''
+var isConnected = false
+var connectedDeviceId = ''
+var lockDevice = {
+ name: ''
+}
+var taskId = 0
+var lockModel = ''
+var lockMac = ''
+var isSearch = false
+var isLockLogin = false
+var isInitReady = false
// ArrayBuffer转16进度字符串示例
function ab2hex(buffer) {
var hexArr = Array.prototype.map.call(
@@ -29,6 +43,12 @@ Page({
* 页面的初始数据
*/
data: {
+ toSearch: true,
+ isSearch: false,
+ event: '',
+ wifiName: '', // wifi名称
+ wifiPwd: '', // wifi密码
+ show2: false, // 配网弹出层
passwordStatus:false,
addpassword:'',
showTwo:false,
@@ -97,21 +117,21 @@ Page({
app.globalData.zgBlueStatus = false
this.AddressPermissions()
let deviceinfo = wx.getStorageSync('deviceinfo')
- // if(deviceinfo){
- // let superAdmin = []
- // var superAdminIdlist = deviceinfo.bluetoothMac.slice(deviceinfo.bluetoothMac.length - 11, deviceinfo.bluetoothMac.length).split(":").join("")
- // for (let i = 0; i < superAdminIdlist.length; i++) {
- // if (superAdminIdlist[i] >= 0 && superAdminIdlist[i] <= 9) {
- // superAdmin.push(superAdminIdlist[i])
- // } else {
- // let adminid = superAdminIdlist.charCodeAt(i)
- // superAdmin.push(adminid)
- // }
- // }
- // let superAdminId = superAdmin.join('').slice(superAdmin.length - 8, superAdmin.length)
- // basecode = superAdminId
- // console.log(basecode, "basecode");
- // }
+ if(deviceinfo.bluetoothMac){
+ let superAdmin = []
+ var superAdminIdlist = deviceinfo.bluetoothMac.slice(deviceinfo.bluetoothMac.length - 11, deviceinfo.bluetoothMac.length).split(":").join("")
+ for (let i = 0; i < superAdminIdlist.length; i++) {
+ if (superAdminIdlist[i] >= 0 && superAdminIdlist[i] <= 9) {
+ superAdmin.push(superAdminIdlist[i])
+ } else {
+ let adminid = superAdminIdlist.charCodeAt(i)
+ superAdmin.push(adminid)
+ }
+ }
+ let superAdminId = superAdmin.join('').slice(superAdmin.length - 8, superAdmin.length)
+ basecode = superAdminId
+ console.log(basecode, "basecode");
+ }
if(deviceinfo.manufactureId==201||deviceinfo.manufactureId == 221){
var data3 = {
code: "zg/bleRegisterInfo",
@@ -192,6 +212,51 @@ Page({
remotePasswordStatus:true
})
},
+ // 配网
+ changeshow2() {
+ this.setData({
+ show2: true
+ })
+ },
+ onClose2() {
+ this.setData({
+ show2: false
+ })
+ },
+ onChangewifi(e) {
+ this.setData({
+ wifiName: e.detail
+ })
+ },
+ onChangewifi1(e) {
+ this.setData({
+ wifiPwd: e.detail
+ })
+ },
+ configurationWifi() {
+ if(this.data.wifiName == '' || this.data.wifiPwd == '') {
+ return wx.showToast({
+ title: 'wifi名称和密码不能为空',
+ duration: 2000,
+ icon: "none"
+ })
+ }
+ let event = {
+ currentTarget: {
+ dataset: {
+ i: '3'
+ }
+ }
+ }
+ this.setData({
+ event: event.currentTarget.dataset.i
+ })
+ if(this.data.isSearch){
+ this.configurewifj()
+ }else{
+ this.btntest1(event)
+ }
+ },
// 前往密码列表
goPasswordList(){
wx.navigateTo({
@@ -1028,8 +1093,1052 @@ Page({
} else {
this.startconnect()
}
+ }else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) {
+ console.log("1202", this.data.isSearch, event);
+ if (this.data.isSearch) {
+ if (event == '0') {
+ this.LwjopenLock()
+ } if(event == '3') {
+ this.configurewifj()
+ }
+ } else {
+ this.searchDevicesMethods()
+ }
+ }
+ },
+ configurewifj() {
+ var that = this
+ taskId = 121
+ that.initBluetooth()
+ },
+ searchDevicesMethods() {
+ var that = this;
+ wx.showLoading({
+ title: '正在搜索',
+ // mask: true
+ })
+ this.setData({
+ searchClick: false
+ })
+ wx.openBluetoothAdapter({
+ success: function (res) {
+ wx.startBluetoothDevicesDiscovery({
+ success: function (res) {
+ wx.getBluetoothDevices({
+ success: function (res) {
+ console.log("1128",res)
+ res.devices.map(it => {
+ var status = it.name.indexOf('WSL')
+ if (status != -1) {
+ if (it.RSSI != 127) {
+ if (it.advertisData != null) {
+ it.adData = util1.ab2hex(it.advertisData)
+ if (it.adData.length > 10) {
+ var macStr = it.adData.substring(4, 16).toUpperCase()
+ //console.log('macStr', macStr)
+ 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)
+ if (it.adData.substring(1, 2) == '1') {
+ it.isLightOn = true
+ it.textColor = 'green'
+ } else {
+ it.isLightOn = false
+ it.textColor = 'black'
+ }
+ if (it.adData.substring(3, 4) == '1') {
+ it.textColor = 'pink'
+ it.isBind = true
+ } else {
+ it.isBind = false
+ }
+ }
+ } else {
+ it.textColor = 'black'
+ }
+ lockModel = util1.getLockModel(it.name)
+ it.lockType = util1.getLockType(lockModel)
+ if (it.name == that.data.deviceinfo.deviceNum) {
+ app.addDeviceWithDevName(it.name, it)
+ connectedDeviceId = it.deviceId
+ lockDevice = it
+ console.log(lockDevice, it, 'lockDevice,it')
+ app.globalData.isSearch = true
+ that.setData({
+ isSearch: true,
+ // lockDevice:it
+ })
+ // let iotLwj = new LwJ(it,isConnected,connectedDeviceId,isInitReady,it.lockModel)
+ // iotLwj.connectTo()
+ if (that.data.event == '0') {
+ // iotLwj.openLock(41)
+ that.LwjopenLock()
+ } else if (that.data.event == '3') {
+ console.log("1298wifi");
+ that.configurewifj()
+ }
+ wx.hideLoading({
+ success: (res) => {},
+ })
+ }
+ }
+ }
+ })
+ if (!that.data.isSearch && that.data.toSearch) {
+ that.searchDevicesMethods()
+ }
+ }
+ })
+ },
+ fail: function (res) {
+ wx.hideLoading({
+ success: (res) => {
+ wx.showToast({
+ title: res.errMsg,
+ duration: 2000,
+ icon: 'none'
+ })
+ },
+ })
+ }
+ })
+ },
+ fail: function (res) {
+ console.log('请打开蓝牙和定位功能')
+ wx.hideLoading({
+ success: (res) => {
+ wx.showToast({
+ title: '请打开蓝牙和定位功能',
+ duration: 2000,
+ icon: 'none'
+ })
+ },
+ })
+ }
+ })
+ },
+ LwjopenLock: function () {
+ var that = this
+ taskId = 41
+ that.initBluetooth()
+ },
+ initBluetooth: function () {
+ var that = this
+ wx.getConnectedBluetoothDevices({
+ services: [config.uuid.serviceUuid],
+ success: function (res) {
+ res.devices.map(function (it) {
+ if (it.deviceId == connectedDeviceId || it.name == lockDevice.name) {
+ isConnected = true
+ }
+ })
+ that.setData({
+ isConnected: isConnected
+ })
+ console.log('isConnected', isConnected)
+ if (isConnected) {
+ if (isInitReady) {
+ console.log(isInitReady, 'isInitReady', taskId)
+ setTimeout(() => {
+ that.doWork()
+ }, 500)
+ } else {
+ that.setupConnection()
+ }
+ } else {
+ that.connectTo()
+ }
+ },
+ })
+ },
+ doWork: function () {
+ console.log(taskId);
+ var that = this
+ switch (taskId) {
+ case 11: {
+ that.onBindLock()
+ break
+ }
+ case 12: {
+ that.onUnbindLock()
+ break
+ }
+ case 21: {
+ that.onQueryBindState()
+ break
+ }
+ case 22: {
+ that.onQueryBattery()
+ break
+ }
+
+ case 31: {
+ that.onQueryNbImei()
+ break
+ }
+ case 32: {
+ that.onLogin()
+ break
+ }
+ case 41: {
+ that.LwjonOpenLock()
+ break
+ }
+ case 42: {
+ that.onSyncClock()
+ break
+ }
+ case 51: {
+ that.onAddPincode()
+ break
+ }
+ case 52: {
+ that.onDelPincode()
+ break
+ }
+ case 61: {
+ if (lockModel > 70) {
+ that.onAddRfCard()
+ } else {
+ wx.showModal({
+ title: '提示',
+ content: '请刷卡!',
+ showCancel: false
+ })
+
+ }
+ break
+ }
+ case 62: {
+ that.onDelRfCard()
+ break
+ }
+ case 71: {
+ that.onAddFingerprint()
+ break
+ }
+ case 72: {
+ that.onDelFingerprint()
+ break
+ }
+ case 81: {
+ that.onChangeAdminPincode()
+ break
+ }
+
+ case 91: {
+ that.onQueryLockSlotState()
+ break
+ }
+
+ case 92: {
+ that.onQueryLockUnlockState()
+ break
+ }
+
+ case 101: {
+ that.onChangeLockUnlockState()
+ break
+ }
+
+ case 102: {
+ that.onChangeLockMutedState()
+ break
+ }
+ case 111: {
+ this.onChangeLockNbState()
+ }
+ case 121: {
+ this.onConfigurewifi()
+ break
+ }
+ case 9010: {
+ this.gotoperson()
+ break
+ }
+
+ default: {
+
+ }
}
},
+ onConfigurewifi() {
+ var that = this
+ var bytes = plugin.configureWifi(lockDevice.name, lockMac, that.data.wifiName, that.data.wifiPwd)
+ that.sendBytes(bytes)
+ this.setData({
+ show2: false
+ })
+ },
+ connectTo: function () {
+ var that = this
+ wx.showLoading({
+ title: '连接中',
+ })
+ wx.createBLEConnection({
+ deviceId: lockDevice.deviceId,
+ timeout: config.ble.connectTimeOut,
+ success: function (res) {
+ console.debug('connectTo', res)
+ isConnected = true
+ wx.hideLoading()
+ setTimeout(function () {
+ that.setupConnection()
+ }, 500)
+ },
+ fail: function (e) {
+ console.debug('connectTo', e)
+ wx.hideLoading()
+ switch (e.errCode) {
+ case 10003: {
+ wx.showModal({
+ title: '连接失败',
+ content: '是否重新连接?',
+ success: function (res) {
+ if (res.confirm) {
+ that.connectTo()
+ }
+ }
+ })
+ break
+ }
+ case 10012: {
+ wx.showModal({
+ title: '连接失败',
+ content: '蓝牙连接超时',
+ showCancel: false
+ })
+ break
+ }
+ case 10002: {
+ wx.showModal({
+ title: '连接失败',
+ content: '没有找到指定设备',
+ showCancel: false
+ })
+ break
+ }
+ }
+ }
+ })
+ },
+ setupConnection: function () {
+ var that = this
+ wx.showLoading({
+ title: '初始化连接中',
+ })
+ wx.getBLEDeviceServices({
+ deviceId: lockDevice.deviceId,
+ success: function (res) {
+ console.log('Services', res)
+ wx.getBLEDeviceCharacteristics({
+ deviceId: lockDevice.deviceId,
+ serviceId: config.uuid.serviceUuid.toUpperCase(),
+ success: function (res) {
+ console.log('Characteristics', res)
+ wx.showLoading({
+ title: '连接成功',
+ })
+ wx.onBLECharacteristicValueChange(function (res) {
+ var bytes = new Uint8Array(res.value)
+ console.log('bytes', bytes)
+ console.log(lockDevice.name, 'lockDevice.name1')
+ var data = plugin.parseBytes(lockDevice.name, basecode, bytes)
+ console.log('data', data)
+ switch (data.cmd) {
+ case 'reportLockBattery': {
+ if (data.data.battery < 10) {
+ wx.showModal({
+ title: '电量报警',
+ content: `门锁当前电量${data.data.battery}%!\n电量严重不足,请立即更换电池!`,
+ showCancel: false
+ })
+ } else if (data.data.battery < 30) {
+ wx.showModal({
+ title: '电量预警',
+ content: `门锁当前电量${data.data.battery}%!\n请及时更换电池!`,
+ showCancel: false
+ })
+ }
+ break
+ }
+ case 'reportRfCardResult': {
+ if (taskId == 61) {
+ wx.showModal({
+ title: '检测到新卡',
+ content: `是否添加此房卡,卡号:${data.data.cardId}?`,
+ success: function (res) {
+ if (res.confirm) {
+ rfCardId = data.data.cardId
+ that.onAddRfCard()
+ }
+ }
+ })
+ } else {
+ if (lockModel > 70) {
+ if (data.data.isValid) {
+ wx.showModal({
+ title: '提示',
+ content: `房卡开锁成功,序号:${data.data.index}!`,
+ showCancel: false
+ })
+ } else {
+ wx.showModal({
+ title: '提示',
+ content: `多次刷房卡开锁失败!`,
+ showCancel: false
+ })
+ }
+ } else {
+ if (data.data.isValid) {
+ wx.showModal({
+ title: '提示',
+ content: `房卡开锁成功,卡号:${data.data.cardId}!`,
+ showCancel: false
+ })
+ } else {
+ wx.showModal({
+ title: '提示',
+ content: `房卡未授权,卡号:${data.data.cardId}!`,
+ showCancel: false
+ })
+ }
+ }
+ }
+ break
+ }
+ case 'reportPincodeResult': {
+ if (lockModel > 70) {
+ if (data.data.isValid) {
+ wx.showModal({
+ title: '提示',
+ content: `密码开锁成功,序号:${data.data.index}!`,
+ showCancel: false
+ })
+ } else {
+ wx.showModal({
+ title: '提示',
+ content: `多次密码开锁失败!`,
+ showCancel: false
+ })
+ }
+ } else {
+ if (data.data.isValid) {
+ wx.showModal({
+ title: '提示',
+ content: `密码:${data.data.pincode}开锁成功!`,
+ showCancel: false
+ })
+ } else {
+ wx.showModal({
+ title: '提示',
+ content: `密码:${data.data.pincode}未授权!`,
+ showCancel: false
+ })
+ }
+ }
+ break
+ }
+ case 'reportFingerprintResult': {
+ if (data.data.isValid) {
+ wx.showModal({
+ title: '提示',
+ content: `指纹开锁成功,序号:${data.data.index}!`,
+ showCancel: false
+ })
+ } else {
+ wx.showModal({
+ title: '提示',
+ content: `多次指纹开锁失败!`,
+ showCancel: false
+ })
+ }
+ break
+ }
+ case 'queryLockState': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '查询失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ that.setData({
+ lock: {
+ mac: data.data.mac,
+ lockType: util1.getLockType(lockModel),
+ },
+ isBindLock: data.data.isBind
+ })
+ lockMac = data.data.mac
+
+ if (taskId > 0) {
+ if (data.data.isBind) {
+ wx.showModal({
+ title: data.data.mac,
+ content: '此设备已经硬件绑定!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ } else {
+ wx.showModal({
+ title: data.data.mac,
+ content: '此设备硬件未绑定!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ }
+ }
+ taskId = 0
+ break
+ }
+ case 'queryLockBattery': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '查询失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ wx.showModal({
+ title: '提示',
+ content: `此门锁电量为${data.data.battery}%`,
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ case 'queryNbImei': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '查询失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ wx.showModal({
+ title: '提示',
+ content: `此NB设备IMEI为${data.data.imei}`,
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ case 'setNbFun': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '设置Nb功能失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ wx.showModal({
+ title: '提示',
+ content: that.data.isNbEnable ? 'NB功能已禁用' : 'NB功能已打开',
+ showCancel: false,
+ })
+ that.setData({
+ isNbEnable: !that.data.isNbEnable
+ })
+ break
+ }
+ case 'sendBindLock': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '绑定失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ that.setData({
+ isBindLock: data.data.isBind
+ })
+ if (data.data.isBind) {
+ wx.showToast({
+ title: '绑定成功!',
+ })
+ } else {
+ wx.showToast({
+ title: '绑定失败!',
+ })
+ }
+ break
+ }
+
+ case 'sendUnbindLock': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '解绑失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ that.setData({
+ isBindLock: data.data.isBind
+ })
+ if (data.data.isBind) {
+ wx.showToast({
+ title: '解绑失败!',
+ })
+ } else {
+ wx.showToast({
+ title: '解绑成功!',
+ })
+ }
+ break
+ }
+ case 'login1':
+ case 'sendOpenLockP1': {
+ if (data.code != 200) {
+ wx.hideLoading()
+ if (taskId == 41) {
+ wx.showModal({
+ title: '提示',
+ content: that.data.isJack ? '上电失败!' : '解锁失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ } else if (taskId == 32) {
+ wx.showModal({
+ title: '提示',
+ content: '登录失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ }
+
+ break
+ }
+ if (taskId == 41) {
+ console.log(lockDevice.name, 'lockDevice.name2')
+ var bytes = plugin.sendOpenLockP2(lockDevice.name, basecode, data.data.randomN)
+ console.debug('bytes', bytes)
+ that.sendBytes(bytes)
+ } else if (taskId == 32) {
+ console.log(lockDevice.name, 'lockDevice.name3')
+ var bytes = plugin.login2(lockDevice.name, basecode, data.data.randomN)
+ console.debug('bytes', bytes)
+ that.sendBytes(bytes)
+ }
+ break;
+ }
+ case 'login':
+ case 'sendOpenLockP2': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ if (taskId == 41) {
+ wx.showModal({
+ title: '提示',
+ content: that.data.isJack ? '上电失败!' : '解锁失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ } else if (taskId == 32) {
+ wx.showModal({
+ title: '提示',
+ content: '登录失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ }
+ break
+ }
+
+ isLockLogin = true
+ if (taskId == 41) {
+ var data = {
+ code: "ble/bleUnlockRecord",
+ data: {
+ deviceNum: that.data.deviceinfo.deviceNum,
+ roomId: that.data.deviceinfo.roomId,
+ roomName: that.data.deviceinfo.roomName,
+ cardName: that.data.userInfo.username,
+ productId: that.data.deviceinfo.manufactureId,
+ userId: '29283991'
+ }
+ }
+ WXAPI.sendCommand(data).then(res => {
+ console.log(res)
+ })
+ wx.showToast({
+ title: that.data.isJack ? '上电成功!' : '解锁成功!',
+ })
+ } else if (taskId == 32) {
+ wx.showToast({
+ title: '登录成功!',
+ })
+ }
+ taskId = 0
+ break;
+ }
+
+ case 'syncClock': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '同步时间失败!' + data.data.msg,
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ wx.showModal({
+ title: '提示',
+ content: '时间更新成功!',
+ showCancel: false
+ })
+ break;
+ }
+ case 'addPincode': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '添加密码失败!' + data.data.msg,
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ that.setData({
+ isPincodeAdd: true
+ })
+ wx.showModal({
+ title: '提示',
+ content: `添加密码${pincode}成功!`,
+ showCancel: false
+ })
+ break
+ }
+
+ case 'delPincode': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '删除密码失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ wx.showModal({
+ title: '提示',
+ content: `删除密码${pincode}成功!`,
+ showCancel: false,
+ })
+ that.setData({
+ isPincodeAdd: false
+ })
+ pincode = -1
+ pincodeIndex = -1
+ break
+ }
+
+ case 'addRfCard': {
+ wx.hideLoading()
+ if (data.code == 100) {
+ wx.showLoading({
+ title: data.data.msg,
+ })
+ break
+ } else if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '添加房卡失败!' + data.data.msg,
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ that.setData({
+ isRfCardAdd: true
+ })
+ if (lockModel > 70) {
+ wx.showModal({
+ title: '提示',
+ content: `添加房卡成功,序号${rfCardIndex}!`,
+ showCancel: false
+ })
+ } else {
+ wx.showModal({
+ title: '提示',
+ content: `添加房卡成功,卡号${rfCardId}!`,
+ showCancel: false
+ })
+ }
+ break
+ }
+
+ case 'delRfCard': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '删除房卡失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ that.setData({
+ isRfCardAdd: false
+ })
+ if (lockModel > 70) {
+ wx.showModal({
+ title: '提示',
+ content: `删除房卡成功,序号${rfCardIndex}!`,
+ showCancel: false,
+ })
+ } else {
+ wx.showModal({
+ title: '提示',
+ content: `删除房卡成功,卡号${rfCardId}!`,
+ showCancel: false,
+ })
+ }
+ rfCardId = -1
+ rfCardIndex = -1
+ break
+ }
+
+ case 'addFingerprint': {
+ wx.hideLoading()
+ if (data.code == 100) {
+ wx.showLoading({
+ title: data.data.msg,
+ })
+ break
+ } else if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '添加指纹失败!' + data.data.msg,
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ that.setData({
+ isFingerprintAdd: true
+ })
+ wx.showModal({
+ title: '提示',
+ content: `添加指纹成功,序号${fingerprintIndex}!`,
+ showCancel: false
+ })
+ break
+ }
+
+ case 'delFingerprint': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '删除指纹失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ wx.showModal({
+ title: '提示',
+ content: `删除指纹成功,序号${fingerprintIndex}!`,
+ showCancel: false,
+ })
+ that.setData({
+ isFingerprintAdd: false
+ })
+ fingerprintIndex = -1
+ break
+ }
+
+ case 'changeAdminPincode': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '修改管理密码失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ wx.showToast({
+ title: '修改管理密码成功!',
+ })
+ }
+
+ case 'queryLockSlotState': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '查询失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ wx.showModal({
+ title: '提示',
+ content: data.data.state == 0 ? '此门锁方舌关闭' : '此门锁方舌打开',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+
+ case 'queryLockUnlockState': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '查询失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ wx.showModal({
+ title: '提示',
+ content: data.data.state == 0 ? '此门锁已关闭' : '此门锁已打开',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+
+ case 'setLockUnlockState': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '设置常开指令失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ wx.showModal({
+ title: '提示',
+ content: data.data.state == 0 ? '常开模式已退出' : '常开模式已开启',
+ showCancel: false,
+ })
+ that.setData({
+ isUnloked: data.data.state == 1
+ })
+ break
+ }
+
+ case 'setLockMuteState': {
+ wx.hideLoading()
+ if (data.code != 200) {
+ wx.showModal({
+ title: '提示',
+ content: '设置静音指令失败!',
+ showCancel: false,
+ success: function (res) {}
+ })
+ break
+ }
+ taskId = 0
+ wx.showModal({
+ title: '提示',
+ content: data.data.state == 1 ? '静音模式已退出' : '静音模式已开启',
+ showCancel: false,
+ })
+ that.setData({
+ isMuted: data.data.state == 0
+ })
+ break
+ }
+ }
+ })
+
+ wx.notifyBLECharacteristicValueChange({
+ deviceId: lockDevice.deviceId,
+ serviceId: config.uuid.serviceUuid.toUpperCase(),
+ characteristicId: config.uuid.notifyUuid.toUpperCase(),
+ state: true,
+ success: function (res) {
+ console.log('setupNotify', res)
+ isInitReady = true
+ setTimeout(function () {
+ wx.hideLoading()
+ // that.onQueryBindState()
+ // if (taskId == '41' && that.data.event == '0') {
+ // that.doWork()
+ // }else if(taskId == '121' && that.data.event == '3') {
+ // that.doWork()
+ // }else if(taskId == '9010' && that.data.event == '8') {
+ // that.doWork()
+ // }
+ that.doWork()
+ }, 500)
+ },
+ })
+ },
+ })
+ },
+ })
+ },
+ LwjonOpenLock: function () {
+ var that = this
+ wx.showLoading({
+ title: that.data.isJack ? '上电中' : '解锁中',
+ })
+ console.log(lockDevice.name, 'lockDevice.name0开锁中')
+ var bytes = plugin.sendOpenLockP1(lockDevice.name, basecode)
+ console.debug('bytes', bytes)
+ that.sendBytes(bytes)
+ },
+ sendBytes(bytes) {
+ console.log(lockDevice, config, bytes, 'sendBytes---')
+ setTimeout(function () {
+ wx.writeBLECharacteristicValue({
+ deviceId: lockDevice.deviceId,
+ serviceId: config.uuid.serviceUuid.toUpperCase(),
+ characteristicId: config.uuid.writeUuid.toUpperCase(),
+ value: bytes,
+ success: function (res) {
+
+ },
+ })
+ }, 50)
+ },
goBlue() {
var that = this
wx.showLoading({
@@ -2031,11 +3140,15 @@ Page({
this.onReady()
}
this.setData({
- bluestatus: false
+ bluestatus: false,
+ toSearch: false
})
this.closeblue()
},
onHide() {
+ this.setData({
+ toSearch: false
+ })
this.closeblue()
},
/**
diff --git a/pages/userbluetoothUnlock/userbluetoothUnlock.wxml b/pages/userbluetoothUnlock/userbluetoothUnlock.wxml
index 86a02e9..c876b00 100644
--- a/pages/userbluetoothUnlock/userbluetoothUnlock.wxml
+++ b/pages/userbluetoothUnlock/userbluetoothUnlock.wxml
@@ -47,7 +47,7 @@
蓝牙开锁
-
+
添加蓝牙密码
@@ -87,6 +87,10 @@
临时密码
+
+
+ 配网
+
设置声音
@@ -134,4 +138,13 @@
-
\ No newline at end of file
+
+
+
+
+
+
+
+ 确定
+
+
\ No newline at end of file