1 |
- import validate from"./utils/validate";import Log from"./constants/log";import globalConfig from"./globalConfig";import{navigateToEid}from"./utils/index";const EIDAppID="wx0e2cb0b052a91c92";function initEid(e="https://eid.faceid.qq.com",o="release",n="https://eid-enhance.faceid.qq.com"){uni.eidBaseUrl=e,uni.eidEnvVersion=o,uni.eidBackUpUrl=n;uni.onAppShow(e=>{console.log("!!!!!!监听onshow事件",e,wx.eidTokenToCallback);var{scene:e,referrerInfo:o}=e,{appId:o,extraData:n}=o||{},{token:i,verifyDone:t}=n||{};1038===e&&o===EIDAppID&&uni.eidTokenToCallback&&(o=i||uni.eidTokenToCallback,uni.reportLogToEid({token:o,event:Log.navigateBackFromEid,errMsg:`从EID核身完成返回,核验未完成或者没有处理核验完成的函数,token:${o},verifyDone:${t},scene:`+e}),uni.eidTokenToCallback)&&uni.eidTokenToCallback===i&&t&&uni.handleEidVerifyDone&&uni.handleEidVerifyDone(n),uni.eidTokenToCallback=""});e=uni.getSystemInfoSync();const d=e["version"];uni.reportLogToEid=function(e){var{token:e="",event:o="",errCode:n="",errMsg:i="",data:t={}}=e,r=new Date;const a={Token:e,SourceType:Log.SourceType,SourceVersion:Log.version,EnvVersion:d,Timestamp:r.getTime(),Event:o,ErrorCode:"number"==typeof n?n.toString():n,ErrorMsg:i,Data:JSON.stringify(t)};console.log("开始上报日志:",a),uni.request({url:uni.eidBaseUrl+"/api/common/ReportEvent",method:"POST",data:a,success(e){console.log("上报日志完成:","payload:",a,"res:",e)}})}}function startEid(e){const{data:o,verifyDoneCallback:n}=e;if(!o||!n)return uni.reportLogToEid({token:i,event:Log.startEidFail,errMsg:"传入的参数有误"}),void uni.showModal({title:"提示",content:"传入的参数有误",showCancel:!1});const{token:i,needJumpPage:t=!1}=o;validate.isValidateToken(i)?(uni.handleEidVerifyDone=e=>{const o=e["token"];t?uni.navigateBack({success(){uni.reportLogToEid({token:o,event:Log.EidVerifyDone,errMsg:"验证完成,token:"+o}),n({token:o,verifyDone:!0})}}):(uni.reportLogToEid({token:o,event:Log.EidVerifyDone,errMsg:"验证完成,token:"+o}),n({token:o,verifyDone:!0}))},t?uni.navigateTo({url:`${globalConfig.normalPath}/mp_ecard_sdk/index/index?token=${i}&needJumpPage=`+t}):navigateToEid(i)):(uni.reportLogToEid({token:i,event:Log.startEidFail,errMsg:"传入的token有误,token:"+i}),uni.showModal({title:"提示",content:"传入的token有误",showCancel:!1}))}export{initEid,startEid};
|