index.js 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. import {
  2. visiteeList,
  3. threeElements,
  4. configList,
  5. riskQuery,
  6. areaInfo,
  7. publicInterface
  8. } from '../../utils/api/api'
  9. import {
  10. getWaterDrop,
  11. getDate
  12. } from '../../utils/index/index'
  13. import {
  14. viceBroadcast, closeSecondaryScreen, openSecondaryScreen
  15. } from '../../utils/index/callAmpe'
  16. import {
  17. encryptAndSign
  18. } from '../../utils/index/getSM4'
  19. import { match } from 'assert'
  20. const app = getApp()
  21. Page({
  22. data: {
  23. toTitleRef: null,
  24. snDisposition: {},
  25. // 访客信息
  26. remainingInfo: {
  27. avatar: '',
  28. visitorName: '',
  29. visitorIdCard: '',
  30. visitorPhone: '',
  31. visitorUnit: '',
  32. carnum: '',
  33. peopleNum: 1,
  34. causeMatterName: '',
  35. },
  36. // 保存用户填写的最后信息
  37. formInfo: {
  38. visitorPhone: '',
  39. visitorUnit: '',
  40. carnum: '',
  41. peopleNum: 1,
  42. causeMatterName: '',
  43. },
  44. // 事由
  45. causeMatterList: [
  46. /*{
  47. name: '业务拜访',
  48. id: 1
  49. },
  50. {
  51. name: '会议邀请',
  52. id: 2
  53. },
  54. {
  55. name: '施工单位',
  56. id: 3
  57. },
  58. {
  59. name: '其他事项',
  60. id: 4
  61. },*/
  62. ],
  63. isShowCauseMatter: false, //是否显示事由选项
  64. floorNum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],
  65. cs: [1, 2, 3, 4, 5, 6,],
  66. // 是否显示搜索项
  67. isShowSearch: false,
  68. // 所有搜索项
  69. searchList: [
  70. {
  71. name: '姓名',
  72. placeholder: '请输入姓名',
  73. value: 'name',
  74. show: true,
  75. },
  76. {
  77. name: '手机号',
  78. placeholder: '请输入手机号',
  79. value: 'phone',
  80. show: true,
  81. },
  82. {
  83. name: '身份证',
  84. placeholder: '请输入身份证',
  85. value: 'idNumber',
  86. show: false,
  87. },
  88. {
  89. name: '单位',
  90. placeholder: '请输入单位',
  91. value: 'company',
  92. show: true,
  93. },
  94. {
  95. name: '部门',
  96. placeholder: '请输入部门',
  97. value: 'unitName',
  98. show: false,
  99. },
  100. {
  101. name: '楼层',
  102. placeholder: '请选择楼层',
  103. value: 'floor',
  104. show: true,
  105. }, {
  106. name: '房间号',
  107. placeholder: '请输入房间号',
  108. value: 'room',
  109. show: true,
  110. }, {
  111. name: '标题',
  112. placeholder: '请输入标题',
  113. value: 'showTitle',
  114. show: true,
  115. }
  116. ],
  117. // 搜索项绑定值
  118. searchForm: {
  119. name: '',
  120. phone: '',
  121. company: '',
  122. floor: '', //选中的楼层
  123. room: '',
  124. showTitle: '',
  125. },
  126. // 受访人信息
  127. intervieweeForm: {
  128. name: '',
  129. phone: '',
  130. idNumber: '',
  131. company: '',
  132. unitName: '',
  133. floor: '',
  134. room: '',
  135. showTitle: '',
  136. },
  137. intervieweeFormCopy: {},
  138. // 是否是手动输入受访人
  139. isEnterInterviewee: false,
  140. carNumberShow: true,
  141. // 触摸开始时间
  142. touchStartTime: 0,
  143. // 触摸结束时间
  144. touchEndTime: 0,
  145. // 最后一次单击事件点击发生时间
  146. lastTapTime: 0,
  147. // 单击事件点击后要触发的函数
  148. lastTapTimeoutFunc: null,
  149. allList: [],
  150. allListCopy: [],
  151. tableList: [],
  152. total: 0,
  153. pageNum: 0, //总页数
  154. pageSize: 0, //当前页数
  155. sliceStart: 0, //截取数组开始
  156. sliceEnd: 15, //截取数组结束
  157. mumberRows: 15, //每页条数
  158. // 键盘开始
  159. notNum: true,
  160. strDisabled: false,
  161. checked: false,
  162. provinceArr: ["粤", "京", "津", "渝", "沪", "冀", "晋", "辽", "吉", "黑", "苏", "浙", "皖", "闽", "赣", "鲁", "豫", "鄂", "湘", "琼", "川", "贵", "云", "陕", "甘", "青", "蒙", "桂", "宁", "新", "藏", "使", "领", "警", "学", "港", "澳"],
  163. strArr: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"],
  164. hiddenPro: true, // 隐藏省份键盘
  165. hiddenStr: true, // 隐藏数字字母键盘
  166. carnum: '', //车牌号码
  167. // 键盘结束
  168. downBtn: '返回',
  169. // 多选楼层开始
  170. isShowfloor: false,
  171. allFloorList: [],
  172. chooseFloorIndex: [], //多选的index
  173. chooseFloorItem: [], //多选的item
  174. // 多选楼层结束
  175. isPortraitScreen: false,// 是否为竖屏:true竖屏 false横屏
  176. screenIntervalId: null, //定时器
  177. // 默认历史
  178. historyPagNum: 1, //当前页数
  179. historyPageSize: 0, //总页数
  180. isHistory: true,
  181. historyList: [],
  182. userVisitorListDetailId: null, // 用户点击的id
  183. historySelObj:{
  184. info1Sel: false,
  185. info2Sel: false,
  186. }
  187. },
  188. onLoad() {
  189. my.hideBackHome();
  190. const _this = this
  191. this.initScreenType().then(isPortraitScreenRes => {
  192. console.log('isPortraitScreenRes', isPortraitScreenRes)
  193. _this.setData({
  194. isPortraitScreen: isPortraitScreenRes
  195. })
  196. })
  197. this.data.intervieweeFormCopy = JSON.parse(JSON.stringify(this.data.intervieweeForm));
  198. this.data.searchFormCopy = JSON.parse(JSON.stringify(this.data.searchForm));
  199. let visitReasonList = (app.globalData.snDisposition.visitReason || '业务拜访/会议邀请/施工单位/其他事项').split('/');
  200. console.log(JSON.stringify(app.globalData.snDisposition))
  201. console.log(JSON.stringify(app.globalData.registerNotDesensitizedColumn))
  202. console.log('phone', app.data.userInfo.phone, app.data.inputPhone)
  203. this.setData({
  204. snDisposition: app.globalData.snDisposition,
  205. causeMatterList: visitReasonList,
  206. 'remainingInfo.visitorPhone': app.data.userInfo.phone || app.data.inputPhone,
  207. 'remainingInfo.visitorName': app.data.userInfo.xm,
  208. 'remainingInfo.visitorIdCard': app.data.userInfo.sfzh,
  209. 'remainingInfo.avatar': app.data.userInfo.avatar,
  210. 'remainingInfo.idCardPhoto': app.data.userInfo.idCardPhoto,
  211. 'remainingInfo.visitorUnit': app.data.userInfo.visitorUnit || '',
  212. carnum: app.data.userInfo.carnum || '',
  213. 'remainingInfo.causeMatterName': visitReasonList.length > 0 ? visitReasonList[0] : '',
  214. 'formInfo.causeMatterName': visitReasonList.length > 0 ? visitReasonList[0] : '',
  215. 'formInfo.visitorPhone': app.data.userInfo.phone || app.data.inputPhone
  216. })
  217. console.log(visitReasonList)
  218. // ⾃然⼈⻛险评分查询
  219. if (this.data.snDisposition.riskCheck) {
  220. this.riskQuery()
  221. }
  222. this.getHistory()
  223. this.getTable()
  224. this.configList()
  225. },
  226. initScreenType() {
  227. let that = this
  228. return new Promise((resolve, reject) => {
  229. if (app.globalData.isPortraitScreen) {
  230. if (app.globalData.isPortraitScreen != null) {
  231. resolve(app.globalData.isPortraitScreen)
  232. }
  233. } else {
  234. that.data.screenIntervalId = setInterval(function () {
  235. if (app.globalData.isPortraitScreen != null) {
  236. resolve(app.globalData.isPortraitScreen)
  237. clearInterval(that.data.screenIntervalId);
  238. }
  239. }, 1000);
  240. }
  241. })
  242. },
  243. async getHistory(historyPagNum){
  244. try {
  245. let params = {
  246. data : {
  247. certNo: this.data.remainingInfo.visitorIdCard,
  248. sn: app.globalData.sn,
  249. },
  250. pageNum: historyPagNum ? historyPagNum : 1,
  251. pageSize: 2
  252. }
  253. let res = await publicInterface(
  254. {
  255. prop: 'fkjHistoryRecordUrl',
  256. defaultProp: '/history',
  257. data: params,
  258. method: 'post',
  259. errorTip: '历史访问记录api请求失败'
  260. }
  261. )
  262. if(res.data.total > 0 ){
  263. let array = res.data.list.map((item,index)=>{
  264. return{
  265. userVisitorListDetailId: item.userVisitorListDetailId,
  266. info1:{
  267. 'carnum': item.carno,
  268. 'visitorName': item.certName,
  269. 'visitorPhone': item.certPhone,
  270. 'visitorUnit': item.company,
  271. 'causeMatterName': item.reason,
  272. 'isSel': false
  273. },
  274. info2:{
  275. "unitName": item.visiteeBm,
  276. "company": item.visiteeCompany,
  277. "floor": item.visiteeFloor ? item.visiteeFloor : '',
  278. "phone": item.visiteePhone,
  279. "room": item.visiteeRoom,
  280. "name": item.visiteeXm,
  281. 'isSel': false
  282. }
  283. }
  284. })
  285. this.setData({
  286. historyPagNum: historyPagNum ? historyPagNum : 1,
  287. historyPageSize: res.data.pages,
  288. historyList: array,
  289. })
  290. }else{
  291. this.setData({
  292. isHistory: false
  293. })
  294. }
  295. } catch (error) {
  296. console.log(error);
  297. my.showToast({
  298. content: error.msg || '历史访问记录api请求失败',
  299. duration: 2000
  300. });
  301. }
  302. },
  303. // 上一页
  304. async historyPreviousFun() {
  305. console.log(this.data)
  306. const pageNum = this.data.historyPagNum - 1
  307. if (pageNum <= 0) {
  308. return
  309. }
  310. await this.getHistory(pageNum)
  311. await this.displaySelectedDataFunc()
  312. },
  313. // 下一页
  314. async historyNextFun() {
  315. const pageNum = this.data.historyPagNum + 1
  316. if (pageNum > this.data.historyPageSize) {
  317. return
  318. }
  319. await this.getHistory(pageNum)
  320. await this.displaySelectedDataFunc()
  321. },
  322. async getTable(e) {
  323. try {
  324. let {
  325. sliceStart,
  326. mumberRows
  327. } = this.data
  328. let dto = {
  329. sn: app.globalData.sn,
  330. }
  331. let res = await visiteeList(app.globalData.snDisposition.visiteeUrl, dto)
  332. var pageNum = Math.ceil(res.data.length / mumberRows)
  333. sliceStart = 0
  334. this.setData({
  335. allList: res.data,
  336. allListCopy: res.data,
  337. tableList: res.data.slice(sliceStart, mumberRows),
  338. total: res.data.length,
  339. sliceStart: 0,
  340. sliceEnd: mumberRows,
  341. pageNum,
  342. pageSize: res.data.length > 0 ? 1 : 0,
  343. })
  344. } catch (error) {
  345. console.log(error);
  346. }
  347. },
  348. displaySelectedDataFunc(){
  349. if(this.data.userVisitorListDetailId){
  350. this.data.historyList.forEach((item,index)=>{
  351. if(item.userVisitorListDetailId === this.data.userVisitorListDetailId){
  352. item.info1.isSel = this.data.historySelObj.info1Sel
  353. item.info2.isSel = this.data.historySelObj.info2Sel
  354. }
  355. })
  356. this.setData({
  357. historyList: this.data.historyList
  358. })
  359. }
  360. },
  361. // 选中受访人信息数据
  362. selInfo: function (e) {
  363. const idx = e.currentTarget.dataset.index; // 获取被点击项的下标
  364. const items = this.data.historyList.map((item,index) => {
  365. item.info1.isSel = false
  366. item.info2.isSel = false
  367. if (index == idx) {
  368. this.setData({
  369. historySelObj:{
  370. info1Sel: true,
  371. info2Sel: true,
  372. },
  373. userVisitorListDetailId: item.userVisitorListDetailId,
  374. carnum: item.info1.carnum,
  375. remainingInfo: {
  376. ...this.data.remainingInfo,
  377. ...item.info1
  378. },
  379. intervieweeForm:{
  380. ...item.info2
  381. }
  382. })
  383. return {
  384. ...item,
  385. info1:{
  386. ...item.info1,
  387. isSel: !item.info1.isSel // 切换选中状态
  388. },
  389. info2:{
  390. ...item.info2,
  391. isSel: !item.info2.isSel // 切换选中状态
  392. }
  393. };
  394. }
  395. return item; // 其他项保持不变
  396. });
  397. this.setData({
  398. historyList: items,
  399. }); // 更新数据状态
  400. },
  401. // 选择访客 单独控制
  402. selInfo1: function (e){
  403. let visitReasonList = (app.globalData.snDisposition.visitReason || '业务拜访/会议邀请/施工单位/其他事项').split('/')
  404. const idx = e.currentTarget.dataset.index; // 获取被点击项的下标
  405. const items = this.data.historyList.map((item,index) => {
  406. if (index == idx) {
  407. if(!item.info1.isSel){
  408. this.setData({
  409. carnum: item.info1.carnum,
  410. remainingInfo:{
  411. ...this.data.remainingInfo,
  412. ...item.info1
  413. }
  414. })
  415. }else{
  416. if(!item.info2.isSel){
  417. this.setData({
  418. historySelObj:{
  419. info1Sel: false,
  420. info2Sel: false,
  421. },
  422. userVisitorListDetailId: null
  423. })
  424. }
  425. this.defaultFormInfo()
  426. }
  427. this.setData({
  428. 'historySelObj.info2Sel': !item.info2.isSel,
  429. })
  430. return {
  431. ...item,
  432. info1:{
  433. ...item.info1,
  434. isSel: !item.info1.isSel // 切换选中状态
  435. }
  436. };
  437. }
  438. return item; // 其他项保持不变
  439. });
  440. this.setData({
  441. historyList: items
  442. }); // 更新数据状态
  443. },
  444. defaultFormInfo(){
  445. this.setData({
  446. carnum: this.data.formInfo.carnum || '',
  447. remainingInfo:{
  448. ...this.data.remainingInfo,
  449. ...this.data.formInfo
  450. }
  451. })
  452. },
  453. // 选择受访人 单独控制
  454. selInfo2: function (e){
  455. const idx = e.currentTarget.dataset.index; // 获取被点击项的下标
  456. const items = this.data.historyList.map((item,index) => {
  457. if (index == idx) {
  458. if(!item.info2.isSel){
  459. this.setData({
  460. intervieweeForm:{
  461. ...item.info2
  462. }
  463. })
  464. }else{
  465. if(!item.info1.isSel){
  466. this.setData({
  467. historySelObj:{
  468. info1Sel: false,
  469. info2Sel: false,
  470. },
  471. userVisitorListDetailId: null
  472. })
  473. }
  474. this.clearIntervieweeValue()
  475. }
  476. this.setData({
  477. 'historySelObj.info2Sel': !item.info2.isSel,
  478. })
  479. return {
  480. ...item,
  481. info2:{
  482. ...item.info2,
  483. isSel: !item.info2.isSel // 切换选中状态
  484. }
  485. };
  486. }
  487. return item; // 其他项保持不变
  488. });
  489. this.setData({
  490. historyList: items
  491. }); // 更新数据状态
  492. },
  493. backEnter(){
  494. this.clearIntervieweeValue()
  495. this.setData({
  496. isHistory: !this.data.isHistory,
  497. })
  498. },
  499. // ⾃然⼈⻛险评分查询
  500. async riskQuery() {
  501. let appKeyRisk = app.globalData.appKeyRisk
  502. let appSecretRisk = app.globalData.appSecretRisk
  503. let privateKeyRisk = app.globalData.privateKeyRisk
  504. let content = {
  505. sn: app.globalData.sn,
  506. name: app.data.userInfo.xm,
  507. idNumber: app.data.userInfo.sfzh,
  508. phone: app.data.userInfo.phone
  509. }
  510. // let content = {
  511. // sn: '136D002002300012',
  512. // name: '张亮',
  513. // idNumber: '321323199007264912',
  514. // phone: '18762761616'
  515. // }
  516. content = JSON.stringify(content)
  517. // 加密
  518. let sm4 = await encryptAndSign(appKeyRisk, appSecretRisk, privateKeyRisk, content, "encrypted")
  519. try {
  520. let data = {
  521. "appId": app.globalData.appIdRisk,
  522. "bizContent": sm4.encrypted,
  523. "reqTimestamp": sm4.timestamp,
  524. "sign": sm4.sign
  525. }
  526. let res = await riskQuery(data)
  527. // 解密
  528. let decryptedData = encryptAndSign(appKeyRisk, appSecretRisk, privateKeyRisk, res.data.bizContent, "decrypt")
  529. this.data.isRisk = false
  530. if (!decryptedData.decrypted) {
  531. return
  532. }
  533. let decrypted = JSON.parse(decryptedData.decrypted)
  534. if (!decrypted.result) {
  535. app.globalData.riskResult = 1
  536. } else if (decrypted.resultInfo.personFxpfjx && decrypted.resultInfo.personFxpfjx[4] == 1) {
  537. app.globalData.riskResult = 2
  538. } else {
  539. app.globalData.riskResult = 3
  540. }
  541. } catch (error) {
  542. console.log(error)
  543. // my.reLaunch({
  544. // url: '/pages/resultPage/index?result=结果页超时&&timer=' + app.globalData.snDisposition.resultPageTimeout,
  545. // })
  546. }
  547. },
  548. // 上一页
  549. previousFun() {
  550. let {
  551. allList,
  552. pageSize,
  553. sliceEnd,
  554. sliceStart,
  555. mumberRows
  556. } = this.data
  557. if (pageSize <= 1) {
  558. return
  559. }
  560. this.setData({
  561. tableList: allList.slice(sliceStart - mumberRows, sliceEnd - mumberRows),
  562. sliceStart: sliceStart - mumberRows,
  563. sliceEnd: sliceEnd - mumberRows,
  564. pageSize: pageSize - 1
  565. })
  566. },
  567. // 下一页
  568. nextFun() {
  569. let {
  570. allList,
  571. pageSize,
  572. pageNum,
  573. sliceEnd,
  574. sliceStart,
  575. mumberRows
  576. } = this.data
  577. if (pageSize >= pageNum) {
  578. return
  579. }
  580. this.setData({
  581. tableList: allList.slice(sliceStart + mumberRows, sliceEnd + mumberRows),
  582. sliceStart: sliceStart + mumberRows,
  583. sliceEnd: sliceEnd + mumberRows,
  584. pageSize: pageSize + 1
  585. })
  586. },
  587. // 倒计时结束
  588. finish() {
  589. this.backToSpecifiedPage('/pages/resultPage/index?result=结果页超时')
  590. },
  591. // 访客信息输入
  592. getValue(e) {
  593. let type = e.target.dataset.type
  594. let val = e.detail.value
  595. let key = `remainingInfo.${type}`
  596. let formKey = `formInfo.${type}`
  597. this.setData({
  598. [key]: val,
  599. [formKey]: val
  600. })
  601. if(this.data.historyList.length>0){
  602. this.data.historyList.forEach(item=>{
  603. item.info1.isSel = false
  604. })
  605. this.setData({
  606. historyList: this.data.historyList
  607. })
  608. }
  609. },
  610. // 事由
  611. openChoose(e) {
  612. this.setData({
  613. isShowCauseMatter: !this.data.isShowCauseMatter,
  614. hiddenPro: true,
  615. hiddenStr: true,
  616. })
  617. },
  618. closeCauseMatter() {
  619. getWaterDrop()
  620. this.setData({
  621. isShowCauseMatter: false
  622. })
  623. },
  624. getCauseMatterVal(e) {
  625. let item = e.currentTarget.dataset.item
  626. this.setData({
  627. 'remainingInfo.causeMatterName': item,
  628. 'formInfo.causeMatterName': item,
  629. isShowCauseMatter: false
  630. })
  631. },
  632. // 是否显示搜索项
  633. getIsShow() {
  634. let {
  635. isShowSearch
  636. } = this.data
  637. let mumberRows = isShowSearch ? 15 : 9
  638. let searchForm = JSON.parse(JSON.stringify(this.data.searchFormCopy));
  639. this.setData({
  640. isShowSearch: !isShowSearch,
  641. mumberRows: mumberRows,
  642. searchForm
  643. })
  644. this.getTable()
  645. },
  646. // 输入搜索项
  647. getSearchValue(e) {
  648. let type = e.target.dataset.type
  649. let val = e.detail.value
  650. let key = `searchForm.${type}`
  651. this.setData({
  652. [key]: val
  653. })
  654. },
  655. // 查询
  656. inquireFun() {
  657. let {
  658. searchForm,
  659. allList,
  660. isShowSearch,
  661. mumberRows,
  662. allListCopy
  663. } = this.data
  664. allList = JSON.parse(JSON.stringify(allListCopy))
  665. // 根据条件过滤数据
  666. let result = this.filterData(searchForm, allList)
  667. var pageNum = Math.ceil(result.length / mumberRows)
  668. let sliceStart = 0
  669. let sliceEnd = mumberRows
  670. this.setData({
  671. tableList: result.slice(sliceStart, mumberRows),
  672. allList: result,
  673. sliceEnd,
  674. sliceStart,
  675. total: result.length,
  676. pageNum,
  677. pageSize: result.length > 0 ? 1 : 0,
  678. })
  679. },
  680. // 多条件过滤,参数queryObj(过滤条件对象),list(需要过滤的数组)
  681. filterData(queryObj, list) {
  682. let arr = list
  683. Object.keys(queryObj).forEach(key => {
  684. if (queryObj[key] == undefined || queryObj[key] == '') return arr
  685. if (key == 'name') {
  686. arr = arr.filter(p => p[key] !== null && (p[key].indexOf(queryObj[key]) > -1 || p['pinyinFirstLetter'].toLowerCase().indexOf(queryObj[key].toLowerCase()) == 0))
  687. } else {
  688. arr = arr.filter(p => p[key] !== null && (p[key].indexOf(queryObj[key]) > -1))
  689. }
  690. })
  691. return arr
  692. },
  693. //清空
  694. clearFun() {
  695. let searchForm = JSON.parse(JSON.stringify(this.data.searchFormCopy));
  696. this.setData({
  697. searchForm
  698. })
  699. this.getTable()
  700. },
  701. // 是否是手动输入受访人
  702. chooseInterviewee() {
  703. this.setData({
  704. isEnterInterviewee: !this.data.isEnterInterviewee
  705. })
  706. },
  707. // 手动输入受访人
  708. getIntervieweeValue(e) {
  709. let type = e.target.dataset.type
  710. let val = e.detail.value
  711. let key = `intervieweeForm.${type}`
  712. this.setData({
  713. [key]: val
  714. })
  715. },
  716. // 清空充填受访人
  717. clearIntervieweeValue() {
  718. let intervieweeForm = JSON.parse(JSON.stringify(this.data.intervieweeFormCopy));
  719. this.setData({
  720. intervieweeForm
  721. })
  722. },
  723. // 选择楼层层数
  724. chooseFloor(e) {
  725. let val = e.currentTarget.dataset.item
  726. let {
  727. searchForm
  728. } = this.data
  729. if (searchForm.floor.length < 2) {
  730. this.setData({
  731. 'searchForm.floor': searchForm.floor + val
  732. })
  733. this.inquireFun()
  734. }
  735. },
  736. // 删除选择的楼层
  737. delFloor() {
  738. let {
  739. searchForm
  740. } = this.data
  741. this.setData({
  742. 'searchForm.floor': searchForm.floor.substr(0, searchForm.floor.length - 1)
  743. })
  744. this.inquireFun()
  745. },
  746. /// 按钮触摸开始触发的事件
  747. touchStart: function (e) {
  748. this.touchStartTime = e.timeStamp
  749. },
  750. /// 按钮触摸结束触发的事件
  751. touchEnd: function (e) {
  752. this.touchEndTime = e.timeStamp
  753. },
  754. chooesFloor(e) {
  755. let item = e.currentTarget.dataset.item
  756. var that = this
  757. // 控制点击事件在350ms内触发,加这层判断是为了防止长按时会触发点击事件
  758. if (that.data.touchEndTime - that.data.touchStartTime < 350) {
  759. // 当前点击的时间
  760. var currentTime = e.timeStamp
  761. var lastTapTime = that.data.lastTapTime
  762. // 更新最后一次点击时间
  763. that.data.lastTapTime = currentTime
  764. // 如果两次点击时间在300毫秒内,则认为是双击事件
  765. if (currentTime - lastTapTime < 300) {
  766. // console.log("双击")
  767. // 成功触发双击事件时,取消单击事件的执行
  768. clearTimeout(that.data.lastTapTimeoutFunc);
  769. that.setData({
  770. intervieweeForm: item
  771. })
  772. that.sure()
  773. } else {
  774. // 单击事件延时300毫秒执行,这和最初的浏览器的点击300ms延时有点像。
  775. that.data.lastTapTimeoutFunc = setTimeout(function () {
  776. that.setData({
  777. isEnterInterviewee: true,
  778. intervieweeForm: item
  779. })
  780. }, 300);
  781. }
  782. }
  783. },
  784. // 确定
  785. async sure() {
  786. if(this.data.isHistory){
  787. if(!this.data.intervieweeForm.name) {
  788. this.backEnter()
  789. return
  790. }
  791. }
  792. let {
  793. remainingInfo,
  794. intervieweeForm,
  795. carnum
  796. } = this.data
  797. let form = Object.assign({}, remainingInfo, intervieweeForm);
  798. console.log('form --->', form)
  799. form.carnum = carnum
  800. form.visitingTime = getDate()
  801. app.data.visitoMsgData = form
  802. // 启用进出记录推送
  803. let transitPushSwitch = app.globalData.snDisposition.transitPushSwitch
  804. if (transitPushSwitch) {
  805. // 获取辖区配置
  806. let areaRes = await areaInfo({
  807. sn: app.globalData.sn,
  808. }).data || {}
  809. /*let data = {
  810. "reason": form.causeMatterName,
  811. "num_peoples": form.peopleNum, //人数
  812. "machine_id": app.globalData.sn,
  813. "xm": form.visitorName,
  814. "sfzh": form.visitorIdCard,
  815. "phone": form.visitorPhone,
  816. // "xm": '张佳燕',
  817. // "sfzh": '331082199910045826',
  818. // "phone": '15888632412',
  819. "company": form.visitorUnit,
  820. "carno": form.carnum,
  821. "visitee_xm": form.name, //受访人姓名
  822. "visitee_bm": form.unitName,
  823. "visitee_company": form.company,
  824. "visitee_room": form.room,
  825. "visiteePhone": intervieweeForm.phone,
  826. "visitee_floor": form.floor,
  827. xp: app.data.userInfo.idCardPhoto,
  828. scene_xp: app.data.userInfo.avatar,
  829. time: form.visitingTime,
  830. }
  831. console.log('data', data)*/
  832. console.log('areaRes ----> ', JSON.stringify(areaRes))
  833. let newPushData = {
  834. "appType": "HHVisit",
  835. "recordid": 0, // 没有
  836. "sn": app.globalData.sn,
  837. "adminId": null, // 没有
  838. "pcsname": areaRes.policeStationName || '', // 所属辖区派出所名称
  839. "pcsdm": areaRes.policeStationCode || '', // 所属辖区派出所代码
  840. "provinceName": areaRes.provinceName || '', // 所属省份
  841. "cityName": areaRes.cityName || '', // 所属城市
  842. "areaName": areaRes.areaName || '', // 所属区/县
  843. "streetName": areaRes.streetName || '', // 街道/乡/镇
  844. "address": areaRes.address || '', // 详细地址
  845. "deviceAddress": areaRes.deviceAddress || '', // 设备地点
  846. "outType": 1, // 服务端设备所属进出口: 0 通用 1进门 2出门
  847. "status": true,// 人员进入是否有效: true 有效 false 无效
  848. "reasonType": null,// 无效原因: 1 未成年人禁止进入 2 黑名单
  849. "userId": 0,// 服务端用户id
  850. "verifyType": app.data.userInfo.verifyType,// todo 识别类型
  851. "certName": form.visitorName, // 用户姓名
  852. "certNo": form.visitorIdCard, // 用户证件号
  853. "certContent": JSON.stringify(app.data.userInfo.certContent || '') || '', // 身份证阅读器返回全部 todo
  854. "phone": form.visitorPhone, // 用户手机号
  855. "cardidex": null, // 用户卡号
  856. "photo": app.data.userInfo.avatar, // 用户现场照片
  857. "originPhoto": '', // 比对源照片url todo
  858. "originPhotoBase64": app.data.userInfo.idCardPhoto, // 比对源照片base64 todo
  859. "verifyScore": null, // 人脸比对分值: 0-100 todo
  860. "company": form.visitorUnit, // 用户单位名称
  861. "carno": form.carnum, // 用户车牌号
  862. "reason": form.causeMatterName, // 拜访事由
  863. "time": form.visitingTime, // 刷脸时间
  864. "visiteeXm": form.name, //受访人姓名
  865. "visiteePhone": intervieweeForm.phone, // 受访人手机号
  866. "visiteeCompany": form.company, // 受访人单位
  867. "visiteeBm": form.unitName, // 受访人部门
  868. "visiteeFloor": form.floor, // 受访人所在楼层
  869. "visiteeRoom": form.room, // 受访人所在房间号
  870. "startTime": null, // 有效期开始时间
  871. "endTime": null, // 有效期结束时间
  872. "event": 1 // 事件类型: 1 登记 2 签离
  873. }
  874. console.log('newPushData ----> ',JSON.stringify(newPushData))
  875. let url = app.globalData.snDisposition.transitPushUrl
  876. try {
  877. // 进出记录推送
  878. let res = await threeElements(url, newPushData)
  879. console.log('commonQrCode', res.data.commonQrCode);
  880. console.log('ladderQrCode', res.data.ladderQrCode);
  881. app.data.visitoMsgData.commonQrCode = res.data.commonQrCode
  882. app.data.visitoMsgData.ladderQrCode = res.data.ladderQrCode
  883. this.backToSpecifiedPage('/pages/resultPage/index?result=登记成功')
  884. viceBroadcast(app.globalData.snDisposition.registerSuccessVoice)
  885. } catch (error) {
  886. this.backToSpecifiedPage('/pages/resultPage/index?result=登记失败')
  887. }
  888. } else {
  889. this.backToSpecifiedPage('/pages/resultPage/index?result=登记成功')
  890. viceBroadcast(app.globalData.snDisposition.registerSuccessVoice)
  891. }
  892. },
  893. closeCanNot() {
  894. this.setData({
  895. hiddenPro: true,
  896. hiddenStr: true,
  897. isShowCauseMatter: false
  898. })
  899. },
  900. // 多选楼层开始
  901. async configList() {
  902. try {
  903. let data = {
  904. sn: app.globalData.sn
  905. }
  906. let res = await configList(data)
  907. this.setData({
  908. allFloorList: res.data
  909. })
  910. } catch (error) {
  911. console.log(error);
  912. }
  913. },
  914. openFloor() {
  915. let {
  916. intervieweeForm,
  917. allFloorList
  918. } = this.data
  919. let floorList = []
  920. if (intervieweeForm.floor) {
  921. floorList = intervieweeForm.floor.split(',')
  922. }
  923. let indexList = []
  924. if (floorList.length > 0) {
  925. floorList.forEach(item1 => {
  926. let index = allFloorList.findIndex(item => {
  927. return item1 == item.actualityFloor
  928. })
  929. if (index > -1) {
  930. indexList.push(index)
  931. }
  932. })
  933. }
  934. this.setData({
  935. isShowfloor: true,
  936. chooseFloorIndex: indexList,
  937. chooseFloorItem: floorList
  938. })
  939. },
  940. multipleChoiceFloor(e) {
  941. let index = e.currentTarget.dataset.index
  942. let item = e.currentTarget.dataset.item
  943. let {
  944. chooseFloorIndex,
  945. chooseFloorItem,
  946. } = this.data
  947. let index1 = chooseFloorIndex.findIndex(item => {
  948. return item == index
  949. })
  950. if (index1 == -1) {
  951. chooseFloorIndex.push(index)
  952. chooseFloorItem.push(item.actualityFloor)
  953. } else {
  954. chooseFloorIndex.splice(index1, 1);
  955. chooseFloorItem.splice(index1, 1);
  956. }
  957. this.setData({
  958. chooseFloorIndex,
  959. chooseFloorItem,
  960. })
  961. },
  962. delmultipleChoiceFloor(e) {
  963. let index = e.currentTarget.dataset.index
  964. let {
  965. chooseFloorIndex,
  966. chooseFloorItem,
  967. } = this.data
  968. chooseFloorIndex.splice(index, 1);
  969. chooseFloorItem.splice(index, 1);
  970. this.setData({
  971. chooseFloorIndex,
  972. chooseFloorItem,
  973. })
  974. },
  975. floorCancel() {
  976. this.setData({
  977. isShowfloor: false,
  978. chooseFloorIndex: [],
  979. chooseFloorItem: []
  980. })
  981. },
  982. floorSure() {
  983. let str = this.data.chooseFloorItem.join(',');
  984. this.setData({
  985. isShowfloor: false,
  986. 'intervieweeForm.floor': str
  987. })
  988. },
  989. // 多选楼层结束
  990. // 键盘函数开始
  991. proTap(e) { //点击省份
  992. let that = this;
  993. let province = e.currentTarget.dataset.province;
  994. let carnum = this.data.carnum;
  995. if (carnum.length < 1) { //避免连续点击
  996. carnum += province;
  997. }
  998. this.setData({
  999. carnum: carnum,
  1000. 'formInfo.carnum': carnum,
  1001. hiddenPro: true,
  1002. hiddenStr: false,
  1003. })
  1004. },
  1005. strTap(e) { //点击字母数字
  1006. let that = this;
  1007. this.setData({
  1008. waiting: true
  1009. })
  1010. let province = e.currentTarget.dataset.str;
  1011. let carnum = this.data.carnum;
  1012. // console.log(carnum.length)
  1013. if (carnum.length <= 8) { //避免连续点击
  1014. carnum += province;
  1015. console.log(carnum);
  1016. }
  1017. // this.setData({
  1018. // notNum: false,
  1019. // carnum: carnum,
  1020. // })
  1021. this.setData({
  1022. notNum: false,
  1023. carnum: carnum,
  1024. 'formInfo.carnum': carnum,
  1025. })
  1026. setTimeout(() => {
  1027. that.setData({
  1028. waiting: false
  1029. })
  1030. }, 100);
  1031. if (carnum.length > 6) {
  1032. this.setData({
  1033. downBtn: '完成',
  1034. strDisabled: true,
  1035. })
  1036. // this.searchCardInfo()
  1037. return; // 车牌长度最多为7个
  1038. }
  1039. },
  1040. backSpace() { //退格
  1041. let carnum = this.data.carnum;
  1042. if (carnum.length <= 7) {
  1043. this.setData({
  1044. downBtn: '返回',
  1045. strDisabled: false,
  1046. })
  1047. }
  1048. var arr = carnum.split('');
  1049. arr.splice(-1, 1)
  1050. var str = arr.join('')
  1051. if (arr.length < 2) {
  1052. this.setData({
  1053. notNum: true
  1054. })
  1055. }
  1056. if (str == '') {
  1057. this.setData({
  1058. hiddenPro: false,
  1059. hiddenStr: true
  1060. })
  1061. }
  1062. this.setData({
  1063. carnum: str
  1064. })
  1065. },
  1066. backKeyboard() { //返回省份键盘
  1067. if (this.data.carnum.length > 6) {
  1068. this.setData({
  1069. downBtn: '完成',
  1070. hiddenPro: true,
  1071. hiddenStr: false
  1072. })
  1073. } else if (this.data.carnum.length > 0) {
  1074. this.setData({
  1075. hiddenPro: true,
  1076. hiddenStr: false
  1077. })
  1078. } else {
  1079. this.setData({
  1080. hiddenPro: false,
  1081. hiddenStr: true
  1082. })
  1083. }
  1084. },
  1085. applyNum() {
  1086. this.setData({
  1087. hiddenPro: true,
  1088. hiddenStr: true,
  1089. })
  1090. },
  1091. closeSecondaryScreenFuc() {
  1092. console.log('关闭副屏', app.data.isSecondaryScreenState)
  1093. if (app.data.isSecondaryScreenState) {
  1094. closeSecondaryScreen()
  1095. // closeCycleSecondaryScreen()
  1096. }
  1097. },
  1098. // 键盘函数结束
  1099. saveRef(ref) {
  1100. // 将ref存起来,在想要调用的地方使用
  1101. this.toTitleRef = ref
  1102. },
  1103. /**
  1104. * 跳转指定页面 并清除顶部计时器
  1105. */
  1106. backToSpecifiedPage(url) {
  1107. this.toTitleRef && this.toTitleRef.clearIntervalAll()
  1108. my.reLaunch({
  1109. url: url,
  1110. })
  1111. setTimeout(() => {
  1112. this.closeSecondaryScreenFuc();
  1113. }, 500)
  1114. },
  1115. back() {
  1116. // 是否能加载到副屏
  1117. let isSecondaryScreenState = app.data.isSecondaryScreenState;
  1118. if (isSecondaryScreenState) {
  1119. // 是否启用副屏处理中页面
  1120. let processingPageSwitch = app.globalData.snDisposition.processingPageSwitch;
  1121. // 是否启用副屏轮播图
  1122. let secondaryPageSwitch = app.globalData.snDisposition.secondaryPageSwitch;
  1123. if (processingPageSwitch && secondaryPageSwitch) {// 启用副屏处理中页面 && 启用副屏轮播图
  1124. app.data.cycleIntervalSwitch = true
  1125. let url = app.globalData.snDisposition.secondaryPageImages[app.data.secondaryPageImagesIndex] || ''
  1126. if (url) {
  1127. openSecondaryScreen(url)
  1128. }
  1129. setTimeout(() => {
  1130. this.toTitleRef && this.toTitleRef.clearIntervalAll()
  1131. my.reLaunch({
  1132. url: '/pages/home/index',
  1133. })
  1134. }, 500)
  1135. } else if (!processingPageSwitch && secondaryPageSwitch) { // 不启用副屏处理中页面 && 启用副屏轮播图
  1136. app.data.cycleIntervalSwitch = true
  1137. let url = app.globalData.snDisposition.secondaryPageImages[app.data.secondaryPageImagesIndex] || ''
  1138. if (url) {
  1139. openSecondaryScreen(url)
  1140. }
  1141. setTimeout(() => {
  1142. this.toTitleRef && this.toTitleRef.clearIntervalAll()
  1143. my.reLaunch({
  1144. url: '/pages/home/index',
  1145. })
  1146. }, 500)
  1147. } else {
  1148. this.backToSpecifiedPage('/pages/home/index')
  1149. }
  1150. } else {
  1151. this.backToSpecifiedPage('/pages/home/index')
  1152. }
  1153. },
  1154. didUnmount() {
  1155. // this.closeSecondaryScreenFuc();
  1156. },
  1157. onUnload() {
  1158. // this.closeSecondaryScreenFuc();
  1159. },
  1160. });