index.js 26 KB

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