123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- // *********************下载集中配置 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{
- $('#ManuallyDownloadError').html("");
- $('#ManuallyDownloadError').hide();
- let req = new Request(),reqIn ={};
- let data = document.getElementsByTagName('input');
- reqIn.reqCenterConfigUrl = data['centerConfigUrl'].value;
- 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*********************/
- /**
- * @description: 读取配置 value=1,可以跳过扫码,直接重置密钥
- * @param {}
- * @return: value=1
- */
- let jumpScan = false //是否跳过扫码
- function ReadCenterScanConfig(){
- $('#loadContent').fadeIn('slow');
- let timeoutFn= setTimeout(function(){
- $('#loadContent').fadeOut('slow')
- let tips = '请求超时'
- ModalStyle(tips,'pathN')
- },timeout)
- let req = new Request();
- req["{e12a3dc0-3a0b-47c4-a8c3-75190a42ae68}"]={
- entity: 'AccessAuthorization' ,
- key: 'SkipScanCode' ,
- reserved1: 0,
- reserved2: 0,
- reserved3: '',
- reserved4: '',
- timeout: 60000,
- }
- HealthManagerService.ReadCenterConfigStr(req, function(ret) {
- logEvent("ReadCenterConfigStr ret: "+JSON.stringify(ret));
- console.log('ReadCenterScanConfig----',ret)
- if(ret){
- $('#loadContent').fadeOut('slow');
- clearTimeout(timeoutFn)
- }
- if(ret.errorCode ===0&&ret.value==1){
- jumpScan = true
- }else{
- jumpScan = false
- }
- })
- }
- // 密钥初始化Btn
- function resetRSA(){
- $('#entityCheckout').fadeOut()
- $('#serverNoAccess').fadeOut()
- $('#navBtns').fadeOut() //二维码没有菜单btns
- console.log('jumpScan---',jumpScan)
- if(jumpScan){
- setTimeout(()=>{ //延时显示,避免内容污染
- $('#RSAReseting').css({display:'flex'});
- initializeNew('admin')
- },500)
- }else{
- setTimeout(()=>{ //延时显示,避免内容污染
- $('#scanIdentity').css({display:'flex'});
- },300)
- }
-
- getHardwareInfo()
- }
- // 扫码登录后接收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 = '重置设备密钥中,稍后自动重启应用<dot class="dot-uos">●●●●●●</dot>'
- }else{
- document.getElementById('restDot').innerHTML = '重置设备密钥中,稍后自动重启应用<dot class="dot">●●●●●●</dot>'
- }
- }
- };
- function initializeNew(code){
- let req = new Request()
- req.strAuthServer = HostUrl;
- req.strUserID = code
- req.strPassword = '88888888' //默认值,后台不做校验
- req.timeout = 60000
- let timeoutFn= setTimeout(function(){
- let tips = '请求超时'
- ModalPrompt(tips,'pathN','InitializeNew')
- stopAnimation();
- document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修'
- $('.hardwareConfig').fadeIn()
- },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 = '重置设备密钥失败,请重试或联系厂商维修'
- $('.hardwareConfig').fadeIn()
- }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 = '重置设备密钥失败,请重试或联系厂商维修'
- $('.hardwareConfig').fadeIn()
- }
- });
- }
- 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(){
- document.getElementsByTagName('input')['centerConfigUrl'].value="";
- $('#ManuallyDownloadError').html("");
- $('#ManuallyDownloadError').hide();
- $('#btn-downLoad').attr('disabled','disabled');
- // 进入的方式,决定退出的方式
- if(window.location.href.indexOf('entityCheck')>-1||window.location.href.indexOf('serverNoAccess')>-1){
- $('#scanIdentity').fadeOut(); //二维码关闭
- $('#RSAReseting').fadeOut(); //重置密钥中···关闭
- $('#ManuallyDownload').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')
- }
- }
|