// *********************下载集中配置 Start*********************/ let ti = 29; let timeout=60000; let timeChange = null; function clock () { if (ti > 0) { ti = ti - 1; document.getElementById('restart-time').innerHTML = ti; } else { clearInterval(timeChange); ti = 29; $('#boxRestart').fadeOut('slow'); exitColck(); DeviceService.RebootShell(); } }; function restart(){ clearInterval(timeChange); ti = 29; $('#boxRestart').fadeOut('slow'); exitColck(); DeviceService.RebootShell(); } function showToast(title){ $('#toastErrTips').html(title); $('#loading_mask').hide(); $('#toastErrorBox').fadeIn('slow') setTimeout(()=>{ $('#toastErrorBox').fadeOut('slow') },2000) } function changeInput(obj){ if(obj.value!=''){ $('#btn-downLoad').removeAttr('disabled'); }else{ $('#btn-downLoad').attr('disabled','disabled'); } } function showManuallyDownloadModal(){ $('#modalErrorBox').fadeOut('slow'); $('#ManuallyDownload').fadeIn('slow'); // RebootShell() } /** * @description: 下载集中配置:自动下载失败,可以进行手动下载 * @param {value:自动下载 auto | 手动下载 manual} * @return: downloadStat */ function downLoadv3(value){ if(value=='auto'){ let req = new Request(); $('#loading_mask').fadeIn('slow'); let timeoutFn= setTimeout(function(){ $('#loading_mask').fadeOut('slow'); let tips = '请求超时' showToast(tips); },timeout) CenterSettingService.Downloadv3(req, function(ret) { logEvent("Download ret: "+JSON.stringify(ret)); console.log("Download ret: "+JSON.stringify(ret)); if(ret){ clearInterval(timeChange); clearTimeout(timeoutFn); $('#loading_mask').fadeOut('slow'); // downloadStat为1表示成功,2表示失败但是不需要手动下载,3表示不需要更新,4表示失败并且允许手动下载 if(ret.downloadStat==1){ // document.getElementById("configUrl").innerHTML = ret.retCenterConfigUrl; $('#boxRestart').fadeIn(); timeChange = setInterval(clock, 1000); }else if(ret.downloadStat==3 || ret.downloadStat==2){ let tips = ret.strErrMsg?ret.strErrMsg:'集中配置下载失败'; showToast(tips); return false }else { let msg = ret.strErrMsg?ret.strErrMsg:'集中配置下载失败'; let tips = msg + ',请联系总行信息部处理,是否进行手动下载?'; $('#modalErrorBox').fadeIn('slow'); $('#modalErrTips').html(tips); return false } } }) }else{ let req = new Request(),reqIn ={} req = Object.assign({},req,reqIn) $('#loading_mask').fadeIn('slow'); let timeoutFn= setTimeout(function(){ $('#loading_mask').fadeOut('slow'); let tips = '请求超时' ModalPrompt(tips,'pathN') },timeout) CenterSettingService.Downloadv3(req, function(ret) { logEvent("Download ret: "+JSON.stringify(ret)); console.log("Download ret: "+JSON.stringify(ret)); if(ret){ clearInterval(timeChange); clearTimeout(timeoutFn); $('#loading_mask').fadeOut('slow'); // downloadStat为1表示成功,2表示失败但是不需要手动下载,3表示不需要更新,4表示失败并且允许手动下载 if(ret.downloadStat==1){ // document.getElementById("configUrl").innerHTML = ret.retCenterConfigUrl; $('#boxRestart').fadeIn(); timeChange = setInterval(clock, 1000); }else if(ret.downloadStat==3){ let tips = ret.strErrMsg?ret.strErrMsg:'集中配置是最新版本'; showToast(tips); return false }else { let msg = ret.strErrMsg?ret.strErrMsg:'集中配置下载失败'; let tips = msg + ',请联系总行信息部处理,是否进行手动下载?'; $('#modalErrorBox').fadeIn('slow'); $('#modalErrTips').html(tips); return false } } }) } } // *********************下载集中配置 End*********************/ //跳过扫码 function handleNext(){ $('#scanIdentity').fadeOut() setTimeout(()=>{ //延时显示,避免内容污染 $('#RSAReseting').css({display:'flex'}); initializeNew('other') },500) } // 密钥初始化Btn function resetRSA(){ $('#entityCheckout').fadeOut() $('#serverNoAccess').fadeOut() $('#navBtns').fadeOut() //二维码没有菜单btns setTimeout(()=>{ //延时显示,避免内容污染 $('#scanIdentity').css({display:'flex'}); },300) getHardwareInfo() setTimeout(()=>{ $('.btn-next').fadeIn() },30000) } // 扫码登录后接收code let codeIndentity window.onmessage = (event) => { console.log('event----',event) if (event && event.data.code) { //接收code参数,格式{code: "********",state:"***********"} codeIndentity = event.data.code; initializeNew(event.data.code) $('#scanIdentity').fadeOut() setTimeout(()=>{ //延时显示,避免内容污染 $('#RSAReseting').css({display:'flex'}); },300) if(navigator.userAgent.toLowerCase().indexOf('windows')<0){ document.getElementById('restDot').innerHTML = '重置设备密钥中,稍后自动重启应用●●●●●●' }else{ document.getElementById('restDot').innerHTML = '重置设备密钥中,稍后自动重启应用●●●●●●' } } }; function initializeNew(code){ let req = new Request() req.strAuthServer = ''; req.strUserID = code req.strPassword = '88888888' // 默认虚拟值,后台不做校验以及相关处理(仅供终端实体逻辑判断-loginway) req.timeout = 60000 let timeoutFn= setTimeout(function(){ let tips = '请求超时' ModalPrompt(tips,'pathN','InitializeNew') stopAnimation(); document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修' },timeout) //重置密钥 AccessAuthService.InitializeNew(req, function(ret) { logEvent("InitializeNew ret: "+JSON.stringify(ret)); console.log("InitializeNew ret: "+JSON.stringify(ret)); if(ret){ stopAnimation(); clearTimeout(timeoutFn) } if(ret.errorCode == 0) { if(ret.Errcode !== 0) { let tips = ret.ErrMsg ? ret.ErrMsg : '重置密钥失败' ModalPrompt(tips,'pathN','InitializeNew') document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修' if(ret.Errcode == 1344405505){ $('.hardwareConfig').fadeIn() }else{ $('.hardwareConfig').fadeOut() } }else{ let tips = '加载主密钥成功' ModalPrompt(tips,'pathY') setTimeout(()=>{ $('#modalPrompt').fadeOut('slow') DeviceService.RebootShell(); exitColck() },2000) } } else{ let tips = ret.errorMsg ? ret.errorMsg : '重置密钥失败' ModalPrompt(tips,'pathN','InitializeNew') document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修' } }); } function startAnimation(){ let elem = document.querySelector('.dot'); if(elem){ elem.classList.remove('paused') } } function stopAnimation(){ let elem = document.querySelector('.dot'); if(elem){ elem.classList.add('paused') } } // 退出 function exit(){ $('#btn-downLoad').attr('disabled','disabled'); // 进入的方式,决定退出的方式 if(window.location.href.indexOf('entityCheck')>-1||window.location.href.indexOf('serverNoAccess')>-1||window.location.href.indexOf('audioErr')>-1||window.location.href.indexOf('homePageErr')>-1){ $('#scanIdentity').fadeOut(); //二维码关闭 $('#RSAReseting').fadeOut(); //重置密钥中···关闭 $('#ManuallyDownload').fadeOut(); $('.btn-next').fadeOut() //···关闭 setTimeout(()=>{ //延时显示,避免内容污染 $('#entityCheckout').fadeIn('slow') $('#serverNoAccess').fadeIn('slow') $('#navBtns').fadeIn('slow') },500) }else{ let req = {}; req.messageType = 0; req.command = 'ChromiumClose'; sendRequest(req); } } // 最小化btn function Minimize(){ let req = {}; req.messageType = 0; req.command = 'ChromiumTomin'; sendRequest(req); } let btnType //重启shell function RebootShell(){ logEvent("RebootShell"); btnType = 'RebootShell' modalConfirm('确认重启应用?') } //重启 function RebootComputer(){ logEvent("RebootComputer"); modalConfirm('确认重启计算机?') btnType = 'RebootComputer' } //关机 function PowerOff(){ logEvent("PowerOff"); btnType = 'PowerOff' modalConfirm('确认关闭计算机?') } // modal二次确认弹窗 function modalConfirm(tips){ $('#modalConfirm').fadeIn('slow') $('#errTipsErr').html(tips); } // modal 确定事件 function clickSure(){ if(!btnType)return false; $('#modalConfirm').fadeOut('slow') exitColck() switch(btnType) { case 'RebootShell': DeviceService.RebootShell(); break; case 'RebootComputer': DeviceService.RebootComputer();break case 'PowerOff': DeviceService.PowerOff(); break; } } // 20s后关闭错误页,自动退出 function exitColck(){ $('#modalExit').fadeIn('slow') let clock = 20 let timer = setInterval(function(){ clock-- if(clock==0){ let req = {}; req.messageType = 0; req.command = 'ChromiumClose'; sendRequest(req); clearInterval(timer) $('#modalExit').fadeOut('slow') } },1000) } function sendRequest(request){ try{ window.cefQuery({ request: JSON.stringify(request), onSuccess: function() { console.log('window.cefQuery success'); }, onFailure: function(error_code, error_message) { console.log('window.cefQuery error,'+error_message + ' (' + error_code + ')'); let tips = error_code + error_message ModalPrompt(tips,'pathN') } }); } catch(ex) { console.log('window.cefQuery exception ',ex); let tips = '退出失败' ModalPrompt(tips,'pathN') } }