setIpAndCom.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>设置服务器的IP地址和端口号</title>
  6. <meta name="viewport"
  7. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  8. <!-- 引入mui样式 -->
  9. <link href="css/mui.min.css" rel="stylesheet" />
  10. <!-- 引入app样式 -->
  11. <link href="css/app.css" rel="stylesheet" />
  12. <!-- 引入App增样式 -->
  13. <link rel="stylesheet" href="css/app.new.css">
  14. <!-- 引入字体 -->
  15. <link rel="stylesheet" href="fonts/font-jt.css">
  16. <style type="text/css">
  17. body {
  18. background-image: url(./img/back/sys_set.png);
  19. height: 100%;
  20. background-size: 100% 100%;
  21. }
  22. /* 提示标签样式 */
  23. .mui-content p {
  24. font-size: 14px;
  25. font-weight: bold;
  26. margin: 20px;
  27. color: rgb(203, 203, 203);
  28. }
  29. /* 追加行样式 */
  30. .mui-content-padded {
  31. height: 120px;
  32. display: flex;
  33. align-items: center;
  34. justify-content: center;
  35. }
  36. /* 追加航按钮样式 */
  37. .mui-content-padded>button {
  38. width: 200px;
  39. height: 44px;
  40. }
  41. /* 设置行样式 */
  42. .cr-set-row {
  43. height: 40px;
  44. line-height: 40px;
  45. display: flex;
  46. flex-direction: row;
  47. margin-left: 20px;
  48. margin-right: 20px;
  49. margin-top: 20px;
  50. color: rgb(203, 203, 203);
  51. align-items: center;
  52. }
  53. /* 设置行所有子元素文字大小 */
  54. .cr-set-row * {
  55. font-size: 13px;
  56. }
  57. /* 设置行标题 */
  58. .cr-set-row>div {
  59. width: 100px;
  60. background-color: rgb(57, 85, 187);
  61. font-size: 13px !important;
  62. text-align: center;
  63. border-left: solid 1px rgb(96, 126, 226);
  64. border-bottom: solid 1px rgb(96, 126, 226);
  65. border-top: solid 1px rgb(96, 126, 226);
  66. height: 100%;
  67. }
  68. /* 设置行输入框 */
  69. .cr-set-row input {
  70. height: 32px;
  71. line-height: 32px;
  72. margin: 0px;
  73. background-color: rgba(255, 255, 255, 0);
  74. border: solid 1px rgb(96, 126, 226);
  75. font-size: 14px !important;
  76. border-radius: 0px;
  77. height: 100%;
  78. }
  79. /* 修正内容样式 */
  80. .mui-content {
  81. background-color: rgba(255, 255, 255, 0);
  82. }
  83. /* 按钮样式 */
  84. .mui-content-padded .mui-btn {
  85. margin-right: 5px;
  86. width: 140px !important;
  87. }
  88. </style>
  89. </head>
  90. <body>
  91. <div class="mui-content">
  92. <div class="cr-set-content">
  93. <div class="mui-input-row cr-set-row">
  94. <div><span class="app-icon app-icon-ip"><span>服务地址</span></div>
  95. <input id="ip" type="text" class="mui-input-clear mui-input f-color jt-font-number"
  96. placeholder="请输入IP地址">
  97. </div>
  98. <div class="mui-input-row cr-set-row">
  99. <div><span class="app-icon app-icon-com"><span>服务端口</span></div>
  100. <input id="com" type="text" class="mui-input-clear mui-input f-color jt-font-number"
  101. placeholder="请输入端口号">
  102. </div>
  103. </div>
  104. <p>如无特殊情况,请勿修改IP地址和端口,否则将导致APP无法使用。</p>
  105. <div class="mui-content-padded">
  106. <button type="button" class="mui-btn mui-btn-primary" onclick="saveIpAndCom()">设置</button>
  107. <!-- <button type="button" class="mui-btn mui-btn-royal" onclick="selectIpAndCom()">选择</button> -->
  108. </div>
  109. </div>
  110. </body>
  111. </html>
  112. <!-- 引入mui脚本 -->
  113. <script src="js/mui.js"></script>
  114. <!-- 引入存储脚本 -->
  115. <script src="js/save.js"></script>
  116. <!-- 引入通用脚本 -->
  117. <script src="js/common.js"></script>
  118. <!-- 引入webview脚本 -->
  119. <script src="js/webview.js" type="text/javascript" charset="utf-8"></script>
  120. <!-- 本页通用脚本 -->
  121. <script type="text/javascript">
  122. mui.init();
  123. var cIP = document.getElementById("ip");
  124. var cCOM = document.getElementById("com");
  125. /* 等待MUI Plus 加载完成 */
  126. mui.plusReady(function() {
  127. plus.navigator.setFullscreen(false);
  128. });
  129. /**
  130. * 页面初次显示
  131. */
  132. function pageShow() {
  133. //获取存储的IP地址及COM端口
  134. getIpAndCom(function(ip, com) {
  135. cIP.value = ip;
  136. cCOM.value = com;
  137. });
  138. }
  139. /**
  140. * 保存设置的Ip地址和端口号
  141. */
  142. function saveIpAndCom() {
  143. var sIP = cIP.value.trim();
  144. var sCOM = cCOM.value.trim();
  145. if (!isValidIP(sIP)) {
  146. muiAlert("输入的Ip地址不符合要求,格式为abb.abb.abb.abb,其a代表0~2,b代表0~5", "提示");
  147. } else if (!isValidCom(sCOM)) {
  148. muiAlert("输入的com端口号不符合要求,格式为4位数字!", "提示");
  149. } else {
  150. setIpAndCom({
  151. ip: sIP,
  152. com: sCOM,
  153. success: function() {
  154. muiAlert("IP和端口号设置成功!", "提示", function() {
  155. /* 此处不能使用mui.back() 否则由于使用了div样式 会导致卡死 */
  156. plus.webview.currentWebview().close();
  157. });
  158. },
  159. error: function(err) {
  160. muiAlertError(err);
  161. }
  162. })
  163. }
  164. }
  165. </script>