import { snConfig, getWXScanQRCodeValue, createWXScanQRCode } from '../../utils/api/api' import { getQRCodeUrl, getWaterDrop, throttle,guid } from '../../utils/index/index' import { closeSecondaryScreen, openSecondaryScreen } from "../../utils/index/callAmpe"; const app = getApp() Page({ data: { snDisposition: {}, tabList: [{ img: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/static/home/tab-one.png', tit: '设置', path: '/pages/settings/login/index' }, { img: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/static/home/tab-two.png', tit: '通讯录', path: '/pages/settings/interviewee/index?formPath="通讯录"' }, { img: '../../image/fkjl-icon.png', tit: '访客记录', path: '/pages/settings/visitorLog/index?formPath="访客记录"' }, ], centerList: [{ img: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/static/home/center-one.png', tit: '刷脸登记', path: '/pages/resultPage/index?result=刷脸登记', isShow: true, id: 1, }, { img: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/static/home/center-two.png', tit: '持证登记', path: '/pages/resultPage/index?result=刷身份证', isShow: true, id: 2, }, { img: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/static/home/center-three.png', tit: '输身份证登记', path: '/pages/inputIDCard/index', isShow: true, id: 3, }, { img: 'https://tx.hz-hanghui.com:8088/yx-fyzd/file/upload/imagesnew/static/home/center-four.png', tit: '签离', path: '/pages/resultPage/index?result=扫码签离', isShow: true, id: 4, }, ], centerListCope: [], qrCodeImg: '', // 微信二维码图片地址 qrCodeUrl: '', // 微信二维码 码值 intervalId: null, //定时器 intervalId1: null, //定时器 }, onLoad() { app.data.cycleIntervalSwitch = true let url = app.globalData.snDisposition.secondaryPageImages[app.data.secondaryPageImagesIndex] || '' if (url) { openSecondaryScreen(url) } this.data.centerListCope = JSON.parse(JSON.stringify(this.data.centerList)) this.snConfig() }, async onShow() { my.hideBackHome(); app.data.userInfo.xm = '' app.data.userInfo.sfzh = '' app.data.userInfo.phone = '' app.data.userInfo.avatar = '' app.data.userInfo.idCardPhoto = '' app.data.userInfo.workPlace = '' app.data.userInfo.carNumber = '' app.data.userInfo.verifyType = 1; app.data.userInfo.certContent = ''; app.globalData.signOffQrcodeUrl = '' app.globalData.ethQrcodeUrl = '' app.globalData.gateGrcodeUrl = '' app.data.inputPhone = '' app.globalData.brushingCardUserIInfo = {} app.globalData.visitoMsgData = {} app.data.isOkBrushingCard = false app.data.isOkQrCodeSignIn = false app.data.isokFaceScan = false app.globalData.riskResult = 1 app.data.isNetworkQueryError = true app.data.clickRetryNum = 0 console.log('clickRetryNum', app.data.clickRetryNum) }, clickAudio() { getWaterDrop() }, // 获取设备配置 snConfig() { let that = this that.assignData() if (!app.globalData.snDisposition.id) { that.data.intervalId = setInterval(function () { if (app.globalData.snDisposition.id) { that.assignData() clearInterval(that.data.intervalId); } }, 1000); } }, // 赋值 async assignData() { this.data.centerList = JSON.parse(JSON.stringify(this.data.centerListCope)) let centerList = this.data.centerList centerList[0].isShow = app.globalData.snDisposition.useAlipayFace centerList[1].isShow = app.globalData.snDisposition.useIdcard centerList[2].isShow = app.globalData.snDisposition.noIdcardRegister centerList[3].isShow = app.globalData.snDisposition.signOut this.setData({ snDisposition: app.globalData.snDisposition, centerList }) // 生成二维码 if (app.globalData.snDisposition.wxQrcodeUrl) { let qrImgWX = await getQRCodeUrl(app.globalData.snDisposition.wxQrcodeUrl) this.setData({ qrImgWX }) } if (app.globalData.snDisposition.wxScanRegister) { let info = { connectionId: `${guid()}`, extInfo: [{ keyName: "carnum", keyboardType: "carNumber", placeholder: "请选择车牌", title: "车牌", type: "", value: "" }, { keyName: "visitorUnit", keyboardType: "text", placeholder: "请输入单位", title: "单位", type: "", value: "" }], // 额外填写信息 mode: 'http', // websocket(长链接)/http(三要素换特殊码) needCertName: true, // 姓名 needCertNo: true, // 证件号 needPhone: false, // 手机号 needPhotoBase64: false, // 照片 needReal: false, // 是否需要实名比对 sn: app.globalData.sn, // 设备sn } let res = await getWXScanQRCodeValue(info); let qrCodeUrl = `https://tx.hz-hanghui.com:8088?connectionId=${res.data.connectionId || ''}&encryptId=${res.data.encryptId || ''}&sn=${app.globalData.sn || ''}&mode=http` // let qrCodeUrl = `https://test.hz-hanghui.com:18890?connectionId=${res.data.connectionId || ''}&encryptId=${res.data.encryptId || ''}&sn=${app.globalData.sn || ''}&mode=http`; let qrRes = await createWXScanQRCode({ qrcodeContent: qrCodeUrl, width: 300, height: 300 }); let qrCodeImg = qrRes.data.qrcodeUrl || ''; // let qrCodeImg = await getQRCodeUrl(qrCodeUrl) this.setData({ qrCodeUrl, qrCodeImg }) } }, // 跳转 goto: throttle(function (e) { let item = e.currentTarget.dataset.item; switch (item.id) { case 1: console.log(app.data.isFaceScanInitialize); if (!app.data.isFaceScanInitialize) { my.showToast({ content: '刷脸初始化失败,请重试', duration: 2000 }); return } app.data.isokFaceScan = true break; case 2: item.path = item.path + `&&timer=${app.globalData.snDisposition.readIdcardTimeout}` break; case 4: item.path = item.path + `&&timer=${app.globalData.snDisposition.singOutTimeout}` break; default: break; } if (item.id) { setTimeout(() => { closeSecondaryScreen() app.data.cycleIntervalSwitch = false }, 1000) } if (item.path) { my.reLaunch({ url: item.path, }) } }, 5000), isMoreThan15Days(date) { var fifteenDaysAgo = new Date(); fifteenDaysAgo.setDate(fifteenDaysAgo.getDate() - 15); return date < fifteenDaysAgo; }, sure() {}, });