login.jsp 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  2. <%@ page language="java" contentType="text/html; charset=UTF-8"
  3. pageEncoding="UTF-8"%>
  4. <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
  5. <jsp:include page="${data._INCLUDE}/header.jsp"></jsp:include>
  6. <script type="text/javascript">
  7. var patientIdx;
  8. var redirectUrl;
  9. $( function(){
  10. $( "#ex_select" ).siblings('label').text( $( "#ex_select" ).children('option:selected').text() );
  11. $.validator.addMethod('selectcheck', function (value) {
  12. console.log( value );
  13. return (value != "0" );
  14. }, "" );
  15. $( "#loginForm" ).validate({
  16. rules : {
  17. id : {
  18. required: true
  19. },
  20. pw : {
  21. required: true
  22. },
  23. centerCode : {
  24. selectcheck : true
  25. }
  26. },
  27. errorPlacement: function( error, element ){
  28. if (element.attr("name") == "locationCode") {
  29. $( "#errMsg" ).text( "지역을 선택해주세요" );
  30. } else if( element.attr( "name" ) == "centerCode" ) {
  31. $( "#errMsg" ).text( "생활센터를 선택해주세요" );
  32. } else if( element.attr( "name" ) == "id" || element.attr( "name" ) == "pw" ) {
  33. if( $( "#id" ).val().length == 0 ) {
  34. $( "#errMsg" ).text( "동호실번호 입력해주세요(동+호실)" );
  35. $( "#id" ).focus();
  36. } else if( $( "#pw" ).val().length == 0 ){
  37. $( "#errMsg" ).text( "생년월일 8자리를 입력해주세요." );
  38. $( "#pw" ).focus();
  39. }
  40. }
  41. },
  42. submitHandler: function(form) {
  43. getAjax( "./check", $("#loginForm").serialize(), function( data ){
  44. console.log("data -- > " + JSON.stringify(data));
  45. var resultCode = data.code;
  46. var resultMsg = data.message;
  47. redirectUrl = data.redirectUrl;
  48. patientIdx = data.patientIdx;
  49. if( data.code == "00" ) {
  50. localStorage.removeItem( "id" );
  51. localStorage.removeItem( "pw" );
  52. localStorage.removeItem( "cc" );
  53. localStorage.id = data.id;
  54. localStorage.pw = $( "#pw" ).val();
  55. localStorage.cc = data.cc;
  56. if( isMobile() ){
  57. token( "getToken" );
  58. } else {
  59. if (redirectUrl != "") {
  60. location.href = '/mobile/menu?redirectUrl=' + redirectUrl;
  61. } else {
  62. location.href = '/mobile/menu';
  63. }
  64. }
  65. } else {
  66. $("#errMsg").text( resultMsg ).stop().animate({
  67. marginLeft: "5px"
  68. }, 50, function(){
  69. $(this).animate({
  70. marginLeft: "0px"
  71. }, 50);
  72. });
  73. };
  74. }, null, null );
  75. }
  76. });
  77. if (localStorage.getItem( "id" ) != null) {
  78. autoLogin();
  79. }
  80. $( "#locationList" ).on( "change", function(){
  81. if($('#locationList > option:selected').val() != "0") {
  82. console.log($('#locationList').val());
  83. // $('#centerDiv').css("display", "block");
  84. $( "#centerList option:not([value='0'])" ).appendTo( "#hideList" );
  85. if ($( "#hideList option[accessKey='"+$('#locationList').val()+"']" ).length == 0) {
  86. $("#centerLabel").text("등록된 생활치료센터가 없습니다.");
  87. // var option = "<option value='99' selected>등록된 생활치료센터가 없습니다.</option>";
  88. // $('#centerList').append(option);
  89. } else {
  90. $("#centerLabel").text("치료센터 선택");
  91. $( "#hideList option[accessKey='"+$('#locationList').val()+"']" ).appendTo( "#centerList" );
  92. $("#centerList").val("0").prop("selected", true);
  93. }
  94. } else {
  95. $( "#centerList option:not([value='0'])" ).appendTo( "#hideList" );
  96. $( "#hideList option" ).appendTo( "#centerList" );
  97. $("#centerLabel").text("치료센터 선택");
  98. }
  99. });
  100. });
  101. function getToken(token, deviceType, macAddress) {
  102. var jsonMsg = {
  103. patientIdx : patientIdx,
  104. deviceType : deviceType,
  105. deviceToken : token,
  106. macAddress : macAddress
  107. };
  108. $.ajax({
  109. url : "/mobile/insertDeviceInfo",
  110. data : JSON.stringify(jsonMsg),
  111. method : "POST",
  112. contentType: 'application/json',
  113. success : function(){
  114. if (redirectUrl != "") {
  115. location.href = '/mobile/menu?redirectUrl=' + redirectUrl;
  116. } else {
  117. location.href = '/mobile/menu';
  118. }
  119. }
  120. });
  121. }
  122. function token(callback) {
  123. var jsonMsg = {
  124. "type":"command",
  125. "functionType":"token",
  126. "value" : {
  127. "callbackFn" : callback
  128. }
  129. }
  130. toNative(jsonMsg);
  131. }
  132. function autoLogin(){
  133. if( localStorage.getItem( "id" ) != null &&
  134. localStorage.getItem( "pw" ) != null &&
  135. localStorage.getItem( "cc" ) != null ) {
  136. $( "#centerList" ).val( localStorage.getItem( "cc" ) );
  137. $( "#id" ).val( localStorage.getItem( "id" ) );
  138. $( "#pw" ).val( localStorage.getItem( "pw" ) );
  139. $( "#submitBtn" ).trigger( "click" );
  140. }
  141. }
  142. </script>
  143. </head>
  144. <body>
  145. <div id="login">
  146. <div class="container">
  147. <div class="title">생활치료센터<br/>비대면진료 서비스<br/><span style="font-size:10px !important;">hcms</span></div>
  148. <form id="loginForm" action="./check" method="post">
  149. <input type="hidden" name="redirectUrl" value="${redirectUrl}">
  150. <div class="login_box">
  151. <div class="visual">
  152. <img src="/resources/images/mobile/login_visual.png" />
  153. </div>
  154. <div class="form">
  155. <div class="part">
  156. <div class="selectbox">
  157. <label for="locationList">전체</label>
  158. <select id="locationList" name="locationCode">
  159. <option value="0" selected>전체</option>
  160. <c:forEach var="i" items="${locationList}">
  161. <option value="${i.locationCode}"> · <c:out value="${i.locationName}" /></option>
  162. </c:forEach>
  163. </select>
  164. </div>
  165. </div>
  166. <div class="part" id="centerDiv">
  167. <div class="selectbox">
  168. <label for="centerList" id="centerLabel">치료센터 선택</label>
  169. <select id="centerList" name="centerCode">
  170. <option value="0" selected>치료센터 선택</option>
  171. <c:forEach var="i" items="${centerList}">
  172. <option value="${i.centerCode}" accessKey="${i.locationCode}"> · <c:out value="${i.centerName}" /></option>
  173. </c:forEach>
  174. </select>
  175. <select id="hideList" style="display:none;"></select>
  176. </div>
  177. </div>
  178. <div class="part">
  179. <div class="input">
  180. <input type="text" id="id" name="id" class="login-id" placeholder="동호실번호" tabindex="1" maxlength="20" autocomplete="off" required>
  181. </div>
  182. </div>
  183. <div class="part">
  184. <div class="input">
  185. <input type="password" id="pw" name="pw" class="login-pw" placeholder="생년월일 8자리 (YYYYMMDD)" autocomplete="off" tabindex="2" autocomplete="off" maxlength="15" required>
  186. </div>
  187. </div>
  188. <div class="part">
  189. <div class="alert" id="errMsg"></div>
  190. </div>
  191. <div class="part">
  192. <div class="button">
  193. <!-- <button id="submitBtn">로그인</button> -->
  194. <button id="submitBtn" type="submit" class="btn btn-lg btn-primary">로그인</button>
  195. </div>
  196. </div>
  197. </div>
  198. </div>
  199. </form>
  200. </div>
  201. </div>
  202. </body>
  203. </html>