You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1078 lines
32 KiB

1 year ago
  1. const WXAPI = require('./request')
  2. import moment from 'moment'
  3. import ICINLocker from "./equipment.js"
  4. /**
  5. * @param {Function} fn 防抖函数
  6. * @param {Number} delay 延迟时间
  7. */
  8. export default class utils {
  9. // 下发凭证
  10. static putCarfidzgAdd(drawerRow,resultArr, row) {
  11. var data = {};
  12. var userTelephone = JSON.parse(row.content).userTelephone;
  13. var userPassword = JSON.parse(row.content).userPassword;
  14. var startTime = row.startTime
  15. var endTime = row.endTime
  16. var passwordStartTime =startTime
  17. var passwordEndTime = endTime
  18. if (row.type == 1) {
  19. var fpId = new Date();
  20. var fingerprint1 = JSON.parse(row.content).fingerprint;
  21. var str = {
  22. imei: resultArr.imei,
  23. deviceNum: resultArr.deviceNum,
  24. userTelephone: userTelephone,
  25. userPassword: userPassword,
  26. password: JSON.parse(row.content).password,
  27. length: fingerprint1.length / 2,
  28. fpTimeId: fpId.getTime(),
  29. operateMode: 16,
  30. order: 6216,
  31. fingerprint: fingerprint1,
  32. passwordStartTime: passwordStartTime,
  33. passwordEndTime: passwordEndTime,
  34. pzname:JSON.parse(row.content).pzname
  35. };
  36. var data3 = {
  37. lockerId: resultArr.deviceNum,
  38. imei: resultArr.imei,
  39. order: 6216,
  40. lockerUserId: JSON.parse(drawerRow.info).userPassword,
  41. keyId: JSON.parse(drawerRow.info).userPassword,
  42. fingerType: 0,
  43. file: fingerprint1,
  44. cardName: row.name+'-'+JSON.parse(row.content).pzname,
  45. roomName: resultArr.roomName,
  46. startTime: passwordStartTime,
  47. endTime: passwordEndTime
  48. };
  49. ICINLocker.addFingerPrints(data3.lockerId, data3.imei, data3.lockerUserId, data3.fingerType, data3
  50. .file, data3.startTime, data3.endTime, data3.cardName, data3.roomName, (callback) => {
  51. if (callback.success) {
  52. var data = {
  53. id: row.id,
  54. serial: callback.data.serialNumber,
  55. };
  56. WXAPI.updateCertificates(data).then((res) => {
  57. wx.showToast({
  58. title: "下发成功",
  59. duration:2000,
  60. icon:"nonoe"
  61. })
  62. });
  63. } else {
  64. wx.showToast({
  65. title: callback.msg,
  66. duration:2000,
  67. icon:"nonoe"
  68. })
  69. }
  70. })
  71. } else if (row.type == 2) {
  72. if (JSON.parse(row.content).password.length != 16) {
  73. wx.showToast({
  74. title: "卡格式错误,请重新录入",
  75. duration:2000,
  76. icon:"nonoe"
  77. })
  78. return
  79. }
  80. var str = {
  81. imei: resultArr.imei,
  82. userTelephone: userTelephone,
  83. cardId: row.cardId,
  84. userPassword: userPassword,
  85. password: JSON.parse(row.content).password,
  86. operateMode: 13,
  87. order: 6213,
  88. passwordStartTime: passwordStartTime,
  89. passwordEndTime: passwordEndTime,
  90. pzname:JSON.parse(row.content).pzname,
  91. is: false,
  92. };
  93. var data3 = {
  94. lockerId: resultArr.deviceNum,
  95. imei: resultArr.imei,
  96. lockerUserId: userPassword,
  97. keyId: userPassword,
  98. action: 1,
  99. taskStatus: 1,
  100. order: 6210,
  101. startTime: passwordStartTime,
  102. endTime: passwordEndTime,
  103. cardType: 36,
  104. cardName: row.name+'-'+JSON.parse(row.content).pzname,
  105. roomName: row.roomName,
  106. cardNo: JSON.parse(row.content).password
  107. };
  108. ICINLocker.RfCardRegister(data3.lockerId, data3.imei, data3.keyId, data3.action, data3.taskStatus,
  109. data3.cardNo, data3.cardType, data3.startTime,
  110. data3.endTime, data3.order, data3.cardName, data3.roomName, (callback) => {
  111. if (callback.success) {
  112. var data = {
  113. id: row.id,
  114. serial: callback.data.serialNumber,
  115. };
  116. WXAPI.updateCertificates(data).then((res) => {
  117. wx.showToast({
  118. title: "下发成功",
  119. duration:2000,
  120. icon:"nonoe"
  121. })
  122. });
  123. } else {
  124. wx.showToast({
  125. title: callback.msg,
  126. duration:2000,
  127. icon:"nonoe"
  128. })
  129. }
  130. })
  131. } else if (row.type == 3) {
  132. if (JSON.parse(row.content).password.length != 8) {
  133. wx.showToast({
  134. title: "卡格式错误,请重新录入",
  135. duration:2000,
  136. icon:"nonoe"
  137. })
  138. return
  139. }
  140. var str = {
  141. imei: resultArr.imei,
  142. userTelephone: userTelephone,
  143. cardId: row.cardId,
  144. userPassword: userPassword,
  145. password: JSON.parse(row.content).password,
  146. operateMode: 10,
  147. order: 6210,
  148. passwordStartTime: passwordStartTime,
  149. passwordEndTime: passwordEndTime,
  150. pzname:JSON.parse(row.content).pzname,
  151. is: false,
  152. };
  153. var data3 = {
  154. lockerId: resultArr.deviceNum,
  155. lockerUserId: userPassword,
  156. keyId: userPassword,
  157. imei: resultArr.imei,
  158. action: 1,
  159. taskStatus: 1,
  160. order: 6210,
  161. startTime: passwordStartTime,
  162. endTime: passwordEndTime,
  163. cardType: 50,
  164. cardName: row.name+'-'+JSON.parse(row.content).pzname,
  165. roomName: row.roomName,
  166. cardNo: JSON.parse(row.content).password
  167. };
  168. ICINLocker.RfCardRegister(data3.lockerId, data3.imei, data3.keyId, data3.action, data3.taskStatus,
  169. data3.cardNo, data3.cardType, data3.startTime,
  170. data3.endTime, data3.order, data3.cardName, data3.roomName, (callback) => {
  171. if (callback.success) {
  172. var data = {
  173. id: row.id,
  174. serial: callback.data.serialNumber,
  175. };
  176. WXAPI.updateCertificates(data).then((res) => {
  177. wx.showToast({
  178. title: "下发成功",
  179. duration:2000,
  180. icon:"nonoe"
  181. })
  182. });
  183. } else {
  184. wx.showToast({
  185. title: callback.msg,
  186. duration:2000,
  187. icon:"nonoe"
  188. })
  189. }
  190. })
  191. } else if (row.type == 4) {
  192. str = {
  193. imei: resultArr.imei,
  194. userTelephone: userTelephone,
  195. cardId: row.cardId,
  196. userPassword: userPassword,
  197. password: JSON.parse(row.content).password,
  198. operateMode: 7,
  199. order: 6207,
  200. passwordStartTime: passwordStartTime,
  201. passwordEndTime: passwordEndTime,
  202. pzname:JSON.parse(row.content).pzname,
  203. is: false,
  204. cardName: row.name+'-'+JSON.parse(row.content).pzname,
  205. roomName: row.roomName
  206. };
  207. var data3 = {
  208. lockerId: resultArr.deviceNum,
  209. imei: resultArr.imei,
  210. order: 6207,
  211. passwordCount: 255,
  212. lockerUserId: userPassword,
  213. keyId: userPassword,
  214. startTime: passwordStartTime,
  215. endTime: passwordEndTime,
  216. action: 1,
  217. password: JSON.parse(row.content).password,
  218. cardName: row.name+'-'+JSON.parse(row.content).pzname,
  219. roomName: row.roomName
  220. };
  221. ICINLocker.addForeverPassword(data3.lockerId, data3.imei, data3.keyId, data3.action, data3.password,
  222. data3.passwordCount, data3.startTime, data3.endTime, data3.order, data3.cardName, data3
  223. .roomName, (callback) => {
  224. if (callback.success) {
  225. var data = {
  226. id: row.id,
  227. serial: callback.data.serialNumber,
  228. };
  229. WXAPI.updateCertificates(data).then((res) => {
  230. wx.showToast({
  231. title: "下发成功",
  232. duration:2000,
  233. icon:"nonoe"
  234. })
  235. });
  236. } else {
  237. wx.showToast({
  238. title: callback.msg,
  239. duration:2000,
  240. icon:"nonoe"
  241. })
  242. }
  243. })
  244. }
  245. }
  246. // 下发凭证
  247. static putCarfidAdd(resultArr, row) {
  248. var data = {};
  249. var userTelephone = JSON.parse(row.content).userTelephone;
  250. var userPassword = JSON.parse(row.content).userPassword;
  251. var startTime = row.startTime
  252. var endTime = row.endTime
  253. var passwordEndTime = moment(endTime*1000).format("YYYYMMDDHHmmss");
  254. var passwordStartTime = moment(startTime*1000).format("YYYYMMDDHHmmss");
  255. if (row.type == 1) {
  256. var fpId = new Date();
  257. var fingerprint = JSON.parse(row.content).fingerprint;
  258. var str = {
  259. imei: resultArr.imei,
  260. deviceNum: resultArr.deviceNum,
  261. userTelephone: userTelephone,
  262. userPassword: userPassword,
  263. password: JSON.parse(row.content).password,
  264. length: fingerprint.length / 2,
  265. fpTimeId: fpId.getTime(),
  266. operateMode: 16,
  267. order: 6216,
  268. fingerprint: fingerprint,
  269. passwordStartTime: passwordStartTime,
  270. passwordEndTime: passwordEndTime,
  271. cardName: row.name+'-'+JSON.parse(row.content).pzname,
  272. roomName: resultArr.roomName,
  273. };
  274. ICINLocker.LDAddFingerPrints(str.deviceNum, str.imei, str.userTelephone, str.userPassword, str
  275. .password, str.passwordStartTime, str.passwordEndTime, str.operateMode, str.order, str.length,
  276. str.fpTimeId, str.fingerprint, str.cardName, str.roomName, (callback) => {
  277. if (callback.success) {
  278. var datafid = {
  279. id: row.id,
  280. serial: callback.data.serialNumber,
  281. };
  282. WXAPI.updateCertificates(datafid).then((res) => {
  283. if (res.success) {
  284. wx.showToast({
  285. title: "下发成功",
  286. duration:2000,
  287. icon:"nonoe"
  288. })
  289. } else {
  290. wx.showToast({
  291. title: "下发失败",
  292. duration:2000,
  293. icon:"nonoe"
  294. })
  295. }
  296. });
  297. } else {
  298. wx.showToast({
  299. title: callback.msg,
  300. duration:2000,
  301. icon:"nonoe"
  302. })
  303. }
  304. })
  305. return false
  306. } else if (row.type == 2) {
  307. data = {
  308. imei: resultArr.imei,
  309. deviceNum: resultArr.deviceNum,
  310. userTelephone: userTelephone,
  311. cardId: row.cardId,
  312. userPassword: userPassword,
  313. password: JSON.parse(row.content).password,
  314. operateMode: 13,
  315. order: 6213,
  316. passwordStartTime: passwordStartTime,
  317. passwordEndTime: passwordEndTime,
  318. is: false,
  319. cardName: row.name+'-'+JSON.parse(row.content).pzname,
  320. roomName: resultArr.roomName,
  321. };
  322. } else if (row.type == 3) {
  323. data = {
  324. imei: resultArr.imei,
  325. deviceNum: resultArr.deviceNum,
  326. userTelephone: userTelephone,
  327. cardId: row.cardId,
  328. userPassword: userPassword,
  329. password: JSON.parse(row.content).password,
  330. operateMode: 10,
  331. order: 6210,
  332. passwordStartTime: passwordStartTime,
  333. passwordEndTime: passwordEndTime,
  334. is: false,
  335. cardName: row.name+'-'+JSON.parse(row.content).pzname,
  336. roomName: resultArr.roomName,
  337. };
  338. } else if (row.type == 4) {
  339. data = {
  340. imei: resultArr.imei,
  341. deviceNum: resultArr.deviceNum,
  342. userTelephone: userTelephone,
  343. cardId: row.cardId,
  344. userPassword: userPassword,
  345. password: JSON.parse(row.content).password,
  346. operateMode: 7,
  347. order: 6207,
  348. passwordStartTime: passwordStartTime,
  349. passwordEndTime: passwordEndTime,
  350. is: false,
  351. cardName: row.name+'-'+JSON.parse(row.content).pzname,
  352. roomName: resultArr.roomName,
  353. };
  354. }
  355. ICINLocker.LDRfCardRegister(data.deviceNum, data.imei, data.userTelephone, data.userPassword, data
  356. .password, data
  357. .passwordStartTime, data.passwordEndTime, data.operateMode, data.order, data.cardName, data
  358. .roomName, (
  359. callback) => {
  360. if (callback.success) {
  361. var datafid = {
  362. id: row.id,
  363. serial: callback.data.serialNumber,
  364. };
  365. WXAPI.updateCertificates(datafid).then((res) => {
  366. if (res.success) {
  367. wx.showToast({
  368. title: "下发成功",
  369. duration:2000,
  370. icon:"nonoe"
  371. })
  372. } else {
  373. wx.showToast({
  374. title: "下发失败",
  375. duration:2000,
  376. icon:"nonoe"
  377. })
  378. }
  379. });
  380. } else {
  381. wx.showToast({
  382. title: callback.msg,
  383. duration:2000,
  384. icon:"nonoe"
  385. })
  386. }
  387. })
  388. }
  389. static getfiId1(row, callback) {
  390. var data = {
  391. q: JSON.stringify({
  392. serial: row.serial,
  393. }),
  394. pageNum: 1,
  395. pageSize: 10,
  396. };
  397. WXAPI.getDeviceResult(data).then((res) => {
  398. callback(res.data.list);
  399. });
  400. }
  401. static putCarfid(resultArr, row, endTime, startTime) {
  402. var data = {};
  403. var userTelephone = JSON.parse(row.content).userTelephone;
  404. var userPassword = JSON.parse(row.content).userPassword;
  405. var content = JSON.parse(row.content);
  406. var passwordEndTime = moment(endTime).format("YYYYMMDDHHmmss");
  407. var passwordStartTime = moment(startTime).format("YYYYMMDDHHmmss");
  408. if (row.type == 1) {
  409. this.getfiId(row, function(data) {
  410. if (data.length > 0) {
  411. if (data.length > 0) {
  412. var fpid = "";
  413. fpid =
  414. data[0].face.toString(16).length != 2 ?
  415. "0" + data[0].face.toString(16) :
  416. data[0].face;
  417. var str = {
  418. imei: resultArr.imei,
  419. deviceNum: resultArr.deviceNum,
  420. password: fpid,
  421. operateMode: 17,
  422. order: 6217,
  423. userPassword: userPassword,
  424. userTelephone: userTelephone,
  425. passwordStartTime: passwordEndTime,
  426. passwordEndTime: passwordStartTime,
  427. is: false,
  428. cardName: row.name,
  429. roomName: resultArr.roomName,
  430. };
  431. WXAPI.getDeviceOperateUserInfo(str).then((res1) => {
  432. if (res1.success) {
  433. content.passwordStartTime = str.passwordStartTime;
  434. content.passwordEndTime = str.passwordEndTime;
  435. var updatedata = {
  436. id: row.id,
  437. content: JSON.stringify(content),
  438. serial: res1.data.serialNumber,
  439. status: 0,
  440. startTime: startTime / 1000,
  441. endTime: endTime / 1000
  442. };
  443. WXAPI.updateCertificates(updatedata)
  444. .then(
  445. (res2) => {
  446. wx.showToast({
  447. title: "修改成功",
  448. duration:2000,
  449. icon:"nonoe"
  450. })
  451. }
  452. );
  453. } else {
  454. wx.showToast({
  455. title: "修改失败",
  456. duration:2000,
  457. icon:"nonoe"
  458. })
  459. }
  460. });
  461. }
  462. }
  463. })
  464. return false
  465. } else if (row.type == 2) {
  466. data = {
  467. imei: resultArr.imei,
  468. deviceNum: resultArr.deviceNum,
  469. userTelephone: userTelephone,
  470. cardId: row.cardId,
  471. userPassword: userPassword,
  472. password: JSON.parse(row.content).password,
  473. operateMode: 14,
  474. order: 6214,
  475. passwordStartTime: passwordStartTime,
  476. passwordEndTime: passwordEndTime,
  477. is: false,
  478. cardName: row.name,
  479. roomName: row.roomName
  480. };
  481. } else if (row.type == 3) {
  482. data = {
  483. imei: resultArr.imei,
  484. deviceNum: resultArr.deviceNum,
  485. userTelephone: userTelephone,
  486. cardId: row.cardId,
  487. userPassword: userPassword,
  488. password: JSON.parse(row.content).password,
  489. operateMode: 11,
  490. order: 6211,
  491. passwordStartTime: passwordStartTime,
  492. passwordEndTime: passwordEndTime,
  493. is: false,
  494. cardName: row.name,
  495. roomName: row.roomName
  496. };
  497. } else if (row.type == 4) {
  498. data = {
  499. imei: resultArr.imei,
  500. deviceNum: resultArr.deviceNum,
  501. userTelephone: userTelephone,
  502. cardId: row.cardId,
  503. userPassword: userPassword,
  504. password: JSON.parse(row.content).password,
  505. operateMode: 8,
  506. order: 6208,
  507. passwordStartTime: passwordStartTime,
  508. passwordEndTime: passwordEndTime,
  509. is: false,
  510. cardName: row.name,
  511. roomName: row.roomName
  512. };
  513. }
  514. ICINLocker.LDRfCardRegister(data.deviceNum, data.imei, data.userTelephone, data.userPassword, data
  515. .password, data
  516. .passwordStartTime, data.passwordEndTime, data.operateMode, data.order, data.cardName, data
  517. .roomName, (
  518. callback) => {
  519. if (callback.success) {
  520. var datafid = {
  521. id: row.id,
  522. content: JSON.stringify(data), //operateMode:NFC-10、把人员添加到凭证-1
  523. status: 0,
  524. serial: callback.data.serialNumber,
  525. startTime: moment(startTime).valueOf() / 1000,
  526. endTime: moment(endTime).valueOf() / 1000,
  527. };
  528. WXAPI.updateCertificates(datafid).then((res) => {
  529. if (res.success) {
  530. wx.showToast({
  531. title: "下发成功",
  532. duration:2000,
  533. icon:"nonoe"
  534. })
  535. } else {
  536. wx.showToast({
  537. title: "下发失败",
  538. duration:2000,
  539. icon:"nonoe"
  540. })
  541. }
  542. });
  543. } else {
  544. wx.showToast({
  545. title: callback.msg,
  546. duration:2000,
  547. icon:"nonoe"
  548. })
  549. }
  550. })
  551. }
  552. // 下发凭证
  553. static putCarfidzg(resultArr, row, endTime, startTime) {
  554. var data = {};
  555. var userTelephone = JSON.parse(row.content).userTelephone;
  556. var userPassword = JSON.parse(row.content).userPassword;
  557. var content = JSON.parse(row.content);
  558. var passwordEndTime = moment(startTime).valueOf() / 1000;
  559. var passwordStartTime = moment(endTime).valueOf() / 1000;
  560. if (row.type == 1) {
  561. this.getfiId1(row, function(data) {
  562. if (data.length > 0) {
  563. var fpid = "";
  564. fpid =
  565. data[0].face.toString(16).length != 2 ?
  566. "0" + data[0].face.toString(16) :
  567. data[0].face;
  568. var pwd = JSON.parse(row.content).userPassword
  569. ICINLocker.modifyFingerPrints(resultArr.deviceNum, resultArr.imei, pwd, 3,
  570. fpid, 0, passwordStartTime, passwordEndTime, row.name, resultArr.roomName, (callback) => {
  571. if (callback.success) {
  572. var str1 = JSON.parse(row.content);
  573. str1.fpTimeId = callback.data.serialNumber;
  574. str1.passwordStartTime = passwordStartTime;
  575. str1.passwordEndTime = passwordEndTime;
  576. var updatedata = {
  577. id: row.id,
  578. content: JSON.stringify(str1),
  579. serial: callback.data.serialNumber,
  580. status: 0,
  581. startTime: passwordStartTime,
  582. endTime: passwordEndTime
  583. };
  584. WXAPI.updateCertificates(updatedata)
  585. .then(
  586. (res2) => {
  587. wx.showToast({
  588. title: "下发成功",
  589. duration:2000,
  590. icon:"nonoe"
  591. })
  592. });
  593. wx.showToast({
  594. title: callback.msg,
  595. duration:2000,
  596. icon:"nonoe"
  597. })
  598. } else {
  599. wx.showToast({
  600. title: callback.msg,
  601. duration:2000,
  602. icon:"nonoe"
  603. })
  604. }
  605. })
  606. } else {
  607. wx.showToast({
  608. title: "修改失败",
  609. duration:2000,
  610. icon:"nonoe"
  611. })
  612. }
  613. })
  614. } else if (row.type == 2) {
  615. var idcard = ''
  616. if (content.password.length == 16) {
  617. idcard = content.password
  618. } else {
  619. idcard = dec2hex(content.password);
  620. }
  621. var userid = JSON.parse(row.content).userPassword
  622. if (idcard.length != 16) {
  623. wx.showToast({
  624. title: "卡格式错误,请重新录入",
  625. duration:2000,
  626. icon:"nonoe"
  627. })
  628. return
  629. }
  630. ICINLocker.RfCardRegister(resultArr.deviceNum, resultArr.imei, userid, 3, 1, idcard
  631. .toUpperCase(), 36, passwordStartTime, passwordEndTime, 6211, row.name, resultArr
  632. .roomName, (callback) => {
  633. if (callback.success) {
  634. var str = JSON.parse(row.content)
  635. str['password'] = idcard.toUpperCase()
  636. var updatedata = {
  637. id: row.id,
  638. content: JSON.stringify(str),
  639. serial: callback.data.serialNumber,
  640. startTime: passwordStartTime,
  641. endTime: passwordEndTime
  642. };
  643. WXAPI.updateCertificates(updatedata).then((res) => {
  644. wx.showToast({
  645. title: "下发成功",
  646. duration:2000,
  647. icon:"nonoe"
  648. })
  649. });
  650. wx.showToast({
  651. title: callback.msg,
  652. duration:2000,
  653. icon:"nonoe"
  654. })
  655. } else {
  656. wx.showToast({
  657. title: callback.msg,
  658. duration:2000,
  659. icon:"nonoe"
  660. })
  661. }
  662. })
  663. } else if (row.type == 3) {
  664. var nfc = "";
  665. if (content.password.length == 8) {
  666. nfc = content.password
  667. } else {
  668. nfc = dec2hex(content.password);
  669. }
  670. var userid = JSON.parse(row.content).userPassword
  671. if (nfc.length != 8) {
  672. wx.showToast({
  673. title: "卡格式错误,请重新录入",
  674. duration:2000,
  675. icon:"nonoe"
  676. })
  677. return
  678. }
  679. ICINLocker.RfCardRegister(resultArr.deviceNum, resultArr.imei, userid, 3, 1, nfc.toUpperCase(),
  680. 50, passwordStartTime, passwordEndTime, 6211, row.name, resultArr.roomName, (
  681. callback) => {
  682. if (callback.success) {
  683. var str = JSON.parse(row.content)
  684. str['password'] = nfc.toUpperCase()
  685. str['pzname'] = that.certificatesContent.pzname
  686. var updatedata = {
  687. id: row.id,
  688. content: JSON.stringify(str),
  689. serial: callback.data.serialNumber,
  690. startTime: passwordStartTime,
  691. endTime: passwordEndTime
  692. };
  693. WXAPI.updateCertificates(updatedata).then((res) => {
  694. wx.showToast({
  695. title: "下发成功",
  696. duration:2000,
  697. icon:"nonoe"
  698. })
  699. });
  700. wx.showToast({
  701. title: callback.msg,
  702. duration:2000,
  703. icon:"nonoe"
  704. })
  705. } else {
  706. wx.showToast({
  707. title: callback.msg,
  708. duration:2000,
  709. icon:"nonoe"
  710. })
  711. }
  712. })
  713. } else if (row.type == 4) {
  714. var pwd = content.password
  715. var userid = JSON.parse(row.content).userPassword
  716. ICINLocker.addForeverPassword(resultArr.deviceNum, resultArr.imei, userid, 3, pwd, 255,
  717. passwordStartTime, passwordEndTime, 6208, row.name, resultArr.roomName, (
  718. callback) => {
  719. if (callback.success) {
  720. var data1 = JSON.parse(row.content)
  721. data1['password'] = content.password
  722. var updatedata = {
  723. id: row.id,
  724. content: JSON.stringify(data1),
  725. serial: callback.data.serialNumber,
  726. startTime: passwordStartTime,
  727. endTime: passwordEndTime
  728. };
  729. WXAPI.updateCertificates(updatedata).then((res) => {
  730. wx.showToast({
  731. title: "下发成功",
  732. duration:2000,
  733. icon:"nonoe"
  734. })
  735. });
  736. wx.showToast({
  737. title: callback.msg,
  738. duration:2000,
  739. icon:"nonoe"
  740. })
  741. } else {
  742. wx.showToast({
  743. title: callback.msg,
  744. duration:2000,
  745. icon:"nonoe"
  746. })
  747. }
  748. })
  749. }
  750. }
  751. static timeTotimeimp(obj) {
  752. var year = obj.substr(0, 4)
  753. var month = obj.substr(4, 2)
  754. var day = obj.substr(6, 2)
  755. var hours = obj.substr(8, 2)
  756. var min = obj.substr(8, 2)
  757. var miao = obj.substr(10, 2)
  758. var hm = obj.substr(12, 2)
  759. var str = year + "-" + month + "-" + day + " " + hours + ":" + min + ":" + miao
  760. var time = new Date(str)
  761. var time1 = time.getTime()
  762. return time1 / 1000;
  763. }
  764. // 格式化时间
  765. static formatTime(time, key) {
  766. var time1 = JSON.stringify(time)
  767. var text = ''
  768. if (time1.length == 14) {
  769. text = moment(this.timeTotimeimp(time1) * 1000).format('YYYY年MM月DD日 HH:mm:ss')
  770. } else if (time1.length == 13) {
  771. text = moment(time).format('YYYY年MM月DD日 HH:mm:ss')
  772. } else if (time1.length == 10) {
  773. text = moment(time * 1000).format('YYYY年MM月DD日 HH:mm:ss')
  774. }
  775. return text;
  776. }
  777. // 去重
  778. static uniqueArray(array, key) {
  779. var result = [array[0]];
  780. for (var i = 1; i < array.length; i++) {
  781. var item = array[i];
  782. var repeat = false;
  783. for (var j = 0; j < result.length; j++) {
  784. if (item[key] == result[j][key]) {
  785. repeat = true;
  786. break;
  787. }
  788. }
  789. if (!repeat) {
  790. result.push(item);
  791. }
  792. }
  793. return result;
  794. }
  795. // 生成树形数据结构
  796. static ztreeToElementTree(data, config) {
  797. var id = 'id' // 定义ztree数据存储id(自身的id)的key值,可以自定义但一般都是id、pid这种
  798. var pid = 'pid' // 定义ztree数据存储pid(父id)的key值
  799. var children = 'children' // 定义生成的element tree存储子节点的key,可以在element中规定defaultProps: {children: 'children'}
  800. var idMap = {} // 将原始数据转化为以id为key的map
  801. var elementTree = [] // 输出的element tree数据
  802. data.forEach(item => {
  803. item['value'] = item.id
  804. item['label'] = item.name
  805. idMap[item.id] = item
  806. })
  807. data.forEach(item => {
  808. // debugger
  809. if (idMap[item.pid] != idMap[item.id] && idMap[item.pid]) { // 该item项有爸爸,放到对应的父节点下
  810. !idMap[item.pid].hasOwnProperty(children) && (idMap[item.pid][children] = [])
  811. idMap[item.pid][children].push(item)
  812. } else { // 根节点
  813. elementTree.push(item)
  814. }
  815. });
  816. return elementTree
  817. }
  818. // 根据选择的父级id,获取所有子级id
  819. static getChild(nodes, item, arr) {
  820. for (let el of nodes) {
  821. if (el.id === item) {
  822. arr.push(el.id);
  823. if (el.children) {
  824. this.childNodesDeep(el.children, arr);
  825. }
  826. } else if (el.children) {
  827. this.getChild(el.children, item, arr);
  828. }
  829. }
  830. return arr;
  831. }
  832. static childNodesDeep(nodes, arr) {
  833. if (nodes)
  834. nodes.forEach((ele) => {
  835. arr.push(ele.id);
  836. if (ele.children) {
  837. this.childNodesDeep(ele.children, arr);
  838. }
  839. });
  840. }
  841. // 过滤两个数组对象相同id的数据
  842. static filterObj(arr1, arr2) {
  843. let arr3 = arr1.filter(obj => !arr2.some(obj1 => obj1 == obj.id))
  844. return arr3
  845. }
  846. // 过滤两个数组对象相同id的数据
  847. static filterObj1(arr1, arr2) {
  848. let arr3 = arr1.filter(obj => arr2.some(obj1 => obj1 == obj.id))
  849. return arr3
  850. }
  851. static loopDepName(treeData, id, joinStr, result) {
  852. let res = []
  853. const fn = (source) => {
  854. source.forEach(el => {
  855. res.push(el)
  856. el.children && el.children.length > 0 ? fn(el.children) : ""
  857. })
  858. }
  859. }
  860. static statusCode(code) {
  861. var str = ''
  862. switch (code) {
  863. case 0:
  864. str = "下发中";
  865. break;
  866. case 1:
  867. str = "下发成功";
  868. break;
  869. case 2:
  870. str = "未下发";
  871. break;
  872. case 3:
  873. str = "下发失败";
  874. break;
  875. case 249:
  876. str = "未发现用户";
  877. break;
  878. case 700:
  879. str = "等待发送";
  880. break;
  881. case 701:
  882. str = "下发中";
  883. break;
  884. case 702:
  885. str = "发送失败";
  886. break;
  887. case 703:
  888. str = "已作废";
  889. break;
  890. //LD返回错误码
  891. case 101224:
  892. str = "系统已锁定";
  893. break;
  894. case 101225:
  895. str = "存储读写错误";
  896. break;
  897. case 101226:
  898. str = "管理员手机号比对失败";
  899. break;
  900. case 101227:
  901. str = "存储空间已满";
  902. break;
  903. case 101228:
  904. str = "本地未检测到该凭证";
  905. break;
  906. case 101229:
  907. str = "参数错误";
  908. break;
  909. case 101230:
  910. str = "绑定失败";
  911. break;
  912. case 101240:
  913. str = "设备未绑定";
  914. break;
  915. case 101241:
  916. str = "设备ID不匹配";
  917. break;
  918. case 101242:
  919. str = "未添加蓝牙密码";
  920. break;
  921. case 101243:
  922. str = "蓝牙密码鉴权失败";
  923. break;
  924. case 101244:
  925. str = "门已反锁";
  926. break;
  927. case 101245:
  928. str = "门已开启";
  929. break;
  930. case 101246:
  931. str = "密码长度异常";
  932. break;
  933. case 101247:
  934. str = "当前用户容量已满";
  935. break;
  936. case 101248:
  937. str = "密码已存在(卡片已存在)";
  938. break;
  939. case 101249:
  940. str = "用户不存在";
  941. break;
  942. case 101250:
  943. str = "用户ID匹配失败";
  944. break;
  945. case 101251:
  946. str = "数据错误";
  947. break;
  948. case 101252:
  949. str = "初始密码比对失败";
  950. break;
  951. case 101253:
  952. str = "凭证ID无效";
  953. break;
  954. //ZG返回错误码
  955. case 201002:
  956. str = "包格式错误";
  957. break;
  958. case 201003:
  959. str = "密码错误";
  960. break;
  961. case 201004:
  962. str = "网络中断";
  963. break;
  964. case 201005:
  965. str = "用户未登记";
  966. break;
  967. case 201006:
  968. str = "参数错误";
  969. break;
  970. case 201007:
  971. str = "需要鉴权";
  972. break;
  973. case 201008:
  974. str = "无权限";
  975. break;
  976. case 201009:
  977. str = "应答超时";
  978. break;
  979. case 201010:
  980. str = "权限校验错误";
  981. break;
  982. case 201011:
  983. str = "钥匙不存在";
  984. break;
  985. case 201012:
  986. str = "钥匙过期";
  987. break;
  988. case 201013:
  989. str = "钥匙数量已到上限";
  990. break;
  991. case 201014:
  992. str = "钥匙无效";
  993. break;
  994. case 201015:
  995. str = "钥匙已存在";
  996. break;
  997. case 201016:
  998. str = "用户已存在";
  999. break;
  1000. case 201017:
  1001. str = "密码失效";
  1002. break;
  1003. case 201018:
  1004. str = "无效指令";
  1005. break;
  1006. case 201019:
  1007. str = "门锁时间异常";
  1008. break;
  1009. case 201020:
  1010. str = "门锁NB芯片故障";
  1011. break;
  1012. case 201021:
  1013. str = "门锁无NB芯片";
  1014. break;
  1015. case 201022:
  1016. str = "升级程序校验通过";
  1017. break;
  1018. case 201023:
  1019. str = "升级程序项目不匹配";
  1020. break;
  1021. case 201024:
  1022. str = "升级程序版本太低";
  1023. break;
  1024. case 201025:
  1025. str = "升级程序长度超长";
  1026. break;
  1027. case 201026:
  1028. str = "升级程序启动失败";
  1029. break;
  1030. case 201033:
  1031. str = "升级程序进行中";
  1032. break;
  1033. case 201034:
  1034. str = "升级数据写入错误";
  1035. break;
  1036. case 201035:
  1037. str = "升级数据校验和错误";
  1038. break;
  1039. case 201049:
  1040. str = "到达数目定义上限";
  1041. break;
  1042. case 201050:
  1043. str = "密码已经存在";
  1044. break;
  1045. case 201051:
  1046. str = "禁止删除超管";
  1047. break;
  1048. case 201052:
  1049. str = "门禁卡故障";
  1050. break;
  1051. case 201053:
  1052. str = "远程指纹录入进行中";
  1053. break;
  1054. case 201054:
  1055. str = "远程指纹上次录入未完成";
  1056. break;
  1057. case 201055:
  1058. str = "远程指纹录入后,重复添加该用户";
  1059. break;
  1060. case 201254:
  1061. str = "设备没有被发现";
  1062. break;
  1063. case 201255:
  1064. str = "异常,未知错误";
  1065. break;
  1066. default:
  1067. str = "异常";
  1068. break;
  1069. }
  1070. return str
  1071. }
  1072. }