1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150 |
- import {
- visiteeList,
- threeElements,
- configList,
- riskQuery, areaInfo,
- } from '../../utils/api/api'
- import {
- getWaterDrop,
- getDate
- } from '../../utils/index/index'
- import {
- viceBroadcast, closeSecondaryScreen, openSecondaryScreen
- } from '../../utils/index/callAmpe'
- import {
- encryptAndSign
- } from '../../utils/index/getSM4'
- import { match } from 'assert'
- const app = getApp()
- Page({
- data: {
- toTitleRef: null,
- snDisposition: {},
- // 访客信息
- remainingInfo: {
- avatar: '',
- visitorName: '',
- visitorIdCard: '',
- visitorPhone: '',
- visitorUnit: '',
- carnum: '',
- peopleNum: 1,
- causeMatterName: '',
- },
- // 保存用户填写的最后信息
- formInfo: {
- visitorPhone: '',
- visitorUnit: '',
- carnum: '',
- peopleNum: 1,
- causeMatterName: '',
- },
- // 事由
- causeMatterList: [
- /*{
- name: '业务拜访',
- id: 1
- },
- {
- name: '会议邀请',
- id: 2
- },
- {
- name: '施工单位',
- id: 3
- },
- {
- name: '其他事项',
- id: 4
- },*/
- ],
- isShowCauseMatter: false, //是否显示事由选项
- floorNum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],
- cs: [1, 2, 3, 4, 5, 6,],
- // 是否显示搜索项
- isShowSearch: false,
- // 所有搜索项
- searchList: [
- {
- name: '姓名',
- placeholder: '请输入姓名',
- value: 'name',
- show: true,
- },
- {
- name: '手机号',
- placeholder: '请输入手机号',
- value: 'phone',
- show: true,
- },
- {
- name: '身份证',
- placeholder: '请输入身份证',
- value: 'idNumber',
- show: false,
- },
- {
- name: '单位',
- placeholder: '请输入单位',
- value: 'company',
- show: true,
- },
- {
- name: '部门',
- placeholder: '请输入部门',
- value: 'unitName',
- show: false,
- },
- {
- name: '楼层',
- placeholder: '请选择楼层',
- value: 'floor',
- show: true,
- }, {
- name: '房间号',
- placeholder: '请输入房间号',
- value: 'room',
- show: true,
- }, {
- name: '标题',
- placeholder: '请输入标题',
- value: 'showTitle',
- show: true,
- }
- ],
- // 搜索项绑定值
- searchForm: {
- name: '',
- phone: '',
- company: '',
- floor: '', //选中的楼层
- room: '',
- showTitle: '',
- },
- // 受访人信息
- intervieweeForm: {
- name: '',
- phone: '',
- idNumber: '',
- company: '',
- unitName: '',
- floor: '',
- room: '',
- showTitle: '',
- },
- intervieweeFormCopy: {},
- // 是否是手动输入受访人
- isEnterInterviewee: false,
- carNumberShow: true,
- // 触摸开始时间
- touchStartTime: 0,
- // 触摸结束时间
- touchEndTime: 0,
- // 最后一次单击事件点击发生时间
- lastTapTime: 0,
- // 单击事件点击后要触发的函数
- lastTapTimeoutFunc: null,
- allList: [],
- allListCopy: [],
- tableList: [],
- total: 0,
- pageNum: 0, //总页数
- pageSize: 0, //当前页数
- sliceStart: 0, //截取数组开始
- sliceEnd: 15, //截取数组结束
- mumberRows: 15, //每页条数
- // 键盘开始
- notNum: true,
- strDisabled: false,
- checked: false,
- provinceArr: ["粤", "京", "津", "渝", "沪", "冀", "晋", "辽", "吉", "黑", "苏", "浙", "皖", "闽", "赣", "鲁", "豫", "鄂", "湘", "琼", "川", "贵", "云", "陕", "甘", "青", "蒙", "桂", "宁", "新", "藏", "使", "领", "警", "学", "港", "澳"],
- 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"],
- hiddenPro: true, // 隐藏省份键盘
- hiddenStr: true, // 隐藏数字字母键盘
- carnum: '', //车牌号码
- // 键盘结束
- downBtn: '返回',
- // 多选楼层开始
- isShowfloor: false,
- allFloorList: [],
- chooseFloorIndex: [], //多选的index
- chooseFloorItem: [], //多选的item
- // 多选楼层结束
- isPortraitScreen: false,// 是否为竖屏:true竖屏 false横屏
- screenIntervalId: null, //定时器
- // 默认历史
- historyPagNum: 1, //当前页数
- historyPageSize: 0, //总页数
- isHistory: true,
- historyList: [],
- },
- onLoad() {
- my.hideBackHome();
- const _this = this
- this.initScreenType().then(isPortraitScreenRes => {
- console.log('isPortraitScreenRes', isPortraitScreenRes)
- _this.setData({
- isPortraitScreen: isPortraitScreenRes
- })
- })
- this.data.intervieweeFormCopy = JSON.parse(JSON.stringify(this.data.intervieweeForm));
- this.data.searchFormCopy = JSON.parse(JSON.stringify(this.data.searchForm));
- let visitReasonList = (app.globalData.snDisposition.visitReason || '业务拜访/会议邀请/施工单位/其他事项').split('/');
- console.log(JSON.stringify(app.globalData.snDisposition))
- console.log(JSON.stringify(app.globalData.registerNotDesensitizedColumn))
- this.setData({
- snDisposition: app.globalData.snDisposition,
- causeMatterList: visitReasonList,
- 'remainingInfo.visitorPhone': app.data.userInfo.phone || app.data.inputPhone,
- 'remainingInfo.visitorName': app.data.userInfo.xm,
- 'remainingInfo.visitorIdCard': app.data.userInfo.sfzh,
- 'remainingInfo.avatar': app.data.userInfo.avatar,
- 'remainingInfo.idCardPhoto': app.data.userInfo.idCardPhoto,
- 'remainingInfo.visitorUnit': app.data.userInfo.visitorUnit || '',
- carnum: app.data.userInfo.carnum || '',
- 'remainingInfo.causeMatterName': visitReasonList.length > 0 ? visitReasonList[0] : '',
- 'formInfo.causeMatterName': visitReasonList.length > 0 ? visitReasonList[0] : '',
- })
- console.log(visitReasonList)
- // ⾃然⼈⻛险评分查询
- if (this.data.snDisposition.riskCheck) {
- this.riskQuery()
- }
- this.getHistory()
- this.getTable()
- this.configList()
- },
- initScreenType() {
- let that = this
- return new Promise((resolve, reject) => {
- if (app.globalData.isPortraitScreen) {
- if (app.globalData.isPortraitScreen != null) {
- resolve(app.globalData.isPortraitScreen)
- }
- } else {
- that.data.screenIntervalId = setInterval(function () {
- if (app.globalData.isPortraitScreen != null) {
- resolve(app.globalData.isPortraitScreen)
- clearInterval(that.data.screenIntervalId);
- }
- }, 1000);
- }
- })
- },
- async getHistory(historyPagNum){
- try {
- let params = {
- data : {
- // "certNo": this.data.remainingInfo.visitorIdCard,
- // sn: app.globalData.sn,
- "certNo": "362330199801077198",
- sn: "118D002000500012",
- },
- pageNum: historyPagNum ? historyPagNum : 1,
- pageSize: 2
- }
- let res = await app.data.publicInterface('fkjHistoryRecordUrl','/history',params,'post','历史访问记录请求失败')
- if(res.data.total > 0 ){
- let array = res.data.list.map((item,index)=>{
- return{
- info1:{
- 'carnum': item.carno,
- 'visitorName': item.certName,
- 'visitorPhone': item.certPhone,
- 'visitorUnit': item.company,
- 'causeMatterName': item.reason,
- 'isSel': false
- },
- info2:{
- "unitName": item.visiteeBm,
- "company": item.visiteeCompany,
- "floor": item.visiteeFloor,
- "phone": item.visiteePhone,
- "room": item.visiteeRoom,
- "name": item.visiteeXm,
- 'isSel': false
- }
- }
- })
- this.setData({
- historyPagNum: historyPagNum ? historyPagNum : 1,
- historyPageSize: res.data.pages,
- historyList: array,
- })
- }else{
- this.setData({
- isHistory: false
- })
- }
- } catch (error) {
- console.log(error);
- }
- },
- // 上一页
- historyPreviousFun() {
- console.log(this.data)
- const pageNum = this.data.historyPagNum - 1
- if (pageNum <= 0) {
- return
- }
- this.setData({
- intervieweeForm:{}
- })
- this.getHistory(pageNum)
- },
- // 下一页
- historyNextFun() {
- const pageNum = this.data.historyPagNum + 1
- if (pageNum > this.data.historyPageSize) {
- return
- }
- this.setData({
- intervieweeForm:{}
- })
- this.getHistory(pageNum)
- },
- async getTable(e) {
- try {
- let {
- sliceStart,
- mumberRows
- } = this.data
- let dto = {
- sn: app.globalData.sn,
- }
- let res = await visiteeList(app.globalData.snDisposition.visiteeUrl, dto)
- var pageNum = Math.ceil(res.data.length / mumberRows)
- sliceStart = 0
- this.setData({
- allList: res.data,
- allListCopy: res.data,
- tableList: res.data.slice(sliceStart, mumberRows),
- total: res.data.length,
- sliceStart: 0,
- sliceEnd: mumberRows,
- pageNum,
- pageSize: res.data.length > 0 ? 1 : 0,
- })
- } catch (error) {
- console.log(error);
- }
- },
- // 选中受访人信息数据
- selInfo: function (e) {
- const idx = e.currentTarget.dataset.index; // 获取被点击项的下标
- const items = this.data.historyList.map((item,index) => {
- item.info1.isSel = false
- item.info2.isSel = false
- if (index == idx) {
- this.setData({
- carnum: item.info1.carnum,
- remainingInfo: {
- ...this.data.remainingInfo,
- ...item.info1
- },
- intervieweeForm:{
- ...item.info2
- }
- })
- return {
- ...item,
- info1:{
- ...item.info1,
- isSel: !item.info1.isSel // 切换选中状态
- },
- info2:{
- ...item.info2,
- isSel: !item.info2.isSel // 切换选中状态
- }
- };
- }
- return item; // 其他项保持不变
- });
- this.setData({
- historyList: items,
- }); // 更新数据状态
- },
- // 选择访客 单独控制
- selInfo1: function (e){
- let visitReasonList = (app.globalData.snDisposition.visitReason || '业务拜访/会议邀请/施工单位/其他事项').split('/')
- const idx = e.currentTarget.dataset.index; // 获取被点击项的下标
- const items = this.data.historyList.map((item,index) => {
- if (index == idx) {
- if(!item.info1.isSel){
- this.setData({
- carnum: item.info1.carnum,
- remainingInfo:{
- ...this.data.remainingInfo,
- ...item.info1
- }
- })
- }else{
- this.defaultFormInfo()
- }
- return {
- ...item,
- info1:{
- ...item.info1,
- isSel: !item.info1.isSel // 切换选中状态
- }
- };
- }
- return item; // 其他项保持不变
- });
- this.setData({
- historyList: items
- }); // 更新数据状态
- },
- defaultFormInfo(){
- console.log(this.data.formInfo)
- this.setData({
- carnum: this.data.formInfo.carnum || '',
- remainingInfo:{
- ...this.data.formInfo
- // 'visitorPhone': app.data.userInfo.phone || app.data.inputPhone,
- // 'visitorName': app.data.userInfo.xm,
- // 'visitorIdCard': app.data.userInfo.sfzh,
- // 'avatar': app.data.userInfo.avatar,
- // 'idCardPhoto': app.data.userInfo.idCardPhoto,
- // 'visitorUnit': app.data.userInfo.visitorUnit || '',
- // 'causeMatterName': visitReasonList.length > 0 ? visitReasonList[0] : '',
- }
- })
- },
- // 选择受访人 单独控制
- selInfo2: function (e){
- const idx = e.currentTarget.dataset.index; // 获取被点击项的下标
- const items = this.data.historyList.map((item,index) => {
- if (index == idx) {
- if(!item.info2.isSel){
- this.setData({
- intervieweeForm:{
- ...item.info2
- }
- })
- }else{
- this.setData({
- intervieweeForm:{}
- })
- }
- return {
- ...item,
- info2:{
- ...item.info2,
- isSel: !item.info2.isSel // 切换选中状态
- }
- };
- }
- return item; // 其他项保持不变
- });
- this.setData({
- historyList: items
- }); // 更新数据状态
- },
- backEnter(){
- this.setData({
- isHistory: !this.data.isHistory,
- intervieweeForm:{}
- })
- },
- // ⾃然⼈⻛险评分查询
- async riskQuery() {
- let appKeyRisk = app.globalData.appKeyRisk
- let appSecretRisk = app.globalData.appSecretRisk
- let privateKeyRisk = app.globalData.privateKeyRisk
- let content = {
- sn: app.globalData.sn,
- name: app.data.userInfo.xm,
- idNumber: app.data.userInfo.sfzh,
- phone: app.data.userInfo.phone
- }
- // let content = {
- // sn: '136D002002300012',
- // name: '张亮',
- // idNumber: '321323199007264912',
- // phone: '18762761616'
- // }
- content = JSON.stringify(content)
- // 加密
- let sm4 = await encryptAndSign(appKeyRisk, appSecretRisk, privateKeyRisk, content, "encrypted")
- try {
- let data = {
- "appId": app.globalData.appIdRisk,
- "bizContent": sm4.encrypted,
- "reqTimestamp": sm4.timestamp,
- "sign": sm4.sign
- }
- let res = await riskQuery(data)
- // 解密
- let decryptedData = encryptAndSign(appKeyRisk, appSecretRisk, privateKeyRisk, res.data.bizContent, "decrypt")
- this.data.isRisk = false
- if (!decryptedData.decrypted) {
- return
- }
- let decrypted = JSON.parse(decryptedData.decrypted)
- if (!decrypted.result) {
- app.globalData.riskResult = 1
- } else if (decrypted.resultInfo.personFxpfjx && decrypted.resultInfo.personFxpfjx[4] == 1) {
- app.globalData.riskResult = 2
- } else {
- app.globalData.riskResult = 3
- }
- } catch (error) {
- console.log(error)
- // my.reLaunch({
- // url: '/pages/resultPage/index?result=结果页超时&&timer=' + app.globalData.snDisposition.resultPageTimeout,
- // })
- }
- },
- // 上一页
- previousFun() {
- let {
- allList,
- pageSize,
- sliceEnd,
- sliceStart,
- mumberRows
- } = this.data
- if (pageSize <= 1) {
- return
- }
- this.setData({
- tableList: allList.slice(sliceStart - mumberRows, sliceEnd - mumberRows),
- sliceStart: sliceStart - mumberRows,
- sliceEnd: sliceEnd - mumberRows,
- pageSize: pageSize - 1
- })
- },
- // 下一页
- nextFun() {
- let {
- allList,
- pageSize,
- pageNum,
- sliceEnd,
- sliceStart,
- mumberRows
- } = this.data
- if (pageSize >= pageNum) {
- return
- }
- this.setData({
- tableList: allList.slice(sliceStart + mumberRows, sliceEnd + mumberRows),
- sliceStart: sliceStart + mumberRows,
- sliceEnd: sliceEnd + mumberRows,
- pageSize: pageSize + 1
- })
- },
- // 倒计时结束
- finish() {
- this.backToSpecifiedPage('/pages/resultPage/index?result=结果页超时')
- },
- // 访客信息输入
- getValue(e) {
- let type = e.target.dataset.type
- let val = e.detail.value
- let key = `remainingInfo.${type}`
- let formKey = `formInfo.${type}`
- this.setData({
- [key]: val,
- [formKey]: val
- })
- console.log(this.data.historyList)
- if(this.data.historyList.length>0){
- this.data.historyList.forEach(item=>{
- item.info1.isSel = false
- })
- this.setData({
- historyList: this.data.historyList
- })
- // let array = this.data.historyList.map(item=>{
- // console.log(item)
- // if(item.info1.isSel){
- // return {
- // ...item,
- // info1:{
- // ...item.info1,
- // isSel: !item.info1.isSel
- // }
- // }
- // }else{
-
- // }
- // })
-
- // this.setData({
- // historyList: array
- // })
- }
- },
- // 事由
- openChoose(e) {
- this.setData({
- isShowCauseMatter: !this.data.isShowCauseMatter,
- hiddenPro: true,
- hiddenStr: true,
- })
- },
- closeCauseMatter() {
- getWaterDrop()
- this.setData({
- isShowCauseMatter: false
- })
- },
- getCauseMatterVal(e) {
- let item = e.currentTarget.dataset.item
- this.setData({
- 'remainingInfo.causeMatterName': item,
- 'formInfo.causeMatterName': item,
- isShowCauseMatter: false
- })
- },
- // 是否显示搜索项
- getIsShow() {
- let {
- isShowSearch
- } = this.data
- let mumberRows = isShowSearch ? 15 : 9
- let searchForm = JSON.parse(JSON.stringify(this.data.searchFormCopy));
- this.setData({
- isShowSearch: !isShowSearch,
- mumberRows: mumberRows,
- searchForm
- })
- this.getTable()
- },
- // 输入搜索项
- getSearchValue(e) {
- let type = e.target.dataset.type
- let val = e.detail.value
- let key = `searchForm.${type}`
- this.setData({
- [key]: val
- })
- },
- // 查询
- inquireFun() {
- let {
- searchForm,
- allList,
- isShowSearch,
- mumberRows,
- allListCopy
- } = this.data
- allList = JSON.parse(JSON.stringify(allListCopy))
- // 根据条件过滤数据
- let result = this.filterData(searchForm, allList)
- var pageNum = Math.ceil(result.length / mumberRows)
- let sliceStart = 0
- let sliceEnd = mumberRows
- this.setData({
- tableList: result.slice(sliceStart, mumberRows),
- allList: result,
- sliceEnd,
- sliceStart,
- total: result.length,
- pageNum,
- pageSize: result.length > 0 ? 1 : 0,
- })
- },
- // 多条件过滤,参数queryObj(过滤条件对象),list(需要过滤的数组)
- filterData(queryObj, list) {
- let arr = list
- Object.keys(queryObj).forEach(key => {
- if (queryObj[key] == undefined || queryObj[key] == '') return arr
- if (key == 'name') {
- arr = arr.filter(p => p[key] !== null && (p[key].indexOf(queryObj[key]) > -1 || p['pinyinFirstLetter'].toLowerCase().indexOf(queryObj[key].toLowerCase()) == 0))
- } else {
- arr = arr.filter(p => p[key] !== null && (p[key].indexOf(queryObj[key]) > -1))
- }
- })
- return arr
- },
- //清空
- clearFun() {
- let searchForm = JSON.parse(JSON.stringify(this.data.searchFormCopy));
- this.setData({
- searchForm
- })
- this.getTable()
- },
- // 是否是手动输入受访人
- chooseInterviewee() {
- this.setData({
- isEnterInterviewee: !this.data.isEnterInterviewee
- })
- },
- // 手动输入受访人
- getIntervieweeValue(e) {
- let type = e.target.dataset.type
- let val = e.detail.value
- let key = `intervieweeForm.${type}`
- this.setData({
- [key]: val
- })
- },
- // 清空充填受访人
- clearIntervieweeValue() {
- let intervieweeForm = JSON.parse(JSON.stringify(this.data.intervieweeFormCopy));
- this.setData({
- intervieweeForm
- })
- },
- // 选择楼层层数
- chooseFloor(e) {
- let val = e.currentTarget.dataset.item
- let {
- searchForm
- } = this.data
- if (searchForm.floor.length < 2) {
- this.setData({
- 'searchForm.floor': searchForm.floor + val
- })
- this.inquireFun()
- }
- },
- // 删除选择的楼层
- delFloor() {
- let {
- searchForm
- } = this.data
- this.setData({
- 'searchForm.floor': searchForm.floor.substr(0, searchForm.floor.length - 1)
- })
- this.inquireFun()
- },
- /// 按钮触摸开始触发的事件
- touchStart: function (e) {
- this.touchStartTime = e.timeStamp
- },
- /// 按钮触摸结束触发的事件
- touchEnd: function (e) {
- this.touchEndTime = e.timeStamp
- },
- chooesFloor(e) {
- let item = e.currentTarget.dataset.item
- var that = this
- // 控制点击事件在350ms内触发,加这层判断是为了防止长按时会触发点击事件
- if (that.data.touchEndTime - that.data.touchStartTime < 350) {
- // 当前点击的时间
- var currentTime = e.timeStamp
- var lastTapTime = that.data.lastTapTime
- // 更新最后一次点击时间
- that.data.lastTapTime = currentTime
- // 如果两次点击时间在300毫秒内,则认为是双击事件
- if (currentTime - lastTapTime < 300) {
- // console.log("双击")
- // 成功触发双击事件时,取消单击事件的执行
- clearTimeout(that.data.lastTapTimeoutFunc);
- that.setData({
- intervieweeForm: item
- })
- that.sure()
- } else {
- // 单击事件延时300毫秒执行,这和最初的浏览器的点击300ms延时有点像。
- that.data.lastTapTimeoutFunc = setTimeout(function () {
- that.setData({
- isEnterInterviewee: true,
- intervieweeForm: item
- })
- }, 300);
- }
- }
- },
- // 确定
- async sure() {
- if(this.data.isHistory){
- if(!this.data.intervieweeForm.name) {
- this.backEnter()
- return
- }
- }
- let {
- remainingInfo,
- intervieweeForm,
- carnum
- } = this.data
- let form = Object.assign({}, remainingInfo, intervieweeForm);
- console.log('form --->', form)
- form.carnum = carnum
- form.visitingTime = getDate()
- app.data.visitoMsgData = form
- // 启用进出记录推送
- let transitPushSwitch = app.globalData.snDisposition.transitPushSwitch
- if (transitPushSwitch) {
- // 获取辖区配置
- let areaRes = await areaInfo({
- sn: app.globalData.sn,
- }).data || {}
- /*let data = {
- "reason": form.causeMatterName,
- "num_peoples": form.peopleNum, //人数
- "machine_id": app.globalData.sn,
- "xm": form.visitorName,
- "sfzh": form.visitorIdCard,
- "phone": form.visitorPhone,
- // "xm": '张佳燕',
- // "sfzh": '331082199910045826',
- // "phone": '15888632412',
- "company": form.visitorUnit,
- "carno": form.carnum,
- "visitee_xm": form.name, //受访人姓名
- "visitee_bm": form.unitName,
- "visitee_company": form.company,
- "visitee_room": form.room,
- "visiteePhone": intervieweeForm.phone,
- "visitee_floor": form.floor,
- xp: app.data.userInfo.idCardPhoto,
- scene_xp: app.data.userInfo.avatar,
- time: form.visitingTime,
- }
- console.log('data', data)*/
- console.log('areaRes ----> ', JSON.stringify(areaRes))
- let newPushData = {
- "appType": "HHVisit",
- "recordid": 0, // 没有
- "sn": app.globalData.sn,
- "adminId": null, // 没有
- "pcsname": areaRes.policeStationName || '', // 所属辖区派出所名称
- "pcsdm": areaRes.policeStationCode || '', // 所属辖区派出所代码
- "provinceName": areaRes.provinceName || '', // 所属省份
- "cityName": areaRes.cityName || '', // 所属城市
- "areaName": areaRes.areaName || '', // 所属区/县
- "streetName": areaRes.streetName || '', // 街道/乡/镇
- "address": areaRes.address || '', // 详细地址
- "deviceAddress": areaRes.deviceAddress || '', // 设备地点
- "outType": 1, // 服务端设备所属进出口: 0 通用 1进门 2出门
- "status": true,// 人员进入是否有效: true 有效 false 无效
- "reasonType": null,// 无效原因: 1 未成年人禁止进入 2 黑名单
- "userId": 0,// 服务端用户id
- "verifyType": app.data.userInfo.verifyType,// todo 识别类型
- "certName": form.visitorName, // 用户姓名
- "certNo": form.visitorIdCard, // 用户证件号
- "certContent": JSON.stringify(app.data.userInfo.certContent || '') || '', // 身份证阅读器返回全部 todo
- "phone": form.visitorPhone, // 用户手机号
- "cardidex": null, // 用户卡号
- "photo": app.data.userInfo.avatar, // 用户现场照片
- "originPhoto": '', // 比对源照片url todo
- "originPhotoBase64": app.data.userInfo.idCardPhoto, // 比对源照片base64 todo
- "verifyScore": null, // 人脸比对分值: 0-100 todo
- "company": form.visitorUnit, // 用户单位名称
- "carno": form.carnum, // 用户车牌号
- "reason": form.causeMatterName, // 拜访事由
- "time": form.visitingTime, // 刷脸时间
- "visiteeXm": form.name, //受访人姓名
- "visiteePhone": intervieweeForm.phone, // 受访人手机号
- "visiteeCompany": form.company, // 受访人单位
- "visiteeBm": form.unitName, // 受访人部门
- "visiteeFloor": form.floor, // 受访人所在楼层
- "visiteeRoom": form.room, // 受访人所在房间号
- "startTime": null, // 有效期开始时间
- "endTime": null, // 有效期结束时间
- "event": 1 // 事件类型: 1 登记 2 签离
- }
- console.log('newPushData ----> ',JSON.stringify(newPushData))
- let url = app.globalData.snDisposition.transitPushUrl
- try {
- // 进出记录推送
- let res = await threeElements(url, newPushData)
- console.log('commonQrCode', res.data.commonQrCode);
- console.log('ladderQrCode', res.data.ladderQrCode);
- app.data.visitoMsgData.commonQrCode = res.data.commonQrCode
- app.data.visitoMsgData.ladderQrCode = res.data.ladderQrCode
- this.backToSpecifiedPage('/pages/resultPage/index?result=登记成功')
- viceBroadcast(app.globalData.snDisposition.registerSuccessVoice)
- } catch (error) {
- this.backToSpecifiedPage('/pages/resultPage/index?result=登记失败')
- }
- } else {
- this.backToSpecifiedPage('/pages/resultPage/index?result=登记成功')
- viceBroadcast(app.globalData.snDisposition.registerSuccessVoice)
- }
- },
- closeCanNot() {
- this.setData({
- hiddenPro: true,
- hiddenStr: true,
- isShowCauseMatter: false
- })
- },
- // 多选楼层开始
- async configList() {
- try {
- let data = {
- sn: app.globalData.sn
- }
- let res = await configList(data)
- this.setData({
- allFloorList: res.data
- })
- } catch (error) {
- console.log(error);
- }
- },
- openFloor() {
- let {
- intervieweeForm,
- allFloorList
- } = this.data
- let floorList = []
- if (intervieweeForm.floor) {
- floorList = intervieweeForm.floor.split(',')
- }
- let indexList = []
- if (floorList.length > 0) {
- floorList.forEach(item1 => {
- let index = allFloorList.findIndex(item => {
- return item1 == item.actualityFloor
- })
- if (index > -1) {
- indexList.push(index)
- }
- })
- }
- this.setData({
- isShowfloor: true,
- chooseFloorIndex: indexList,
- chooseFloorItem: floorList
- })
- },
- multipleChoiceFloor(e) {
- let index = e.currentTarget.dataset.index
- let item = e.currentTarget.dataset.item
- let {
- chooseFloorIndex,
- chooseFloorItem,
- } = this.data
- let index1 = chooseFloorIndex.findIndex(item => {
- return item == index
- })
- if (index1 == -1) {
- chooseFloorIndex.push(index)
- chooseFloorItem.push(item.actualityFloor)
- } else {
- chooseFloorIndex.splice(index1, 1);
- chooseFloorItem.splice(index1, 1);
- }
- this.setData({
- chooseFloorIndex,
- chooseFloorItem,
- })
- },
- delmultipleChoiceFloor(e) {
- let index = e.currentTarget.dataset.index
- let {
- chooseFloorIndex,
- chooseFloorItem,
- } = this.data
- chooseFloorIndex.splice(index, 1);
- chooseFloorItem.splice(index, 1);
- this.setData({
- chooseFloorIndex,
- chooseFloorItem,
- })
- },
- floorCancel() {
- this.setData({
- isShowfloor: false,
- chooseFloorIndex: [],
- chooseFloorItem: []
- })
- },
- floorSure() {
- let str = this.data.chooseFloorItem.join(',');
- this.setData({
- isShowfloor: false,
- 'intervieweeForm.floor': str
- })
- },
- // 多选楼层结束
- // 键盘函数开始
- proTap(e) { //点击省份
- let that = this;
- let province = e.currentTarget.dataset.province;
- let carnum = this.data.carnum;
- if (carnum.length < 1) { //避免连续点击
- carnum += province;
- }
- this.setData({
- carnum: carnum,
- hiddenPro: true,
- hiddenStr: false,
- })
- },
- strTap(e) { //点击字母数字
- let that = this;
- this.setData({
- waiting: true
- })
- let province = e.currentTarget.dataset.str;
- let carnum = this.data.carnum;
- // console.log(carnum.length)
- if (carnum.length <= 8) { //避免连续点击
- carnum += province;
- console.log(carnum);
- }
- this.setData({
- notNum: false,
- carnum: carnum,
- })
- this.setData({
- notNum: false,
- carnum: carnum,
- })
- setTimeout(() => {
- that.setData({
- waiting: false
- })
- }, 100);
- if (carnum.length > 6) {
- this.setData({
- downBtn: '完成',
- strDisabled: true,
- })
- // this.searchCardInfo()
- return; // 车牌长度最多为7个
- }
- },
- backSpace() { //退格
- let carnum = this.data.carnum;
- if (carnum.length <= 7) {
- this.setData({
- downBtn: '返回',
- strDisabled: false,
- })
- }
- var arr = carnum.split('');
- arr.splice(-1, 1)
- var str = arr.join('')
- if (arr.length < 2) {
- this.setData({
- notNum: true
- })
- }
- if (str == '') {
- this.setData({
- hiddenPro: false,
- hiddenStr: true
- })
- }
- this.setData({
- carnum: str
- })
- },
- backKeyboard() { //返回省份键盘
- if (this.data.carnum.length > 6) {
- this.setData({
- downBtn: '完成',
- hiddenPro: true,
- hiddenStr: false
- })
- } else if (this.data.carnum.length > 0) {
- this.setData({
- hiddenPro: true,
- hiddenStr: false
- })
- } else {
- this.setData({
- hiddenPro: false,
- hiddenStr: true
- })
- }
- },
- applyNum() {
- this.setData({
- hiddenPro: true,
- hiddenStr: true,
- })
- },
- closeSecondaryScreenFuc() {
- console.log('关闭副屏', app.data.isSecondaryScreenState)
- if (app.data.isSecondaryScreenState) {
- closeSecondaryScreen()
- // closeCycleSecondaryScreen()
- }
- },
- // 键盘函数结束
- saveRef(ref) {
- // 将ref存起来,在想要调用的地方使用
- this.toTitleRef = ref
- },
- /**
- * 跳转指定页面 并清除顶部计时器
- */
- backToSpecifiedPage(url) {
- this.toTitleRef && this.toTitleRef.clearIntervalAll()
- my.reLaunch({
- url: url,
- })
- setTimeout(() => {
- this.closeSecondaryScreenFuc();
- }, 500)
- },
- back() {
- // 是否能加载到副屏
- let isSecondaryScreenState = app.data.isSecondaryScreenState;
- if (isSecondaryScreenState) {
- // 是否启用副屏处理中页面
- let processingPageSwitch = app.globalData.snDisposition.processingPageSwitch;
- // 是否启用副屏轮播图
- let secondaryPageSwitch = app.globalData.snDisposition.secondaryPageSwitch;
- if (processingPageSwitch && secondaryPageSwitch) {// 启用副屏处理中页面 && 启用副屏轮播图
- app.data.cycleIntervalSwitch = true
- let url = app.globalData.snDisposition.secondaryPageImages[app.data.secondaryPageImagesIndex] || ''
- if (url) {
- openSecondaryScreen(url)
- }
- setTimeout(() => {
- this.toTitleRef && this.toTitleRef.clearIntervalAll()
- my.reLaunch({
- url: '/pages/home/index',
- })
- }, 500)
- } else if (!processingPageSwitch && secondaryPageSwitch) { // 不启用副屏处理中页面 && 启用副屏轮播图
- app.data.cycleIntervalSwitch = true
- let url = app.globalData.snDisposition.secondaryPageImages[app.data.secondaryPageImagesIndex] || ''
- if (url) {
- openSecondaryScreen(url)
- }
- setTimeout(() => {
- this.toTitleRef && this.toTitleRef.clearIntervalAll()
- my.reLaunch({
- url: '/pages/home/index',
- })
- }, 500)
- } else {
- this.backToSpecifiedPage('/pages/home/index')
- }
- } else {
- this.backToSpecifiedPage('/pages/home/index')
- }
- },
- didUnmount() {
- // this.closeSecondaryScreenFuc();
- },
- onUnload() {
- // this.closeSecondaryScreenFuc();
- },
- });
|