diff --git a/pages/addperson/addperson.js b/pages/addperson/addperson.js index 497d66f..aa99606 100644 --- a/pages/addperson/addperson.js +++ b/pages/addperson/addperson.js @@ -18,7 +18,7 @@ import { BLE } from "../../utils/btls/ble"; const emitter = app.globalData.emitter -const ADD_NFC_MODE=10 +const ADD_NFC_MODE = 10 // ArrayBuffer转16进度字符串示例 function ab2hex(buffer) { var hexArr = Array.prototype.map.call( @@ -93,7 +93,9 @@ var rfCardId = -1 var rfCardIndex = -1 var fingerprintIndex = -1 -var passwordLiAll = {id:''} +var passwordLiAll = { + id: '' +} var isLockLogin = false var serialNumber = '' let letterRandom = [ @@ -160,10 +162,11 @@ let letterRandom = [ "Y", "Z", ]; -function randomMethods(){ - let str= '' + +function randomMethods() { + let str = '' for (let i = 0; i < 8; i++) { - str+= + str += letterRandom[Math.round(Math.random() * (letterRandom.length - 1))]; } return str @@ -183,11 +186,11 @@ Page({ isNbEnable: true, lockModel: 0, lock: {}, - isSearch:app.globalData.isSearch, + isSearch: app.globalData.isSearch, activeKey: 0, NfcList: [], - FpList:[], + FpList: [], passwordList: [], show: false, datetimerange: [CurentTime(), CurentTime1()], @@ -201,17 +204,32 @@ Page({ currentIndex: '', fingerprintId: '', backstatus: false, - radioDetil:'', - passwordStatus:true, - items: [ - {value: '0', name: '左手大拇指',checked:false}, - {value: '1', name: '左手食指',checked:false}, - {value: '2', name: '右手大拇指',checked:false}, - {value: '3', name: '右手食指',checked:false} + radioDetil: '', + passwordStatus: true, + items: [{ + value: '0', + name: '左手大拇指', + checked: false + }, + { + value: '1', + name: '左手食指', + checked: false + }, + { + value: '2', + name: '右手大拇指', + checked: false + }, + { + value: '3', + name: '右手食指', + checked: false + } ], - showLoading:false, - requestSatatus:true, - password:'' + showLoading: false, + requestSatatus: true, + password: '' }, /** @@ -224,9 +242,11 @@ Page({ let minDate = wx.getStorageSync('minDate') let minDate1 = wx.getStorageSync('minDate1') this.setData({ - cgInfo: cgInfo,minDate,minDate1, - starttime:minDate, - endtime:minDate1, + cgInfo: cgInfo, + minDate, + minDate1, + starttime: minDate, + endtime: minDate1, deviceinfo: deviceinfo, personLi: personLi, isSearch: false @@ -235,38 +255,53 @@ Page({ this.getNfc() this.getCarId() this.getFp() - if(deviceinfo.manufactureId == 1201){ + if (deviceinfo.manufactureId == 1201) { this.searchDevicesMethods() - }else if(deviceinfo.manufactureId == 101){ + } else if (deviceinfo.manufactureId == 101) { app.watch(this.getcartcount, 'backdata') app.watch(this.fingerprintFun, 'fingerprintId') } }, // 指纹选择 - radioChange(e){ - var personLi=wx.getStorageSync('personLi') - var pzname='' - if(e.detail.value==0){ - pzname="左手大拇指" - }else if(e.detail.value==1){ - pzname="左手食指" - }else if(e.detail.value==2){ - pzname="右手大拇指" - }else if(e.detail.value==3){ - pzname="右手食指" + radioChange(e) { + var personLi = wx.getStorageSync('personLi') + var pzname = '' + if (e.detail.value == 0) { + pzname = "左手大拇指" + } else if (e.detail.value == 1) { + pzname = "左手食指" + } else if (e.detail.value == 2) { + pzname = "右手大拇指" + } else if (e.detail.value == 3) { + pzname = "右手食指" } this.setData({ - radioDetil:pzname + radioDetil: pzname }) - this.getfingerprintMrhods(pzname,personLi.cardId,11) + this.getfingerprintMrhods(pzname, personLi.cardId, 11) }, - getfingerprintMrhods(pzname,id,type){ - var that=this - var items=[ - {value: '0', name: '左手大拇指',checked:false}, - {value: '1', name: '左手食指',checked:false}, - {value: '2', name: '右手大拇指',checked:false}, - {value: '3', name: '右手食指',checked:false} + getfingerprintMrhods(pzname, id, type) { + var that = this + var items = [{ + value: '0', + name: '左手大拇指', + checked: false + }, + { + value: '1', + name: '左手食指', + checked: false + }, + { + value: '2', + name: '右手大拇指', + checked: false + }, + { + value: '3', + name: '右手食指', + checked: false + } ] var data = { pageNum: 0, @@ -275,43 +310,43 @@ Page({ q: { cardId: id, types: type, - deviceNum:this.data.deviceinfo.deviceNum, - inStatus:'0,1,702' + deviceNum: this.data.deviceinfo.deviceNum, + inStatus: '0,1,702' }, }; - WXAPI.getCertificates(data).then(res=>{ - var dataOne=util.zlib_unzip(res.data) - if(res.success){ - dataOne.map(li=>{ + WXAPI.getCertificates(data).then(res => { + var dataOne = util.zlib_unzip(res.data) + if (res.success) { + dataOne.map(li => { var content = JSON.parse(li.content) if (content.fingerprintAlias == pzname) { wx.showModal({ title: '提示', content: '该指纹已存在,请选择其他', - success (res1) { + success(res1) { if (res1.confirm) { console.log('用户点击确定') that.setData({ items, - radioDetil:'' + radioDetil: '' }) } else if (res1.cancel) { console.log('用户点击取消') that.setData({ items, - radioDetil:'' + radioDetil: '' }) } } }) } }) - }else{ + } else { wx.showToast({ title: '获取失败', - mask:true, - duration:'2000', - icon:'none' + mask: true, + duration: '2000', + icon: 'none' }) } }) @@ -326,198 +361,198 @@ Page({ var timestamp = moment().format("x") wx.showLoading({ title: '添加指纹中', - mask:true + mask: true }) if (app.globalData.backdata == 3 && this.data.backstatus) { bleall.startFp_29(deviceNum, 0x02, timestamp, function (res) {}) } else if (app.globalData.backdata == 2 && this.data.backstatus) { bleall.startFp_29(deviceNum, 0x01, timestamp, function (res) {}) } else if (app.globalData.backdata == 1 && this.data.backstatus) { - console.log(app.globalData.backdata, this.data.backstatus,'app.globalData.backdata, this.data.backstatus',this.data.fingerprintId) - if(this.data.fingerprintId!=255){ - var info = JSON.parse(this.data.personLi.info) - var time1 = moment(this.data.datetimerange[0]).format("YYYYMMDDHHmmss") - var time2 = moment(this.data.datetimerange[1]).format("YYYYMMDDHHmmss") - var time3 = new Date(this.data.datetimerange[0].replace(/-/g, '/')) - var time4 = new Date(this.data.datetimerange[1].replace(/-/g, '/')) - var passwordStartTime = time3.getTime() / 1000 - var passwordEndTime = time4.getTime() / 1000 - var data = { - managerTelephone: "18270949468", - managerPassword: "202108", - userTelephone: info.userTelephone, - userPassword: info.userPassword, - startTime: time1, - endTime: time2 - } - console.log(data, this.data.fingerprintId) - // if(app.globalData.fingerprintId != -1){ - // setTimeout(() => { - // app.globalData.backdata = -1 - this.setData({ - backstatus: false - }) - let fingerprintId = '' - console.log(_this.data.fingerprintId, typeof (_this.data.fingerprintId)) - if (Number(_this.data.fingerprintId) < 9) { - fingerprintId = '0' + _this.data.fingerprintId.toString(16) - } else { - fingerprintId = _this.data.fingerprintId.toString(16) - } - let deviceinfo = that.data.deviceinfo - bleall.startFp_63(data.managerTelephone, data.managerPassword, data.userTelephone, data.userPassword, - data.startTime, data.endTime, 16, this.data.fingerprintId, timestamp, - function (res) { - console.log(res, 'resres') - if (res.success) { - wx.hideLoading() - var cardName='',pzname='' - if(that.data.pzname){ - cardName=that.data.personLi.name+'-蓝牙-'+that.data.pzname - pzname='蓝牙-'+that.data.pzname - }else{ - cardName=that.data.personLi.name+'-蓝牙-指纹'+that.data.FpList.length+1 - pzname='蓝牙-指纹'+that.data.FpList.length+1 - } - var str = { - // cardId: this.personInfo.cardId, - imei: _this.data.deviceinfo.imei, - pzname:pzname, - password: '', - userTelephone: info.userTelephone, - operateMode: 16, - fingerprintAlias:_this.data.radioDetil, - userPassword: info.userPassword, - passwordStartTime: time1, - passwordEndTime: time2, - is: false, - pass:true - } - var data3 = { - code: "ble/operateUserInfo", - data: { - deviceNum: deviceinfo.deviceNum, - imei: deviceinfo.imei, + console.log(app.globalData.backdata, this.data.backstatus, 'app.globalData.backdata, this.data.backstatus', this.data.fingerprintId) + if (this.data.fingerprintId != 255) { + var info = JSON.parse(this.data.personLi.info) + var time1 = moment(this.data.datetimerange[0]).format("YYYYMMDDHHmmss") + var time2 = moment(this.data.datetimerange[1]).format("YYYYMMDDHHmmss") + var time3 = new Date(this.data.datetimerange[0].replace(/-/g, '/')) + var time4 = new Date(this.data.datetimerange[1].replace(/-/g, '/')) + var passwordStartTime = time3.getTime() / 1000 + var passwordEndTime = time4.getTime() / 1000 + var data = { + managerTelephone: "18270949468", + managerPassword: "202108", + userTelephone: info.userTelephone, + userPassword: info.userPassword, + startTime: time1, + endTime: time2 + } + console.log(data, this.data.fingerprintId) + // if(app.globalData.fingerprintId != -1){ + // setTimeout(() => { + // app.globalData.backdata = -1 + this.setData({ + backstatus: false + }) + let fingerprintId = '' + console.log(_this.data.fingerprintId, typeof (_this.data.fingerprintId)) + if (Number(_this.data.fingerprintId) < 9) { + fingerprintId = '0' + _this.data.fingerprintId.toString(16) + } else { + fingerprintId = _this.data.fingerprintId.toString(16) + } + let deviceinfo = that.data.deviceinfo + bleall.startFp_63(data.managerTelephone, data.managerPassword, data.userTelephone, data.userPassword, + data.startTime, data.endTime, 16, this.data.fingerprintId, timestamp, + function (res) { + console.log(res, 'resres') + if (res.success) { + wx.hideLoading() + var cardName = '', + pzname = '' + if (that.data.pzname) { + cardName = that.data.personLi.name + '-蓝牙-' + that.data.pzname + pzname = '蓝牙-' + that.data.pzname + } else { + cardName = that.data.personLi.name + '-蓝牙-指纹' + that.data.FpList.length + 1 + pzname = '蓝牙-指纹' + that.data.FpList.length + 1 + } + var str = { + // cardId: this.personInfo.cardId, + imei: _this.data.deviceinfo.imei, + pzname: pzname, + password: '', userTelephone: info.userTelephone, + operateMode: 16, + fingerprintAlias: _this.data.radioDetil, userPassword: info.userPassword, - password: fingerprintId, - userStartTime: time1, - userEndTime: time2, passwordStartTime: time1, passwordEndTime: time2, - operateMode: 16, - order: 6216, - timestamp: timestamp, - managerTelephone: '18270949468', - managerPassword: '202108', - passwordLength: 10, - permission: 4294967295, - times: 255, - recycleTime: "65535", - roomName: _this.data.deviceinfo.roomName, - cardName:cardName, + is: false, + pass: true } - } - console.log(data3, 'pppppp') - WXAPI.sendCommand(data3).then(res3 => { - console.log(res3, 'resres3') - if (res3.success) { - var data4 = { - result: 1, - serial: res3.data.serialNumber - } - WXAPI.updatePush(data4).then(res4 => { - - }) - var data6 = { - result: 1, - serial: res3.data.serialNumber, - face: fingerprintId + var data3 = { + code: "ble/operateUserInfo", + data: { + deviceNum: deviceinfo.deviceNum, + imei: deviceinfo.imei, + userTelephone: info.userTelephone, + userPassword: info.userPassword, + password: fingerprintId, + userStartTime: time1, + userEndTime: time2, + passwordStartTime: time1, + passwordEndTime: time2, + operateMode: 16, + order: 6216, + timestamp: timestamp, + managerTelephone: '18270949468', + managerPassword: '202108', + passwordLength: 10, + permission: 4294967295, + times: 255, + recycleTime: "65535", + roomName: _this.data.deviceinfo.roomName, + cardName: cardName, } - WXAPI.editPushBySerial(data6).then(res4 => { + } + console.log(data3, 'pppppp') + WXAPI.sendCommand(data3).then(res3 => { + console.log(res3, 'resres3') + if (res3.success) { + var data4 = { + result: 1, + serial: res3.data.serialNumber + } + WXAPI.updatePush(data4).then(res4 => { - }) - var data = { - cardId: _this.data.personLi.cardId, - content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1 - deviceNum: _this.data.deviceinfo.deviceNum, - type: 1, - imei: _this.data.deviceinfo.imei, - serial: res3.data.serialNumber, - startTime: passwordStartTime, - endTime: passwordEndTime, - }; - var datalist = { - cardId: _this.data.personLi.cardId, - content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1 - type: 11, - startTime: passwordStartTime, - endTime: passwordEndTime, - }; - WXAPI.addCertificates(datalist).then(res6 => {}) - console.log(data, '添加凭证') - WXAPI.addCertificates(data).then(res4 => { - if (res4.success) { - var updatedata = { - id: res4.data, - status:1 - }; - WXAPI.updateCertificates(updatedata).then((res2) => { - }); - console.log(res3, '添加凭证成功') - _this.getFp() - _this.setData({ - show: false - }) - wx.hideLoading() - wx.showToast({ - title: '添加成功', - icon: 'none', - mask:true, - duration: 2000 - }) - } else { - wx.hideLoading() - wx.showToast({ - title: '添加失败', - mask:true, - icon: 'none', - duration: 2000 - }) + }) + var data6 = { + result: 1, + serial: res3.data.serialNumber, + face: fingerprintId } - }) + WXAPI.editPushBySerial(data6).then(res4 => { - } else { - wx.hideLoading() - wx.showToast({ - title: res3.msg, - mask:true, - icon: 'none', - duration: 2000 - }) - } - }) - }else{ - wx.hideLoading() - wx.showToast({ - title: '添加失败', - duration:2000, - icon:'none' - }) - } - if (res.data == "蓝牙功能暂不支持") { - _this.startconnect() - } - }) - // }, 200) - // } - }else{ + }) + var data = { + cardId: _this.data.personLi.cardId, + content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1 + deviceNum: _this.data.deviceinfo.deviceNum, + type: 1, + imei: _this.data.deviceinfo.imei, + serial: res3.data.serialNumber, + startTime: passwordStartTime, + endTime: passwordEndTime, + }; + var datalist = { + cardId: _this.data.personLi.cardId, + content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1 + type: 11, + startTime: passwordStartTime, + endTime: passwordEndTime, + }; + WXAPI.addCertificates(datalist).then(res6 => {}) + console.log(data, '添加凭证') + WXAPI.addCertificates(data).then(res4 => { + if (res4.success) { + var updatedata = { + id: res4.data, + status: 1 + }; + WXAPI.updateCertificates(updatedata).then((res2) => {}); + console.log(res3, '添加凭证成功') + _this.getFp() + _this.setData({ + show: false + }) + wx.hideLoading() + wx.showToast({ + title: '添加成功', + icon: 'none', + mask: true, + duration: 2000 + }) + } else { + wx.hideLoading() + wx.showToast({ + title: '添加失败', + mask: true, + icon: 'none', + duration: 2000 + }) + } + }) + + } else { + wx.hideLoading() + wx.showToast({ + title: res3.msg, + mask: true, + icon: 'none', + duration: 2000 + }) + } + }) + } else { + wx.hideLoading() + wx.showToast({ + title: '添加失败', + duration: 2000, + icon: 'none' + }) + } + if (res.data == "蓝牙功能暂不支持") { + _this.startconnect() + } + }) + // }, 200) + // } + } else { wx.hideLoading() wx.showToast({ title: '添加失败', - mask:true, - duration:2000, - icon:'none' + mask: true, + duration: 2000, + icon: 'none' }) } } @@ -537,10 +572,10 @@ Page({ this.delPassword1(index) } else if (current == 2) { this.delNfc1(index) - }else if (current == 3) { + } else if (current == 3) { this.delFp1(index) } - } else if (deviceinfo.manufactureId == 201||deviceinfo.manufactureId == 221) { + } else if (deviceinfo.manufactureId == 201 || deviceinfo.manufactureId == 221) { if (current == 1) { this.delPassword(index) } else if (current == 2) { @@ -548,23 +583,27 @@ Page({ } else if (current == 3) { this.delFp(index) } - }else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) { - if (current == 1) { - this.delPasswordLwj(index) - } else if (current == 2) { - this.delNfcLwj(index) - } else if (current == 3) { - this.delFpLwj(index) + } else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) { + if (this.data.isSearch) { + if (current == 1) { + this.delPasswordLwj(index) + } else if (current == 2) { + this.delNfcLwj(index) + } else if (current == 3) { + this.delFpLwj(index) + } + }else{ + this.searchDevicesMethods() } } }, - getNFCIndexLwj(index, callback){ + getNFCIndexLwj(index, callback) { var data = { q: JSON.stringify({ cardId: this.data.personLi.cardId, - inStatus:"1", - types:'3', - deviceNum:this.data.NfcList[index].deviceNum, + inStatus: "1", + types: '3', + deviceNum: this.data.NfcList[index].deviceNum, // this.data.NfcList[index].serial, // result:1 }), @@ -574,13 +613,13 @@ Page({ }; WXAPI.getCertificates(data).then(res => { if (res.success) { - var dataOne=util.zlib_unzip(res.data) - console.log(dataOne,'ddd') + var dataOne = util.zlib_unzip(res.data) + console.log(dataOne, 'ddd') callback(dataOne) } else { wx.showToast({ title: '获取失败', - mask:true, + mask: true, duration: 2000, icon: 'none' }) @@ -591,20 +630,20 @@ Page({ var data = { q: JSON.stringify({ serial: this.data.NfcList[index].serial, - result:1 + result: 1 }), pageNum: 1, pageSize: 10, }; WXAPI.getDeviceResult(data).then(res => { if (res.success) { - var dataOne=util.zlib_unzip(res.data) - console.log(dataOne,'ddd') + var dataOne = util.zlib_unzip(res.data) + console.log(dataOne, 'ddd') callback(dataOne) } else { wx.showToast({ title: '获取失败', - mask:true, + mask: true, duration: 2000, icon: 'none' }) @@ -621,14 +660,14 @@ Page({ }; WXAPI.getDeviceResult(data).then(res => { if (res.success) { - var dataOne=util.zlib_unzip(res.data) - console.log(dataOne,'ddd') + var dataOne = util.zlib_unzip(res.data) + console.log(dataOne, 'ddd') callback(dataOne) } else { wx.showToast({ title: '获取失败', duration: 2000, - mask:true, + mask: true, icon: 'none' }) } @@ -667,7 +706,7 @@ Page({ endtime: str }) }, - delNfc1(index){ + delNfc1(index) { wx.showLoading({ title: '正在删除', mask: true @@ -676,11 +715,11 @@ Page({ var personLi = this.data.NfcList[index] var deviceinfo = this.data.deviceinfo var info = JSON.parse(personLi.content) - var personInfo=JSON.parse(this.data.personLi.info) + var personInfo = JSON.parse(this.data.personLi.info) var _this = this this.getNFCIndex(index, function (data) { - console.log(data,'datatdatata',data[0]) - if (data.length > 0 && data[0].face!=null ) { + console.log(data, 'datatdatata', data[0]) + if (data.length > 0 && data[0].face != null) { var FPindex = data[0].face var dataPasswod = { code: "zg/cardOperate", @@ -690,39 +729,39 @@ Page({ lockerUserId: personInfo.userId, keyId: personInfo.userId, action: 2, - taskStatus:1, - cardType:50, - cardNo:info.password, - cardIndex:FPindex, + taskStatus: 1, + cardType: 50, + cardNo: info.password, + cardIndex: FPindex, startTime: personLi.startTime, endTime: personLi.endTime, order: 6212, type: 12, roomName: _this.data.deviceinfo.roomName, - cardName: _this.data.personLi.name+personLi.pzname, + cardName: _this.data.personLi.name + personLi.pzname, } } WXAPI.sendCommand(dataPasswod).then(res => { - console.log(res, '获取索引',FPindex) + console.log(res, '获取索引', FPindex) if (res.success) { - var serialNumber= res.data.serialNumber + var serialNumber = res.data.serialNumber var fingerNo = FPindex.toString(16) - if (fingerNo.length==1) { + if (fingerNo.length == 1) { fingerNo = '0' + fingerNo } else { fingerNo = fingerNo } ICINLocker.getSignKey(cgInfo.lockerId, cgInfo.superId, cgInfo.superId, (callback) => { - console.log(callback,fingerNo) + console.log(callback, fingerNo) if (callback.status == '00') { ICINLocker.getCommonKey(cgInfo.lockerId, cgInfo.superId, cgInfo.superId, callback.signKey, (callback1) => { console.log(callback1) if (callback1.status == '00') { var startTime = personLi.startTime.toString(16).toUpperCase() var endTime = personLi.endTime.toString(16).toUpperCase() - console.log(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, fingerNo.toUpperCase(), '--','01', callback.signKey, startTime, endTime, callback1.commonKey) - ICINLocker.modifyRFCard(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, fingerNo.toUpperCase(), '','01', callback.signKey, startTime, endTime, callback1.commonKey, ( + console.log(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, fingerNo.toUpperCase(), '--', '01', callback.signKey, startTime, endTime, callback1.commonKey) + ICINLocker.modifyRFCard(cgInfo.lockerId, cgInfo.superId, personInfo.userId, personInfo.userId, fingerNo.toUpperCase(), '', '01', callback.signKey, startTime, endTime, callback1.commonKey, ( callback2) => { console.log(callback2) if (callback2.status == '00') { @@ -730,7 +769,7 @@ Page({ code: "zg/bleSendVoucherReply", data: { lockerId: deviceinfo.deviceNum, - serialNumber:serialNumber, + serialNumber: serialNumber, index: FPindex, type: 12, result: 1 @@ -741,7 +780,7 @@ Page({ }) wx.showToast({ title: '下发成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -754,14 +793,14 @@ Page({ _this.getNfc() wx.showToast({ title: '删除成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) } else { wx.showToast({ title: '删除失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -771,7 +810,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '删除失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -794,7 +833,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '删除失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -817,7 +856,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '删除失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -839,7 +878,7 @@ Page({ } else { wx.showToast({ title: res.msg, - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -849,14 +888,14 @@ Page({ wx.hideLoading() wx.showToast({ title: '删除失败', - mask:true, + mask: true, duration: 2000, icon: 'none' }) } }) }, - delNfcLwj(index){ + delNfcLwj(index) { wx.showLoading({ title: '正在删除', mask: true @@ -865,52 +904,52 @@ Page({ passwordLiAll = personLi var deviceinfo = this.data.deviceinfo var info = JSON.parse(personLi.content) - var personInfo=JSON.parse(this.data.personLi.info) + var personInfo = JSON.parse(this.data.personLi.info) var _this = this this.getNFCIndexLwj(index, function (data) { if (data.length > 0) { let passwordIndex = JSON.parse(data[0].content).index || '' - var dataPasswod = { - code: "lwj/passwordOperate", - data: { - lockerId: deviceinfo.deviceNum, - lockerUserId: personInfo.userId, - startTime:personLi.startTime, - endTime:personLi.endTime, - order: 6212, - operateMode:12, - action: 2, - // cardNo: info.password, - passwordIndex:passwordIndex, - type: 12, - cardName:_this.data.personLi.name, - roomName:deviceinfo.roomName - } + var dataPasswod = { + code: "lwj/passwordOperate", + data: { + lockerId: deviceinfo.deviceNum, + lockerUserId: personInfo.userId, + startTime: personLi.startTime, + endTime: personLi.endTime, + order: 6212, + operateMode: 12, + action: 2, + // cardNo: info.password, + passwordIndex: passwordIndex, + type: 12, + cardName: _this.data.personLi.name, + roomName: deviceinfo.roomName } - console.log(dataPasswod,'dataPasswod',info) - WXAPI.sendCommand(dataPasswod).then(res => { - console.log(res, '获取索引') - if (res.success) { - rfCardIndex = res.data.index - serialNumber = res.data.serialNumber - rfCardId = info.password - taskId = 62 - _this.initBluetooth() - }else{ - wx.hideLoading() - wx.showToast({ - title: res.msg, - mask:true, - icon: 'none', - duration: 2000 - }) - } - }) + } + console.log(dataPasswod, 'dataPasswod', info) + WXAPI.sendCommand(dataPasswod).then(res => { + console.log(res, '获取索引') + if (res.success) { + rfCardIndex = res.data.index + serialNumber = res.data.serialNumber + rfCardId = info.password + taskId = 62 + _this.initBluetooth() + } else { + wx.hideLoading() + wx.showToast({ + title: res.msg, + mask: true, + icon: 'none', + duration: 2000 + }) + } + }) } else { wx.hideLoading() wx.showToast({ title: '删除失败', - mask:true, + mask: true, duration: 2000, icon: 'none' }) @@ -985,14 +1024,14 @@ Page({ _this.getFp() wx.showToast({ title: '删除成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) } else { wx.showToast({ title: '删除失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -1011,13 +1050,13 @@ Page({ } else { wx.showToast({ title: res1.msg, - mask:true, + mask: true, icon: 'none', duration: 2000 }) } }) - }else{ + } else { wx.hideLoading() } }) @@ -1025,14 +1064,14 @@ Page({ wx.hideLoading() wx.showToast({ title: '获取指纹ID失败', - mask:true, + mask: true, duration: 2000, icon: 'none' }) } }) }, - delFpLwj(index){ + delFpLwj(index) { console.log("删除指纹"); wx.showLoading({ title: '正在删除', @@ -1048,11 +1087,30 @@ Page({ if (data.length > 0) { var FPindex = data[0].face // 删除 + var dataFP = { + code: "", + data: { + lockerId: deviceinfo.deviceNum, + imei: deviceinfo.imei, + lockerUserId: info.userPassword, + keyId: info.userPassword, + fingerType: 0, + order: 6216, + fingerId: '', + roomName: deviceinfo.roomName, + cardName: cardName, + startTime: passwordStartTime, + endTime: passwordEndTime, + file: '', + type: 1, + action: 2 + } + } } else { wx.hideLoading() wx.showToast({ title: '获取指纹ID失败', - mask:true, + mask: true, duration: 2000, icon: 'none' }) @@ -1068,7 +1126,7 @@ Page({ var personLi = this.data.FpList[index] var deviceinfo = this.data.deviceinfo var info = JSON.parse(personLi.content) - var personInfo=JSON.parse(this.data.personLi.info) + var personInfo = JSON.parse(this.data.personLi.info) var _this = this this.getFpIndex(index, function (data) { if (data.length > 0) { @@ -1129,7 +1187,7 @@ Page({ }) wx.showToast({ title: '下发成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -1142,14 +1200,14 @@ Page({ _this.getFp() wx.showToast({ title: '删除成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) } else { wx.showToast({ title: '删除失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -1159,7 +1217,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '删除失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -1182,7 +1240,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '删除失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -1205,7 +1263,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '删除失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -1250,7 +1308,7 @@ Page({ wx.hideLoading() wx.showToast({ title: res.msg, - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -1260,7 +1318,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '获取失败', - mask:true, + mask: true, duration: 2000, icon: 'none' }) @@ -1338,7 +1396,7 @@ Page({ wx.showToast({ title: '删除成功', icon: 'none', - mask:true, + mask: true, duration: 2000 }) } else { @@ -1346,7 +1404,7 @@ Page({ wx.showToast({ title: '删除失败', icon: 'none', - mask:true, + mask: true, duration: 2000 }) } @@ -1367,7 +1425,7 @@ Page({ mask: true }) this.setData({ - showLoading:true + showLoading: true }) // this.setData({ // showLoading:true @@ -1386,7 +1444,7 @@ Page({ if (res.type == 'connect') { if (res.data == "未打开适配器") { this.setData({ - showLoading:false + showLoading: false }) wx.hideLoading() wx.showModal({ @@ -1400,7 +1458,7 @@ Page({ if (res.data == '蓝牙已连接') { app.globalData.bleStatus = res.data this.setData({ - showLoading:false + showLoading: false }) if (this.data.current == 0) { this.sendPassword() @@ -1415,7 +1473,7 @@ Page({ }) } }, - delPasswordLwj(index){ + delPasswordLwj(index) { wx.showLoading({ title: '正在删除', mask: true @@ -1425,25 +1483,25 @@ Page({ var passwordLi = this.data.passwordList[index] passwordLiAll = passwordLi var info = JSON.parse(passwordLi.content) - var personInfo=JSON.parse(this.data.personLi.info) + var personInfo = JSON.parse(this.data.personLi.info) var cgInfo = this.data.cgInfo var dataPasswod = { code: "lwj/passwordOperate", data: { lockerId: deviceinfo.deviceNum, lockerUserId: personInfo.userId, - startTime:passwordLi.startTime, - endTime:passwordLi.endTime, + startTime: passwordLi.startTime, + endTime: passwordLi.endTime, order: 6209, - operateMode:9, + operateMode: 9, action: 2, password: info.password, type: 9, - cardName:_this.data.personLi.name, - roomName:deviceinfo.roomName + cardName: _this.data.personLi.name, + roomName: deviceinfo.roomName } } - console.log(dataPasswod,'dataPasswod',info) + console.log(dataPasswod, 'dataPasswod', info) WXAPI.sendCommand(dataPasswod).then(res => { console.log(res, '获取索引') if (res.success) { @@ -1451,11 +1509,11 @@ Page({ serialNumber = res.data.serialNumber taskId = 52 _this.initBluetooth() - }else{ + } else { wx.hideLoading() wx.showToast({ title: res.msg, - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -1490,7 +1548,7 @@ Page({ var passwordLi = this.data.passwordList[index] passwordLiAll = passwordLi var info = JSON.parse(passwordLi.content) - var personInfo=JSON.parse(this.data.personLi.info) + var personInfo = JSON.parse(this.data.personLi.info) var cgInfo = this.data.cgInfo var dataPasswod = { code: "zg/tempPassword", @@ -1506,208 +1564,208 @@ Page({ action: 2, password: info.password, type: 1, - cardName:_this.data.personLi.name, - roomName:deviceinfo.roomName + cardName: _this.data.personLi.name, + roomName: deviceinfo.roomName } } - console.log(dataPasswod,'dataPasswod',info) + console.log(dataPasswod, 'dataPasswod', info) WXAPI.sendCommand(dataPasswod).then(res => { console.log(res, '获取索引') if (res.success) { var pwdNo = res.data.index.toString(16) var passwordIndex = res.data.index - if (pwdNo < 9) { - pwdNo = '0' + pwdNo - } else { - pwdNo = pwdNo - } - ICINLocker.getUserSignKey(cgInfo.lockerId, cgInfo.superId, personInfo.userId, cgInfo.superId, cgInfo.authKey, '01', (callback) => { - console.log(callback) - if (callback.status == '00') { - var userSignKey = callback.userSignKey - ICINLocker.getCommonKey(cgInfo.lockerId,personInfo.userId, personInfo.userId, userSignKey, (callback) => { - if (callback.status == '00') { - console.log(callback, 'commonKey') - var commonKey = callback.commonKey - var startTime = passwordLi.startTime.toString(16).toUpperCase() - var endTime = passwordLi.endTime.toString(16).toUpperCase() - ICINLocker.handlePwd(deviceinfo.deviceNum, cgInfo.superId, personInfo.userId, info.password, pwdNo, cgInfo.superId, cgInfo.authKey, '', startTime, endTime, 0, commonKey, (callback) => { - console.log(callback) - if (callback.status == '00') { - var datacom = { - code: "zg/bleSendVoucherReply", - data: { - lockerId: deviceinfo.deviceNum, - serialNumber: res.data.serialNumber, - index: passwordIndex, - type: 9, - result: 1 - } + if (pwdNo < 9) { + pwdNo = '0' + pwdNo + } else { + pwdNo = pwdNo + } + ICINLocker.getUserSignKey(cgInfo.lockerId, cgInfo.superId, personInfo.userId, cgInfo.superId, cgInfo.authKey, '01', (callback) => { + console.log(callback) + if (callback.status == '00') { + var userSignKey = callback.userSignKey + ICINLocker.getCommonKey(cgInfo.lockerId, personInfo.userId, personInfo.userId, userSignKey, (callback) => { + if (callback.status == '00') { + console.log(callback, 'commonKey') + var commonKey = callback.commonKey + var startTime = passwordLi.startTime.toString(16).toUpperCase() + var endTime = passwordLi.endTime.toString(16).toUpperCase() + ICINLocker.handlePwd(deviceinfo.deviceNum, cgInfo.superId, personInfo.userId, info.password, pwdNo, cgInfo.superId, cgInfo.authKey, '', startTime, endTime, 0, commonKey, (callback) => { + console.log(callback) + if (callback.status == '00') { + var datacom = { + code: "zg/bleSendVoucherReply", + data: { + lockerId: deviceinfo.deviceNum, + serialNumber: res.data.serialNumber, + index: passwordIndex, + type: 9, + result: 1 } - WXAPI.sendCommand(datacom).then(res2 => { - if (res2.success) {} - }) - var data = { - ids: [passwordLiAll.id] + } + WXAPI.sendCommand(datacom).then(res2 => { + if (res2.success) {} + }) + var data = { + ids: [passwordLiAll.id] + } + WXAPI.deleteCertificates(data).then(res1 => { + if (res1.success) { + _this.getPassword() + wx.hideLoading() + wx.showToast({ + title: '删除成功', + mask: true, + icon: 'none', + duration: 2000 + }) + } else { + wx.hideLoading() + wx.showToast({ + title: '删除失败', + mask: true, + icon: 'none', + duration: 2000 + }) } - WXAPI.deleteCertificates(data).then(res1 => { - if (res1.success) { - _this.getPassword() - wx.hideLoading() - wx.showToast({ - title: '删除成功', - mask:true, - icon: 'none', - duration: 2000 - }) - } else { - wx.hideLoading() - wx.showToast({ - title: '删除失败', - mask:true, - icon: 'none', - duration: 2000 - }) - } - }) - } else { - wx.hideLoading() - wx.showToast({ - title: '删除失败', - mask:true, - icon: 'none', - duration: 2000 - }) - var datacom = { - code: "zg/bleSendVoucherReply", - data: { - lockerId: deviceinfo.deviceNum, - serialNumber: res.data.serialNumber, - index: res.data.index, - type: 9, - result: 0 - } + }) + } else { + wx.hideLoading() + wx.showToast({ + title: '删除失败', + mask: true, + icon: 'none', + duration: 2000 + }) + var datacom = { + code: "zg/bleSendVoucherReply", + data: { + lockerId: deviceinfo.deviceNum, + serialNumber: res.data.serialNumber, + index: res.data.index, + type: 9, + result: 0 } - WXAPI.sendCommand(datacom).then(res2 => { - console.log(res2, '失败') - }) } - }) - } else { - wx.hideLoading() - wx.showToast({ - title: '删除失败', - mask:true, - icon: 'none', - duration: 2000 - }) - } - }) - } else { - wx.hideLoading() - wx.showToast({ - title: '删除失败', - mask:true, - icon: 'none', - duration: 2000 - }) - } - }) + WXAPI.sendCommand(datacom).then(res2 => { + console.log(res2, '失败') + }) + } + }) + } else { + wx.hideLoading() + wx.showToast({ + title: '删除失败', + mask: true, + icon: 'none', + duration: 2000 + }) + } + }) + } else { + wx.hideLoading() + wx.showToast({ + title: '删除失败', + mask: true, + icon: 'none', + duration: 2000 + }) + } + }) } else { wx.hideLoading() wx.showToast({ title: res.msg, - mask:true, + mask: true, icon: 'none', duration: 2000 }) } }) }, - getPassWordMehods(content,id,type){ - var that=this + getPassWordMehods(content, id, type) { + var that = this var data = { pageNum: 0, pageSize: 0, orderBy: "create_at desc", q: { cardId: id, - password:content, - deviceNum:this.data.deviceinfo.deviceNum, + password: content, + deviceNum: this.data.deviceinfo.deviceNum, types: type, - inStatus:'0,1,702' + inStatus: '0,1,702' }, }; - WXAPI.getCertificates(data).then(res=>{ - if(res.success){ - var dataOne=util.zlib_unzip(res.data) - if(dataOne.length>0){ + WXAPI.getCertificates(data).then(res => { + if (res.success) { + var dataOne = util.zlib_unzip(res.data) + if (dataOne.length > 0) { wx.showModal({ title: '提示', content: '该密码已存在,不能重复添加', - success (res1) { + success(res1) { if (res1.confirm) { console.log('用户点击确定') that.setData({ - password:'', - passwordStatus:false + password: '', + passwordStatus: false }) } else if (res1.cancel) { console.log('用户点击取消') that.setData({ - password:'', - passwordStatus:false + password: '', + passwordStatus: false }) } } }) - }else{ - this.setData({ - passwordStatus:true + } else { + this.setData({ + passwordStatus: true }) } - }else{ + } else { wx.showToast({ title: '获取失败', - duration:'2000', - mask:true, - icon:'none' + duration: '2000', + mask: true, + icon: 'none' }) } }) }, sendPassword() { let passwordLength = this.data.password.toString() - if(passwordLength.length != 6){ + if (passwordLength.length != 6) { wx.showToast({ title: '格式错误,密码为6位数字!', - icon:'none' + icon: 'none' }) return false; } wx.showLoading({ title: '正在添加', - mask:true, + mask: true, }) var time3 = new Date(this.data.datetimerange[0].replace(/-/g, '/')) var time4 = new Date(this.data.datetimerange[1].replace(/-/g, '/')) var passwordStartTimecontrast = time3.getTime() / 1000 var passwordEndTimecontrast = time4.getTime() / 1000 - this.getPassWordMehods(this.data.password,this.data.personLi.cardId,14) - if(this.data.password==''){ + this.getPassWordMehods(this.data.password, this.data.personLi.cardId, 14) + if (this.data.password == '') { wx.showToast({ title: '密码不能为空', - mask:true, + mask: true, duration: 2000, icon: 'none' }) return } - if(!this.data.passwordStatus){ + if (!this.data.passwordStatus) { wx.showToast({ title: '已存在该密码,请重输', duration: 2000, - mask:true, + mask: true, icon: 'none' }) return @@ -1716,14 +1774,14 @@ Page({ wx.showToast({ title: '开始时间不能大于结束时间', duration: 2000, - mask:true, + mask: true, icon: 'none' }) return } wx.showLoading({ title: '正在添加', - mask:true + mask: true }) var _this = this var deviceinfo = this.data.deviceinfo @@ -1750,12 +1808,13 @@ Page({ function (res) { console.log(res) if (res.success) { - var pzname='',cardName='' - pzname='蓝牙-密码'+(_this.data.passwordList.length+1) - cardName=_this.data.personLi.name+'-蓝牙-密码'+(_this.data.passwordList.length+1) + var pzname = '', + cardName = '' + pzname = '蓝牙-密码' + (_this.data.passwordList.length + 1) + cardName = _this.data.personLi.name + '-蓝牙-密码' + (_this.data.passwordList.length + 1) var str = { // cardId: this.personInfo.cardId, - pzname:pzname, + pzname: pzname, imei: _this.data.deviceinfo.imei, password: _this.data.password.toString(), userTelephone: JSON.parse(_this.data.personLi.info).userTelephone, @@ -1764,7 +1823,7 @@ Page({ passwordStartTime: time1, passwordEndTime: time2, is: false, - pass:true + pass: true } var data3 = { code: "ble/operateUserInfo", @@ -1817,18 +1876,17 @@ Page({ startTime: passwordStartTime, endTime: passwordEndTime, }; - console.log(datalist,'密码11') + console.log(datalist, '密码11') WXAPI.addCertificates(datalist).then(res6 => { - console.log(datalist,'密码22') + console.log(datalist, '密码22') }) WXAPI.addCertificates(data).then(res3 => { if (res3.success) { var updatedata = { id: res3.data, - status:1 + status: 1 }; - WXAPI.updateCertificates(updatedata).then((res2) => { - }); + WXAPI.updateCertificates(updatedata).then((res2) => {}); _this.getPassword() _this.setData({ show: false @@ -1837,14 +1895,14 @@ Page({ wx.showToast({ title: '添加成功', icon: 'none', - mask:true, + mask: true, duration: 2000 }) } else { wx.hideLoading() wx.showToast({ title: '添加失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -1853,13 +1911,13 @@ Page({ } else { wx.showToast({ title: res3.msg, - mask:true, + mask: true, icon: 'none', duration: 2000 }) } }) - }else{ + } else { wx.hideLoading() if (res.data == "蓝牙功能暂不支持") { // wx.showToast({ @@ -1868,25 +1926,26 @@ Page({ // icon: "none" // }) _this.startconnect() - }else{ + } else { wx.showToast({ title: '下发失败', - mask:true, + mask: true, duration: 2000, icon: "none" }) } } }) - } else if (deviceinfo.manufactureId == 201||deviceinfo.manufactureId == 221) { + } else if (deviceinfo.manufactureId == 201 || deviceinfo.manufactureId == 221) { var cgInfo = this.data.cgInfo 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 pzname='',cardName='' - pzname='蓝牙-密码'+(_this.data.passwordList.length+1) - cardName=_this.data.personLi.name+'-蓝牙-密码'+(_this.data.passwordList.length+1) + var pzname = '', + cardName = '' + pzname = '蓝牙-密码' + (_this.data.passwordList.length + 1) + cardName = _this.data.personLi.name + '-蓝牙-密码' + (_this.data.passwordList.length + 1) var dataPasswod = { code: "zg/tempPassword", data: { @@ -1913,16 +1972,16 @@ Page({ // var str = res.data.index pwdNo = pwdNo.toString(16) if (pwdNo.length < 2) { - pwdNo='0'+pwdNo + pwdNo = '0' + pwdNo } var startTime = passwordStartTime.toString(16).toUpperCase() var endTime = passwordEndTime.toString(16).toUpperCase() - info.startTime=startTime - info.endTime=endTime - info.pwdNo=pwdNo - info.password=this.data.password.toString() - methods.bluetoothOperation_ZH(cgInfo,info,3).then(result=>{ - if (result.status == '00' ||result.status == '0a' ) { + info.startTime = startTime + info.endTime = endTime + info.pwdNo = pwdNo + info.password = this.data.password.toString() + methods.bluetoothOperation_ZH(cgInfo, info, 3).then(result => { + if (result.status == '00' || result.status == '0a') { var datacom = { code: "zg/bleSendVoucherReply", data: { @@ -1936,7 +1995,7 @@ Page({ var str = { // cardId: this.personInfo.cardId, imei: _this.data.deviceinfo.imei, - pzname:pzname, + pzname: pzname, password: _this.data.password.toString(), userTelephone: JSON.parse(_this.data.personLi.info).userTelephone, operateMode: 7, @@ -1944,7 +2003,7 @@ Page({ passwordStartTime: passwordStartTime, passwordEndTime: passwordEndTime, is: false, - pass:true + pass: true } var data = { cardId: _this.data.personLi.cardId, @@ -1963,19 +2022,18 @@ Page({ startTime: passwordStartTime, endTime: passwordEndTime, }; - console.log(datalist,'密码11') - WXAPI.addCertificates(datalist).then(res6 => { - console.log(datalist,'密码22',res6) + console.log(datalist, '密码11') + WXAPI.addCertificates(datalist).then(res6 => { + console.log(datalist, '密码22', res6) }) console.log(data, '添加凭证') WXAPI.addCertificates(data).then(res3 => { if (res3.success) { var updatedata = { id: res3.data, - status:1 + status: 1 }; - WXAPI.updateCertificates(updatedata).then((res2) => { - }); + WXAPI.updateCertificates(updatedata).then((res2) => {}); WXAPI.sendCommand(datacom).then(res2 => { if (res2.success) {} }) @@ -1987,7 +2045,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -1995,7 +2053,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -2004,7 +2062,7 @@ Page({ } else { wx.showToast({ title: '添加失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -2025,12 +2083,12 @@ Page({ }) }) } - }).catch(err=>{ + }).catch(err => { wx.hideLoading() wx.showToast({ title: '添加失败', icon: 'none', - mask:true, + mask: true, duration: 2000 }) var datacom = { @@ -2054,17 +2112,17 @@ Page({ wx.showToast({ title: res.msg, duration: 2000, - mask:true, + mask: true, icon: 'none' }) } }) - }else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241){ + } else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) { console.log(this.data.isSearch); - if(this.data.isSearch){ + if (this.data.isSearch) { wx.hideLoading() this.addPincode() - }else{ + } else { this.searchDevicesMethods() } } @@ -2081,18 +2139,19 @@ Page({ var time2 = new Date(that.data.endtime.replace(/-/g, '/')) var passwordStartTime = time1.getTime() / 1000 var passwordEndTime = time2.getTime() / 1000 - var pzname='',cardName='' - pzname='蓝牙-密码'+(that.data.passwordList.length+1) - cardName=that.data.personLi.name+'-蓝牙-密码'+(that.data.passwordList.length+1) + var pzname = '', + cardName = '' + pzname = '蓝牙-密码' + (that.data.passwordList.length + 1) + cardName = that.data.personLi.name + '-蓝牙-密码' + (that.data.passwordList.length + 1) var dataPasswod = { code: "lwj/passwordOperate", data: { lockerId: deviceinfo.deviceNum, lockerUserId: info.userId, - startTime:passwordStartTime, - endTime:passwordEndTime, + startTime: passwordStartTime, + endTime: passwordEndTime, order: 6207, - operateMode:7, + operateMode: 7, action: 1, password: this.data.password.toString(), type: 7, @@ -2112,8 +2171,8 @@ Page({ // var startTime = util1.getLocalTime(8) // var endTime = new Date(startTime.getTime() + 5 * 60 * 1000) //有效期5分钟 }, - sendAddPincode(){ - var that =this + sendAddPincode() { + var that = this var startTime = new Date(Number(moment(that.data.starttime).format('x'))) var endTime = new Date(Number(moment(that.data.endtime).format('x'))) pincode = this.data.password @@ -2141,7 +2200,7 @@ Page({ that.setData({ isConnected: isConnected }) - console.log(isInitReady,'isConnected', isConnected) + console.log(isInitReady, 'isConnected', isConnected) if (isConnected) { console.log("2144"); if (isInitReady) { @@ -2172,11 +2231,11 @@ Page({ console.log('Characteristics', res) wx.showToast({ title: '连接成功', - duration:1000, - icon:'none' + duration: 1000, + icon: 'none' }) wx.onBLECharacteristicValueChange(function (res) { - console.log(res,'reslllllll') + console.log(res, 'reslllllll') var bytes = new Uint8Array(res.value) console.log('bytes', bytes) var data = plugin.parseBytes(lockDevice.name, basecode, bytes) @@ -2205,7 +2264,7 @@ Page({ content: `是否添加此房卡,卡号:${data.data.cardId}?`, success: function (res) { if (res.confirm) { - console.log( data.data,'rfCardIdrfCardId') + console.log(data.data, 'rfCardIdrfCardId') // rfCardId = randomMethods()//data.data.cardId that.onAddRfCard() } @@ -2503,7 +2562,7 @@ Page({ } isLockLogin = true - if (taskId == 41) { + if (taskId == 41) { // var data = { // code: "zg/bleUnlockRecord", // data: { @@ -2517,11 +2576,11 @@ Page({ 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' + 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 => { @@ -2561,30 +2620,30 @@ Page({ case 'addPincode': { // console.log(data.data,'data.data') // wx.hideLoading() - let data2={ - "code":"ble/bleSendVoucherReply", - "data":{ - "deviceNum":that.data.deviceinfo.deviceNum, - "serialNumber":serialNumber, - "index":pincodeIndex, - "type":7, - "result":1, - "productId":that.data.deviceinfo.manufactureId + let data2 = { + "code": "ble/bleSendVoucherReply", + "data": { + "deviceNum": that.data.deviceinfo.deviceNum, + "serialNumber": serialNumber, + "index": pincodeIndex, + "type": 7, + "result": 1, + "productId": that.data.deviceinfo.manufactureId } - } + } if (data.code != 200) { - data2={ - "code":"ble/bleSendVoucherReply", - "data":{ - "deviceNum":that.data.deviceinfo.deviceNum, - "serialNumber":serialNumber, - "index":pincodeIndex, - "type":7, - "result":0, - "productId":that.data.deviceinfo.manufactureId + data2 = { + "code": "ble/bleSendVoucherReply", + "data": { + "deviceNum": that.data.deviceinfo.deviceNum, + "serialNumber": serialNumber, + "index": pincodeIndex, + "type": 7, + "result": 0, + "productId": that.data.deviceinfo.manufactureId } - } - WXAPI.sendCommand(data2).then(res=>{ + } + WXAPI.sendCommand(data2).then(res => { }) wx.showModal({ @@ -2599,22 +2658,23 @@ Page({ var time2 = new Date(that.data.endtime.replace(/-/g, '/')) var passwordStartTime = time1.getTime() / 1000 var passwordEndTime = time2.getTime() / 1000 - var pzname='',cardName=''; - pzname='蓝牙-密码'+(that.data.passwordList.length+1) - cardName=that.data.personLi.name+'-蓝牙-密码'+(that.data.passwordList.length+1) + var pzname = '', + cardName = ''; + pzname = '蓝牙-密码' + (that.data.passwordList.length + 1) + cardName = that.data.personLi.name + '-蓝牙-密码' + (that.data.passwordList.length + 1) var str = { // cardId: this.personInfo.cardId, imei: that.data.deviceinfo.imei, - pzname:pzname, + pzname: pzname, password: that.data.password.toString(), userTelephone: JSON.parse(that.data.personLi.info).userTelephone, operateMode: 7, userPassword: JSON.parse(that.data.personLi.info).userPassword, passwordStartTime: passwordStartTime, passwordEndTime: passwordEndTime, - index:pincodeIndex, + index: pincodeIndex, is: false, - pass:true + pass: true } var data1 = { cardId: that.data.personLi.cardId, @@ -2633,19 +2693,18 @@ Page({ startTime: passwordStartTime, endTime: passwordEndTime, }; - WXAPI.addCertificates(datalist).then(res6 => { - console.log(datalist,'密码22',res6) + WXAPI.addCertificates(datalist).then(res6 => { + console.log(datalist, '密码22', res6) }) WXAPI.addCertificates(data1).then(res3 => { if (res3.success) { var updatedata = { id: res3.data, - status:1 + status: 1 }; - WXAPI.updateCertificates(updatedata).then((res2) => { - }); - WXAPI.sendCommand(data2).then(res=>{ - + WXAPI.updateCertificates(updatedata).then((res2) => {}); + WXAPI.sendCommand(data2).then(res => { + }) that.getPassword() that.setData({ @@ -2654,7 +2713,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -2662,7 +2721,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -2690,7 +2749,7 @@ Page({ lockerId: that.data.deviceinfo.deviceNum, serialNumber: serialNumber, index: pincodeIndex, - action:2, + action: 2, type: 9, result: 0 } @@ -2719,7 +2778,7 @@ Page({ lockerId: that.data.deviceinfo.deviceNum, serialNumber: serialNumber, index: pincodeIndex, - action:2, + action: 2, type: 9, result: 1 } @@ -2736,7 +2795,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '删除成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -2744,7 +2803,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '删除失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -2775,7 +2834,7 @@ Page({ type: ADD_NFC_MODE, cardNo: '', result: 0, - productId:that.data.deviceinfo.manufactureId + productId: that.data.deviceinfo.manufactureId } } WXAPI.sendCommand(datacom).then(res2 => {}) @@ -2791,9 +2850,9 @@ Page({ that.setData({ isRfCardAdd: true }) - + if (lockModel > 70) { - console.log(data.data,'rfCardIndexrfCardIndex') + console.log(data.data, 'rfCardIndexrfCardIndex') // rfCardId = randomMethods() wx.showModal({ title: '提示', @@ -2801,8 +2860,8 @@ Page({ showCancel: false }) that.addRfcardCertificates() - } else { - console.log(data.data,'rfCardIndexrfCardIndex1') + } else { + console.log(data.data, 'rfCardIndexrfCardIndex1') // rfCardId = randomMethods() wx.showModal({ title: '提示', @@ -2823,7 +2882,7 @@ Page({ lockerId: that.data.deviceinfo.deviceNum, serialNumber: serialNumber, index: rfCardIndex, - action:2, + action: 2, type: 12, result: 0 } @@ -2862,7 +2921,7 @@ Page({ lockerId: that.data.deviceinfo.deviceNum, serialNumber: serialNumber, index: rfCardIndex, - action:2, + action: 2, type: 12, result: 1 } @@ -2870,22 +2929,22 @@ Page({ WXAPI.sendCommand(datacom).then(res2 => { console.log(res2, '失败') }) - var data = { - ids: [passwordLiAll.id] - } + var data = { + ids: [passwordLiAll.id] + } WXAPI.deleteCertificates(data).then(res1 => { if (res1.success) { that.getNfc() wx.showToast({ title: '删除成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) } else { wx.showToast({ title: '删除失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -2909,16 +2968,16 @@ Page({ content: '添加指纹失败!' + data.data.msg, showCancel: false, success: function (res) {} - }) + }) var datacom = { code: "ble/bleSendVoucherReply", data: { deviceNum: that.data.deviceinfo.deviceNum, serialNumber: serialNumber, - index:0, + index: 0, type: 16, result: 0, - productId:that.data.deviceinfo.manufactureId + productId: that.data.deviceinfo.manufactureId } } WXAPI.sendCommand(datacom).then(res2 => { @@ -2940,29 +2999,30 @@ Page({ var time2 = new Date(that.data.endtime.replace(/-/g, '/')) var passwordStartTime = time1.getTime() / 1000 var passwordEndTime = time2.getTime() / 1000 - var cardName='',pzname='' - if(that.data.pzname){ - cardName=that.data.personLi.name+'-蓝牙-'+that.data.pzname - pzname='蓝牙-'+that.data.pzname - }else{ - cardName=that.data.personLi.name+'-蓝牙-指纹'+(that.data.FpList.length+1) - pzname='蓝牙-指纹'+(that.data.FpList.length+1) - } + var cardName = '', + pzname = '' + if (that.data.pzname) { + cardName = that.data.personLi.name + '-蓝牙-' + that.data.pzname + pzname = '蓝牙-' + that.data.pzname + } else { + cardName = that.data.personLi.name + '-蓝牙-指纹' + (that.data.FpList.length + 1) + pzname = '蓝牙-指纹' + (that.data.FpList.length + 1) + } var str = { // cardId: this.personInfo.cardId, imei: that.data.deviceinfo.imei, pzname: pzname, password: '', - fingerprintAlias:that.data.radioDetil, + fingerprintAlias: that.data.radioDetil, userTelephone: JSON.parse(that.data.personLi.info).userTelephone, operateMode: 16, userPassword: JSON.parse(that.data.personLi.info).userPassword, passwordStartTime: passwordStartTime, passwordEndTime: passwordEndTime, - index:fingerprintIndex, + index: fingerprintIndex, is: false, - pass:true + pass: true } var data2 = { cardId: that.data.personLi.cardId, @@ -2970,7 +3030,7 @@ Page({ deviceNum: that.data.deviceinfo.deviceNum, type: 1, imei: that.data.deviceinfo.imei, - serial:serialNumber, + serial: serialNumber, startTime: passwordStartTime, endTime: passwordEndTime, status: 1 @@ -2987,10 +3047,10 @@ Page({ data: { deviceNum: that.data.deviceinfo.deviceNum, serialNumber: serialNumber, - index:fingerprintIndex, + index: fingerprintIndex, type: 16, result: 1, - productId:that.data.deviceinfo.manufactureId + productId: that.data.deviceinfo.manufactureId } } WXAPI.addCertificates(datalist).then(res6 => {}) @@ -2999,10 +3059,9 @@ Page({ if (res3.success) { var updatedata = { id: res3.data, - status:1 + status: 1 }; - WXAPI.updateCertificates(updatedata).then((res2) => { - }); + WXAPI.updateCertificates(updatedata).then((res2) => {}); WXAPI.sendCommand(datacom).then(res2 => { if (res2.success) {} }) @@ -3014,7 +3073,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -3022,11 +3081,11 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) - } + } }) break } @@ -3245,7 +3304,7 @@ Page({ case 61: { // that.onAddRfCard() // if (lockModel > 70) { - that.sendAddRfcard() + that.sendAddRfcard() // } else { // wx.showModal({ // title: '提示', @@ -3352,25 +3411,25 @@ Page({ } }) }, - - searchDevicesMethods(){ + + searchDevicesMethods() { var that = this; wx.showLoading({ title: '正在搜索', // mask: true }) this.setData({ - searchClick:false + searchClick: false }) wx.openBluetoothAdapter({ success: function (res) { wx.startBluetoothDevicesDiscovery({ success: function (res) { wx.getBluetoothDevices({ - success: function (res) { - res.devices.map(it=>{ - var status=it.name.indexOf('WSL_') - if(status!=-1){ + success: function (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) @@ -3390,38 +3449,38 @@ Page({ 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){ + if (it.name == that.data.deviceinfo.deviceNum) { app.addDeviceWithDevName(it.name, it) lockDevice = it connectedDeviceId = it.deviceId that.setData({ - isSearch:true + isSearch: true }) that.initBluetooth() } } - } - }) - if(!that.data.isSearch){ - that.searchDevicesMethods() } + }) + if (!that.data.isSearch) { + that.searchDevicesMethods() } + } }) }, - fail:function(res){ + fail: function (res) { wx.hideLoading({ success: (res) => { wx.showToast({ title: res.errMsg, - duration:2000, - icon:'none' + duration: 2000, + icon: 'none' }) }, }) @@ -3434,8 +3493,8 @@ Page({ success: (res) => { wx.showToast({ title: '请打开蓝牙和定位功能', - duration:2000, - icon:'none' + duration: 2000, + icon: 'none' }) }, }) @@ -3447,7 +3506,7 @@ Page({ wx.showLoading({ title: that.data.isJack ? '上电中' : '解锁中', }) - console.log(lockDevice.name,'lockDevice.name0') + console.log(lockDevice.name, 'lockDevice.name0') var bytes = plugin.sendOpenLockP1(lockDevice.name, basecode) console.debug('bytes', bytes) that.sendBytes(bytes) @@ -3458,14 +3517,14 @@ Page({ that.initBluetooth() }, sendBytes(bytes) { - setTimeout(()=> { + setTimeout(() => { wx.writeBLECharacteristicValue({ deviceId: lockDevice.deviceId, serviceId: config.uuid.serviceUuid.toUpperCase(), characteristicId: config.uuid.writeUuid.toUpperCase(), value: bytes, success: function (res) { - + }, }) }, 50) @@ -3479,7 +3538,7 @@ Page({ wx.showToast({ title: '开始时间不能大于结束时间', duration: 2000, - mask:true, + mask: true, icon: 'none' }) return @@ -3492,21 +3551,22 @@ Page({ var deviceinfo = this.data.deviceinfo var info = JSON.parse(this.data.personLi.info) if (deviceinfo.manufactureId == 101) { - - } else if (deviceinfo.manufactureId == 201||deviceinfo.manufactureId == 221) { + + } else if (deviceinfo.manufactureId == 201 || deviceinfo.manufactureId == 221) { var cgInfo = this.data.cgInfo 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 pzname=_this.data.pzname,cardName='' - if(pzname==""){ - pzname='蓝牙-NFC'+(_this.data.NfcList.length+1) - cardName=_this.data.personLi.name+'-蓝牙-NFC'+(_this.data.NfcList.length+1) - }else{ - pzname='蓝牙-'+pzname - cardName=_this.data.personLi.name+'-蓝牙-'+pzname - } + var pzname = _this.data.pzname, + cardName = '' + if (pzname == "") { + pzname = '蓝牙-NFC' + (_this.data.NfcList.length + 1) + cardName = _this.data.personLi.name + '-蓝牙-NFC' + (_this.data.NfcList.length + 1) + } else { + pzname = '蓝牙-' + pzname + cardName = _this.data.personLi.name + '-蓝牙-' + pzname + } var dataPasswod = { code: "zg/cardOperate", data: { @@ -3525,25 +3585,25 @@ Page({ cardName: cardName, } } - console.log(dataPasswod,'dataPasswod') + console.log(dataPasswod, 'dataPasswod') WXAPI.sendCommand(dataPasswod).then(res => { - console.log(res,'resres') + console.log(res, 'resres') if (res.success) { var pwdNo = res.data.index var passwordIndex = res.data.index - var serialNumber=res.data.serialNumber + var serialNumber = res.data.serialNumber pwdNo = pwdNo.toString(16) if (pwdNo.length < 2) { - pwdNo='0'+pwdNo + pwdNo = '0' + pwdNo } var startTime = passwordStartTime.toString(16).toUpperCase() var endTime = passwordEndTime.toString(16).toUpperCase() - info.startTime=startTime - info.endTime=endTime - info.pwdNo = pwdNo - methods.bluetoothOperation_ZH(cgInfo,info,7).then(result=>{ + info.startTime = startTime + info.endTime = endTime + info.pwdNo = pwdNo + methods.bluetoothOperation_ZH(cgInfo, info, 7).then(result => { if (result.status == '00') { - let carNoId=this.processCardNumber(result.cardNo) + let carNoId = this.processCardNumber(result.cardNo) var datacom = { code: "zg/bleSendVoucherReply", data: { @@ -3559,31 +3619,31 @@ Page({ if (res2.success) { var str = { // cardId: this.personInfo.cardId, - pzname:pzname, + pzname: pzname, imei: _this.data.deviceinfo.imei, password: carNoId.toUpperCase(), - blueCardNo:result.cardNo, + blueCardNo: result.cardNo, userTelephone: JSON.parse(_this.data.personLi.info).userTelephone, operateMode: 10, userPassword: JSON.parse(_this.data.personLi.info).userPassword, passwordStartTime: passwordStartTime, passwordEndTime: passwordEndTime, is: false, - roomName:_this.data.deviceinfo.roomName, + roomName: _this.data.deviceinfo.roomName, } var data = { cardId: _this.data.personLi.cardId, content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1 deviceNum: _this.data.deviceinfo.deviceNum, type: 3, - blueCardNo:result.cardNo, + blueCardNo: result.cardNo, imei: _this.data.deviceinfo.imei, serial: serialNumber, startTime: passwordStartTime, endTime: passwordEndTime, }; console.log(data, '添加凭证') - + var datalist = { cardId: _this.data.personLi.cardId, content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1 @@ -3591,17 +3651,16 @@ Page({ startTime: passwordStartTime, endTime: passwordEndTime, }; - WXAPI.addCertificates(datalist).then(res6 => { - console.log(datalist,'NFC',res6) + WXAPI.addCertificates(datalist).then(res6 => { + console.log(datalist, 'NFC', res6) }) WXAPI.addCertificates(data).then(res3 => { if (res3.success) { var updatedata = { id: res3.data, - status:1 + status: 1 }; - WXAPI.updateCertificates(updatedata).then((res2) => { - }); + WXAPI.updateCertificates(updatedata).then((res2) => {}); console.log(res3, '添加凭证成功') _this.getNfc() _this.setData({ @@ -3610,7 +3669,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -3618,7 +3677,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -3630,7 +3689,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -3651,7 +3710,7 @@ Page({ }) }) } - }).catch(err=>{ + }).catch(err => { var datacom = { code: "zg/bleSendVoucherReply", data: { @@ -3669,7 +3728,7 @@ Page({ }) wx.showToast({ title: '添加失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -3678,16 +3737,16 @@ Page({ wx.showToast({ title: res.msg, duration: 2000, - mask:true, + mask: true, icon: 'none' }) } }) - }else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241){ - if(this.data.isSearch){ + } else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) { + if (this.data.isSearch) { wx.hideLoading() this.addRfCard() - }else{ + } else { this.searchDevicesMethods() } } @@ -3709,15 +3768,16 @@ Page({ console.debug('bytes', bytes) that.sendBytes(bytes) }, - addRfcardCertificates(){ + addRfcardCertificates() { var that = this var time1 = new Date(that.data.starttime.replace(/-/g, '/')) var time2 = new Date(that.data.endtime.replace(/-/g, '/')) var passwordStartTime = time1.getTime() / 1000 var passwordEndTime = time2.getTime() / 1000 - var pzname='',cardName=''; - pzname='蓝牙-NFC'+(that.data.passwordList.length+1) - cardName=that.data.personLi.name+'-蓝牙-NFC'+(that.data.passwordList.length+1) + var pzname = '', + cardName = ''; + pzname = '蓝牙-NFC' + (that.data.passwordList.length + 1) + cardName = that.data.personLi.name + '-蓝牙-NFC' + (that.data.passwordList.length + 1) let carNoId = rfCardId var datacom = { code: "ble/bleSendVoucherReply", @@ -3728,39 +3788,39 @@ Page({ type: ADD_NFC_MODE, cardNo: rfCardId.toUpperCase(), result: 1, - productId:that.data.deviceinfo.manufactureId + productId: that.data.deviceinfo.manufactureId } } WXAPI.sendCommand(datacom).then(res2 => { if (res2.success) { var str = { // cardId: this.personInfo.cardId, - pzname:pzname, + pzname: pzname, imei: that.data.deviceinfo.imei, password: carNoId.toUpperCase(), - blueCardNo:rfCardIndex, + blueCardNo: rfCardIndex, userTelephone: JSON.parse(that.data.personLi.info).userTelephone, operateMode: 10, userPassword: JSON.parse(that.data.personLi.info).userPassword, passwordStartTime: passwordStartTime, passwordEndTime: passwordEndTime, is: false, - index:rfCardIndex, - roomName:that.data.deviceinfo.roomName, + index: rfCardIndex, + roomName: that.data.deviceinfo.roomName, } var data2 = { cardId: that.data.personLi.cardId, content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1 deviceNum: that.data.deviceinfo.deviceNum, type: 3, - blueCardNo:carNoId, + blueCardNo: carNoId, imei: that.data.deviceinfo.imei, serial: serialNumber, startTime: passwordStartTime, endTime: passwordEndTime, }; console.log(data2, '添加凭证') - + var datalist = { cardId: that.data.personLi.cardId, content: JSON.stringify(str), //operateMode:NFC-10、把人员添加到凭证-1 @@ -3768,17 +3828,16 @@ Page({ startTime: passwordStartTime, endTime: passwordEndTime, }; - WXAPI.addCertificates(datalist).then(res6 => { - console.log(datalist,'NFC',res6) + WXAPI.addCertificates(datalist).then(res6 => { + console.log(datalist, 'NFC', res6) }) WXAPI.addCertificates(data2).then(res3 => { if (res3.success) { var updatedata = { id: res3.data, - status:1 + status: 1 }; - WXAPI.updateCertificates(updatedata).then((res2) => { - }); + WXAPI.updateCertificates(updatedata).then((res2) => {}); console.log(res3, '添加凭证成功') that.getNfc() that.setData({ @@ -3787,7 +3846,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -3795,22 +3854,22 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) } }) - }else{ + } else { wx.showToast({ title: res2.message, - duration:2000, - icon:'none' + duration: 2000, + icon: 'none' }) } }) }, - sendAddRfcard(){ + sendAddRfcard() { var that = this var info = JSON.parse(this.data.personLi.info) let deviceinfo = this.data.deviceinfo @@ -3818,19 +3877,24 @@ Page({ var time2 = new Date(that.data.endtime.replace(/-/g, '/')) var passwordStartTime = time1.getTime() / 1000 var passwordEndTime = time2.getTime() / 1000 - var pzname='',cardName='' - pzname='蓝牙-NFC'+(that.data.NfcList.length+1) - cardName=that.data.personLi.name+'-蓝牙-NFC'+(that.data.NfcList.length+1) + var pzname = '', + cardName = '' + if(that.data.pzname == ''){ + pzname = '蓝牙-NFC' + (that.data.NfcList.length + 1) + }else{ + pzname = '蓝牙-NFC' + that.data.pzname + } + cardName = that.data.personLi.name + '-蓝牙-NFC' + (that.data.NfcList.length + 1) rfCardId = randomMethods() var dataPasswod = { code: "lwj/cardOperate", data: { lockerId: deviceinfo.deviceNum, lockerUserId: info.userId, - startTime:passwordStartTime, - endTime:passwordEndTime, + startTime: passwordStartTime, + endTime: passwordEndTime, order: 6210, - operateMode:10, + operateMode: 10, action: 1, cardNo: rfCardId, type: 10, @@ -3844,19 +3908,19 @@ Page({ var pwdNo = res.data.index serialNumber = res.data.serialNumber rfCardIndex = pwdNo - setTimeout(()=>{ + setTimeout(() => { that.onAddRfCard() - },500) + }, 500) } }) }, - processCardNumber(cardNo){ - var str1=cardNo.substr(0,8) - var str2=cardNo.substr(8,8) - var num=str2.split("") - var status=num.every(item=> item==0) - console.log(status,num,'numnum',str1,str2) - if(status){ + processCardNumber(cardNo) { + var str1 = cardNo.substr(0, 8) + var str2 = cardNo.substr(8, 8) + var num = str2.split("") + var status = num.every(item => item == 0) + console.log(status, num, 'numnum', str1, str2) + if (status) { var bbb = str1.split("") var a, b; var aIndex = 0; @@ -3864,20 +3928,20 @@ Page({ var arr = []; bbb.forEach((str, index) => { if (index % 2 === 0) { - a = str; - aIndex += 1 + a = str; + aIndex += 1 } else { - b = str - bIndex += 1 + b = str + bIndex += 1 } - if (a&&b&&(bIndex-aIndex === 1)) { - arr.push(a+b) + if (a && b && (bIndex - aIndex === 1)) { + arr.push(a + b) } }); console.log(arr) return arr.join("") - }else{ - var ll=str1+str2 + } else { + var ll = str1 + str2 return ll } }, @@ -3890,20 +3954,20 @@ Page({ wx.showToast({ title: '开始时间不能大于结束时间', duration: 2000, - mask:true, + mask: true, icon: 'none' }) return } - if(this.data.radioDetil==''){ + if (this.data.radioDetil == '') { wx.showToast({ title: '请选择是那个指纹?', - mask:true, + mask: true, duration: 2000, icon: 'none' }) return - } + } wx.showLoading({ title: '正在添加指纹', mask: true @@ -3932,21 +3996,22 @@ Page({ _this.startconnect() } }) - - } else if (deviceinfo.manufactureId == 201||deviceinfo.manufactureId == 221) { + + } else if (deviceinfo.manufactureId == 201 || deviceinfo.manufactureId == 221) { var cgInfo = this.data.cgInfo 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 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.FpList.length+1) - pzname='蓝牙-指纹'+(_this.data.FpList.length+1) - } + 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.FpList.length + 1) + pzname = '蓝牙-指纹' + (_this.data.FpList.length + 1) + } var dataPasswod = { code: "zg/addFingerPrint", data: { @@ -3970,11 +4035,11 @@ Page({ if (res.success) { var startTime = passwordStartTime.toString(16).toUpperCase() var endTime = passwordEndTime.toString(16).toUpperCase() - info.startTime=startTime - info.endTime=endTime - methods.bluetoothOperation_ZH(cgInfo,info,5).then(result=>{ + info.startTime = startTime + info.endTime = endTime + methods.bluetoothOperation_ZH(cgInfo, info, 5).then(result => { if (result.status == '00' && result.completeFlag == '01') { - console.log(result,'callback2callback2') + console.log(result, 'callback2callback2') var datacom = { code: "zg/bleSendVoucherReply", data: { @@ -3991,14 +4056,14 @@ Page({ imei: _this.data.deviceinfo.imei, pzname: pzname, password: '', - fingerprintAlias:_this.data.radioDetil, + fingerprintAlias: _this.data.radioDetil, userTelephone: JSON.parse(_this.data.personLi.info).userTelephone, operateMode: 16, userPassword: JSON.parse(_this.data.personLi.info).userPassword, passwordStartTime: passwordStartTime, passwordEndTime: passwordEndTime, is: false, - pass:true + pass: true } var data = { cardId: _this.data.personLi.cardId, @@ -4024,10 +4089,9 @@ Page({ if (res3.success) { var updatedata = { id: res3.data, - status:1 + status: 1 }; - WXAPI.updateCertificates(updatedata).then((res2) => { - }); + WXAPI.updateCertificates(updatedata).then((res2) => {}); WXAPI.sendCommand(datacom).then(res2 => { if (res2.success) {} }) @@ -4039,7 +4103,7 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加成功', - mask:true, + mask: true, icon: 'none', duration: 2000 }) @@ -4047,20 +4111,20 @@ Page({ wx.hideLoading() wx.showToast({ title: '添加失败', - mask:true, + mask: true, icon: 'none', duration: 2000 }) } }) } - }).catch(err=>{ + }).catch(err => { var datacom = { code: "zg/bleSendVoucherReply", data: { lockerId: deviceinfo.deviceNum, serialNumber: res.data.serialNumber, - index:0, + index: 0, type: 16, result: 0 } @@ -4069,13 +4133,13 @@ Page({ if (res2.success) {} }) }) - } else { + } else { var datacom = { code: "zg/bleSendVoucherReply", data: { lockerId: deviceinfo.deviceNum, serialNumber: res.data.serialNumber, - index:0, + index: 0, type: 16, result: 0 } @@ -4086,13 +4150,13 @@ Page({ wx.showToast({ title: res.msg, duration: 2000, - mask:true, + mask: true, icon: 'none' }) } }) - }else if(deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241){ - if(this.data.isSearch){ + } else if (deviceinfo.manufactureId == 1201 || deviceinfo.manufactureId == 1241) { + if (this.data.isSearch) { // fingerprintIndex = 1 // serialNumber = 1686309639840 // this.onAddFingerprint() @@ -4101,19 +4165,20 @@ Page({ var time2 = new Date(_this.data.datetimerange[1].replace(/-/g, '/')) var passwordStartTime = time1.getTime() / 1000 var passwordEndTime = time2.getTime() / 1000 - 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.FpList.length+1) - pzname='蓝牙-指纹'+(_this.data.FpList.length+1) - } + 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.FpList.length + 1) + pzname = '蓝牙-指纹' + (_this.data.FpList.length + 1) + } var dataPasswod = { code: "lwj/fpOperate", data: { lockerId: deviceinfo.deviceNum, - action:1, + action: 1, lockerUserId: info.userPassword, fpData: '', operateMode: 16, @@ -4126,13 +4191,13 @@ Page({ } } WXAPI.sendCommand(dataPasswod).then(res => { - if(res.success){ + if (res.success) { fingerprintIndex = res.data.index serialNumber = res.data.serialNumber this.onAddFingerprint() } }) - }else{ + } else { this.searchDevicesMethods() } } @@ -4187,12 +4252,12 @@ Page({ cardId: this.data.personLi.cardId, deviceNum: this.data.deviceinfo.deviceNum, types: "4", - inStatus:'0,1,702' + inStatus: '0,1,702' }) } console.log(data) WXAPI.getCertificates(data).then(res => { - var dataOne=util.zlib_unzip(res.data) + var dataOne = util.zlib_unzip(res.data) if (res.success) { dataOne.map(li => { li['pzname'] = JSON.parse(li.content).pzname @@ -4212,13 +4277,13 @@ Page({ cardId: this.data.personLi.cardId, deviceNum: this.data.deviceinfo.deviceNum, types: "3", - inStatus:'0,1,702' + inStatus: '0,1,702' }) } WXAPI.getCertificates(data).then(res => { console.log(res) - var dataOne=util.zlib_unzip(res.data) - console.log(dataOne) + var dataOne = util.zlib_unzip(res.data) + console.log(dataOne) if (res.success) { dataOne.map(li => { li['pzname'] = JSON.parse(li.content).pzname @@ -4238,16 +4303,16 @@ Page({ cardId: this.data.personLi.cardId, deviceNum: this.data.deviceinfo.deviceNum, types: "1", - inStatus:'0,1,702' + inStatus: '0,1,702' }) } WXAPI.getCertificates(data).then(res => { - var dataOne=util.zlib_unzip(res.data) + var dataOne = util.zlib_unzip(res.data) if (res.success) { dataOne.map(li => { li['pzname'] = JSON.parse(li.content).pzname li['password'] = '' - li['fingerprintAlias'] = JSON.parse(li.content).fingerprintAlias || '' + li['fingerprintAlias'] = JSON.parse(li.content).fingerprintAlias || '' }) this.setData({ FpList: dataOne @@ -4263,11 +4328,11 @@ Page({ cardId: this.data.personLi.cardId, deviceNum: this.data.deviceinfo.deviceNum, types: "2", - inStatus:'0,1,702' + inStatus: '0,1,702' }) } WXAPI.getCertificates(data).then(res => { - var dataOne=util.zlib_unzip(res.data) + var dataOne = util.zlib_unzip(res.data) if (res.success) { dataOne.map(li => { li['pzname'] = JSON.parse(li.content).pzname @@ -4305,12 +4370,12 @@ Page({ */ onUnload: function () { if (isConnected) { - console.log(connectedDeviceId,'connectedDeviceId') + console.log(connectedDeviceId, 'connectedDeviceId') wx.closeBLEConnection({ deviceId: connectedDeviceId, success: function (res) { isConnected = false - app.globalData.isConnected =false + app.globalData.isConnected = false }, }) } diff --git a/pages/openLockLog/openLockLog.js b/pages/openLockLog/openLockLog.js index 4e87553..0ef4dcd 100644 --- a/pages/openLockLog/openLockLog.js +++ b/pages/openLockLog/openLockLog.js @@ -271,6 +271,7 @@ Page({ q: JSON.stringify(q) } WXAPI.getOpenRecord(data1).then(res=>{ + console.log(res); if (res.success) { if (res.data.length<10) { this.data.stoppull = true