123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- //页面初始化
- window.onload=function(){
- if (typeof(document.onselectstart) != "undefined") {
- // IE禁止元素选取
- document.onselectstart = function (event){
- if(event.target.tagName!="INPUT"){
- return false;
- }
- }
- }
-
- WebSocketBase.socket.onerror = function () {
- logEvent("HealthManagerService startSession callback");
- let tips = "终端链接失败"
- ModalPrompt(tips, 'pathN')
- }
- let date = +new Date
- let dateTime = getFamtterTimer(date)
- $('.currDate').html(dateTime)
- let Request = GetRequest();
- if(Request['showlimit'] && Request['showlimit'] ==1){
- $("#resetPsd").css({display:'flex'});
- $("#downLoadConfig").css({display:'flex'});
- }else{
- $("#resetPsd").hide()
- $("#downLoadConfig").hide()
- }
- if(Request['showmin'] && Request['showmin'] ==1){
- $("#minimize").css({display:'flex'});
- }else{
- $("#minimize").fadeOut()
- }
- HealthManagerService.init();
- ResourceWatcherService.init();
- getHardwareInfo()
- // getAccessUrl()
- getCertainAceessUrl() //准入接口
- $('#loadContent').fadeIn('slow');
- $('.hardwareConfig').fadeOut() //页面开始加载的时候,强制隐藏一下硬件配置按钮
- // dot 类名加载,loading点点在UOS需重新处理
- if(navigator.userAgent.toLowerCase().indexOf('windows')<0){
- $('#retestBtn dot').removeClass('test-dot')
- $('#retestBtn dot').addClass('test-dot-uos')
- $('#restDot dot').removeClass('dot')
- $('#restDot dot').addClass('dot-uos')
- }
-
- }
- /**
- * @description: 查询终端实体信息
- * @param {}
- * @return: terminalNo,termVersion
- */
- let terminalNo,hardwareConfigURI=''
- function getHardwareInfo(){
- let req = new Request()
- let timeoutFn= setTimeout(function(){
- let tips = 'QueryHardwareInfo 请求超时'
- ModalPrompt(tips, 'pathN')
- $('#loadContent').fadeOut('slow');
- },60000)
- HealthManagerService.QueryHardwareInfo(req, function(res) {
- logEvent("QueryHardwareInfo ret: "+JSON.stringify(res));
- if(res){
- clearTimeout(timeoutFn);
- $('.terminalNo').html(res.terminalNo)
- $('.termVersion').html('V'+res.termVersion)
- $('#loadContent').fadeOut('slow');
- terminalNo = res.terminalNo;
- let clientId ='';
- switch(res.reserved1){
- case 0:
- clientId = '6898ec10629f499187d7b31fbe9823a4';
- hardwareConfigURI='https://firmregisterfront.paas.cmbchina.cn';
- break; //DEV
- case 1:
- clientId = '6898ec10629f499187d7b31fbe9823a4';
- hardwareConfigURI='https://firmregisterfront.paasst.cmbchina.cn';
- break; //ST
- case 2:
- clientId = '6898ec10629f499187d7b31fbe9823a4';
- hardwareConfigURI='https://firmregisterfront.paasuat.cmbchina.cn';
- break; //UAT
- case 3:
- clientId = '9e7e54105fce408cae37322dbbd64046';
- hardwareConfigURI='https://firmregisterfront.paas.cmbchina.cn';
- break; //PRD
- default:
- clientId = '9e7e54105fce408cae37322dbbd64046';
- hardwareConfigURI='https://firmregisterfront.paas.cmbchina.cn';
- break; //PRD
- }
- //todo
- if(document.getElementById('iframeSrc')){
- let iframeSrc = 'https://one-account-gateway.paasuat.cmbchina.cn/auth-plugin/v2/identity-authentication?clientId='+clientId+'&ui=eyJhdXRoVHlwZXMiOlsicXJDb2RlIl0sImhlYWRlciI6dHJ1ZX0%253D'
- //Pad https://oa-auth.paas.cmbchina.com/auth-plugin/v2/identity-authentication
- //大机 https://oa-auth.paas.cmbchina.cn/auth-plugin/v2/identity-authentication
- if(res.reserved1==3){
- if(res.machineType.toUpperCase()=='RVC.PAD'){
- iframeSrc = 'https://oa-auth.paas.cmbchina.com/auth-plugin/v2/identity-authentication?clientId='+clientId+'&ui=eyJhdXRoVHlwZXMiOlsicXJDb2RlIl0sImhlYWRlciI6dHJ1ZX0%253D'
- }else{
- iframeSrc = 'https://oa-auth.paas.cmbchina.cn/auth-plugin/v2/identity-authentication?clientId='+clientId+'&ui=eyJhdXRoVHlwZXMiOlsicXJDb2RlIl0sImhlYWRlciI6dHJ1ZX0%253D'
- }
- }
-
- document.getElementById('iframeSrc').src = iframeSrc
- }
-
- }
- })
- }
- function hardwareConfig(module){ //todo
- window.location.href =`${hardwareConfigURI}/hardwareConfig?terminalNo=${terminalNo}&loginWay=3&module=${module}&url=xx#/`
- }
- /**
- * @description: 查询准入地址
- * @param {reqName:'HostUrl'}
- * @return: HostUrl
- */
- function getCertainAceessUrl(){
- let req = new Request()
- req['{e12a3dc0-3a0b-47c4-a8c3-75190a42ae68}'] ={entity:'AccessAuthorization',key:'HostUrl'}
- let timeoutFn= setTimeout(function(){
- let tips = 'ReadCenterConfigStr 请求超时'
- ModalPrompt(tips, 'pathN')
- },60000)
-
- HealthManagerService.ReadCenterConfigStr(req, function(ret) {
- logEvent("ReadCenterConfigStr ret: "+JSON.stringify(ret));
- console.log("ReadCenterConfigStr ret: "+JSON.stringify(ret));
- if(ret){
- clearTimeout(timeoutFn);
- $('.urlAccessAddr').html(ret.value)
- }
- })
- }
- /**
- * @description: modal显示设置
- * @param {tips: 提示信息,pathType:pathY|pathN 提示类型,origion:选填 来源 InitializeNew| }
- * @return:
- */
- let promptType='',origion=''
- function ModalPrompt(tips,pathType,origions){
- $('#modalPrompt').fadeIn('slow')
- $('#loadContent').fadeOut('slow')
- $('#errTips').html(tips);
- let path = (pathType == 'pathY') ? './images/success.png' : './images/fail.png'
- $('#modalPrompt img').attr('src', path)
- promptType = pathType;
- if(origions){
- origion= origions;
- }
-
- }
- /**
- * @description: modal关闭设置
- * @param {type}
- * @return:
- */
- function closeModal(type){
- if(type=='prompt'){
- $('#modalPrompt').fadeOut('slow')
- // 重置设备密钥失败后,切换title话术,显示重试按钮
- if(promptType=='pathN' && origion=='InitializeNew'){
- $('#scanIdentity').fadeOut(); //二维码关闭
- $('#RSAReseting').fadeOut(); //重置密钥中···关闭
- setTimeout(()=>{ //延时显示,避免内容污染
- $('#entityCheckout').fadeIn('slow')
- $('#serverNoAccess').fadeIn('slow')
- $('#navBtns').fadeIn('slow')
- },500)
- }
- } else{
- $('#modalConfirm').fadeOut('slow')
- }
- }
- // 关闭错误页
- function chromiumClose(){
- if(navigator.userAgent.toLowerCase().indexOf('windows')<0){
- open(location, '_self').close() //UOS退出关闭页
- }else{
- let req = {};
- req.messageType = 0;
- req.command = 'ChromiumClose';
- sendRequest(req);
- }
- }
- 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')
- }
- }
|