Browse Source

1101,对接了人脸录入接口

master
xiaoheiiskinder 1 year ago
parent
commit
bec07894e9
5 changed files with 79 additions and 118 deletions
  1. +32
    -47
      pages/roomDetail/roomDetail.js
  2. +2
    -2
      pages/roomDetail/roomDetail.wxml
  3. +41
    -67
      pagesA/facepeople/facepeople.js
  4. +1
    -1
      pagesA/facepeople/facepeople.wxml
  5. +3
    -1
      pagesA/selectFace/selectFace.js

+ 32
- 47
pages/roomDetail/roomDetail.js View File

@ -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)
},
})


+ 2
- 2
pages/roomDetail/roomDetail.wxml View File

@ -54,11 +54,11 @@
<view class="iconfont icon-renyuanguanli text-green"></view>
<view class="text-grey text-sm">人员管理</view>
</view>
<view class="actionli" bindtap="goImageManagement" data-i="11" wx:if="{{(deviceinfo.manufactureId ==1201 || deviceinfo.manufactureId == 1241) && authority}}">
<view class="actionli" bindtap="gotofaceadd" wx:if="{{(deviceinfo.manufactureId ==1201 || deviceinfo.manufactureId == 1241) && authority}}">
<view class="iconfont icon-quanxianguanli text-green"></view>
<view class="text-grey text-sm">图像管理</view>
</view>
<view class="actionli" bindtap="changeshow2" data-i="3" wx:if="{{(deviceinfo.manufactureId ==1201 || deviceinfo.manufactureId == 1241) && authority}}">
<view class="actionli" bindtap="changeshow2" wx:if="{{(deviceinfo.manufactureId ==1201 || deviceinfo.manufactureId == 1241) && authority}}">
<view class="iconfont icon-shezhi text-green"></view>
<view class="text-grey text-sm">配网</view>
</view>


+ 41
- 67
pagesA/facepeople/facepeople.js View File

@ -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({


+ 1
- 1
pagesA/facepeople/facepeople.wxml View File

@ -37,7 +37,7 @@
<!-- 影响弹出框 -->
<van-popup show="{{ show2 }}" bind:close="onClose" round>
<view class="addfaces">
<van-field value="{{ facename }}" placeholder="请输入图像名称" label="人脸" border="{{ true }}" bind:change="onChange2" maxlength="8" />
<!-- <van-field value="{{ facename }}" placeholder="请输入图像名称" label="人脸" border="{{ true }}" bind:change="onChange2" maxlength="8" /> -->
<picker mode="date" value="{{starttime}}" start="{{minDate}}" end="{{ minDate1 }}" bindchange="bindDateChange">
<van-field value="{{ starttime }}" placeholder="请选择开始时间" label="开始时间" border="{{ true }}" readonly />
</picker>


+ 3
- 1
pagesA/selectFace/selectFace.js View File

@ -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()


Loading…
Cancel
Save