2 lines
4.5 KiB
JavaScript
2 lines
4.5 KiB
JavaScript
(function(_0x12ba10,_0x363f5a){if(typeof define==='function'&&define['amd']){define(['jquery'],_0x363f5a);}else if(typeof exports==='object'){module['exports']=_0x363f5a(require('./js/jquery-3.6.1.min'));}else{_0x12ba10['Living']=_0x363f5a(_0x12ba10['$']);}}(this,function(_0x2283ac){function _0x28601d(_0x4d0a63,_0x2a999c){this['page']=_0x4d0a63;this['token']=_0x2a999c['token'];this['proxy']=_0x2a999c['proxy'];this['timer']=_0x2a999c['timer']||0xf0f5d^0xf284d;this['rate']=_0x2a999c['rate']||0xaff99^0xafffd;this['action']=_0x2a999c['action']||[];this['onDetectStart']=_0x2a999c['onDetectStart']&&typeof _0x2a999c['onDetectStart']==='function'?_0x2a999c['onDetectStart']:function(){};this['onDetectActionProgress']=_0x2a999c['onDetectActionProgress']&&typeof _0x2a999c['onDetectActionProgress']==='function'?_0x2a999c['onDetectActionProgress']:function(){};this['onDetectActionStart']=_0x2a999c['onDetectActionStart']&&typeof _0x2a999c['onDetectActionStart']==='function'?_0x2a999c['onDetectActionStart']:function(){};this['onDetectActionFinish']=_0x2a999c['onDetectActionFinish']&&typeof _0x2a999c['onDetectActionFinish']==='function'?_0x2a999c['onDetectActionFinish']:function(){};this['onDetectFinish']=_0x2a999c['onDetectFinish']&&typeof _0x2a999c['onDetectFinish']==='function'?_0x2a999c['onDetectFinish']:function(){};this['getFacePicture']=_0x2a999c['getFacePicture']&&typeof _0x2a999c['getFacePicture']==='function'?_0x2a999c['getFacePicture']:function(){};this['requestId']='';this['t']=null;}_0x28601d['prototype']={'start':function(){let _0x3378f0=this;this['getRequestId'](function(_0x5c3b12){_0x3378f0['requestId']=_0x5c3b12;_0x3378f0['checking']();_0x3378f0['onDetectStart']();});},'getRequestId':function(_0x37686a){let _0xfd3f05=this;_0x2283ac['ajax']({'type':'get','url':_0xfd3f05['proxy']+'/openapi/livingDetect/v1/getRequestId','dataType':'json','beforeSend':function(_0x5578ed){_0x5578ed['setRequestHeader']('Authorization','Bearer\x20'+_0xfd3f05['token']);},'success':function(_0x8186d6){if(_0x8186d6['code']==='0'){_0x37686a&&_0x37686a(_0x8186d6['data']['requestId']);}},'error':function(_0x3ed909){console['log'](_0x3ed909);}});},'checkAction':function(_0xe33a8c){let _0x1f4ccb=this;this['timeLoop'](_0x1f4ccb['action'][_0xe33a8c])['then'](function(_0x239a5a){_0x1f4ccb['stopLoop']();_0x1f4ccb['onDetectActionFinish'](_0x1f4ccb['action'][_0xe33a8c],{'code':0x1,'msg':'动作检测成功'});if(_0x1f4ccb['action'][_0xe33a8c+(0x1b77b^0x1b77a)]){_0x1f4ccb['checkAction'](_0xe33a8c+(0xb7504^0xb7505));}if(_0xe33a8c===_0x1f4ccb['action']['length']-(0x5f816^0x5f817)){_0x1f4ccb['stop']();_0x1f4ccb['onDetectFinish']({'code':0x1,'msg':'活体检测成功','file':_0x239a5a});}},function(){_0x1f4ccb['stop']();_0x1f4ccb['onDetectActionFinish'](_0x1f4ccb['action'][_0xe33a8c],{'code':0x0,'msg':'动作检测失败'});_0x1f4ccb['onDetectFinish']({'code':0x0,'msg':'活体检测失败'});});},'checking':function(){if(!this['action']['length']){return;}this['checkAction'](0x8171f^0x8171f);},'timeLoop':function(_0x358c73){let _0x3b2170=this;let _0x3d2180=this['rate'];this['onDetectActionStart'](_0x358c73,_0x3b2170['timer']);let _0x57c115=0xdfcde^0xdfcdf;var _0x3e15bf=_0x2283ac['Deferred']();let _0x19a9c8=_0x3b2170['timer'];_0x3b2170['t']=setInterval(function(){if(_0x19a9c8===(0x3a426^0x3a426)){_0x3b2170['stopLoop']();_0x3e15bf['reject']();return;}_0x19a9c8-=_0x3d2180;_0x3b2170['onDetectActionProgress'](_0x358c73,_0x19a9c8);_0x3b2170['upload'](_0x57c115++,_0x358c73,function(_0x4101fe){_0x3e15bf['resolve'](_0x4101fe);},function(){_0x3e15bf['reject']();});},_0x3d2180);return _0x3e15bf['promise']();},'upload':function(_0x31444d,_0x3278d8,_0x31de13,_0xb8cec1){let _0x21beb0=this;let _0xac3985=this['getFacePicture']();var _0x53190b=new FormData();_0x53190b['append']('picFile',_0xac3985['file']);_0x53190b['append']('requestId',_0x21beb0['requestId']||'');_0x53190b['append']('actionType',_0x3278d8);_0x53190b['append']('picSerialNumber',_0x31444d+'');_0x2283ac['ajax']({'type':'POST','url':_0x21beb0['proxy']+'/openapi/livingDetect/v1/start?time='+new Date()['getTime'](),'contentType':![],'processData':![],'beforeSend':function(_0x57d52c){_0x57d52c['setRequestHeader']('Authorization','Bearer\x20'+_0x21beb0['token']);},'data':_0x53190b,'success':function(_0x2d4654){if(_0x2d4654['code']==='0'){if(_0x2d4654['data']['isLiving']==='1'){_0x31de13&&_0x31de13({'file':_0xac3985['file']});}}},'error':function(_0x2da092){console['log'](_0x2da092);_0xb8cec1&&_0xb8cec1();}});},'stopLoop':function(){clearInterval(this['t']);},'stop':function(){this['stopLoop']();this['requestId']='';}};return _0x28601d;}));
|