index.js 29 KB

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