DelvAddrAddPopWeb.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <form class="form_wrap form_full" name="deliveryAddForm" id="deliveryAddForm">
  2. <div class="modal-header">
  3. <h5 class="modal-title" id="adrsAddLabel">배송지 등록</h5>
  4. </div>
  5. <div class="modal-body">
  6. <div class="pop_cont">
  7. <div class="area_adrsinfo">
  8. <h6>배송지 정보</h6>
  9. <th:block th:if="${isLogin} == true">
  10. <div class="default_addrs">
  11. <div class="form_field">
  12. <input id="chk-default-addrs" type="checkbox" name="defaultYn" checked="">
  13. <label for="chk-default-addrs"><span>기본 배송지로 등록</span></label>
  14. </div>
  15. </div>
  16. </th:block>
  17. <div class="form_field">
  18. <label class="input_label sr-only">받는 분</label>
  19. <div class="ui_col_12">
  20. <div class="input_wrap">
  21. <input type="text" class="form_control" name="recipNm" maxlength="10" placeholder="받는 분">
  22. </div>
  23. </div>
  24. </div>
  25. <div class="form_field">
  26. <label class="input_label sr-only">휴대폰 번호</label>
  27. <div class="ui_col_12">
  28. <div class="input_wrap">
  29. <input type="text" name="recipPhnno" placeholder="휴대폰 번호" class="form_control" minlength="12" maxlength="13"/>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="form_field">
  34. <label class="input_label sr-only">배송주소</label>
  35. <div class="ui_col_12">
  36. <div class="input_wrap">
  37. <input type="hidden" class="form_control" name="recipZipcode" placeholder="우편번호" readonly="readonly">
  38. <input type="hidden" class="form_control" name="recipBaseAddr" placeholder="기본주소" readonly="readonly">
  39. <input type="text" class="form_control" name="recipAddr" placeholder="배송주소" readonly="readonly">
  40. </div>
  41. <button type="button" class="btn btn_dark btn_sm" onclick="fnOpenDaumAddr();"><span>우편번호 찾기</span></button>
  42. </div>
  43. </div>
  44. <div class="form_field">
  45. <label class="input_label sr-only">상세주소</label>
  46. <div class="ui_col_12">
  47. <div class="input_wrap">
  48. <input type="text" class="form_control" name="recipDtlAddr" maxlength="50" placeholder="상세주소">
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="area_request">
  54. <h6>배송요청 사항</h6>
  55. <div class="form_field">
  56. <div>
  57. <input type="radio" name="rdi-request1" id="rdi-request11" value="문 앞" >
  58. <label for="rdi-request11"><span>문 앞</span></label>
  59. </div>
  60. <div>
  61. <input type="radio" name="rdi-request1" id="rdi-request12" value="직접 받고 부재 시 문 앞" checked>
  62. <label for="rdi-request12"><span>직접 받고 부재 시 문 앞</span></label>
  63. </div>
  64. <div>
  65. <input type="radio" name="rdi-request1" id="rdi-request13" value="경비실">
  66. <label for="rdi-request13"><span>경비실</span></label>
  67. </div>
  68. <div>
  69. <input type="radio" name="rdi-request1" id="rdi-request14" value="택배함">
  70. <label for="rdi-request14"><span>택배함</span></label>
  71. </div>
  72. <div>
  73. <input type="radio" name="rdi-request1" id="rdi-request15" value="기타사항">
  74. <label for="rdi-request15"><span>기타사항</span></label>
  75. <div class="info_box">
  76. <div class="input_wrap">
  77. <input type="text" name="delvMemoText" class="form_control" maxlength="30" placeholder="보관장소만 입력 (필수)" disabled>
  78. <p>보관 장소 외 다른 내용 입력시 통보없이 삭제 될 수 있습니다.</p>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. <div class="modal-footer">
  87. <button type="button" class="btn btn_dark" id="btn_delivery_addr_save"><span>배송지 등록</span></button>
  88. </div>
  89. </form>
  90. <script th:inline="javascript">
  91. var isLogin = [[${isLogin}]]; // 로그인여부
  92. //컨텐츠 호출
  93. $(document).ready( function() {
  94. // 배송요청사항 버튼기능
  95. $("#deliveryAddForm input[name=rdi-request1]").each(function(){
  96. // 기타기능 버튼기능
  97. $(this).on("click", function(){
  98. var temp = $(this).parent().find('span').text();
  99. $("#deliveryAddForm input[name=delvMemoText]").val("");
  100. if (temp == "기타사항") {
  101. $("#deliveryAddForm input[name=delvMemoText]").attr("disabled", false);
  102. } else {
  103. $("#deliveryAddForm input[name=delvMemoText]").attr("disabled", true);
  104. }
  105. });
  106. });
  107. $(document).on('click','#adrsAddPop .close-modal',function(e){
  108. $('#adrsAddPop .modal-dialog .modal-content').html('');
  109. });
  110. });
  111. // 배송지등록버튼
  112. $("#btn_delivery_addr_save").on("click", function(){
  113. // 유효성체크
  114. if (!deliveryAddFormCheck()){
  115. return false;
  116. }
  117. // 기본배송지여부
  118. var defaultYn = "N";
  119. if ($("#deliveryAddForm input[name=defaultYn]").is(":checked")) {
  120. defaultYn = "Y";
  121. }
  122. // 기타사항일때 텍스트 등록
  123. var delvMemo = $("#deliveryAddForm input[name=rdi-request1]:checked").parent().find('span').text();
  124. if ("기타사항" == delvMemo) {
  125. delvMemo = $("#deliveryAddForm input[name=delvMemoText]").val();
  126. }
  127. // 2021.04.29 추가
  128. if (gagajf.isNull(delvMemo)) {
  129. mcxDialog.alert("기타사항을 입력해주세요.");
  130. $("#deliveryAddForm input[name=delvMemoText]").focus();
  131. return false;
  132. }
  133. // custDelvAddrSq 부모창으로 전달
  134. var delvObj = {
  135. "custDelvAddrSq" : 0
  136. , "dispYn" : "Y"
  137. , "defaultYn" : defaultYn
  138. , "recipNm" : $("#deliveryAddForm input[name=recipNm]").val()
  139. , "recipPhnno" : $("#deliveryAddForm input[name=recipPhnno]").val()
  140. , "recipZipcode" : $("#deliveryAddForm input[name=recipZipcode]").val()
  141. , "recipBaseAddr" : $("#deliveryAddForm input[name=recipBaseAddr]").val()
  142. , "recipDtlAddr" : $("#deliveryAddForm input[name=recipDtlAddr]").val()
  143. , "delvMemo" : delvMemo
  144. }
  145. // 비회원
  146. if (isLogin == false) {
  147. // 부모장으로 값 전닫
  148. delvAddrSet(delvObj);
  149. // 팝업닫기
  150. $(".close-modal").trigger("click");
  151. return false;
  152. }
  153. var jsonData = JSON.stringify(delvObj);
  154. $.ajax( {
  155. type : "POST",
  156. url : '/common/createCustDeliveryAddr',
  157. data : jsonData,
  158. dataType : 'html',
  159. beforeSend : function(xhr, settings) {
  160. xhr.setRequestHeader("AJAX" , "true");
  161. xhr.setRequestHeader('Accept' , 'application/json');
  162. xhr.setRequestHeader('Content-Type' , 'application/json');
  163. },
  164. success : function(result) {
  165. if (result != null) {
  166. delvObj.custDelvAddrSq = result;
  167. // 부모장으로 값 전닫
  168. delvAddrSet(delvObj);
  169. }
  170. // 팝업닫기
  171. $(".close-modal").trigger("click");
  172. }
  173. });
  174. });
  175. // 유효성체크 함수
  176. var deliveryAddFormCheck = function() {
  177. // TODO 유효성 체크 추가
  178. if (gagajf.isNull($("#deliveryAddForm input[name=recipNm]").val())) {
  179. mcxDialog.alert("받는분을 입력해주세요.");
  180. $('#deliveryAddForm input[name=custNm]').focus();
  181. return false;
  182. }
  183. if (gagajf.isNull($("#deliveryAddForm input[name=recipPhnno]").val())) {
  184. mcxDialog.alert("휴대폰번호를 입력해주세요.");
  185. $('#deliveryAddForm input[name=recipPhnno]').focus();
  186. return false;
  187. }
  188. if ($("#deliveryAddForm input[name=recipPhnno]").val().length < 12) {
  189. mcxDialog.alert("휴대폰번호를 정확히 입력해주세요.");
  190. $('#deliveryAddForm input[name=recipPhnno]').focus();
  191. return false;
  192. }
  193. if ($("#deliveryAddForm input[name=recipPhnno]").val().length > 13) {
  194. mcxDialog.alert("휴대폰번호를 정확히 입력해주세요.");
  195. $('#deliveryAddForm input[name=recipPhnno]').focus();
  196. return false;
  197. }
  198. if (gagajf.isNull($("#deliveryAddForm input[name=recipZipcode]").val())) {
  199. mcxDialog.alert("배송주소를 입력해주세요.");
  200. $('#deliveryAddForm input[name=recipAddr]').focus();
  201. return false;
  202. }
  203. if (gagajf.isNull($("#deliveryAddForm input[name=recipBaseAddr]").val())) {
  204. mcxDialog.alert("배송주소를 입력해주세요.");
  205. $('#deliveryAddForm input[name=recipAddr]').focus();
  206. return false;
  207. }
  208. if (gagajf.isNull($("#deliveryAddForm input[name=recipDtlAddr]").val())) {
  209. mcxDialog.alert("상세주소를 입력해주세요.");
  210. $('#deliveryAddForm input[name=recipDtlAddr]').focus();
  211. return false;
  212. }
  213. return true;
  214. }
  215. //우편번호 DAUM을 이용한 우편번호 팝업 레이어
  216. var fnOpenDaumAddr = function() {
  217. let daumZip = new daum.Postcode({
  218. oncomplete: function(data) {
  219. $('#deliveryAddForm input[name=recipAddr]').val(data.zonecode + ' ' + cfnGetDaumRoadAddr(data));
  220. $('#deliveryAddForm input[name=recipZipcode]').val(data.zonecode);
  221. $('#deliveryAddForm input[name=recipBaseAddr]').val(cfnGetDaumRoadAddr(data));
  222. $('#deliveryAddForm input[name=recipDtlAddr]').focus();
  223. cfnCloseDaumAddr();
  224. },
  225. width: '100%'
  226. });
  227. cfnOpenDaumAddr(daumZip);
  228. }
  229. // 2021.04.09 하이픈처리
  230. $(document).on("keyup", "#deliveryAddForm input[name=recipPhnno]", function() {
  231. $(this).val( $(this).val().replace(/[^0-9]/g, "").replace(/(^02|^0505|^1[0-9]{3}|^0[0-9]{2})([0-9]+)?([0-9]{4})$/,"$1-$2-$3").replace("--", "-") );
  232. });
  233. </script>