const WXAPI = require('./request')
|
|
import moment from 'moment'
|
|
import ICINLocker from "./equipment.js"
|
|
/**
|
|
* @param {Function} fn 防抖函数
|
|
* @param {Number} delay 延迟时间
|
|
*/
|
|
|
|
export default class utils {
|
|
// 下发凭证
|
|
static putCarfidzgAdd(drawerRow,resultArr, row) {
|
|
var data = {};
|
|
var userTelephone = JSON.parse(row.content).userTelephone;
|
|
var userPassword = JSON.parse(row.content).userPassword;
|
|
var startTime = row.startTime
|
|
var endTime = row.endTime
|
|
var passwordStartTime =startTime
|
|
var passwordEndTime = endTime
|
|
|
|
if (row.type == 1) {
|
|
var fpId = new Date();
|
|
var fingerprint1 = JSON.parse(row.content).fingerprint;
|
|
var str = {
|
|
imei: resultArr.imei,
|
|
deviceNum: resultArr.deviceNum,
|
|
userTelephone: userTelephone,
|
|
userPassword: userPassword,
|
|
password: JSON.parse(row.content).password,
|
|
length: fingerprint1.length / 2,
|
|
fpTimeId: fpId.getTime(),
|
|
operateMode: 16,
|
|
order: 6216,
|
|
fingerprint: fingerprint1,
|
|
passwordStartTime: passwordStartTime,
|
|
passwordEndTime: passwordEndTime,
|
|
pzname:JSON.parse(row.content).pzname
|
|
};
|
|
var data3 = {
|
|
lockerId: resultArr.deviceNum,
|
|
imei: resultArr.imei,
|
|
order: 6216,
|
|
lockerUserId: JSON.parse(drawerRow.info).userPassword,
|
|
keyId: JSON.parse(drawerRow.info).userPassword,
|
|
fingerType: 0,
|
|
file: fingerprint1,
|
|
cardName: row.name+'-'+JSON.parse(row.content).pzname,
|
|
roomName: resultArr.roomName,
|
|
startTime: passwordStartTime,
|
|
endTime: passwordEndTime
|
|
};
|
|
ICINLocker.addFingerPrints(data3.lockerId, data3.imei, data3.lockerUserId, data3.fingerType, data3
|
|
.file, data3.startTime, data3.endTime, data3.cardName, data3.roomName, (callback) => {
|
|
if (callback.success) {
|
|
var data = {
|
|
id: row.id,
|
|
serial: callback.data.serialNumber,
|
|
};
|
|
WXAPI.updateCertificates(data).then((res) => {
|
|
wx.showToast({
|
|
title: "下发成功",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
})
|
|
} else if (row.type == 2) {
|
|
if (JSON.parse(row.content).password.length != 16) {
|
|
wx.showToast({
|
|
title: "卡格式错误,请重新录入",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
return
|
|
}
|
|
var str = {
|
|
imei: resultArr.imei,
|
|
userTelephone: userTelephone,
|
|
cardId: row.cardId,
|
|
userPassword: userPassword,
|
|
password: JSON.parse(row.content).password,
|
|
operateMode: 13,
|
|
order: 6213,
|
|
passwordStartTime: passwordStartTime,
|
|
passwordEndTime: passwordEndTime,
|
|
pzname:JSON.parse(row.content).pzname,
|
|
is: false,
|
|
};
|
|
var data3 = {
|
|
lockerId: resultArr.deviceNum,
|
|
imei: resultArr.imei,
|
|
lockerUserId: userPassword,
|
|
keyId: userPassword,
|
|
action: 1,
|
|
taskStatus: 1,
|
|
order: 6210,
|
|
startTime: passwordStartTime,
|
|
endTime: passwordEndTime,
|
|
cardType: 36,
|
|
cardName: row.name+'-'+JSON.parse(row.content).pzname,
|
|
roomName: row.roomName,
|
|
cardNo: JSON.parse(row.content).password
|
|
};
|
|
ICINLocker.RfCardRegister(data3.lockerId, data3.imei, data3.keyId, data3.action, data3.taskStatus,
|
|
data3.cardNo, data3.cardType, data3.startTime,
|
|
data3.endTime, data3.order, data3.cardName, data3.roomName, (callback) => {
|
|
if (callback.success) {
|
|
var data = {
|
|
id: row.id,
|
|
serial: callback.data.serialNumber,
|
|
};
|
|
WXAPI.updateCertificates(data).then((res) => {
|
|
wx.showToast({
|
|
title: "下发成功",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
})
|
|
} else if (row.type == 3) {
|
|
if (JSON.parse(row.content).password.length != 8) {
|
|
wx.showToast({
|
|
title: "卡格式错误,请重新录入",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
return
|
|
}
|
|
var str = {
|
|
imei: resultArr.imei,
|
|
userTelephone: userTelephone,
|
|
cardId: row.cardId,
|
|
userPassword: userPassword,
|
|
password: JSON.parse(row.content).password,
|
|
operateMode: 10,
|
|
order: 6210,
|
|
passwordStartTime: passwordStartTime,
|
|
passwordEndTime: passwordEndTime,
|
|
pzname:JSON.parse(row.content).pzname,
|
|
is: false,
|
|
};
|
|
var data3 = {
|
|
lockerId: resultArr.deviceNum,
|
|
lockerUserId: userPassword,
|
|
keyId: userPassword,
|
|
imei: resultArr.imei,
|
|
action: 1,
|
|
taskStatus: 1,
|
|
order: 6210,
|
|
startTime: passwordStartTime,
|
|
endTime: passwordEndTime,
|
|
cardType: 50,
|
|
cardName: row.name+'-'+JSON.parse(row.content).pzname,
|
|
roomName: row.roomName,
|
|
cardNo: JSON.parse(row.content).password
|
|
};
|
|
ICINLocker.RfCardRegister(data3.lockerId, data3.imei, data3.keyId, data3.action, data3.taskStatus,
|
|
data3.cardNo, data3.cardType, data3.startTime,
|
|
data3.endTime, data3.order, data3.cardName, data3.roomName, (callback) => {
|
|
if (callback.success) {
|
|
var data = {
|
|
id: row.id,
|
|
serial: callback.data.serialNumber,
|
|
};
|
|
WXAPI.updateCertificates(data).then((res) => {
|
|
wx.showToast({
|
|
title: "下发成功",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
})
|
|
} else if (row.type == 4) {
|
|
str = {
|
|
imei: resultArr.imei,
|
|
userTelephone: userTelephone,
|
|
cardId: row.cardId,
|
|
userPassword: userPassword,
|
|
password: JSON.parse(row.content).password,
|
|
operateMode: 7,
|
|
order: 6207,
|
|
passwordStartTime: passwordStartTime,
|
|
passwordEndTime: passwordEndTime,
|
|
pzname:JSON.parse(row.content).pzname,
|
|
is: false,
|
|
cardName: row.name+'-'+JSON.parse(row.content).pzname,
|
|
roomName: row.roomName
|
|
};
|
|
var data3 = {
|
|
lockerId: resultArr.deviceNum,
|
|
imei: resultArr.imei,
|
|
order: 6207,
|
|
passwordCount: 255,
|
|
lockerUserId: userPassword,
|
|
keyId: userPassword,
|
|
startTime: passwordStartTime,
|
|
endTime: passwordEndTime,
|
|
action: 1,
|
|
password: JSON.parse(row.content).password,
|
|
cardName: row.name+'-'+JSON.parse(row.content).pzname,
|
|
roomName: row.roomName
|
|
};
|
|
ICINLocker.addForeverPassword(data3.lockerId, data3.imei, data3.keyId, data3.action, data3.password,
|
|
data3.passwordCount, data3.startTime, data3.endTime, data3.order, data3.cardName, data3
|
|
.roomName, (callback) => {
|
|
if (callback.success) {
|
|
var data = {
|
|
id: row.id,
|
|
serial: callback.data.serialNumber,
|
|
};
|
|
WXAPI.updateCertificates(data).then((res) => {
|
|
wx.showToast({
|
|
title: "下发成功",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
});
|
|
|
|
} else {
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
})
|
|
|
|
}
|
|
}
|
|
// 下发凭证
|
|
static putCarfidAdd(resultArr, row) {
|
|
var data = {};
|
|
var userTelephone = JSON.parse(row.content).userTelephone;
|
|
var userPassword = JSON.parse(row.content).userPassword;
|
|
var startTime = row.startTime
|
|
var endTime = row.endTime
|
|
var passwordEndTime = moment(endTime*1000).format("YYYYMMDDHHmmss");
|
|
var passwordStartTime = moment(startTime*1000).format("YYYYMMDDHHmmss");
|
|
if (row.type == 1) {
|
|
var fpId = new Date();
|
|
var fingerprint = JSON.parse(row.content).fingerprint;
|
|
var str = {
|
|
imei: resultArr.imei,
|
|
deviceNum: resultArr.deviceNum,
|
|
userTelephone: userTelephone,
|
|
userPassword: userPassword,
|
|
password: JSON.parse(row.content).password,
|
|
length: fingerprint.length / 2,
|
|
fpTimeId: fpId.getTime(),
|
|
operateMode: 16,
|
|
order: 6216,
|
|
fingerprint: fingerprint,
|
|
passwordStartTime: passwordStartTime,
|
|
passwordEndTime: passwordEndTime,
|
|
cardName: row.name+'-'+JSON.parse(row.content).pzname,
|
|
roomName: resultArr.roomName,
|
|
};
|
|
ICINLocker.LDAddFingerPrints(str.deviceNum, str.imei, str.userTelephone, str.userPassword, str
|
|
.password, str.passwordStartTime, str.passwordEndTime, str.operateMode, str.order, str.length,
|
|
str.fpTimeId, str.fingerprint, str.cardName, str.roomName, (callback) => {
|
|
if (callback.success) {
|
|
var datafid = {
|
|
id: row.id,
|
|
serial: callback.data.serialNumber,
|
|
};
|
|
WXAPI.updateCertificates(datafid).then((res) => {
|
|
if (res.success) {
|
|
wx.showToast({
|
|
title: "下发成功",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: "下发失败",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
})
|
|
return false
|
|
} else if (row.type == 2) {
|
|
data = {
|
|
imei: resultArr.imei,
|
|
deviceNum: resultArr.deviceNum,
|
|
userTelephone: userTelephone,
|
|
cardId: row.cardId,
|
|
userPassword: userPassword,
|
|
password: JSON.parse(row.content).password,
|
|
operateMode: 13,
|
|
order: 6213,
|
|
passwordStartTime: passwordStartTime,
|
|
passwordEndTime: passwordEndTime,
|
|
is: false,
|
|
cardName: row.name+'-'+JSON.parse(row.content).pzname,
|
|
roomName: resultArr.roomName,
|
|
};
|
|
} else if (row.type == 3) {
|
|
data = {
|
|
imei: resultArr.imei,
|
|
deviceNum: resultArr.deviceNum,
|
|
userTelephone: userTelephone,
|
|
cardId: row.cardId,
|
|
userPassword: userPassword,
|
|
password: JSON.parse(row.content).password,
|
|
operateMode: 10,
|
|
order: 6210,
|
|
passwordStartTime: passwordStartTime,
|
|
passwordEndTime: passwordEndTime,
|
|
is: false,
|
|
cardName: row.name+'-'+JSON.parse(row.content).pzname,
|
|
roomName: resultArr.roomName,
|
|
};
|
|
} else if (row.type == 4) {
|
|
data = {
|
|
imei: resultArr.imei,
|
|
deviceNum: resultArr.deviceNum,
|
|
userTelephone: userTelephone,
|
|
cardId: row.cardId,
|
|
userPassword: userPassword,
|
|
password: JSON.parse(row.content).password,
|
|
operateMode: 7,
|
|
order: 6207,
|
|
passwordStartTime: passwordStartTime,
|
|
passwordEndTime: passwordEndTime,
|
|
is: false,
|
|
cardName: row.name+'-'+JSON.parse(row.content).pzname,
|
|
roomName: resultArr.roomName,
|
|
};
|
|
}
|
|
ICINLocker.LDRfCardRegister(data.deviceNum, data.imei, data.userTelephone, data.userPassword, data
|
|
.password, data
|
|
.passwordStartTime, data.passwordEndTime, data.operateMode, data.order, data.cardName, data
|
|
.roomName, (
|
|
callback) => {
|
|
if (callback.success) {
|
|
var datafid = {
|
|
id: row.id,
|
|
serial: callback.data.serialNumber,
|
|
};
|
|
WXAPI.updateCertificates(datafid).then((res) => {
|
|
if (res.success) {
|
|
wx.showToast({
|
|
title: "下发成功",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: "下发失败",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
})
|
|
}
|
|
static getfiId1(row, callback) {
|
|
var data = {
|
|
q: JSON.stringify({
|
|
serial: row.serial,
|
|
}),
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
};
|
|
WXAPI.getDeviceResult(data).then((res) => {
|
|
callback(res.data.list);
|
|
});
|
|
}
|
|
static putCarfid(resultArr, row, endTime, startTime) {
|
|
var data = {};
|
|
var userTelephone = JSON.parse(row.content).userTelephone;
|
|
var userPassword = JSON.parse(row.content).userPassword;
|
|
var content = JSON.parse(row.content);
|
|
var passwordEndTime = moment(endTime).format("YYYYMMDDHHmmss");
|
|
var passwordStartTime = moment(startTime).format("YYYYMMDDHHmmss");
|
|
if (row.type == 1) {
|
|
this.getfiId(row, function(data) {
|
|
if (data.length > 0) {
|
|
if (data.length > 0) {
|
|
var fpid = "";
|
|
fpid =
|
|
data[0].face.toString(16).length != 2 ?
|
|
"0" + data[0].face.toString(16) :
|
|
data[0].face;
|
|
var str = {
|
|
imei: resultArr.imei,
|
|
deviceNum: resultArr.deviceNum,
|
|
password: fpid,
|
|
operateMode: 17,
|
|
order: 6217,
|
|
userPassword: userPassword,
|
|
userTelephone: userTelephone,
|
|
passwordStartTime: passwordEndTime,
|
|
passwordEndTime: passwordStartTime,
|
|
is: false,
|
|
cardName: row.name,
|
|
roomName: resultArr.roomName,
|
|
};
|
|
WXAPI.getDeviceOperateUserInfo(str).then((res1) => {
|
|
if (res1.success) {
|
|
content.passwordStartTime = str.passwordStartTime;
|
|
content.passwordEndTime = str.passwordEndTime;
|
|
var updatedata = {
|
|
id: row.id,
|
|
content: JSON.stringify(content),
|
|
serial: res1.data.serialNumber,
|
|
status: 0,
|
|
startTime: startTime / 1000,
|
|
endTime: endTime / 1000
|
|
};
|
|
WXAPI.updateCertificates(updatedata)
|
|
.then(
|
|
(res2) => {
|
|
wx.showToast({
|
|
title: "修改成功",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
);
|
|
} else {
|
|
wx.showToast({
|
|
title: "修改失败",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
});
|
|
}
|
|
}
|
|
})
|
|
return false
|
|
} else if (row.type == 2) {
|
|
data = {
|
|
imei: resultArr.imei,
|
|
deviceNum: resultArr.deviceNum,
|
|
userTelephone: userTelephone,
|
|
cardId: row.cardId,
|
|
userPassword: userPassword,
|
|
password: JSON.parse(row.content).password,
|
|
operateMode: 14,
|
|
order: 6214,
|
|
passwordStartTime: passwordStartTime,
|
|
passwordEndTime: passwordEndTime,
|
|
is: false,
|
|
cardName: row.name,
|
|
roomName: row.roomName
|
|
};
|
|
} else if (row.type == 3) {
|
|
data = {
|
|
imei: resultArr.imei,
|
|
deviceNum: resultArr.deviceNum,
|
|
userTelephone: userTelephone,
|
|
cardId: row.cardId,
|
|
userPassword: userPassword,
|
|
password: JSON.parse(row.content).password,
|
|
operateMode: 11,
|
|
order: 6211,
|
|
passwordStartTime: passwordStartTime,
|
|
passwordEndTime: passwordEndTime,
|
|
is: false,
|
|
cardName: row.name,
|
|
roomName: row.roomName
|
|
};
|
|
} else if (row.type == 4) {
|
|
data = {
|
|
imei: resultArr.imei,
|
|
deviceNum: resultArr.deviceNum,
|
|
userTelephone: userTelephone,
|
|
cardId: row.cardId,
|
|
userPassword: userPassword,
|
|
password: JSON.parse(row.content).password,
|
|
operateMode: 8,
|
|
order: 6208,
|
|
passwordStartTime: passwordStartTime,
|
|
passwordEndTime: passwordEndTime,
|
|
is: false,
|
|
cardName: row.name,
|
|
roomName: row.roomName
|
|
};
|
|
}
|
|
ICINLocker.LDRfCardRegister(data.deviceNum, data.imei, data.userTelephone, data.userPassword, data
|
|
.password, data
|
|
.passwordStartTime, data.passwordEndTime, data.operateMode, data.order, data.cardName, data
|
|
.roomName, (
|
|
callback) => {
|
|
if (callback.success) {
|
|
var datafid = {
|
|
id: row.id,
|
|
content: JSON.stringify(data), //operateMode:NFC-10、把人员添加到凭证-1
|
|
status: 0,
|
|
serial: callback.data.serialNumber,
|
|
startTime: moment(startTime).valueOf() / 1000,
|
|
endTime: moment(endTime).valueOf() / 1000,
|
|
};
|
|
WXAPI.updateCertificates(datafid).then((res) => {
|
|
if (res.success) {
|
|
wx.showToast({
|
|
title: "下发成功",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: "下发失败",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
})
|
|
}
|
|
// 下发凭证
|
|
static putCarfidzg(resultArr, row, endTime, startTime) {
|
|
var data = {};
|
|
var userTelephone = JSON.parse(row.content).userTelephone;
|
|
var userPassword = JSON.parse(row.content).userPassword;
|
|
var content = JSON.parse(row.content);
|
|
var passwordEndTime = moment(startTime).valueOf() / 1000;
|
|
var passwordStartTime = moment(endTime).valueOf() / 1000;
|
|
if (row.type == 1) {
|
|
this.getfiId1(row, function(data) {
|
|
if (data.length > 0) {
|
|
var fpid = "";
|
|
fpid =
|
|
data[0].face.toString(16).length != 2 ?
|
|
"0" + data[0].face.toString(16) :
|
|
data[0].face;
|
|
var pwd = JSON.parse(row.content).userPassword
|
|
ICINLocker.modifyFingerPrints(resultArr.deviceNum, resultArr.imei, pwd, 3,
|
|
fpid, 0, passwordStartTime, passwordEndTime, row.name, resultArr.roomName, (callback) => {
|
|
if (callback.success) {
|
|
var str1 = JSON.parse(row.content);
|
|
str1.fpTimeId = callback.data.serialNumber;
|
|
str1.passwordStartTime = passwordStartTime;
|
|
str1.passwordEndTime = passwordEndTime;
|
|
var updatedata = {
|
|
id: row.id,
|
|
content: JSON.stringify(str1),
|
|
serial: callback.data.serialNumber,
|
|
status: 0,
|
|
startTime: passwordStartTime,
|
|
endTime: passwordEndTime
|
|
};
|
|
WXAPI.updateCertificates(updatedata)
|
|
.then(
|
|
(res2) => {
|
|
wx.showToast({
|
|
title: "下发成功",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
});
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: "修改失败",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
})
|
|
} else if (row.type == 2) {
|
|
var idcard = ''
|
|
if (content.password.length == 16) {
|
|
idcard = content.password
|
|
} else {
|
|
idcard = dec2hex(content.password);
|
|
}
|
|
var userid = JSON.parse(row.content).userPassword
|
|
if (idcard.length != 16) {
|
|
wx.showToast({
|
|
title: "卡格式错误,请重新录入",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
return
|
|
}
|
|
ICINLocker.RfCardRegister(resultArr.deviceNum, resultArr.imei, userid, 3, 1, idcard
|
|
.toUpperCase(), 36, passwordStartTime, passwordEndTime, 6211, row.name, resultArr
|
|
.roomName, (callback) => {
|
|
if (callback.success) {
|
|
var str = JSON.parse(row.content)
|
|
str['password'] = idcard.toUpperCase()
|
|
var updatedata = {
|
|
id: row.id,
|
|
content: JSON.stringify(str),
|
|
serial: callback.data.serialNumber,
|
|
startTime: passwordStartTime,
|
|
endTime: passwordEndTime
|
|
};
|
|
WXAPI.updateCertificates(updatedata).then((res) => {
|
|
wx.showToast({
|
|
title: "下发成功",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
|
|
});
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
})
|
|
} else if (row.type == 3) {
|
|
var nfc = "";
|
|
if (content.password.length == 8) {
|
|
nfc = content.password
|
|
} else {
|
|
nfc = dec2hex(content.password);
|
|
}
|
|
var userid = JSON.parse(row.content).userPassword
|
|
if (nfc.length != 8) {
|
|
wx.showToast({
|
|
title: "卡格式错误,请重新录入",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
return
|
|
}
|
|
ICINLocker.RfCardRegister(resultArr.deviceNum, resultArr.imei, userid, 3, 1, nfc.toUpperCase(),
|
|
50, passwordStartTime, passwordEndTime, 6211, row.name, resultArr.roomName, (
|
|
callback) => {
|
|
if (callback.success) {
|
|
var str = JSON.parse(row.content)
|
|
str['password'] = nfc.toUpperCase()
|
|
str['pzname'] = that.certificatesContent.pzname
|
|
var updatedata = {
|
|
id: row.id,
|
|
content: JSON.stringify(str),
|
|
serial: callback.data.serialNumber,
|
|
startTime: passwordStartTime,
|
|
endTime: passwordEndTime
|
|
};
|
|
WXAPI.updateCertificates(updatedata).then((res) => {
|
|
wx.showToast({
|
|
title: "下发成功",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
});
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
})
|
|
} else if (row.type == 4) {
|
|
var pwd = content.password
|
|
var userid = JSON.parse(row.content).userPassword
|
|
ICINLocker.addForeverPassword(resultArr.deviceNum, resultArr.imei, userid, 3, pwd, 255,
|
|
passwordStartTime, passwordEndTime, 6208, row.name, resultArr.roomName, (
|
|
callback) => {
|
|
if (callback.success) {
|
|
var data1 = JSON.parse(row.content)
|
|
data1['password'] = content.password
|
|
var updatedata = {
|
|
id: row.id,
|
|
content: JSON.stringify(data1),
|
|
serial: callback.data.serialNumber,
|
|
startTime: passwordStartTime,
|
|
endTime: passwordEndTime
|
|
};
|
|
WXAPI.updateCertificates(updatedata).then((res) => {
|
|
wx.showToast({
|
|
title: "下发成功",
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
});
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: callback.msg,
|
|
duration:2000,
|
|
icon:"nonoe"
|
|
})
|
|
}
|
|
})
|
|
|
|
}
|
|
}
|
|
static timeTotimeimp(obj) {
|
|
var year = obj.substr(0, 4)
|
|
var month = obj.substr(4, 2)
|
|
var day = obj.substr(6, 2)
|
|
var hours = obj.substr(8, 2)
|
|
var min = obj.substr(8, 2)
|
|
var miao = obj.substr(10, 2)
|
|
var hm = obj.substr(12, 2)
|
|
var str = year + "-" + month + "-" + day + " " + hours + ":" + min + ":" + miao
|
|
var time = new Date(str)
|
|
var time1 = time.getTime()
|
|
return time1 / 1000;
|
|
}
|
|
// 格式化时间
|
|
static formatTime(time, key) {
|
|
var time1 = JSON.stringify(time)
|
|
var text = ''
|
|
if (time1.length == 14) {
|
|
text = moment(this.timeTotimeimp(time1) * 1000).format('YYYY年MM月DD日 HH:mm:ss')
|
|
} else if (time1.length == 13) {
|
|
text = moment(time).format('YYYY年MM月DD日 HH:mm:ss')
|
|
} else if (time1.length == 10) {
|
|
text = moment(time * 1000).format('YYYY年MM月DD日 HH:mm:ss')
|
|
}
|
|
return text;
|
|
}
|
|
// 去重
|
|
static uniqueArray(array, key) {
|
|
var result = [array[0]];
|
|
for (var i = 1; i < array.length; i++) {
|
|
var item = array[i];
|
|
var repeat = false;
|
|
for (var j = 0; j < result.length; j++) {
|
|
if (item[key] == result[j][key]) {
|
|
repeat = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!repeat) {
|
|
result.push(item);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
// 生成树形数据结构
|
|
static ztreeToElementTree(data, config) {
|
|
var id = 'id' // 定义ztree数据存储id(自身的id)的key值,可以自定义但一般都是id、pid这种
|
|
var pid = 'pid' // 定义ztree数据存储pid(父id)的key值
|
|
var children = 'children' // 定义生成的element tree存储子节点的key,可以在element中规定defaultProps: {children: 'children'}
|
|
var idMap = {} // 将原始数据转化为以id为key的map
|
|
var elementTree = [] // 输出的element tree数据
|
|
data.forEach(item => {
|
|
item['value'] = item.id
|
|
item['label'] = item.name
|
|
idMap[item.id] = item
|
|
})
|
|
data.forEach(item => {
|
|
// debugger
|
|
if (idMap[item.pid] != idMap[item.id] && idMap[item.pid]) { // 该item项有爸爸,放到对应的父节点下
|
|
!idMap[item.pid].hasOwnProperty(children) && (idMap[item.pid][children] = [])
|
|
idMap[item.pid][children].push(item)
|
|
} else { // 根节点
|
|
elementTree.push(item)
|
|
}
|
|
});
|
|
return elementTree
|
|
}
|
|
// 根据选择的父级id,获取所有子级id
|
|
static getChild(nodes, item, arr) {
|
|
for (let el of nodes) {
|
|
if (el.id === item) {
|
|
arr.push(el.id);
|
|
if (el.children) {
|
|
this.childNodesDeep(el.children, arr);
|
|
}
|
|
} else if (el.children) {
|
|
this.getChild(el.children, item, arr);
|
|
}
|
|
}
|
|
return arr;
|
|
}
|
|
static childNodesDeep(nodes, arr) {
|
|
if (nodes)
|
|
nodes.forEach((ele) => {
|
|
arr.push(ele.id);
|
|
if (ele.children) {
|
|
this.childNodesDeep(ele.children, arr);
|
|
}
|
|
});
|
|
}
|
|
// 过滤两个数组对象相同id的数据
|
|
static filterObj(arr1, arr2) {
|
|
let arr3 = arr1.filter(obj => !arr2.some(obj1 => obj1 == obj.id))
|
|
return arr3
|
|
}
|
|
// 过滤两个数组对象相同id的数据
|
|
static filterObj1(arr1, arr2) {
|
|
let arr3 = arr1.filter(obj => arr2.some(obj1 => obj1 == obj.id))
|
|
return arr3
|
|
}
|
|
static loopDepName(treeData, id, joinStr, result) {
|
|
let res = []
|
|
const fn = (source) => {
|
|
source.forEach(el => {
|
|
res.push(el)
|
|
el.children && el.children.length > 0 ? fn(el.children) : ""
|
|
})
|
|
}
|
|
}
|
|
static statusCode(code) {
|
|
var str = ''
|
|
switch (code) {
|
|
case 0:
|
|
str = "下发中";
|
|
break;
|
|
case 1:
|
|
str = "下发成功";
|
|
break;
|
|
case 2:
|
|
str = "未下发";
|
|
break;
|
|
case 3:
|
|
str = "下发失败";
|
|
break;
|
|
case 249:
|
|
str = "未发现用户";
|
|
break;
|
|
case 700:
|
|
str = "等待发送";
|
|
break;
|
|
case 701:
|
|
str = "下发中";
|
|
break;
|
|
case 702:
|
|
str = "发送失败";
|
|
break;
|
|
case 703:
|
|
str = "已作废";
|
|
break;
|
|
//LD返回错误码
|
|
case 101224:
|
|
str = "系统已锁定";
|
|
break;
|
|
case 101225:
|
|
str = "存储读写错误";
|
|
break;
|
|
case 101226:
|
|
str = "管理员手机号比对失败";
|
|
break;
|
|
case 101227:
|
|
str = "存储空间已满";
|
|
break;
|
|
case 101228:
|
|
str = "本地未检测到该凭证";
|
|
break;
|
|
case 101229:
|
|
str = "参数错误";
|
|
break;
|
|
case 101230:
|
|
str = "绑定失败";
|
|
break;
|
|
case 101240:
|
|
str = "设备未绑定";
|
|
break;
|
|
case 101241:
|
|
str = "设备ID不匹配";
|
|
break;
|
|
case 101242:
|
|
str = "未添加蓝牙密码";
|
|
break;
|
|
case 101243:
|
|
str = "蓝牙密码鉴权失败";
|
|
break;
|
|
case 101244:
|
|
str = "门已反锁";
|
|
break;
|
|
case 101245:
|
|
str = "门已开启";
|
|
break;
|
|
case 101246:
|
|
str = "密码长度异常";
|
|
break;
|
|
case 101247:
|
|
str = "当前用户容量已满";
|
|
break;
|
|
case 101248:
|
|
str = "密码已存在(卡片已存在)";
|
|
break;
|
|
case 101249:
|
|
str = "用户不存在";
|
|
break;
|
|
case 101250:
|
|
str = "用户ID匹配失败";
|
|
break;
|
|
case 101251:
|
|
str = "数据错误";
|
|
break;
|
|
case 101252:
|
|
str = "初始密码比对失败";
|
|
break;
|
|
case 101253:
|
|
str = "凭证ID无效";
|
|
break;
|
|
//ZG返回错误码
|
|
case 201002:
|
|
str = "包格式错误";
|
|
break;
|
|
case 201003:
|
|
str = "密码错误";
|
|
break;
|
|
case 201004:
|
|
str = "网络中断";
|
|
break;
|
|
case 201005:
|
|
str = "用户未登记";
|
|
break;
|
|
case 201006:
|
|
str = "参数错误";
|
|
break;
|
|
case 201007:
|
|
str = "需要鉴权";
|
|
break;
|
|
case 201008:
|
|
str = "无权限";
|
|
break;
|
|
case 201009:
|
|
str = "应答超时";
|
|
break;
|
|
case 201010:
|
|
str = "权限校验错误";
|
|
break;
|
|
case 201011:
|
|
str = "钥匙不存在";
|
|
break;
|
|
case 201012:
|
|
str = "钥匙过期";
|
|
break;
|
|
case 201013:
|
|
str = "钥匙数量已到上限";
|
|
break;
|
|
case 201014:
|
|
str = "钥匙无效";
|
|
break;
|
|
case 201015:
|
|
str = "钥匙已存在";
|
|
break;
|
|
case 201016:
|
|
str = "用户已存在";
|
|
break;
|
|
case 201017:
|
|
str = "密码失效";
|
|
break;
|
|
case 201018:
|
|
str = "无效指令";
|
|
break;
|
|
case 201019:
|
|
str = "门锁时间异常";
|
|
break;
|
|
case 201020:
|
|
str = "门锁NB芯片故障";
|
|
break;
|
|
case 201021:
|
|
str = "门锁无NB芯片";
|
|
break;
|
|
case 201022:
|
|
str = "升级程序校验通过";
|
|
break;
|
|
case 201023:
|
|
str = "升级程序项目不匹配";
|
|
break;
|
|
case 201024:
|
|
str = "升级程序版本太低";
|
|
break;
|
|
case 201025:
|
|
str = "升级程序长度超长";
|
|
break;
|
|
case 201026:
|
|
str = "升级程序启动失败";
|
|
break;
|
|
case 201033:
|
|
str = "升级程序进行中";
|
|
break;
|
|
case 201034:
|
|
str = "升级数据写入错误";
|
|
break;
|
|
case 201035:
|
|
str = "升级数据校验和错误";
|
|
break;
|
|
case 201049:
|
|
str = "到达数目定义上限";
|
|
break;
|
|
case 201050:
|
|
str = "密码已经存在";
|
|
break;
|
|
case 201051:
|
|
str = "禁止删除超管";
|
|
break;
|
|
case 201052:
|
|
str = "门禁卡故障";
|
|
break;
|
|
case 201053:
|
|
str = "远程指纹录入进行中";
|
|
break;
|
|
case 201054:
|
|
str = "远程指纹上次录入未完成";
|
|
break;
|
|
case 201055:
|
|
str = "远程指纹录入后,重复添加该用户";
|
|
break;
|
|
case 201254:
|
|
str = "设备没有被发现";
|
|
break;
|
|
case 201255:
|
|
str = "异常,未知错误";
|
|
break;
|
|
default:
|
|
str = "异常";
|
|
break;
|
|
}
|
|
return str
|
|
}
|
|
}
|