index.js 32 KB

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