index.js 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  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. this.setData({
  400. carnum: this.data.formInfo.carnum || '',
  401. remainingInfo:{
  402. ...this.data.formInfo
  403. }
  404. })
  405. },
  406. // 选择受访人 单独控制
  407. selInfo2: function (e){
  408. const idx = e.currentTarget.dataset.index; // 获取被点击项的下标
  409. const items = this.data.historyList.map((item,index) => {
  410. if (index == idx) {
  411. if(!item.info2.isSel){
  412. this.setData({
  413. intervieweeForm:{
  414. ...item.info2
  415. }
  416. })
  417. }else{
  418. this.setData({
  419. intervieweeForm:{}
  420. })
  421. }
  422. return {
  423. ...item,
  424. info2:{
  425. ...item.info2,
  426. isSel: !item.info2.isSel // 切换选中状态
  427. }
  428. };
  429. }
  430. return item; // 其他项保持不变
  431. });
  432. this.setData({
  433. historyList: items
  434. }); // 更新数据状态
  435. },
  436. backEnter(){
  437. this.setData({
  438. isHistory: !this.data.isHistory,
  439. intervieweeForm:{}
  440. })
  441. },
  442. // ⾃然⼈⻛险评分查询
  443. async riskQuery() {
  444. let appKeyRisk = app.globalData.appKeyRisk
  445. let appSecretRisk = app.globalData.appSecretRisk
  446. let privateKeyRisk = app.globalData.privateKeyRisk
  447. let content = {
  448. sn: app.globalData.sn,
  449. name: app.data.userInfo.xm,
  450. idNumber: app.data.userInfo.sfzh,
  451. phone: app.data.userInfo.phone
  452. }
  453. // let content = {
  454. // sn: '136D002002300012',
  455. // name: '张亮',
  456. // idNumber: '321323199007264912',
  457. // phone: '18762761616'
  458. // }
  459. content = JSON.stringify(content)
  460. // 加密
  461. let sm4 = await encryptAndSign(appKeyRisk, appSecretRisk, privateKeyRisk, content, "encrypted")
  462. try {
  463. let data = {
  464. "appId": app.globalData.appIdRisk,
  465. "bizContent": sm4.encrypted,
  466. "reqTimestamp": sm4.timestamp,
  467. "sign": sm4.sign
  468. }
  469. let res = await riskQuery(data)
  470. // 解密
  471. let decryptedData = encryptAndSign(appKeyRisk, appSecretRisk, privateKeyRisk, res.data.bizContent, "decrypt")
  472. this.data.isRisk = false
  473. if (!decryptedData.decrypted) {
  474. return
  475. }
  476. let decrypted = JSON.parse(decryptedData.decrypted)
  477. if (!decrypted.result) {
  478. app.globalData.riskResult = 1
  479. } else if (decrypted.resultInfo.personFxpfjx && decrypted.resultInfo.personFxpfjx[4] == 1) {
  480. app.globalData.riskResult = 2
  481. } else {
  482. app.globalData.riskResult = 3
  483. }
  484. } catch (error) {
  485. console.log(error)
  486. // my.reLaunch({
  487. // url: '/pages/resultPage/index?result=结果页超时&&timer=' + app.globalData.snDisposition.resultPageTimeout,
  488. // })
  489. }
  490. },
  491. // 上一页
  492. previousFun() {
  493. let {
  494. allList,
  495. pageSize,
  496. sliceEnd,
  497. sliceStart,
  498. mumberRows
  499. } = this.data
  500. if (pageSize <= 1) {
  501. return
  502. }
  503. this.setData({
  504. tableList: allList.slice(sliceStart - mumberRows, sliceEnd - mumberRows),
  505. sliceStart: sliceStart - mumberRows,
  506. sliceEnd: sliceEnd - mumberRows,
  507. pageSize: pageSize - 1
  508. })
  509. },
  510. // 下一页
  511. nextFun() {
  512. let {
  513. allList,
  514. pageSize,
  515. pageNum,
  516. sliceEnd,
  517. sliceStart,
  518. mumberRows
  519. } = this.data
  520. if (pageSize >= pageNum) {
  521. return
  522. }
  523. this.setData({
  524. tableList: allList.slice(sliceStart + mumberRows, sliceEnd + mumberRows),
  525. sliceStart: sliceStart + mumberRows,
  526. sliceEnd: sliceEnd + mumberRows,
  527. pageSize: pageSize + 1
  528. })
  529. },
  530. // 倒计时结束
  531. finish() {
  532. this.backToSpecifiedPage('/pages/resultPage/index?result=结果页超时')
  533. },
  534. // 访客信息输入
  535. getValue(e) {
  536. let type = e.target.dataset.type
  537. let val = e.detail.value
  538. let key = `remainingInfo.${type}`
  539. let formKey = `formInfo.${type}`
  540. this.setData({
  541. [key]: val,
  542. [formKey]: val
  543. })
  544. console.log(this.data.historyList)
  545. if(this.data.historyList.length>0){
  546. this.data.historyList.forEach(item=>{
  547. item.info1.isSel = false
  548. })
  549. this.setData({
  550. historyList: this.data.historyList
  551. })
  552. // let array = this.data.historyList.map(item=>{
  553. // console.log(item)
  554. // if(item.info1.isSel){
  555. // return {
  556. // ...item,
  557. // info1:{
  558. // ...item.info1,
  559. // isSel: !item.info1.isSel
  560. // }
  561. // }
  562. // }else{
  563. // }
  564. // })
  565. // this.setData({
  566. // historyList: array
  567. // })
  568. }
  569. },
  570. // 事由
  571. openChoose(e) {
  572. this.setData({
  573. isShowCauseMatter: !this.data.isShowCauseMatter,
  574. hiddenPro: true,
  575. hiddenStr: true,
  576. })
  577. },
  578. closeCauseMatter() {
  579. getWaterDrop()
  580. this.setData({
  581. isShowCauseMatter: false
  582. })
  583. },
  584. getCauseMatterVal(e) {
  585. let item = e.currentTarget.dataset.item
  586. this.setData({
  587. 'remainingInfo.causeMatterName': item,
  588. 'formInfo.causeMatterName': item,
  589. isShowCauseMatter: false
  590. })
  591. },
  592. // 是否显示搜索项
  593. getIsShow() {
  594. let {
  595. isShowSearch
  596. } = this.data
  597. let mumberRows = isShowSearch ? 15 : 9
  598. let searchForm = JSON.parse(JSON.stringify(this.data.searchFormCopy));
  599. this.setData({
  600. isShowSearch: !isShowSearch,
  601. mumberRows: mumberRows,
  602. searchForm
  603. })
  604. this.getTable()
  605. },
  606. // 输入搜索项
  607. getSearchValue(e) {
  608. let type = e.target.dataset.type
  609. let val = e.detail.value
  610. let key = `searchForm.${type}`
  611. this.setData({
  612. [key]: val
  613. })
  614. },
  615. // 查询
  616. inquireFun() {
  617. let {
  618. searchForm,
  619. allList,
  620. isShowSearch,
  621. mumberRows,
  622. allListCopy
  623. } = this.data
  624. allList = JSON.parse(JSON.stringify(allListCopy))
  625. // 根据条件过滤数据
  626. let result = this.filterData(searchForm, allList)
  627. var pageNum = Math.ceil(result.length / mumberRows)
  628. let sliceStart = 0
  629. let sliceEnd = mumberRows
  630. this.setData({
  631. tableList: result.slice(sliceStart, mumberRows),
  632. allList: result,
  633. sliceEnd,
  634. sliceStart,
  635. total: result.length,
  636. pageNum,
  637. pageSize: result.length > 0 ? 1 : 0,
  638. })
  639. },
  640. // 多条件过滤,参数queryObj(过滤条件对象),list(需要过滤的数组)
  641. filterData(queryObj, list) {
  642. let arr = list
  643. Object.keys(queryObj).forEach(key => {
  644. if (queryObj[key] == undefined || queryObj[key] == '') return arr
  645. if (key == 'name') {
  646. arr = arr.filter(p => p[key] !== null && (p[key].indexOf(queryObj[key]) > -1 || p['pinyinFirstLetter'].toLowerCase().indexOf(queryObj[key].toLowerCase()) == 0))
  647. } else {
  648. arr = arr.filter(p => p[key] !== null && (p[key].indexOf(queryObj[key]) > -1))
  649. }
  650. })
  651. return arr
  652. },
  653. //清空
  654. clearFun() {
  655. let searchForm = JSON.parse(JSON.stringify(this.data.searchFormCopy));
  656. this.setData({
  657. searchForm
  658. })
  659. this.getTable()
  660. },
  661. // 是否是手动输入受访人
  662. chooseInterviewee() {
  663. this.setData({
  664. isEnterInterviewee: !this.data.isEnterInterviewee
  665. })
  666. },
  667. // 手动输入受访人
  668. getIntervieweeValue(e) {
  669. let type = e.target.dataset.type
  670. let val = e.detail.value
  671. let key = `intervieweeForm.${type}`
  672. this.setData({
  673. [key]: val
  674. })
  675. },
  676. // 清空充填受访人
  677. clearIntervieweeValue() {
  678. let intervieweeForm = JSON.parse(JSON.stringify(this.data.intervieweeFormCopy));
  679. this.setData({
  680. intervieweeForm
  681. })
  682. },
  683. // 选择楼层层数
  684. chooseFloor(e) {
  685. let val = e.currentTarget.dataset.item
  686. let {
  687. searchForm
  688. } = this.data
  689. if (searchForm.floor.length < 2) {
  690. this.setData({
  691. 'searchForm.floor': searchForm.floor + val
  692. })
  693. this.inquireFun()
  694. }
  695. },
  696. // 删除选择的楼层
  697. delFloor() {
  698. let {
  699. searchForm
  700. } = this.data
  701. this.setData({
  702. 'searchForm.floor': searchForm.floor.substr(0, searchForm.floor.length - 1)
  703. })
  704. this.inquireFun()
  705. },
  706. /// 按钮触摸开始触发的事件
  707. touchStart: function (e) {
  708. this.touchStartTime = e.timeStamp
  709. },
  710. /// 按钮触摸结束触发的事件
  711. touchEnd: function (e) {
  712. this.touchEndTime = e.timeStamp
  713. },
  714. chooesFloor(e) {
  715. let item = e.currentTarget.dataset.item
  716. var that = this
  717. // 控制点击事件在350ms内触发,加这层判断是为了防止长按时会触发点击事件
  718. if (that.data.touchEndTime - that.data.touchStartTime < 350) {
  719. // 当前点击的时间
  720. var currentTime = e.timeStamp
  721. var lastTapTime = that.data.lastTapTime
  722. // 更新最后一次点击时间
  723. that.data.lastTapTime = currentTime
  724. // 如果两次点击时间在300毫秒内,则认为是双击事件
  725. if (currentTime - lastTapTime < 300) {
  726. // console.log("双击")
  727. // 成功触发双击事件时,取消单击事件的执行
  728. clearTimeout(that.data.lastTapTimeoutFunc);
  729. that.setData({
  730. intervieweeForm: item
  731. })
  732. that.sure()
  733. } else {
  734. // 单击事件延时300毫秒执行,这和最初的浏览器的点击300ms延时有点像。
  735. that.data.lastTapTimeoutFunc = setTimeout(function () {
  736. that.setData({
  737. isEnterInterviewee: true,
  738. intervieweeForm: item
  739. })
  740. }, 300);
  741. }
  742. }
  743. },
  744. // 确定
  745. async sure() {
  746. if(this.data.isHistory){
  747. if(!this.data.intervieweeForm.name) {
  748. this.backEnter()
  749. return
  750. }
  751. }
  752. let {
  753. remainingInfo,
  754. intervieweeForm,
  755. carnum
  756. } = this.data
  757. let form = Object.assign({}, remainingInfo, intervieweeForm);
  758. console.log('form --->', form)
  759. form.carnum = carnum
  760. form.visitingTime = getDate()
  761. app.data.visitoMsgData = form
  762. // 启用进出记录推送
  763. let transitPushSwitch = app.globalData.snDisposition.transitPushSwitch
  764. if (transitPushSwitch) {
  765. // 获取辖区配置
  766. let areaRes = await areaInfo({
  767. sn: app.globalData.sn,
  768. }).data || {}
  769. /*let data = {
  770. "reason": form.causeMatterName,
  771. "num_peoples": form.peopleNum, //人数
  772. "machine_id": app.globalData.sn,
  773. "xm": form.visitorName,
  774. "sfzh": form.visitorIdCard,
  775. "phone": form.visitorPhone,
  776. // "xm": '张佳燕',
  777. // "sfzh": '331082199910045826',
  778. // "phone": '15888632412',
  779. "company": form.visitorUnit,
  780. "carno": form.carnum,
  781. "visitee_xm": form.name, //受访人姓名
  782. "visitee_bm": form.unitName,
  783. "visitee_company": form.company,
  784. "visitee_room": form.room,
  785. "visiteePhone": intervieweeForm.phone,
  786. "visitee_floor": form.floor,
  787. xp: app.data.userInfo.idCardPhoto,
  788. scene_xp: app.data.userInfo.avatar,
  789. time: form.visitingTime,
  790. }
  791. console.log('data', data)*/
  792. console.log('areaRes ----> ', JSON.stringify(areaRes))
  793. let newPushData = {
  794. "appType": "HHVisit",
  795. "recordid": 0, // 没有
  796. "sn": app.globalData.sn,
  797. "adminId": null, // 没有
  798. "pcsname": areaRes.policeStationName || '', // 所属辖区派出所名称
  799. "pcsdm": areaRes.policeStationCode || '', // 所属辖区派出所代码
  800. "provinceName": areaRes.provinceName || '', // 所属省份
  801. "cityName": areaRes.cityName || '', // 所属城市
  802. "areaName": areaRes.areaName || '', // 所属区/县
  803. "streetName": areaRes.streetName || '', // 街道/乡/镇
  804. "address": areaRes.address || '', // 详细地址
  805. "deviceAddress": areaRes.deviceAddress || '', // 设备地点
  806. "outType": 1, // 服务端设备所属进出口: 0 通用 1进门 2出门
  807. "status": true,// 人员进入是否有效: true 有效 false 无效
  808. "reasonType": null,// 无效原因: 1 未成年人禁止进入 2 黑名单
  809. "userId": 0,// 服务端用户id
  810. "verifyType": app.data.userInfo.verifyType,// todo 识别类型
  811. "certName": form.visitorName, // 用户姓名
  812. "certNo": form.visitorIdCard, // 用户证件号
  813. "certContent": JSON.stringify(app.data.userInfo.certContent || '') || '', // 身份证阅读器返回全部 todo
  814. "phone": form.visitorPhone, // 用户手机号
  815. "cardidex": null, // 用户卡号
  816. "photo": app.data.userInfo.avatar, // 用户现场照片
  817. "originPhoto": '', // 比对源照片url todo
  818. "originPhotoBase64": app.data.userInfo.idCardPhoto, // 比对源照片base64 todo
  819. "verifyScore": null, // 人脸比对分值: 0-100 todo
  820. "company": form.visitorUnit, // 用户单位名称
  821. "carno": form.carnum, // 用户车牌号
  822. "reason": form.causeMatterName, // 拜访事由
  823. "time": form.visitingTime, // 刷脸时间
  824. "visiteeXm": form.name, //受访人姓名
  825. "visiteePhone": intervieweeForm.phone, // 受访人手机号
  826. "visiteeCompany": form.company, // 受访人单位
  827. "visiteeBm": form.unitName, // 受访人部门
  828. "visiteeFloor": form.floor, // 受访人所在楼层
  829. "visiteeRoom": form.room, // 受访人所在房间号
  830. "startTime": null, // 有效期开始时间
  831. "endTime": null, // 有效期结束时间
  832. "event": 1 // 事件类型: 1 登记 2 签离
  833. }
  834. console.log('newPushData ----> ',JSON.stringify(newPushData))
  835. let url = app.globalData.snDisposition.transitPushUrl
  836. try {
  837. // 进出记录推送
  838. let res = await threeElements(url, newPushData)
  839. console.log('commonQrCode', res.data.commonQrCode);
  840. console.log('ladderQrCode', res.data.ladderQrCode);
  841. app.data.visitoMsgData.commonQrCode = res.data.commonQrCode
  842. app.data.visitoMsgData.ladderQrCode = res.data.ladderQrCode
  843. this.backToSpecifiedPage('/pages/resultPage/index?result=登记成功')
  844. viceBroadcast(app.globalData.snDisposition.registerSuccessVoice)
  845. } catch (error) {
  846. this.backToSpecifiedPage('/pages/resultPage/index?result=登记失败')
  847. }
  848. } else {
  849. this.backToSpecifiedPage('/pages/resultPage/index?result=登记成功')
  850. viceBroadcast(app.globalData.snDisposition.registerSuccessVoice)
  851. }
  852. },
  853. closeCanNot() {
  854. this.setData({
  855. hiddenPro: true,
  856. hiddenStr: true,
  857. isShowCauseMatter: false
  858. })
  859. },
  860. // 多选楼层开始
  861. async configList() {
  862. try {
  863. let data = {
  864. sn: app.globalData.sn
  865. }
  866. let res = await configList(data)
  867. this.setData({
  868. allFloorList: res.data
  869. })
  870. } catch (error) {
  871. console.log(error);
  872. }
  873. },
  874. openFloor() {
  875. let {
  876. intervieweeForm,
  877. allFloorList
  878. } = this.data
  879. let floorList = []
  880. if (intervieweeForm.floor) {
  881. floorList = intervieweeForm.floor.split(',')
  882. }
  883. let indexList = []
  884. if (floorList.length > 0) {
  885. floorList.forEach(item1 => {
  886. let index = allFloorList.findIndex(item => {
  887. return item1 == item.actualityFloor
  888. })
  889. if (index > -1) {
  890. indexList.push(index)
  891. }
  892. })
  893. }
  894. this.setData({
  895. isShowfloor: true,
  896. chooseFloorIndex: indexList,
  897. chooseFloorItem: floorList
  898. })
  899. },
  900. multipleChoiceFloor(e) {
  901. let index = e.currentTarget.dataset.index
  902. let item = e.currentTarget.dataset.item
  903. let {
  904. chooseFloorIndex,
  905. chooseFloorItem,
  906. } = this.data
  907. let index1 = chooseFloorIndex.findIndex(item => {
  908. return item == index
  909. })
  910. if (index1 == -1) {
  911. chooseFloorIndex.push(index)
  912. chooseFloorItem.push(item.actualityFloor)
  913. } else {
  914. chooseFloorIndex.splice(index1, 1);
  915. chooseFloorItem.splice(index1, 1);
  916. }
  917. this.setData({
  918. chooseFloorIndex,
  919. chooseFloorItem,
  920. })
  921. },
  922. delmultipleChoiceFloor(e) {
  923. let index = e.currentTarget.dataset.index
  924. let {
  925. chooseFloorIndex,
  926. chooseFloorItem,
  927. } = this.data
  928. chooseFloorIndex.splice(index, 1);
  929. chooseFloorItem.splice(index, 1);
  930. this.setData({
  931. chooseFloorIndex,
  932. chooseFloorItem,
  933. })
  934. },
  935. floorCancel() {
  936. this.setData({
  937. isShowfloor: false,
  938. chooseFloorIndex: [],
  939. chooseFloorItem: []
  940. })
  941. },
  942. floorSure() {
  943. let str = this.data.chooseFloorItem.join(',');
  944. this.setData({
  945. isShowfloor: false,
  946. 'intervieweeForm.floor': str
  947. })
  948. },
  949. // 多选楼层结束
  950. // 键盘函数开始
  951. proTap(e) { //点击省份
  952. let that = this;
  953. let province = e.currentTarget.dataset.province;
  954. let carnum = this.data.carnum;
  955. if (carnum.length < 1) { //避免连续点击
  956. carnum += province;
  957. }
  958. this.setData({
  959. carnum: carnum,
  960. 'formInfo.carnum': carnum,
  961. hiddenPro: true,
  962. hiddenStr: false,
  963. })
  964. },
  965. strTap(e) { //点击字母数字
  966. let that = this;
  967. this.setData({
  968. waiting: true
  969. })
  970. let province = e.currentTarget.dataset.str;
  971. let carnum = this.data.carnum;
  972. // console.log(carnum.length)
  973. if (carnum.length <= 8) { //避免连续点击
  974. carnum += province;
  975. console.log(carnum);
  976. }
  977. // this.setData({
  978. // notNum: false,
  979. // carnum: carnum,
  980. // })
  981. this.setData({
  982. notNum: false,
  983. carnum: carnum,
  984. 'formInfo.carnum': carnum,
  985. })
  986. setTimeout(() => {
  987. that.setData({
  988. waiting: false
  989. })
  990. }, 100);
  991. if (carnum.length > 6) {
  992. this.setData({
  993. downBtn: '完成',
  994. strDisabled: true,
  995. })
  996. // this.searchCardInfo()
  997. return; // 车牌长度最多为7个
  998. }
  999. },
  1000. backSpace() { //退格
  1001. let carnum = this.data.carnum;
  1002. if (carnum.length <= 7) {
  1003. this.setData({
  1004. downBtn: '返回',
  1005. strDisabled: false,
  1006. })
  1007. }
  1008. var arr = carnum.split('');
  1009. arr.splice(-1, 1)
  1010. var str = arr.join('')
  1011. if (arr.length < 2) {
  1012. this.setData({
  1013. notNum: true
  1014. })
  1015. }
  1016. if (str == '') {
  1017. this.setData({
  1018. hiddenPro: false,
  1019. hiddenStr: true
  1020. })
  1021. }
  1022. this.setData({
  1023. carnum: str
  1024. })
  1025. },
  1026. backKeyboard() { //返回省份键盘
  1027. if (this.data.carnum.length > 6) {
  1028. this.setData({
  1029. downBtn: '完成',
  1030. hiddenPro: true,
  1031. hiddenStr: false
  1032. })
  1033. } else if (this.data.carnum.length > 0) {
  1034. this.setData({
  1035. hiddenPro: true,
  1036. hiddenStr: false
  1037. })
  1038. } else {
  1039. this.setData({
  1040. hiddenPro: false,
  1041. hiddenStr: true
  1042. })
  1043. }
  1044. },
  1045. applyNum() {
  1046. this.setData({
  1047. hiddenPro: true,
  1048. hiddenStr: true,
  1049. })
  1050. },
  1051. closeSecondaryScreenFuc() {
  1052. console.log('关闭副屏', app.data.isSecondaryScreenState)
  1053. if (app.data.isSecondaryScreenState) {
  1054. closeSecondaryScreen()
  1055. // closeCycleSecondaryScreen()
  1056. }
  1057. },
  1058. // 键盘函数结束
  1059. saveRef(ref) {
  1060. // 将ref存起来,在想要调用的地方使用
  1061. this.toTitleRef = ref
  1062. },
  1063. /**
  1064. * 跳转指定页面 并清除顶部计时器
  1065. */
  1066. backToSpecifiedPage(url) {
  1067. this.toTitleRef && this.toTitleRef.clearIntervalAll()
  1068. my.reLaunch({
  1069. url: url,
  1070. })
  1071. setTimeout(() => {
  1072. this.closeSecondaryScreenFuc();
  1073. }, 500)
  1074. },
  1075. back() {
  1076. // 是否能加载到副屏
  1077. let isSecondaryScreenState = app.data.isSecondaryScreenState;
  1078. if (isSecondaryScreenState) {
  1079. // 是否启用副屏处理中页面
  1080. let processingPageSwitch = app.globalData.snDisposition.processingPageSwitch;
  1081. // 是否启用副屏轮播图
  1082. let secondaryPageSwitch = app.globalData.snDisposition.secondaryPageSwitch;
  1083. if (processingPageSwitch && secondaryPageSwitch) {// 启用副屏处理中页面 && 启用副屏轮播图
  1084. app.data.cycleIntervalSwitch = true
  1085. let url = app.globalData.snDisposition.secondaryPageImages[app.data.secondaryPageImagesIndex] || ''
  1086. if (url) {
  1087. openSecondaryScreen(url)
  1088. }
  1089. setTimeout(() => {
  1090. this.toTitleRef && this.toTitleRef.clearIntervalAll()
  1091. my.reLaunch({
  1092. url: '/pages/home/index',
  1093. })
  1094. }, 500)
  1095. } else if (!processingPageSwitch && secondaryPageSwitch) { // 不启用副屏处理中页面 && 启用副屏轮播图
  1096. app.data.cycleIntervalSwitch = true
  1097. let url = app.globalData.snDisposition.secondaryPageImages[app.data.secondaryPageImagesIndex] || ''
  1098. if (url) {
  1099. openSecondaryScreen(url)
  1100. }
  1101. setTimeout(() => {
  1102. this.toTitleRef && this.toTitleRef.clearIntervalAll()
  1103. my.reLaunch({
  1104. url: '/pages/home/index',
  1105. })
  1106. }, 500)
  1107. } else {
  1108. this.backToSpecifiedPage('/pages/home/index')
  1109. }
  1110. } else {
  1111. this.backToSpecifiedPage('/pages/home/index')
  1112. }
  1113. },
  1114. didUnmount() {
  1115. // this.closeSecondaryScreenFuc();
  1116. },
  1117. onUnload() {
  1118. // this.closeSecondaryScreenFuc();
  1119. },
  1120. });