getTerminalInfo.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. //页面初始化
  2. window.onload=function(){
  3. if (typeof(document.onselectstart) != "undefined") {
  4. // IE禁止元素选取
  5. document.onselectstart = function (event){
  6. if(event.target.tagName!="INPUT"){
  7. return false;
  8. }
  9. }
  10. }
  11. WebSocketBase.socket.onerror = function () {
  12. logEvent("HealthManagerService startSession callback");
  13. let tips = "终端链接失败"
  14. ModalPrompt(tips, 'pathN')
  15. }
  16. let date = +new Date
  17. let dateTime = getFamtterTimer(date)
  18. $('.currDate').html(dateTime)
  19. let Request = GetRequest();
  20. if(Request['showlimit'] && Request['showlimit'] ==1){
  21. $("#resetPsd").css({display:'flex'});
  22. $("#downLoadConfig").css({display:'flex'});
  23. }else{
  24. $("#resetPsd").hide()
  25. $("#downLoadConfig").hide()
  26. }
  27. if(Request['showmin'] && Request['showmin'] ==1){
  28. $("#minimize").css({display:'flex'});
  29. }else{
  30. $("#minimize").fadeOut()
  31. }
  32. HealthManagerService.init();
  33. ResourceWatcherService.init();
  34. getHardwareInfo()
  35. // getAccessUrl()
  36. getCertainAceessUrl() //准入接口
  37. $('#loadContent').fadeIn('slow');
  38. $('.hardwareConfig').fadeOut() //页面开始加载的时候,强制隐藏一下硬件配置按钮
  39. // dot 类名加载,loading点点在UOS需重新处理
  40. if(navigator.userAgent.toLowerCase().indexOf('windows')<0){
  41. $('#retestBtn dot').removeClass('test-dot')
  42. $('#retestBtn dot').addClass('test-dot-uos')
  43. $('#restDot dot').removeClass('dot')
  44. $('#restDot dot').addClass('dot-uos')
  45. }
  46. }
  47. /**
  48. * @description: 查询终端实体信息
  49. * @param {}
  50. * @return: terminalNo,termVersion
  51. */
  52. let terminalNo,hardwareConfigURI=''
  53. function getHardwareInfo(){
  54. let req = new Request()
  55. let timeoutFn= setTimeout(function(){
  56. let tips = 'QueryHardwareInfo 请求超时'
  57. ModalPrompt(tips, 'pathN')
  58. $('#loadContent').fadeOut('slow');
  59. },60000)
  60. HealthManagerService.QueryHardwareInfo(req, function(res) {
  61. logEvent("QueryHardwareInfo ret: "+JSON.stringify(res));
  62. if(res){
  63. clearTimeout(timeoutFn);
  64. $('.terminalNo').html(res.terminalNo)
  65. $('.termVersion').html('V'+res.termVersion)
  66. $('#loadContent').fadeOut('slow');
  67. terminalNo = res.terminalNo;
  68. let clientId ='';
  69. switch(res.reserved1){
  70. case 0:
  71. clientId = '6898ec10629f499187d7b31fbe9823a4';
  72. hardwareConfigURI='https://firmregisterfront.paas.cmbchina.cn';
  73. break; //DEV
  74. case 1:
  75. clientId = '6898ec10629f499187d7b31fbe9823a4';
  76. hardwareConfigURI='https://firmregisterfront.paasst.cmbchina.cn';
  77. break; //ST
  78. case 2:
  79. clientId = '6898ec10629f499187d7b31fbe9823a4';
  80. hardwareConfigURI='https://firmregisterfront.paasuat.cmbchina.cn';
  81. break; //UAT
  82. case 3:
  83. clientId = '9e7e54105fce408cae37322dbbd64046';
  84. hardwareConfigURI='https://firmregisterfront.paas.cmbchina.cn';
  85. break; //PRD
  86. default:
  87. clientId = '9e7e54105fce408cae37322dbbd64046';
  88. hardwareConfigURI='https://firmregisterfront.paas.cmbchina.cn';
  89. break; //PRD
  90. }
  91. //todo
  92. if(document.getElementById('iframeSrc')){
  93. let iframeSrc = 'https://one-account-gateway.paasuat.cmbchina.cn/auth-plugin/v2/identity-authentication?clientId='+clientId+'&ui=eyJhdXRoVHlwZXMiOlsicXJDb2RlIl0sImhlYWRlciI6dHJ1ZX0%253D'
  94. //Pad https://oa-auth.paas.cmbchina.com/auth-plugin/v2/identity-authentication
  95. //大机 https://oa-auth.paas.cmbchina.cn/auth-plugin/v2/identity-authentication
  96. if(res.reserved1==3){
  97. if(res.machineType.toUpperCase()=='RVC.PAD'){
  98. iframeSrc = 'https://oa-auth.paas.cmbchina.com/auth-plugin/v2/identity-authentication?clientId='+clientId+'&ui=eyJhdXRoVHlwZXMiOlsicXJDb2RlIl0sImhlYWRlciI6dHJ1ZX0%253D'
  99. }else{
  100. iframeSrc = 'https://oa-auth.paas.cmbchina.cn/auth-plugin/v2/identity-authentication?clientId='+clientId+'&ui=eyJhdXRoVHlwZXMiOlsicXJDb2RlIl0sImhlYWRlciI6dHJ1ZX0%253D'
  101. }
  102. }
  103. document.getElementById('iframeSrc').src = iframeSrc
  104. }
  105. }
  106. })
  107. }
  108. function hardwareConfig(module){ //todo
  109. window.location.href =`${hardwareConfigURI}/hardwareConfig?terminalNo=${terminalNo}&loginWay=3&module=${module}&url=xx#/`
  110. }
  111. /**
  112. * @description: 查询准入地址
  113. * @param {reqName:'HostUrl'}
  114. * @return: HostUrl
  115. */
  116. function getCertainAceessUrl(){
  117. let req = new Request()
  118. req['{e12a3dc0-3a0b-47c4-a8c3-75190a42ae68}'] ={entity:'AccessAuthorization',key:'HostUrl'}
  119. let timeoutFn= setTimeout(function(){
  120. let tips = 'ReadCenterConfigStr 请求超时'
  121. ModalPrompt(tips, 'pathN')
  122. },60000)
  123. HealthManagerService.ReadCenterConfigStr(req, function(ret) {
  124. logEvent("ReadCenterConfigStr ret: "+JSON.stringify(ret));
  125. console.log("ReadCenterConfigStr ret: "+JSON.stringify(ret));
  126. if(ret){
  127. clearTimeout(timeoutFn);
  128. $('.urlAccessAddr').html(ret.value)
  129. }
  130. })
  131. }
  132. /**
  133. * @description: modal显示设置
  134. * @param {tips: 提示信息,pathType:pathY|pathN 提示类型,origion:选填 来源 InitializeNew| }
  135. * @return:
  136. */
  137. let promptType='',origion=''
  138. function ModalPrompt(tips,pathType,origions){
  139. $('#modalPrompt').fadeIn('slow')
  140. $('#loadContent').fadeOut('slow')
  141. $('#errTips').html(tips);
  142. let path = (pathType == 'pathY') ? './images/success.png' : './images/fail.png'
  143. $('#modalPrompt img').attr('src', path)
  144. promptType = pathType;
  145. if(origions){
  146. origion= origions;
  147. }
  148. }
  149. /**
  150. * @description: modal关闭设置
  151. * @param {type}
  152. * @return:
  153. */
  154. function closeModal(type){
  155. if(type=='prompt'){
  156. $('#modalPrompt').fadeOut('slow')
  157. // 重置设备密钥失败后,切换title话术,显示重试按钮
  158. if(promptType=='pathN' && origion=='InitializeNew'){
  159. $('#scanIdentity').fadeOut(); //二维码关闭
  160. $('#RSAReseting').fadeOut(); //重置密钥中···关闭
  161. setTimeout(()=>{ //延时显示,避免内容污染
  162. $('#entityCheckout').fadeIn('slow')
  163. $('#serverNoAccess').fadeIn('slow')
  164. $('#navBtns').fadeIn('slow')
  165. },500)
  166. }
  167. } else{
  168. $('#modalConfirm').fadeOut('slow')
  169. }
  170. }
  171. // 关闭错误页
  172. function chromiumClose(){
  173. if(navigator.userAgent.toLowerCase().indexOf('windows')<0){
  174. open(location, '_self').close() //UOS退出关闭页
  175. }else{
  176. let req = {};
  177. req.messageType = 0;
  178. req.command = 'ChromiumClose';
  179. sendRequest(req);
  180. }
  181. }
  182. function sendRequest(request){
  183. try{
  184. window.cefQuery({
  185. request: JSON.stringify(request),
  186. onSuccess: function() {
  187. console.log('window.cefQuery success');
  188. },
  189. onFailure: function(error_code, error_message) {
  190. console.log('window.cefQuery error,'+error_message + ' (' + error_code + ')');
  191. let tips = error_code + error_message
  192. ModalPrompt(tips,'pathN')
  193. }
  194. });
  195. }
  196. catch(ex) {
  197. console.log('window.cefQuery exception ',ex);
  198. let tips = '退出失败'
  199. ModalPrompt(tips,'pathN')
  200. }
  201. }