<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : OrderDeliveryAddrInfoMob.html
 * @desc    : 배송정보 Page
 *============================================================================
 * STYLE24
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2021.04.05   jsh77b     최초 작성
 *******************************************************************************
 -->
<!-- 배송지정보 -->
<input type="hidden" name="recipNm" 		th:value="${deliveryAddrInfo.recipNm}"/>
<input type="hidden" name="recipPhnno" 		th:value="${deliveryAddrInfo.recipPhnno}"/>
<input type="hidden" name="recipZipcode" 	th:value="${deliveryAddrInfo.recipZipcode}"/>
<input type="hidden" name="recipBaseAddr" 	th:value="${deliveryAddrInfo.recipBaseAddr}"/>
<input type="hidden" name="recipDtlAddr" 	th:value="${deliveryAddrInfo.recipDtlAddr}"/>
<input type="hidden" name="delvMemo" 		th:value="${deliveryAddrInfo.delvMemo}"/>
<input type="hidden" name="foreignBuyYn" 	th:value="${order.foreignBuyYn}"/>
<input type="hidden" name="orderMadeYn" 	th:value="${order.orderMadeYn}"/>

<div class="foldGroup shipfold">
	<ul>
		<li class="fold_delivery">
			<div class="fold_head">
				<a href="javascript:void(0)">
					<div>
						<div class="fold_tit"><span>배송지 정보</span></div>
						<div class="data">
							<th:block th:if="${deliveryAddrInfo.recipZipcode} == '00000'">
								<span id="recipAddr">배송지 정보를 등록해 주세요.</span>
							</th:block>
							<th:block th:if="${deliveryAddrInfo.recipZipcode} != '00000'">
								<span id="recipAddr" th:text="${deliveryAddrInfo.recipBaseAddr} + '   ' + ${deliveryAddrInfo.recipDtlAddr}"></span>
							</th:block>
						</div>
					</div>
				</a>
			</div>
			<div class="fold_cont">
				<!-- 배송지 정보 변경가능 -->
				<div class="ship_info ship_edit exist">
					<button type="button" class="btn_popup btn_adrsChange_pop">
						<span>배송지 변경</span>
					</button>
					<dl>
						<div class="company">
							<dt><span class="sr-only">배송지명</span></dt>
							<dd>
								<th:block th:text="${deliveryAddrInfo.recipNm}"></th:block> 
								<span class="icon_tag"> 
									<th:block th:if="${deliveryAddrInfo.defaultYn} == 'Y'">
										<em class="tag_stype1 defaultYn">기본배송지</em> 
									</th:block>
									<em class="tag_stype2 shotDelv" style="display:none">총알배송</em>
								</span>
							</dd>
						</div>
						<div class="phone">
							<dt><span class="sr-only">휴대폰 번호</span></dt>
							<th:block th:if="${deliveryAddrInfo.recipZipcode} == '00000'">
								<dd>휴대폰번호를 등록해 주세요.</dd>
							</th:block>
							<th:block th:if="${deliveryAddrInfo.recipZipcode} != '00000'">
								<dd th:text="${deliveryAddrInfo.recipPhnno}"></dd>
							</th:block>
							
						</div>
						<div class="addr">
							<dt><span class="sr-only">배송주소</span></dt>
							<th:block th:if="${deliveryAddrInfo.recipZipcode} == '00000'">
								<dd id="recipAddr">배송지 정보를 등록해 주세요.</dd>
							</th:block>
							<th:block th:if="${deliveryAddrInfo.recipZipcode} != '00000'">
								<dd th:text="${deliveryAddrInfo.recipBaseAddr} + '    ' + ${deliveryAddrInfo.recipDtlAddr}"></dd>
							</th:block>
						</div>
						
						<div class="ship_request ship_select">
							<span>배송요청 사항</span>
							<div class="ship_option">
								<div class="form_field">
									<div class="select_custom delivery_list"> <!-- 비활성화시 disabled 추가 -->
										<div class="combo">
											<div class="select" th:text="${deliveryAddrInfo.delvMemo}">선택</div>
											<ul class="list">
												<!-- 선택처리 class="selected" / 선택불가 aria-disabled="true"추가  -->
												<li>문 앞</li> 
												<li>직접 받고 부재 시 문 앞</li>
												<li>경비실</li> 
												<li>택배함</li>
												<li class="select_etc">기타사항</li>
											</ul>
										</div>
									</div>
								</div>
							</div>
							<div class="ship_etc">
								<div class="form_text etc">
									<input type="text" name="delvMemoText" placeholder="보관 장소만 입력 (필수)" maxlength="30" disabled>
									<p class="desc_txt">보관 장소 외 다른 내용 입력시 통보 없이 삭제 될 수 있습니다.</p>
								</div>
							</div>
						</div>
					</dl>
				</div>
				<!-- //배송지 정보 변경가능 -->
				
				<!-- 210428_추가 : 배송지 정보가 없을 경우 -->
				<div class="ship_info none">
					<button type="button" class="btn_popup btn_adrsChange_pop"><span>배송지 변경</span></button>
					<p>배송지 정보를 등록해 주세요.</p>
				</div> 
			</div>
		</li>
	</ul>
</div>
<!-- //배송지정보 -->

<script th:inline="javascript">
var dispYn 		= [[${order.dispYn}]]; // 노출여부
var delvMemo 	= [[${deliveryAddrInfo.delvMemo}]]; // 노출여부

//화면노출
var deliveryAddrInfoDispYn = function(temp) {
	if (temp == "Y") {
		$("#deliveryAddrInfo .fold_head").addClass("on");
		$("#deliveryAddrInfo .fold_cont").show();
	} else {
		$("#deliveryAddrInfo .fold_head").removeClass("on");
		$("#deliveryAddrInfo .fold_cont").hide();
	}
}

//컨텐츠 호출
$(document).ready( function() {
	// 화면펼침
	deliveryAddrInfoDispYn("Y");
	
	var delvMemoArr = ["문 앞", "직접 받고 부재 시 문 앞", "경비실", "택배함"];
	var tempMemo = true;
	
	$("#orderForm .ship_request .delivery_list li").removeClass("selected");
	
	// 배송요청사항설정
	for (i=0 ; i<delvMemoArr.length ; i++) {
		if (delvMemoArr[i] == delvMemo) {
			tempMemo = false;
		}
	}

	// 배송메모설정
	$("#orderForm .ship_request .delivery_list li").each(function(){
		if (delvMemo == $(this).text()) {
			$(this).addClass("selected");
		}
	});
	
	if (tempMemo) {
		$("#orderForm .ship_request .delivery_list .select").text("기타사항");
		$("#orderForm input[name=delvMemoText]").attr("disabled", false);
		$("#orderForm input[name=delvMemoText]").val(delvMemo);
		$("#orderForm .delvMemo li").eq(4).addClass("selected");
		$(".ship_etc").show();
	}
	
	// 콤보박스 
	var od_delivery_list = new sCombo('#orderForm .ship_select .select_custom.delivery_list');
	
	// 210405_배송요청 사항 기타사항 selected시 기타사항 input 구현
	$("#orderForm .select_custom.delivery_list .combo .list > li").on("click", function(){
		if ($("#orderForm .select_etc").hasClass("selected")){
			$(".ship_etc").show();
			$("#orderForm input[name=delvMemoText]").attr("disabled", false);
		} else {
			$(".ship_etc").hide();
			$("#orderForm input[name=delvMemoText]").attr("disabled", true);
		}
	});
});
</script>
</html>