123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535 |
- import {
- tracking,
- snConfig,
- getVisitDeviceUser,
- visitorCodeSignOut
- } from './utils/api/api'
- import {
- getForm,
- getDate,
- formatTime
- } from './utils/index/index'
- import {
- closeSecondaryScreen, openCycleSecondaryScreen, openSecondaryScreen
- } from './utils/index/callAmpe'
- App({
- data: {
-
- inputIdCard: '',
-
- inputPhone: '',
-
- TIME_COUNT: 60,
- timer: null,
-
- userInfo: {
- avatar: '',
- idCardPhoto: '',
- xm: '',
- sfzh: '',
- phone: '',
- workPlace: '',
- carNumber: '',
-
-
-
- },
-
- brushingCardUserIInfo: {},
-
- visitoMsgData: {},
-
- signOffMsg: {},
-
- isOkBrushingCard: false,
-
- isOkQrCodeSignIn: false,
-
- isokFaceScan: false,
-
- isFaceScanInitialize: false,
- isNetworkQueryError: true,
- clickRetryNum: 0,
- isSecondaryScreenState: true,
- cycleIntervalId: null,
- cycleIntervalSwitch: false,
- secondaryPageImagesIndex: 0,
- },
- onLaunch(options) {
-
- let snDisposition = my.getStorageSync({
- key: 'snDisposition'
- }).data;
- if (snDisposition) {
- this.globalData.snDisposition = snDisposition
- }
- this.globalData.snDisposition.id = null
- this.getSecondaryScreenState()
- this.getSystemInfo()
- this.getSystemInfoSync()
- this.getDeviceInformation()
- this.initialize()
- this.brushingCard()
- this.scanCode()
-
- },
- onShow(options) {
-
- },
-
- initialize() {
-
- let params = {
- "action": "initFace",
- "event": "open",
- "taskId": "2",
- "params": {
- "scope": "auth_user,order_service"
- }
- }
- console.log('刷脸初始化开始');
- my.call("ampeHHCommunication", params, res => {
- console.log(res, '刷脸初始化结束')
- if (res.success) {
- this.data.isFaceScanInitialize = true
- }
- });
- },
- initSecondaryScreen() {
-
- console.log(this.data.isSecondaryScreenState && this.globalData.snDisposition.secondaryPageSwitch)
- if (this.data.isSecondaryScreenState && this.globalData.snDisposition.secondaryPageSwitch) {
- console.log('打开副屏轮播', this.data.isSecondaryScreenState);
- openCycleSecondaryScreen()
- }
-
-
-
-
-
- },
-
- getSecondaryScreenState() {
- let params = {
- "action": "getSecondaryScreenState",
- "event": "open",
- "taskId": "10",
- }
- try {
- my.call("ampeHHCommunication", params, res => {
- console.log(res, '获取副屏状态')
- this.data.cycleIntervalId && clearInterval(this.data.cycleIntervalId);
- this.data.isSecondaryScreenState = false
- this.data.secondaryPageImagesIndex = 0
- if (res.success) {
-
- let screenState = res.data.getSecondaryScreenState;
- this.data.isSecondaryScreenState = true
- if (screenState == -1) {
- this.data.cycleIntervalSwitch = false
- } else if (screenState == 1) {
- closeSecondaryScreen()
- }
- this.initSecondaryScreen()
- console.log('ampeHHCommunication', res);
- console.log(this.data.isSecondaryScreenState)
- } else {
- this.data.cycleIntervalSwitch = false
- }
- })
- } catch (error) {
- console.log(error);
- }
- },
-
- trackingInterval() {
- let {
- TIME_COUNT,
- timer,
- count
- } = this.data
- if (!timer) {
- count = TIME_COUNT;
- timer = setInterval(async () => {
- if (count > 0 && count <= TIME_COUNT) {
- count--;
- } else {
- clearInterval(timer);
- this.data.timer = null;
- await this.tracking()
- this.trackingInterval()
- }
- }, 60 * 1000)
- }
- },
- async tracking() {
- let form = {
- sn: this.globalData.sn
- }
- try {
- let res = await tracking(form)
- } catch (error) {
- console.log(error);
- }
- },
-
- getDeviceInformation() {
- let params = {
- "action": "getDeviceInfo",
- "event": "open",
- "taskId": "4"
- }
- let that = this
- try {
- my.call('ampeHHCommunication', params, res => {
- console.log(res, '获取设备信息');
- if (res.data) {
- that.globalData.deviceInformation = res.data
- that.globalData.sn = res.data.sn
- that.snConfig()
- that.tracking()
- that.trackingInterval()
- }
- });
- } catch (error) {
- console.log(error);
- }
- },
- getSystemInfo() {
-
- my.getSystemInfo({
- success: (res) => {
-
- if (res.screenWidth / res.screenHeight > 1) {
- this.globalData.isPortraitScreen = false
- console.log('getSystemInfo====>横屏模式');
- } else {
- this.globalData.isPortraitScreen = true
- console.log('getSystemInfo====>竖屏模式');
- }
- },
- fail: (err) => {
- console.log(err);
- }
- });
- },
-
- getSystemInfoSync() {
- const accountInfo = my.getAccountInfoSync();
- this.globalData.appVersion = accountInfo.miniProgram.version
- },
-
- async snConfig() {
- let data = {
- "token": this.globalData.FKJConfiguration,
- "sn": this.globalData.sn
- }
- try {
- let res = await snConfig(data)
- this.globalData.snDisposition = res.data
- my.setStorageSync({
- data: res.data,
- key: 'snDisposition'
- });
- } catch (error) {
- console.log(error);
- }
- },
-
- brushingCard() {
- my.on('initIDCardListener', res => {
- console.log("刷身份证监听", this.data.isOkBrushingCard, res.data)
- if (!this.data.isOkBrushingCard && !this.data.isokFaceScan) {
- if (res.data) {
- this.data.isOkBrushingCard = true
- this.data.brushingCardUserIInfo = res.data
- this.data.brushingCardUserIInfo.name = this.data.brushingCardUserIInfo.name.replace(/\s*/g, "")
- setTimeout(()=>{
- closeSecondaryScreen()
- this.data.cycleIntervalSwitch = false
- }, 1000)
- this.data.userInfo.idCardPhoto = res.data.photoBase64
- my.reLaunch({
- url: '/pages/resultPage/index?result=首页刷证',
- })
- } else {
- my.showToast({
- content: '刷证失败,请重试',
- duration: 2000
- });
- }
- } else {
- return
- }
- })
- },
-
- scanCode() {
- my.on('initQRListener', async res => {
- console.log('⼆维码监听 ', res.data)
-
- if (res.data && res.data.qrCode && res.data.qrCode.indexOf('HHFKJ') > -1) {
- if (!this.data.isOkQrCodeSignIn) {
- this.data.isOkQrCodeSignIn = true
- let data = getForm(res.data.qrCode)
- this.getVisitDeviceUser(data)
- }
- } else if (res.data && res.data.qrCode) {
- if (res.data.qrCode.indexOf('\\000026') > -1 || res.data.qrCode.indexOf('\\000029') > -1) {
- res.data.qrCode = res.data.qrCode.slice(7)
- }
- console.log(res.data.qrCode);
-
- let data = {
- sn: this.globalData.sn,
- code: res.data.qrCode
- }
- console.log(data);
- try {
- let res = await visitorCodeSignOut(data)
- console.log(res.data);
- this.data.signOffMsg = res.data
- setTimeout(()=>{
- closeSecondaryScreen()
- this.data.cycleIntervalSwitch = false
- }, 1000)
- my.reLaunch({
- url: '/pages/resultPage/index?result=签离成功'
- });
- } catch (error) {
- console.log(error);
- my.showToast({
- content: error.msg || '扫码失败,请重试',
- duration: 2000
- });
- }
- } else {
- my.showToast({
- content: '扫码失败,请重试',
- duration: 2000
- });
- }
- })
- },
-
- async getVisitDeviceUser(data) {
- let data1 = {
- userId: data.serId,
- timestamp: data.timestamp,
- }
- try {
- let res = await getVisitDeviceUser(data1)
- this.data.userInfo.avatar = res.data.avatar
- this.data.userInfo.xm = res.data.username
- this.data.userInfo.sfzh = res.data.idNumber
- this.data.userInfo.phone = res.data.phone
- this.data.userInfo.visitorUnit = res.data.workPlace
- this.data.userInfo.carnum = res.data.carNumber
- this.data.userInfo.verifyType = 6;
- this.data.userInfo.certContent = res.data;
- let reminderAuth = this.globalData.snDisposition.reminderAuth;
-
- if (reminderAuth) {
- my.reLaunch({
- url: '/pages/tipsPage/index'
- })
- } else {
-
- let processingPageSwitch = this.globalData.snDisposition.processingPageSwitch;
- if (this.data.isSecondaryScreenState && processingPageSwitch) {
- console.log('打开副屏', this.data.isSecondaryScreenState);
- closeSecondaryScreen()
- this.data.cycleIntervalSwitch = false
- openSecondaryScreen(this.globalData.snDisposition.processingPageImage || '')
- }
- my.reLaunch({
- url: '/pages/interviewee/index'
- })
- }
- } catch (error) {
- console.log(error);
- this.data.isOkQrCodeSignIn = false
- setTimeout(()=>{
- closeSecondaryScreen()
- this.data.cycleIntervalSwitch = false
- }, 1000)
- my.reLaunch({
- url: '/pages/resultPage/index?result=结果页超时&&timer=' + this.globalData.snDisposition.resultPageTimeout,
- })
- }
- },
- globalData: {
- isPortraitScreen: null,
-
- sn: '',
- appVersion: '',
-
- FKJConfiguration: '01f8624317168a4a52fd89f673a3ccbc',
-
- modifyType: [0, 1, 2, 3, 4],
-
- snDisposition: {
- mode: null,
- sn: null,
- status: null,
- useAlipayFace: true,
- useIdcard: true,
- usePersonCard: true,
- voiceVolume: 80,
- mpassword: "117521",
- purchaserId: null,
- applicationTypeId: null,
- deviceModelHardwareId: null,
- deviceModelEnvironmentId: null,
- systemTypeCode: null,
- noIdcardRegister: false,
- noIdcardInputPhone: true,
- wxScanRegister: false,
- zfbScanRegister: false,
- wxQrcodeUrl: "https://tx.hz-hanghui.com:8088/yx-fyzd/faceCheckVisitor?type=2",
- zfbQrcodeUrl: "https://tx.hz-hanghui.com:8088/yx-fyzd/faceCheckVisitor?type=2",
- visiteeUrl: "https://tx.hz-hanghui.com:8088/yx-fyzd/api/v1/fkj/visitee/list",
- areaUrl: "https://tx.hz-hanghui.com:8088/yx-fyzd/api/v1/fkj/area/info",
- transitPushSwitch: true,
- transitPushUrl: "https://tx.hz-hanghui.com:8088/yx-fyzd/visitorReport",
- printVisitorList: false,
- signOut: true,
- riskCheck: false,
- hiddenButton: false,
- reminderAuth: false,
- reminder: '',
- reminderPlayText: '',
- confirmCountdownSwitch: true,
- confirmCountdownTime: 15,
- secondaryPageSwitch: true,
- secondaryPageImages: [],
- processingPageSwitch: true,
- processingPageImage: '',
- generalQrcode: true,
- generalQrcodeTitle: "",
- ethQrcode: true,
- ethQrcodeTitle: "梯控二维码",
- ethQrcodeUrl: "https://tx.hz-hanghui.com:8088/yx-fyzd/api/v1/fkj/visitor/eth/qrCode",
- chooseVisiteeTimeout: 90,
- readIdcardTimeout: 15,
- inputIdcardTimeout: 30,
- inputPhoneTimeout: 30,
- singOutTimeout: 15,
- resultPageTimeout: 5,
- successVoice: "比对成功",
- failVoice: "比对失败,请重试,或刷身份证",
- registerSuccessVoice: "正在打印访客单",
- readIdcardVoice: "请刷身份证",
- inputIdcardVoice: "请输入身份证号",
- inputPhoneVoice: "请输入手机号",
- connectSearchVoice: "正在联网查询信息,请耐心等待",
- singOutVoice: "请将二维码对准设备的扫码窗",
- notDesensitizedColumn: [],
- registerNotDesensitizedColumn: [],
- faceTimeout: 40,
- oneToOneTimeout: 40,
- connectSearchTimeout: 40,
- faceFailHandInput: false,
- visitReason: '',
- expirationDate: null,
- },
-
- deviceInformation: {},
-
- serviceAddress: '',
-
- appId: '3292340fd1d913395fe32f781399604a',
- appKey: 'hhLOhU8Wb5x',
- appSecret: '3ade6850270e2964bb7499492493e464ceccf937',
- privateKey: 'wxuoukkrts68aqwv',
-
- appIdRisk: 'be454b553daa209177e8d51883e828d2',
- appKeyRisk: 'hh0SLerEB5E',
- appSecretRisk: '2ec80e28fa7c98936fd053c9b72aa81692bb5ec5',
- privateKeyRisk: 'yfxrbbnnmsyuteaj',
-
- riskResult: 1,
- expirationDateOpenNum: 0,
- },
-
- });
|