<html lang="ko"
	  xmlns:th="http://www.thymeleaf.org">

<!-- 다다익선 상품보기 팝업 -->
<div class="lap" th:with="imgGoodsUrl=${@environment.getProperty('upload.goods.view')}, uxImgUrl=${@environment.getProperty('domain.uximage')}, imgUrl=${@environment.getProperty('upload.image.view')}">
	<div class="popup_close">카테고리닫기</div>
	<div class="popup_head">
		<h2>다다익선 할인 상품</h2>
		<div class="area_benefit">
			<span class="tag primary">SALE</span>
			<p>
				<span th:each="desc, index : ${tmtbDcDescList}" th:text="${desc}"></span>
			</p>
		</div>
	</div>
	<div class="popup_con">
		<div class="part_goods">
			<ul>
				<li th:each="goods, status : ${goodsList}">
					<div class="goods_detail">
						<div class="thumb_box">
							<a th:href="|javascript:fnGoToGoodsDetail('${goods.goodsCd}')|">
								<img class="vLHTC pd_img" th:src="${imgGoodsUrl} + '/' + ${goods.sysImgNm} + '?RS=150'" src="/" width="100%" th:onerror="'this.src=\''+@{${uxImgUrl}+ '/images/pc/thumb/bg_item_none.png'}+'\';'"  th:alt="${goods.sysImgNm}" alt="">
							</a>
						</div>
						<div class="info_box">
							<div class="od_name">
								<div class="brand">
									<span th:text="${goods.brandGroupNm}"></span>
								</div>
								<div class="name"><a th:href="|javascript:fnGoToGoodsDetail('${goods.goodsCd}')|" th:text="${goods.goodsFullNm}"></a></div>
							</div>
							<div class="od_calc">
								<p class="price">
									<span class="selling_price"><em th:text="${#numbers.formatInteger(goods.currPrice, 1, 'COMMA')}"></em>원</span>
									<th:block th:if="${goods.listPrice != goods.currPrice}">
										<span class="sale_price"><del><em th:text="${#numbers.formatInteger(goods.listPrice, 1, 'COMMA')}"></em>원</del></span>
										<span class="sale_percent" th:text="${#numbers.formatInteger(goods.dcRate, 0, 'COMMA') + '%'}"></span>
									</th:block>
								</p>
							</div>
							<div class="od_shoppingbag">
								<button type="button" class="btn btn_primary_line" th:onclick="fnAddCartTmtbSalesGoods([[${goods.goodsCd}]])"><span>쇼핑백 담기</span></button>
							</div>
						</div>
					</div>
				</li>
			</ul>
		</div>
	</div>
</div>

<script th:inline="javascript">
	$(document).ready(function() {
		var goodsListCnt = [[${goodsList.size()}]];
		if(goodsListCnt < 1) {
			mcxDialog.alert("다다익선 적용 가능한 다른 상품이 없습니다.");
			$(".popup_close").trigger("click");
		} else {
			$('#moresalePop').show().addClass("active");
			$("body").css({"overflow":"hidden"});
			// $("#moresalePop").modal("show");
		}
	});

	function fnAddCartTmtbSalesGoods(goodsCd) {
		let data = JSON.stringify({goodsCd : goodsCd});
		$.ajax( {
			type		: "POST",
			url 		: '/cart/tmtb/sales/goods/optcd',
			data		: data,
			dataType 	: 'json',
			beforeSend : function(xhr, settings) {
				xhr.setRequestHeader("AJAX"			, "true");
				xhr.setRequestHeader('Accept'		, 'application/json');
				xhr.setRequestHeader('Content-Type'	, 'application/json');
			},
			success 	: function(result) {
				let compsList = [];
				let temp 			= new Object;
				temp.goodsCd 		= goodsCd;
				temp.optCd 			= result.optCd;
				temp.goodsQty 		= 1;
				temp.goodsType 		= "G056_N";
				temp.cartGb 		= "C";
				temp.popupYn		= "Y";
				compsList.push(temp);

				cfnAddCart(compsList);
			}
		});
	};
</script>
<!-- //다다익선 상품보기 팝업 -->
</html>