login.jsp 16 KB

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