login.jsp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
  3. <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
  4. <%@ page language="java" contentType="text/html; charset=UTF-8"
  5. pageEncoding="UTF-8"%>
  6. <jsp:include page="${data._INCLUDE}/header.jsp"></jsp:include>
  7. <script type="text/javascript">
  8. var patientIdx;
  9. var redirectUrl;
  10. $( function(){
  11. $( "#locationList option[value='98']" ).remove();
  12. // $( "#ex_select" ).siblings('label').text( $( "#ex_select" ).children('option:selected').text() );
  13. $.validator.addMethod('selectcheck', function (value) {
  14. console.log( value );
  15. return (value != "0" );
  16. }, "" );
  17. $( "#loginForm" ).validate({
  18. rules : {
  19. id : {
  20. required: true
  21. },
  22. pw : {
  23. required: true
  24. },
  25. centerCode : {
  26. selectcheck : true
  27. }
  28. },
  29. errorPlacement: function( error, element ){
  30. if (element.attr("name") == "locationCode") {
  31. $( "#errMsg" ).text( '<spring:message code="login.required.location" />' );
  32. } else if( element.attr( "name" ) == "centerCode" ) {
  33. $( "#errMsg" ).text( '<spring:message code="login.required.center" />' );
  34. } else if( element.attr( "name" ) == "id" || element.attr( "name" ) == "pw" ) {
  35. if( $( "#id" ).val().length == 0 ) {
  36. var centerType = $("input[name='centerType']:checked").val();
  37. if( centerType == 'C' ) {
  38. $( "#errMsg" ).text( '<spring:message code="login.required.id" />' );
  39. } else if( centerType == 'S' ){
  40. $( "#errMsg" ).text( '<spring:message code="login.required.residence" />' );
  41. }
  42. // $( "#id" ).focus();
  43. return;
  44. } else if( $( "#pw" ).val().length == 0 ){
  45. $( "#errMsg" ).text( '<spring:message code="login.required.jumin" />' );
  46. $( "#pw" ).focus();
  47. }
  48. }
  49. },
  50. submitHandler: function(form) {
  51. getAjax( "./check", $("#loginForm").serialize(), function( data ){
  52. console.log("data -- > " + JSON.stringify(data));
  53. var resultCode = data.code;
  54. var resultMsg = data.message;
  55. redirectUrl = data.redirectUrl;
  56. patientIdx = data.patientIdx;
  57. if( data.code == "00" ) {
  58. localStorage.removeItem( "id" );
  59. localStorage.removeItem( "pw" );
  60. localStorage.removeItem( "cc" );
  61. localStorage.id = data.id;
  62. localStorage.pw = $( "#pw" ).val();
  63. localStorage.cc = data.cc;
  64. if( isMobile() ){
  65. token( "getToken" );
  66. } else {
  67. if (redirectUrl != "") {
  68. location.href = '/mobile/menu?redirectUrl=' + redirectUrl;
  69. } else {
  70. location.href = '/mobile/menu?lang='+setLocale;
  71. }
  72. }
  73. } else {
  74. $("#errMsg").text( resultMsg ).stop().animate({
  75. marginLeft: "5px"
  76. }, 50, function(){
  77. $(this).animate({
  78. marginLeft: "0px"
  79. }, 50);
  80. });
  81. // $( "#startLoading" ).hide();
  82. };
  83. }, null, null );
  84. }
  85. });
  86. if (localStorage.getItem( "id" ) != null) {
  87. autoLogin();
  88. } else {
  89. // $( "#startLoading" ).fadeOut( 500 );
  90. }
  91. $( "#locationList" ).on( "change", function(){
  92. setCenterType( $("input[name='centerType']:checked").val() );
  93. var type = $("input[name='centerType']:checked").val();
  94. if($('#locationList > option:selected').val() != "0") {
  95. // $('#centerDiv').css("display", "block");
  96. $( "#centerList option:not([value='0'])" ).appendTo( "#hideList" );
  97. if ($( "#hideList option[data-center-type='" + type +"'][accessKey='"+$('#locationList').val()+"']" ).length == 0) {
  98. $("#centerLabel").text('<spring:message code="login.required.noCenter" />');
  99. // var option = "<option value='99' selected>등록된 생활치료센터가 없습니다.</option>";
  100. // $('#centerList').append(option);
  101. } else {
  102. $("#centerLabel").text('<spring:message code="login.required.selectCenter" />');
  103. $( "#hideList option[data-center-type='" + type +"'][accessKey='"+$('#locationList').val()+"']" ).appendTo( "#centerList" );
  104. $("#centerList").val("0").prop("selected", true);
  105. }
  106. } else {
  107. $( "#centerList option:not([value='0'])" ).appendTo( "#hideList" );
  108. $( "#hideList option[data-center-type='" + type +"']" ).appendTo( "#centerList" );
  109. $("#centerLabel").text('<spring:message code="login.required.selectCenter" />');
  110. }
  111. });
  112. $("#localeSelectBox").change(function(){
  113. var locale = $(this).val();
  114. location.href="?lang=" + locale;
  115. })
  116. // 생치 : C
  117. // 재택치료 : S
  118. var centerType = $("input[name='centerType']:checked").val();
  119. setCenterType( centerType );
  120. $( "#locationList" ).val("0").prop("selected", true);
  121. $( "input[name='centerType']" ).on( "change", function() {
  122. $("#locationList").val("0").prop("selected", true);
  123. $("#locationList").siblings("label").text( $("#locationList option:checked").text() );
  124. $("#centerList").val("0").prop("selected", true);
  125. $("#centerLabel").text($("#centerList option:checked").text());
  126. setCenterType( $("input[name='centerType']:checked").val() );
  127. });
  128. });
  129. function setCenterType( type ){
  130. $( "#centerList option:not([value='0'])" ).appendTo( "#hideList2" );
  131. console.log( " type :::: " + type );
  132. $( "#hideList option[data-center-type='"+type+"']").appendTo("#centerList");
  133. $( "#hideList2 option[data-center-type='"+type+"']" ).appendTo( "#centerList" );
  134. $("#centerList").val("0").prop("selected", true);
  135. if( type == 'C' ) {
  136. $( "#id" ).attr( "placeholder", '<spring:message code="login.placeholder.id" />' );
  137. } else if( type == 'S' ) {
  138. $( "#id" ).attr( "placeholder", '<spring:message code="login.placeholder.residence" />' );
  139. }
  140. if( $( "#errMsg" ).text() != "" ) {
  141. $( "#loginForm" ).valid();
  142. }
  143. }
  144. function getToken(token, deviceType, macAddress) {
  145. var jsonMsg = {
  146. patientIdx : patientIdx,
  147. deviceType : deviceType,
  148. deviceToken : token,
  149. macAddress : macAddress
  150. };
  151. $.ajax({
  152. url : "/mobile/insertDeviceInfo",
  153. data : JSON.stringify(jsonMsg),
  154. method : "POST",
  155. contentType: 'application/json',
  156. success : function(){
  157. if (redirectUrl != "") {
  158. location.href = '/mobile/menu?redirectUrl=' + redirectUrl;
  159. } else {
  160. location.href = '/mobile/menu?lang='+setLocale;
  161. }
  162. }
  163. });
  164. }
  165. function token(callback) {
  166. var jsonMsg = {
  167. "type":"command",
  168. "functionType":"token",
  169. "value" : {
  170. "callbackFn" : callback
  171. }
  172. }
  173. toNative(jsonMsg);
  174. }
  175. function autoLogin(){
  176. if( localStorage.getItem( "id" ) != null &&
  177. localStorage.getItem( "pw" ) != null &&
  178. localStorage.getItem( "cc" ) != null ) {
  179. $( "#centerList" ).val( localStorage.getItem( "cc" ) );
  180. $( "#id" ).val( localStorage.getItem( "id" ) );
  181. $( "#pw" ).val( localStorage.getItem( "pw" ) );
  182. $( "#submitBtn" ).trigger( "click" );
  183. }
  184. }
  185. </script>
  186. <style>
  187. .locale-box {
  188. position: fixed;
  189. top: 20px;
  190. right: 20px;
  191. z-index:20;
  192. }
  193. .locale-box select {
  194. padding: 2px 5px 2px 0;
  195. border-radius: 3px;
  196. border: 1px solid #d4d4d4;
  197. background: #FFFFFF;
  198. }
  199. .center-type-ul{
  200. font-size:0;
  201. }
  202. .center-type-ul li{
  203. display:inline-block;width:50%;
  204. font-size:0;
  205. text-align: center;
  206. }
  207. .center-type-ul li input[type="radio"] + label {
  208. font-size:17px;
  209. height: 50px;
  210. width: 100%;
  211. display: inline-block;
  212. margin: 0;
  213. padding: 0 5px;
  214. vertical-align: top;
  215. line-height: 50px;
  216. color:#9e9e9e;
  217. }
  218. .center-type-ul li input[type="radio"]:checked + label {
  219. color: #426ddb;
  220. border-bottom:1px solid #426ddb;
  221. transition: 0.5s;
  222. }
  223. </style>
  224. </head>
  225. <body>
  226. <!-- <div id="startLoading" style="position:fixed;top:0;left:0;right:0;bottom:0;background:#FFFFFF;z-index:9999999;"></div> -->
  227. <div id="login">
  228. <div class="locale-box">
  229. <select id="localeSelectBox">
  230. <option value="ko" <c:if test="${data._LOCALE_CODE eq 'ko'}">selected</c:if>>한국어</option>
  231. <option value="en" <c:if test="${data._LOCALE_CODE eq 'en'}">selected</c:if>>English</option><!-- 영어 -->
  232. <option value="vi" <c:if test="${data._LOCALE_CODE eq 'vi'}">selected</c:if>>Tiếng Việt</option><!-- 베트남어 -->
  233. <option value="ru" <c:if test="${data._LOCALE_CODE eq 'ru'}">selected</c:if>>русский</option><!-- 러시아어 -->
  234. <option value="ar" <c:if test="${data._LOCALE_CODE eq 'ar'}">selected</c:if>>عربي</option><!-- 아랍어 -->
  235. <option value="fr" <c:if test="${data._LOCALE_CODE eq 'fr'}">selected</c:if>>français</option><!-- 프랑스어어 -->
  236. <option value="th" <c:if test="${data._LOCALE_CODE eq 'th'}">selected</c:if>>ไทย</option><!-- 태국어 -->
  237. </select>
  238. </div>
  239. <div class="container">
  240. <div class="title">
  241. <spring:message code="login.top.title" />
  242. <br/><span style="font-size:10px !important;">hcms</span>
  243. </div>
  244. <form id="loginForm" action="./check" method="post">
  245. <input type="hidden" name="redirectUrl" value="${redirectUrl}">
  246. <div class="login_box">
  247. <div class="visual">
  248. <img src="/resources/images/mobile/login_visual.png" />
  249. </div>
  250. <div class="form">
  251. <div class="part">
  252. <ul class="center-type-ul">
  253. <li>
  254. <input type="radio" id="centerTypeC" name="centerType" value="C" checked="checked">
  255. <label for="centerTypeC"><span></span><spring:message code="menu.center.title" /></label>
  256. </li>
  257. <li>
  258. <input type="radio" id="centerTypeS" name="centerType" value="S">
  259. <label for="centerTypeS"><span></span><spring:message code="login.location.list.재택치료" /></label>
  260. </li>
  261. </ul>
  262. </div>
  263. <div class="part">
  264. <div class="selectbox">
  265. <label for="locationList"><spring:message code="login.select.all" /></label>
  266. <select id="locationList" name="locationCode">
  267. <option value="0" selected><spring:message code="login.select.all" /></option>
  268. <c:forEach var="i" items="${locationList}">
  269. <c:if test="${i.locationCode ne '99'}">
  270. <option value="${i.locationCode}"> ·
  271. <spring:message code="login.location.list.${i.locationName}" />
  272. </option>
  273. </c:if>
  274. </c:forEach>
  275. </select>
  276. </div>
  277. </div>
  278. <div class="part" id="centerDiv">
  279. <div class="selectbox">
  280. <label for="centerList" id="centerLabel"><spring:message code="login.select.center" /></label>
  281. <select id="centerList" name="centerCode">
  282. <option value="0" selected><spring:message code="login.select.center" /></option>
  283. <c:forEach var="i" items="${centerList}">
  284. <c:if test="${i.centerCode ne '0'}">
  285. <option value="${i.centerCode}"
  286. accessKey="${i.locationCode}"
  287. data-center-type="<c:out value="${i.centerType}"/>"
  288. > · <c:out value="${i.centerName}" /></option>
  289. </c:if>
  290. </c:forEach>
  291. </select>
  292. <select id="hideList" style="display:none;"></select>
  293. <select id="hideList2" style="display:none;"></select>
  294. </div>
  295. </div>
  296. <!-- 크롬 autocomplete 방지 -->
  297. <input type="text" name="userId" style="opacity:0;position:absolute;width:0;height:0;">
  298. <input type="password" name="userPassword" style="opacity:0;position:absolute;width:0;height:0;">
  299. <!-- --------------------- -->
  300. <div class="part">
  301. <div class="input">
  302. <input type="text" id="id" name="id" class="login-id" placeholder='<spring:message code="login.placeholder.id" />' tabindex="1" maxlength="20" autocomplete="off" required>
  303. </div>
  304. </div>
  305. <div class="part">
  306. <div class="input">
  307. <input type="password" id="pw" name="pw" class="login-pw" placeholder='<spring:message code="login.placeholder.pw" />' autocomplete="off" tabindex="2" autocomplete="new-password" maxlength="15" required>
  308. </div>
  309. </div>
  310. <div class="part">
  311. <div class="alert" id="errMsg"></div>
  312. </div>
  313. <div class="part">
  314. <div class="button">
  315. <!-- <button id="submitBtn">로그인</button> -->
  316. <button id="submitBtn" type="submit" class="btn btn-lg btn-primary"><spring:message code="login.btn.login" /></button>
  317. </div>
  318. </div>
  319. </div>
  320. </div>
  321. </form>
  322. </div>
  323. </div>
  324. </body>
  325. </html>