diff --git a/pages/roomDetail/roomDetail.js b/pages/roomDetail/roomDetail.js index 37fcbbc..c82c508 100644 --- a/pages/roomDetail/roomDetail.js +++ b/pages/roomDetail/roomDetail.js @@ -290,19 +290,12 @@ Page({ } }, // 配网 - changeshow2(e) { - var event = e.currentTarget.dataset.i - var that = this; - this.setData({ - event - }) + changeshow2() { var deviceinfo = this.data.deviceinfo if (deviceinfo.manufactureId == '1241') { - if (event == '3') { - this.setData({ - show2: true - }) - } + this.setData({ + show2: true + }) }else{ wx.showToast({ title: '该类型锁不支持配网功能', @@ -312,6 +305,13 @@ Page({ } }, configurationWifi() { + if(this.data.wifiName == '' || this.data.wifiPwd == ''){ + return wx.showToast({ + title: 'WiFi名称和密码不能为空', + duration: 2000, + icon: 'none' + }) + } let event = { currentTarget: { dataset: { @@ -319,6 +319,10 @@ Page({ } } } + this.setData({ + event: event.currentTarget.dataset.i + }) + console.log(this.data.isSearch); if(!this.data.isSearch){ this.btntest1(event) }else{ @@ -333,16 +337,6 @@ Page({ show2: false }) }, - // 前往图像管理 - goImageManagement(e) { - if(this.data.isSearch){ - wx.navigateTo({ - url: '/pagesA/facepeople/facepeople', - }) - }else{ - this.btntest1(e) - } - }, genOfflinePincodeShowMethods() { // if(this.data.isSearch){ this.setData({ @@ -1168,7 +1162,7 @@ Page({ }) var event = e.currentTarget.dataset.i var that = this; - this.data.event = event + this.setData({ event }) var deviceinfo = this.data.deviceinfo if (deviceinfo.manufactureId == 201 || deviceinfo.manufactureId == 221) { if (app.globalData.zgBlueStatus) { @@ -1215,12 +1209,13 @@ Page({ this.startconnect() } } else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) { + console.log("1202", this.data.isSearch, event); if (this.data.isSearch) { if (event == '0') { // let iotLwj = new LwJ(this.data.lockDevice,isConnected,connectedDeviceId,isInitReady,this.data.lockDevice.lockModel) // iotLwj.openLock(41) this.LwjopenLock() - } else if (event == 6) { + } else if (event == '6') { this.setData({ show: true }) @@ -1228,8 +1223,6 @@ Page({ this.configurewifj() }else if(event == '8') { this.personnelmanagement() - }else if(event == '11') { - this.facemanagement() } } else { this.searchDevicesMethods() @@ -1312,11 +1305,11 @@ Page({ show: true }) } else if (that.data.event == '3') { + console.log("1298wifi"); that.configurewifj() }else if(that.data.event == '8') { + console.log("1301person"); that.personnelmanagement() - }else if(that.data.event == '11') { - that.facemanagement() } wx.hideLoading({ success: (res) => {}, @@ -1374,12 +1367,6 @@ Page({ taskId = 9010 that.initBluetooth() }, - // 图像管理 - facemanagement() { - var that = this - taskId = 9011 - that.initBluetooth() - }, LwjonOpenLock: function () { var that = this wx.showLoading({ @@ -1420,6 +1407,7 @@ Page({ }) }, doWork: function () { + console.log(taskId); var that = this switch (taskId) { case 11: { @@ -1517,15 +1505,13 @@ Page({ } case 121: { this.onConfigurewifi() + break } - // 人员管理 case 9010: { this.gotoperson() + break } - // 图像管理 - case 9011: { - this.gotofaceadd() - } + default: { } @@ -2262,15 +2248,14 @@ Page({ 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() - }else if(taskId == 9011 && that.data.event == '11') { - that.doWork() - } + // 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) }, }) diff --git a/pages/roomDetail/roomDetail.wxml b/pages/roomDetail/roomDetail.wxml index ad97937..2ce41e5 100644 --- a/pages/roomDetail/roomDetail.wxml +++ b/pages/roomDetail/roomDetail.wxml @@ -54,11 +54,11 @@ 人员管理 - + 图像管理 - + 配网 diff --git a/pagesA/facepeople/facepeople.js b/pagesA/facepeople/facepeople.js index b757925..b70862a 100644 --- a/pagesA/facepeople/facepeople.js +++ b/pagesA/facepeople/facepeople.js @@ -77,6 +77,7 @@ var fingerprintIndex = -1 var passwordLiAll = { id: '' } +var faceaddIndex = -1 var isLockLogin = false var serialNumber = '' Page({ @@ -97,6 +98,7 @@ Page({ datetimerange: [CurentTime(), CurentTime1()], chooseface: false, avatarPath: "", // 上传的图片数据 + facepic: "", // 上传的图片的base64格式 isSearch: app.globalData.isSearch, cgInfo: {}, deviceinfo: {}, @@ -245,80 +247,52 @@ Page({ var deviceinfo = this.data.deviceinfo var info = JSON.parse(this.data.personLi.info) if (deviceinfo.manufactureId == 1241) { - if (this.data.isSearch) { - var time1 = new Date(_this.data.datetimerange[0].replace(/-/g, '/')) - var time2 = new Date(_this.data.datetimerange[1].replace(/-/g, '/')) - var passwordStartTime = time1.getTime() / 1000 - var passwordEndTime = time2.getTime() / 1000 - var facepic = "" - var cardName = "", - pzname = "" - if(this.data.pzname) { - cardName = _this.data.personLi.name + '-蓝牙-' + _this.data.pzname, - pzname = '蓝牙-' + _this.data.pzname - }else{ - cardName = _this.data.personLi.name + '-蓝牙-人脸' + (_this.data.faceList.length + 1) - pzname = '蓝牙-人脸' + (_this.data.faceList.length + 1) - } - // 修改图片格式 - // wx.readFile({ - // filePath: _this.data.avatarPath, - // encoding: 'base64', - // success: function(res) { - // console.log(res); - // const base64Img = res.data - // facepic = base64Img - // }, - // fail: function(res) { - // console.log('读取文件失败', res); - // } - // }) - facepic = wx.getFileSystemManager().readFileSync(_this.data.avatarPath, "base64") - var dataface = { - code: "lwj/faceOperate", - data: { - action: 1, - endTime: passwordEndTime, - faceData: facepic, - lockerId: deviceinfo.deviceNum, - lockerUserId: info.userPassword, - startTime: passwordStartTime, - } + var time1 = new Date(_this.data.datetimerange[0].replace(/-/g, '/')) + var time2 = new Date(_this.data.datetimerange[1].replace(/-/g, '/')) + var passwordStartTime = time1.getTime() / 1000 + var passwordEndTime = time2.getTime() / 1000 + // let facepicture = wx.getFileSystemManager().readFileSync(_this.data.avatarPath, "base64") + // facepic = `data:image/jpg;base64, ${facepicture}` + var dataface = { + code: "lwj/faceOperate", + data: { + action: 1, + endTime: passwordEndTime, + faceData: _this.data.facepic, + lockerId: deviceinfo.deviceNum, + lockerUserId: info.userPassword, + startTime: passwordStartTime, } - console.log(facepic, dataface); - // WXAPI.sendCommand(dataface).then(res => { - // console.log(res); - // if(res.success){ - _this.onAddFace() - // } - // }) - } else { - this.searchDevicesMethods() } + console.log(_this.data.avatarPath, dataface); + WXAPI.sendCommand(dataface).then(res => { + console.log(res); + if (res.success) { + faceaddIndex = res.data.index + serialNumber = res.data.serialNumber + }else{ + wx.showToast({ + title: res.msg, + icon: 'none', + duration: 2000 + }) + } + }) } }, - onAddFace() { - var that = this - wx.showLoading({ - title: '添加人脸中', - }) - var startTime = new Date(Number(moment(that.data.starttime).format('x'))) - var endTime = new Date(Number(moment(that.data.endtime).format('x'))) - // var bytes = plugin.faceOperate() - }, sendBytes(bytes) { setTimeout(() => { - wx.writeBLECharacteristicValue({ - deviceId: lockDevice.deviceId, - serviceId: config.uuid.serviceUuid.toUpperCase(), - characteristicId: config.uuid.writeUuid.toUpperCase(), - value: bytes, - success: function (res) { - - }, - }) + wx.writeBLECharacteristicValue({ + deviceId: lockDevice.deviceId, + serviceId: config.uuid.serviceUuid.toUpperCase(), + characteristicId: config.uuid.writeUuid.toUpperCase(), + value: bytes, + success: function (res) { + + }, + }) }, 50) - }, + }, searchDevicesMethods() { var that = this; wx.showLoading({ diff --git a/pagesA/facepeople/facepeople.wxml b/pagesA/facepeople/facepeople.wxml index 9a4feee..aca0aab 100644 --- a/pagesA/facepeople/facepeople.wxml +++ b/pagesA/facepeople/facepeople.wxml @@ -37,7 +37,7 @@ - + diff --git a/pagesA/selectFace/selectFace.js b/pagesA/selectFace/selectFace.js index 92c98c0..e90aca4 100644 --- a/pagesA/selectFace/selectFace.js +++ b/pagesA/selectFace/selectFace.js @@ -254,9 +254,11 @@ takePhoto() { var pages = getCurrentPages(); if (pages.length > 1) { var prePage = pages[pages.length - 2]; + var facepicture = wx.getFileSystemManager().readFileSync(data.tempFilePath, "base64") prePage.setData({ avatarPath: data.tempFilePath, - chooseface: true + chooseface: true, + facepic: `${facepicture}` }) } wx.navigateBack()