getTerminalInfo.js 6.5 KB

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