appMobileConnectCheck.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!DOCTYPE html>
  2. <html>
  3. <head lang="en">
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  5. <link rel="stylesheet" type="text/css" href="../x_desktop/css/style.css" charset="UTF-8" />
  6. <link rel="stylesheet" href="../x_desktop/css/mBoxNotice.css" charset="UTF-8" />
  7. <link rel="stylesheet" href="../x_desktop/css/mBoxTooltip.css" charset="UTF-8" />
  8. <script src="../o2_core/o2.min.js"></script>
  9. <script src="js/base_simple_anonymous.js"></script>
  10. <title>移动App访问检查</title>
  11. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  12. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
  13. <meta content="yes" name="apple-mobile-web-app-capable" />
  14. <meta content="black" name="apple-mobile-web-app-status-bar-style" />
  15. <meta content="telephone=no" name="format-detection" />
  16. </head>
  17. <body style="height: 100%;overflow: auto; margin:0px;display: block;">
  18. <div id="errorArea" style="margin: 30px 20px; word-break: break-all;display: none;">
  19. </div>
  20. <div id="centerArea" style="margin: 30px 20px; word-break: break-all;">
  21. </div>
  22. <div id="appArea" style="margin: 30px 20px; word-break: break-all;">
  23. </div>
  24. <div id="contentArea" style="margin: 30px 20px; word-break: break-all;">
  25. </div>
  26. <script>
  27. layout.addReady(function(){
  28. (function(layout){
  29. //var uri = new URI(window.location.href);
  30. var hostname = window.location.hostname;
  31. console.log(hostname)
  32. var _showJson = function(json) {
  33. if (json) {
  34. var jsonstr=JSON.stringify(json, null, 2);
  35. var divNode = new Element("div", {
  36. styles:{
  37. "margin": "10px",
  38. "color": "#666666"
  39. },
  40. html: "返回数据:"
  41. }).inject( $("contentArea") );
  42. new Element("pre", {html: jsonstr}).inject(divNode);
  43. }
  44. };
  45. var _showError = function(error, json) {
  46. var errorNode = new Element("div", {
  47. styles:{
  48. "margin": "10px",
  49. "color": "#ff0000"
  50. }
  51. }).inject( $("errorArea") );
  52. $("errorArea").setStyle("display", "block");
  53. new Element("p", {"html": "错误,"+error}).inject(errorNode);
  54. };
  55. var _showSuccess = function(info,area) {
  56. new Element("div", {
  57. styles:{
  58. "margin": "10px",
  59. "color": "#5fbf78"
  60. },
  61. text: info
  62. }).inject( $(area) );
  63. };
  64. // 测试连接认证服务器
  65. var _loadAuthApp = function(authApp, webServer) {
  66. if (authApp && authApp.host && authApp.port) {
  67. var protocal = "http://";
  68. if (webServer && webServer.sslEnable == true) {
  69. protocal = "https://";
  70. }
  71. var url =protocal+authApp.host+":"+authApp.port+"/x_organization_assemble_authentication/jaxrs/echo";
  72. o2.xhr_get(url, function(json) {
  73. console.log(json);
  74. if (json && json.response) {
  75. var res = JSON.parse(json.response);
  76. if (res && res.type == "success") {
  77. _showSuccess("连接应用服务器成功!", "appArea");
  78. return;
  79. }
  80. }
  81. _showError("获取应用服务器地址信息失败!");
  82. })
  83. } else {
  84. _showError("获取应用服务器失败!");
  85. }
  86. };
  87. // 测试连接中心服务器
  88. var _loadCenter = function() {
  89. o2.Actions.load("x_program_center").DistributeAction.assembleWithWebServer(hostname, function(json){
  90. // 中心服务器连接成功
  91. _showSuccess("中心服务器连接成功", "centerArea");
  92. if (json && json.type === "success") {
  93. if (json.data && json.data.assembles) {
  94. _loadAuthApp(json.data.assembles.x_organization_assemble_authentication, json.data.webServer);
  95. _showJson(json);
  96. } else {
  97. // 应用服务器获取不到
  98. _showError("获取应用服务器失败!");
  99. _showJson(json);
  100. }
  101. } else {
  102. // 获取地址信息失败
  103. _showError("获取中心服务器地址信息失败!");
  104. _showJson(json);
  105. }
  106. }.bind(this));
  107. };
  108. _loadCenter();
  109. })(layout);
  110. });
  111. </script>
  112. </body>
  113. </html>