getTerminalInfo.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. CenterSettingService.init();
  34. ResourceWatcherService.init();
  35. getHardwareInfo()
  36. // getAccessUrl()
  37. getCertainAceessUrl() //准入接口
  38. ReadCenterScanConfig() //读取扫码配置
  39. $('#loadContent').fadeIn('slow');
  40. $('.hardwareConfig').fadeOut() //页面开始加载的时候,强制隐藏一下硬件配置按钮
  41. // dot 类名加载,loading点点在UOS需重新处理
  42. if(navigator.userAgent.toLowerCase().indexOf('windows')<0){
  43. $('#retestBtn dot').removeClass('test-dot')
  44. $('#retestBtn dot').addClass('test-dot-uos')
  45. $('#restDot dot').removeClass('dot')
  46. $('#restDot dot').addClass('dot-uos')
  47. }
  48. }
  49. /**
  50. * @description: 查询终端实体信息
  51. * @param {}
  52. * @return: terminalNo,termVersion
  53. */
  54. let terminalNo,hardwareConfigURI=''
  55. function getHardwareInfo(){
  56. let req = new Request()
  57. let timeoutFn= setTimeout(function(){
  58. let tips = 'QueryHardwareInfo 请求超时'
  59. ModalPrompt(tips, 'pathN')
  60. $('#loadContent').fadeOut('slow');
  61. },60000)
  62. HealthManagerService.QueryHardwareInfo(req, function(res) {
  63. logEvent("QueryHardwareInfo ret: "+JSON.stringify(res));
  64. if(res){
  65. clearTimeout(timeoutFn);
  66. $('.terminalNo').html(res.terminalNo)
  67. $('.termVersion').html('V'+res.termVersion)
  68. $('#loadContent').fadeOut('slow');
  69. terminalNo = res.terminalNo;
  70. let clientId ='';
  71. switch(res.reserved1){
  72. case 0:
  73. clientId = '6898ec10629f499187d7b31fbe9823a4';
  74. hardwareConfigURI='https://firmregisterfront.paas.cmbchina.cn';
  75. break; //DEV
  76. case 1:
  77. clientId = '6898ec10629f499187d7b31fbe9823a4';
  78. hardwareConfigURI='https://firmregisterfront.paasst.cmbchina.cn';
  79. break; //ST
  80. case 2:
  81. clientId = '6898ec10629f499187d7b31fbe9823a4';
  82. hardwareConfigURI='firmregisterfront.paasuat.cmbchina.cn';
  83. break; //UAT
  84. case 3:
  85. clientId = '9e7e54105fce408cae37322dbbd64046';
  86. hardwareConfigURI='firmregisterfront.paas.cmbchina.cn';
  87. break; //PRD
  88. default:
  89. clientId = '9e7e54105fce408cae37322dbbd64046';
  90. hardwareConfigURI='firmregisterfront.paas.cmbchina.cn';
  91. break; //PRD
  92. }
  93. //todo
  94. if(document.getElementById('iframeSrc')){
  95. let iframeSrc = 'https://one-account-gateway.paasuat.cmbchina.cn/auth-plugin/v2/identity-authentication?clientId='+clientId+'&ui=eyJhdXRoVHlwZXMiOlsicXJDb2RlIl0sImhlYWRlciI6dHJ1ZX0%253D'
  96. //Pad https://oa-auth.paas.cmbchina.com/auth-plugin/v2/identity-authentication
  97. //大机 https://oa-auth.paas.cmbchina.cn/auth-plugin/v2/identity-authentication
  98. // if(res.reserved1==3){
  99. // if(res.machineType.toUpperCase()=='RVC.PAD'){
  100. // iframeSrc = 'https://oa-auth.paas.cmbchina.com/auth-plugin/v2/identity-authentication?clientId='+clientId+'&ui=eyJhdXRoVHlwZXMiOlsicXJDb2RlIl0sImhlYWRlciI6dHJ1ZX0%253D'
  101. // }else{
  102. // iframeSrc = 'https://oa-auth.paas.cmbchina.cn/auth-plugin/v2/identity-authentication?clientId='+clientId+'&ui=eyJhdXRoVHlwZXMiOlsicXJDb2RlIl0sImhlYWRlciI6dHJ1ZX0%253D'
  103. // }
  104. // }
  105. document.getElementById('iframeSrc').src = iframeSrc
  106. }
  107. }
  108. })
  109. }
  110. function hardwareConfig(){ //todo
  111. window.location.href =`${hardwareConfigURI}/hardwareConfig?terminalNo=${terminalNo}&loginWay=3&url=xx#/`
  112. }
  113. /**
  114. * @description: 查询初始化地址
  115. * @param {}
  116. * @return: HostUrl
  117. */
  118. let HostUrl = ''
  119. function getAccessUrl(){
  120. let req = new Request()
  121. let timeoutFn= setTimeout(function(){
  122. let tips = 'GetAccessUrl 请求超时'
  123. ModalPrompt(tips, 'pathN')
  124. },60000)
  125. CenterSettingService.GetAccessUrl(req, function(ret) {
  126. logEvent("GetAccessUrl ret: "+JSON.stringify(ret));
  127. console.log("GetAccessUrl ret: "+JSON.stringify(ret));
  128. if(ret){
  129. clearTimeout(timeoutFn);
  130. HostUrl = ret.HostUrl
  131. // $('.urlAccessAddr').html(ret.HostUrl)
  132. }
  133. })
  134. }
  135. /**
  136. * @description: 查询准入地址
  137. * @param {reqName:'HostUrl'}
  138. * @return: HostUrl
  139. */
  140. function getCertainAceessUrl(){
  141. let req = new Request()
  142. req.reqName = 'HostUrl'
  143. let timeoutFn= setTimeout(function(){
  144. let tips = 'GetCertainAceessUrl 请求超时'
  145. ModalPrompt(tips, 'pathN')
  146. },60000)
  147. CenterSettingService.GetCertainAceessUrl(req, function(ret) {
  148. logEvent("GetCertainAceessUrl ret: "+JSON.stringify(ret));
  149. console.log("GetCertainAceessUrl ret: "+JSON.stringify(ret));
  150. if(ret){
  151. clearTimeout(timeoutFn);
  152. HostUrl = ret.CertainAceessUrl
  153. $('.urlAccessAddr').html(ret.CertainAceessUrl)
  154. }
  155. })
  156. }
  157. /**
  158. * @description: modal显示设置
  159. * @param {tips: 提示信息,pathType:pathY|pathN 提示类型,origion:选填 来源 InitializeNew| }
  160. * @return:
  161. */
  162. let promptType='',origion=''
  163. function ModalPrompt(tips,pathType,origions){
  164. $('#modalPrompt').fadeIn('slow')
  165. $('#loadContent').fadeOut('slow')
  166. $('#errTips').html(tips);
  167. let path = (pathType == 'pathY') ? './images/success.png' : './images/fail.png'
  168. $('#modalPrompt img').attr('src', path)
  169. promptType = pathType;
  170. if(origions){
  171. origion= origions;
  172. }
  173. }
  174. /**
  175. * @description: modal关闭设置
  176. * @param {type}
  177. * @return:
  178. */
  179. function closeModal(type){
  180. if(type=='prompt'){
  181. $('#modalPrompt').fadeOut('slow')
  182. // 重置设备密钥失败后,切换title话术,显示重试按钮
  183. if(promptType=='pathN' && origion=='InitializeNew'){
  184. $('#scanIdentity').fadeOut(); //二维码关闭
  185. $('#RSAReseting').fadeOut(); //重置密钥中···关闭
  186. $('#ManuallyDownload').fadeOut();
  187. setTimeout(()=>{ //延时显示,避免内容污染
  188. $('#entityCheckout').fadeIn('slow')
  189. $('#serverNoAccess').fadeIn('slow')
  190. $('#navBtns').fadeIn('slow')
  191. },500)
  192. }
  193. }else if(type=='toast'){
  194. $('#modalErrorBox').fadeOut('slow')
  195. } else{
  196. $('#modalConfirm').fadeOut('slow')
  197. }
  198. }
  199. // 关闭错误页
  200. function chromiumClose(){
  201. if(navigator.userAgent.toLowerCase().indexOf('windows')<0){
  202. open(location, '_self').close() //UOS退出关闭页
  203. }else{
  204. let req = {};
  205. req.messageType = 0;
  206. req.command = 'ChromiumClose';
  207. sendRequest(req);
  208. }
  209. }
  210. function sendRequest(request){
  211. try{
  212. window.cefQuery({
  213. request: JSON.stringify(request),
  214. onSuccess: function() {
  215. console.log('window.cefQuery success');
  216. },
  217. onFailure: function(error_code, error_message) {
  218. console.log('window.cefQuery error,'+error_message + ' (' + error_code + ')');
  219. let tips = error_code + error_message
  220. ModalPrompt(tips,'pathN')
  221. }
  222. });
  223. }
  224. catch(ex) {
  225. console.log('window.cefQuery exception ',ex);
  226. let tips = '退出失败'
  227. ModalPrompt(tips,'pathN')
  228. }
  229. }