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