login.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport"
  6. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no viewport-fit=cover" />
  7. <meta name="apple-mobile-web-app-capable" content="yes" />
  8. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  9. <title>登录页面</title>
  10. <link href="css/mui.min.css" rel="stylesheet" />
  11. <link href="css/app.css" rel="stylesheet">
  12. <script src="js/mui.min.js"></script>
  13. <style>
  14. /* 全局样式 */
  15. * {
  16. margin: 0px;
  17. padding: 0px;
  18. }
  19. body,
  20. html {
  21. width: 100%;
  22. height: calc(100vh);
  23. }
  24. /* 顶部视图容器样式 */
  25. .wc-ico-panel {
  26. width: 100%;
  27. height: 170px;
  28. line-height: 170px;
  29. text-align: center;
  30. margin-top: 10px;
  31. margin-bottom: 10px;
  32. }
  33. /* 顶部视图图标样式 */
  34. .wc-ico {
  35. width: 100px;
  36. height: 100px;
  37. }
  38. /* 顶部视图标题文字样式 */
  39. .wc-title {
  40. font-size: 26px;
  41. height: 40px;
  42. line-height: 40px;
  43. font-weight: bold;
  44. color: rgb(59, 146, 255);
  45. }
  46. /* 顶部视图APP版本样式 */
  47. .wc-version {
  48. position: relative;
  49. font-size: 15px;
  50. height: 30px;
  51. line-height: 30px;
  52. font-weight: normal;
  53. color: rgb(59, 146, 255);
  54. }
  55. /* 底部容器样式 */
  56. .wc-div-bottom {
  57. position: absolute;
  58. width: 100%;
  59. bottom: 10px;
  60. text-align: center;
  61. }
  62. /* 底部容器内段落样式 */
  63. .wc-div-bottom p {
  64. font-size: 12px;
  65. color: #000;
  66. margin: 0px;
  67. padding: 0px;
  68. }
  69. /* 底部连接样式 */
  70. .link-area {
  71. display: block;
  72. margin-top: 25px;
  73. text-align: center;
  74. font-size: 15px;
  75. }
  76. /* 输入行样式 */
  77. .wc-input-row {
  78. position: relative;
  79. height: 40px;
  80. line-height: 40px;
  81. border: solid 1px rgb(121, 183, 246);
  82. border-radius: 20px;
  83. margin-left: 15%;
  84. margin-right: 15%;
  85. display: flex;
  86. flex-direction: row;
  87. align-items: center;
  88. margin-bottom: 10px;
  89. }
  90. .wc-input-row-none {
  91. border: solid 0px rgb(121, 183, 246);
  92. }
  93. /* 输入行小图标样式 */
  94. .wc-input-img {
  95. width: 24px;
  96. height: 24px;
  97. margin-left: 20px;
  98. margin-right: 10px;
  99. }
  100. /* 输入行竖向分隔线样式 */
  101. .wc-input-v-line {
  102. width: 1px;
  103. height: 80%;
  104. background-color: rgb(145, 195, 249);
  105. }
  106. /* 输入行输入行样式 */
  107. .wc-input-row .mui-input-row {
  108. width: 90% !important;
  109. }
  110. /* 输入行输入控件样式 */
  111. .wc-input-row .mui-input-row>input {
  112. margin-bottom: 0px !important;
  113. height: 34px !important;
  114. border: solid 0px red !important;
  115. background-color: rgba(255, 255, 255, 0) !important;
  116. }
  117. /* 标签样式 */
  118. .wc-input-label {
  119. margin-left: 20px;
  120. font-size: 14px;
  121. }
  122. /* 开关样式 */
  123. .wc-input-switch {
  124. margin-left: auto;
  125. margin-right: 20px;
  126. }
  127. /* 按钮样式 */
  128. .wc-login-btn {
  129. border-radius: 25px;
  130. height: 50px;
  131. display: flex;
  132. flex-direction: row;
  133. align-items: center;
  134. justify-content: center;
  135. border: solid 1px rgba(255, 255, 255, 0);
  136. }
  137. /* 整体内容样式 */
  138. .wc-content {
  139. position: absolute;
  140. width: 100%;
  141. top: 30%;
  142. }
  143. </style>
  144. </head>
  145. <body style="background-image: url(img/login/back_login.jpg);background-size: 100% 100%;">
  146. <div class="wc-content">
  147. <!-- 顶部图标及应用名称 -->
  148. <div class="mui-row">
  149. <div class="wc-ico-panel">
  150. <div style="height: 100px;line-height: 100px;">
  151. <img src="img/login/login_log.png" class="wc-ico" />
  152. </div>
  153. <div class="wc-title">兰山区综合执法</div>
  154. <div class="wc-version">APP版本{V3.0.0}</div>
  155. </div>
  156. </div>
  157. <!-- 账号输入框 -->
  158. <div class="mui-row wc-input-row">
  159. <img class="wc-input-img" src="img/login/ico_login_user.png">
  160. <div class="wc-input-v-line"></div>
  161. <div class="mui-input-row">
  162. <input id="userName" type="text" class="mui-input-clear mui-input f-color" placeholder="请输入账号">
  163. </div>
  164. </div>
  165. <!-- 密码输入框 -->
  166. <div class="mui-row wc-input-row">
  167. <img class="wc-input-img" src="img/login/ico_login_passwrod.png">
  168. <div class="wc-input-v-line"></div>
  169. <div class="mui-input-row">
  170. <input id="passWord" type="password" class="mui-input mui-input-password f-color"
  171. placeholder="请输入密码">
  172. </div>
  173. </div>
  174. <!-- 记住用户名和密码 -->
  175. <div class="mui-row wc-input-row wc-input-row-none">
  176. <span class="wc-input-label f-color">记住用户名和密码</span>
  177. <div id="autoLogin" class="mui-switch mui-active mui-switch-blue mui-switch-mini wc-input-switch">
  178. <div class="mui-switch-handle"></div>
  179. </div>
  180. </div>
  181. <!-- 登录按钮 -->
  182. <div class="mui-content-padded" style="margin-top: 50px;margin-left: 15%;margin-right: 15%;">
  183. <button type="button" class="mui-btn mui-btn-block mui-btn-primary wc-login-btn"
  184. onclick="loginCheck()">登录</button>
  185. <div class="link-area">
  186. <a href="#" onclick="setting()">服务设置</a>
  187. </div>
  188. </div>
  189. </div>
  190. <div id="divButtom" class="wc-div-bottom">
  191. <p>版权所有:临沂市兰山区自然资源与规划局</p>
  192. <p>技术支持:金田产业发展(山东)集团有限公司 @2021</p>
  193. </div>
  194. </body>
  195. </html>
  196. <!-- 引入存储脚本 -->
  197. <script type="text/javascript" src="js/save.js"></script>
  198. <!-- 引入远程请求脚本 -->
  199. <script type="text/javascript" src="js/ajax.js"></script>
  200. <!-- 通用脚本 -->
  201. <script src="js/common.js" type="text/javascript" charset="utf-8"></script>
  202. <!-- 引入webview脚本 -->
  203. <script src="js/webview.js" type="text/javascript" charset="utf-8"></script>
  204. <!-- 引入数据库管理脚本 -->
  205. <script src="js/DatabaseManager.js" type="text/javascript" charset="utf-8"></script>
  206. <!-- 本页独有脚本 -->
  207. <script type="text/javascript">
  208. /* 变量定义及绑定 */
  209. var dUserName = document.getElementById('userName');
  210. var dPassWord = document.getElementById('passWord');
  211. var divButtom = document.getElementById("divButtom");
  212. var dAutoLoginSwitch = document.getElementById("autoLogin");
  213. var height = window.innerHeight; //初始的窗口高度
  214. mui.init(); /* 初始化*/
  215. /**
  216. * plus初始化完成
  217. */
  218. plusInit(function() {
  219. /* 设置状态栏背景色 注意不能设置为沉浸式 否则无效 */
  220. plus.navigator.setStatusBarBackground(colorBackground);
  221. /* 设置全屏 */
  222. plus.navigator.setFullscreen(true);
  223. /* 窗口变化监听 */
  224. window.onresize = function(e) {
  225. var curHeight = window.innerHeight;
  226. if (curHeight < height) {
  227. divButtom.style.display = 'none';
  228. } else {
  229. divButtom.style.display = 'block';
  230. }
  231. }
  232. /* 获取存储的用户名和密码 填充*/
  233. getUserNameAndPassword({
  234. success: function(userData) {
  235. dUserName.value = userData.username;
  236. dPassWord.value = userData.password;
  237. },
  238. });
  239. /* 检测数据库文件 */
  240. DB_CheckDatabase({
  241. success:function(msg){
  242. printToConsole(msg);
  243. },
  244. error:function(err){
  245. printToConsole(err);
  246. }
  247. });
  248. });
  249. /* iOS平台单独初始化 */
  250. plusInitiOS(function() {
  251. });
  252. /* Android平台单独初始化 */
  253. plusInitAndroid(function() {
  254. })
  255. /* 打开设置页面 */
  256. function setting() {
  257. // mui.openWindow('setIpAndCom.html');
  258. createAndOpenPage({
  259. htmlPath: 'setIpAndCom.html',
  260. autoback: true,
  261. title: '设置Ip和端口'
  262. });
  263. }
  264. /**
  265. * 登录信息检查验证
  266. */
  267. function loginCheck() {
  268. var strUserName = dUserName.value.trim();
  269. var strPassWord = dPassWord.value.trim();
  270. if (strUserName == "") {
  271. muiAlert("请输入用户名!", "提示", function() {
  272. dUserName.focus();
  273. });
  274. } else if (strPassWord == "") {
  275. muiAlert("请输入密码!", "提示", function() {
  276. dPassWord.focus();
  277. });
  278. } else {
  279. var userData = {
  280. userId: strUserName,
  281. userPwd: strPassWord
  282. };
  283. /* 登录请求 */
  284. login(userData);
  285. }
  286. }
  287. /**
  288. * 登录请求
  289. * @param {JSON} userData 账号数据
  290. */
  291. function login(userData) {
  292. /**
  293. * 远程请求
  294. */
  295. sendAjax({
  296. data: userData,
  297. type: 'post',
  298. url: 'appQueryUser',
  299. waitMessage: '正在认证登录...',
  300. success: function(resData) {
  301. /* 如果认证成功 则保存用户信息 */
  302. saveUserInfo({
  303. user: resData[0],
  304. success: function() {
  305. /* 判断是否需要保存账号和密码 */
  306. var isSave = dAutoLoginSwitch.classList.contains("mui-active");
  307. if (isSave) {
  308. saveUserNameAndPassword({
  309. username: userData.userId,
  310. password: userData.userPwd,
  311. success: function() {
  312. getLayers(resData[0].userID);
  313. },
  314. error: function(err) {
  315. muiAlert(err, "错误");
  316. }
  317. })
  318. } else {
  319. removeUserNameAndPassword({
  320. success: function() {
  321. getLayers(resData[0].userID);
  322. },
  323. error: function(err) {
  324. muiAlert(err, "错误");
  325. }
  326. })
  327. }
  328. },
  329. error: function(err) {
  330. muiAlert(err, "错误");
  331. }
  332. })
  333. },
  334. nodata: function(msg) {
  335. muiAlert(msg, "警告");
  336. },
  337. error: function(err) {
  338. muiAlert(err, "错误");
  339. }
  340. })
  341. }
  342. /**
  343. * 获取图层列表
  344. * @param {String} userId 账号Id
  345. */
  346. function getLayers(userId) {
  347. /**
  348. * 远程请求
  349. */
  350. sendAjax({
  351. data: {
  352. userId: userId
  353. },
  354. type: 'post',
  355. url: 'appQueryLayers',
  356. waitMessage: '初始化地图图层...',
  357. success: function(resData) {
  358. saveUserLayers({
  359. layers: resData,
  360. success: function() {
  361. mui.openWindow({
  362. url: 'main.html',
  363. show: {
  364. autoShow: true, //页面loaded事件发生后自动显示,默认为true
  365. aniShow: 'slide-in-right', //页面显示动画,默认为”slide-in-right“;
  366. duration: 300 //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒;
  367. },
  368. styles: {
  369. "contentAdjust": false
  370. },
  371. });
  372. },
  373. error: function(err) {
  374. muiAlert(err, "错误");
  375. }
  376. })
  377. },
  378. nodata: function(msg) {
  379. muiAlert(msg, "警告");
  380. },
  381. error: function(err) {
  382. muiAlert(err, "错误");
  383. }
  384. })
  385. }
  386. </script>