Quellcode durchsuchen

팝업관련 작업

eskim vor 5 Jahren
Ursprung
Commit
6603fa4781

+ 26 - 2
src/main/java/com/style24/front/biz/service/TsfDisplayService.java

@@ -32,6 +32,8 @@ import com.style24.persistence.domain.searchengine.SearchEngine;
 
 import lombok.extern.slf4j.Slf4j;
 
+import com.gagaframework.web.parameter.GagaMap;
+
 /**
  * 전시 Service
  *
@@ -366,9 +368,31 @@ public class TsfDisplayService {
 	 * @author eskim
 	 * @date 2021. 3. 30
 	 */
-	public Collection<Popup> getPopupList(Popup popup) {
+	public GagaMap getPopupList(Popup popup) {
+		GagaMap result = new GagaMap();
+		Collection<Popup> popupList = new ArrayList<Popup>();
 		popup.setSiteCd(TscConstants.Site.STYLE24.value());
-		return displayDao.getPopupList(popup);
+		
+		if ("P".equals(popup.getFrontGb())) {
+			result.set("dataList", displayDao.getPopupList(popup));
+		}else {
+			//우선순위 full 팝
+			popup.setPopupGb("F");
+			popupList = displayDao.getPopupList(popup);
+			result.set("popupGb", "F");
+			result.set("dataList", popupList);
+			if (popupList != null && popupList.size() > 0) {
+				return result;
+			}
+			popup.setPopupGb("H");
+			popupList = displayDao.getPopupList(popup);
+			result.set("popupGb", "H");
+			result.set("dataList", popupList);
+		}
+		
+		// Collection<Popup>
+		
+		return result;
 	}
 
 	/**

+ 7 - 1
src/main/java/com/style24/front/biz/web/TsfDisplayController.java

@@ -570,7 +570,10 @@ public class TsfDisplayController extends TsfBaseController {
 	 */
 	@GetMapping("/popup/list")
 	@ResponseBody
-	public Collection<Popup> getPopupList(@RequestParam HashMap<String, String> paramMap) {
+	public GagaMap getPopupList(@RequestParam HashMap<String, String> paramMap) {
+		
+		GagaMap result = new GagaMap();
+		 
 		Popup popup = new Popup();
 		popup.setFrontGb(TsfSession.getFrontGb());
 		popup.setViewPage(paramMap.get("viewPage"));
@@ -581,6 +584,9 @@ public class TsfDisplayController extends TsfBaseController {
 		popup.setPlanSq((StringUtils.isBlank(paramMap.get("planSq").toString()) ? 0 : Integer.parseInt(paramMap.get("planSq"))));
 		popup.setPreview(paramMap.get("preview"));
 		popup.setViewDt(paramMap.get("viewDt"));
+		
+		//result.set("dataList", displayService.getPopupList(popup));
+	
 		return displayService.getPopupList(popup);
 	}
 

+ 12 - 5
src/main/java/com/style24/persistence/mybatis/shop/TsfDisplay.xml

@@ -541,6 +541,7 @@
 		         , IMG_URL1
 		         , LINK_URL1
 		         , UNEXP_DAYS
+		         , LINK_TARGET
 		         , ROW_NUMBER() OVER( ORDER BY DISP_ORD, REG_DT DESC) AS RNUM
 		    <choose>
 		         <when test='preview != null and preview == "Y"'>
@@ -551,11 +552,17 @@
 		         </otherwise>
 		    </choose>
 		    WHERE  1 = 1
-		    AND ( FRONT_GB = 'A'
-		    <if test='frontGb != null and frontGb !=""'>
-		          OR FRONT_GB = #{frontGb}
+		    <choose>
+		    <when test='frontGb != null and frontGb =="P"'>
+		    AND FRONT_GB = #{frontGb}
+		    </when>
+		    <otherwise>
+		    AND FRONT_GB = 'M'
+		    </otherwise>
+		    </choose>
+		    <if test="popupGb != null and popupGb != ''">
+		    AND POPUP_GB = #{popupGb}
 		    </if>
-		         )
 		    AND ( VIEW_PAGE = 'G037_10'
 		    <if test='viewPage != null and viewPage !=""'>
 		          OR ( VIEW_PAGE = #{viewPage}
@@ -583,7 +590,7 @@
 		    AND DISP_EDDT >= NOW()
 		    </otherwise>
 		    </choose>
-		    ORDER BY DISP_ORD, REG_DT DESC
+		    ORDER BY POPUP_GB, DISP_ORD, REG_DT DESC
 		) Z 
 	</select>
 	

+ 139 - 0
src/main/webapp/WEB-INF/views/mob/common/fragments/FooterMob.html

@@ -200,10 +200,149 @@
 			});
 	}
 	
+	// 팝업
+	let fnGetPopup = function(){
+		let data = {viewPage : [[${viewPage}]]
+					,cateNo : [[${popupCateNo}]]
+					,brandCd : [[${popupBrandCd}]]
+					,planSq : [[${popupPlanSq}]]
+					,preview : [[${preview}]]
+					,viewDt : [[${viewDt}]]
+		};
+		$.getJSON('/display/popup/list', data, function(result, status) {
+			if (status === 'success') {
+				if(result.dataList.length>0){
+					let pClass = "";
+					if ("H" == result.popupGb){
+						pClass = "half";
+					}
+					let popupYn = "N";
+					let popupSq = "";
+					let tag = '';
+					tag += '<div id="popupMainNotice" class="popup_main_notice half active">\n';  <!-- half 팝업일 경우 : half 클래스 포함 -->
+					tag += '	<div class="popup_content">\n';
+					if ("H" == result.popupGb){
+						
+						$.each(result.dataList, function(idx, item) {
+							if(document.cookie.match('(^|;)?style_popup_'+item.popupSq+'=([^;]*)(;|$)')==null) {
+								popupSq += item.popupSq +"|";
+							}
+						});	
+						
+					tag += '		<div class="popup_header">\n';
+					tag += '			<a href="javascript:void(0);" onclick="fnLayerPopupUnexpDaysClose(\''+popupSq+'\',1);" class="btn_underline"> 하루 보지 않기</a>\n';
+					tag += '			<a href="javascript:void(0);" id="btnPopupClose" onclick="fnLayerPopupClose();" class="btn_popup_close">닫기</a>\n';
+					tag += '		</div>\n';
+					}
+					tag += '		<div class="popup_body">\n';
+					tag += '			<div class="swiper-container">\n';
+					tag += '				<div class="swiper-wrapper">\n';
+					$.each(result.dataList, function(idx, item) {
+						if(document.cookie.match('(^|;)?style_popup_'+item.popupSq+'=([^;]*)(;|$)')==null) {
+							tag += '					<div class="swiper-slide">\n';
+							if(!gagajf.isNull(item.linkUrl1) && item.linkUrl1 !== "#"){
+								let linkTarget = "";
+								if ("N" == item.linkTarget){
+									linkTarget = "target=\"_blank\"";
+								}
+							tag += '						<a href="'+ item.linkUrl1 +'" '+linkTarget+' >\n';	
+							}
+							tag += '						<img src="'+ _imgUrl+'/'+item.imgUrl1+'" alt="">\n';
+							if(!gagajf.isNull(item.linkUrl1) && item.linkUrl1 !== "#"){
+							tag += '						</a>\n';
+							}
+							tag += '					</div>\n';
+							popupYn = "Y";
+							popupSq += item.popupSq +"|";
+						}
+					});	
+					tag += '				</div>\n';
+					tag += '				<div class="swiper-pagination"></div>\n';
+					tag += '			</div>\n';
+					tag += '		</div>\n';
+					if ("F" == result.popupGb){
+					tag += '		<div class="popup_footer">\n';
+					tag += '			<a href="javascript:void(0);" onclick="fnLayerPopupUnexpDaysClose(\''+popupSq+'\',1);" class="btn_underline"> 하루 보지 않기</a>\n';
+					tag += '			<a href="javascript:void(0);" id="btnPopupClose" onclick="fnLayerPopupClose();" class="btn_popup_close">닫기</a>\n';
+					tag += '		</div>\n';
+					}
+					tag += '	</div>\n';
+					tag += '</div>\n';
+					
+					if (popupYn == "Y"){
+						if ($('#popupMainNotice').length === 0) {
+							$('body').append(tag);
+						}	
+					}
+					
+					/* SLIDE - 메인 공지 팝업 */
+					var popup_main_notice_slide = new Swiper ('.popup_main_notice .swiper-container', {
+						loop: true,
+						spaceBetween: 0,
+						speed:200,
+						autoplay: {
+							delay: 4000,
+							disableOnInteraction: false,
+						},
+						pagination: {
+							el: '.popup_main_notice .swiper-pagination',
+							type: 'fraction',
+						},
+					});			
+
+					if($(".popup_main_notice").hasClass("active")){
+						$("body").css({"overflow":"hidden"});
+					}else{
+						$("body").css({"overflow":"visible"});
+					};
+
+					/* 메인 공지 팝업 닫기 */
+					$(document).on('click','#btnPopupClose',function(e){
+						$('#popupMainNotice').hide();
+						$(".popup_main_notice").removeClass("active");
+
+						if(!$(".popup_main_notice").hasClass("active")){
+							$("body").css({"overflow":"visible"});
+						}else{
+							$("body").css({"overflow":"hidden"});
+						};
+						return false;
+					});	
+					
+				}
+			}
+		});
+	}
+
+	let fnLayerPopupUnexpDaysClose = function(seq, unexpDays){
+		let arrSeq = seq.split("|");
+		if (arrSeq.length > 0){
+			let todayDate = new Date();
+			//todayDate = new Date(parseInt(todayDate.getTime() / 86400000) * 86400000 + 54000000);
+			todayDate = new Date(parseInt(todayDate.getTime() / 86400000) * 86400000);	// 당일 자정처리
+			todayDate.setDate(todayDate.getDate() + unexpDays);
+			
+			$.each(arrSeq, function (idx, item) {
+				if (!gagajf.isNull(item)){
+					document.cookie = "style_popup_"+item+"=Y; path=/; expires=" + todayDate.toGMTString() + ";";	
+				}
+			});
+		}
+		
+		fnLayerPopupClose();
+	}
+	// 창 닫기
+	let fnLayerPopupClose = function(){
+		$('#popupMainNotice').remove();
+	}
+	
 	$(document).ready(function() {
 		// 퀵메뉴탭 조회
 		fnCreateQuickMenuTab();
 		
+		// 팝업조회
+		fnGetPopup();
+		
 		$.getJSON('/cart/goods/not/soldout/cnt', function (order, status) {
 			let cartCnt;
 			if (order.cartGoodsList.length > 99) {

+ 7 - 3
src/main/webapp/WEB-INF/views/web/common/fragments/FooterWeb.html

@@ -1406,7 +1406,7 @@
 		};
 		$.getJSON('/display/popup/list', data, function(result, status) {
 			if (status === 'success') {
-				if(result.length>0){
+				if(result.dataList.length>0){
 					let popupYn = "N";
 					let popupSq = "";
 					let tag = '';
@@ -1415,11 +1415,15 @@
 					tag += '		<div class="popup_body">\n';
 					tag += '			<div class="swiper-container">\n';
 					tag += '				<div class="swiper-wrapper">\n';
-					$.each(result, function(idx, item) {
+					$.each(result.dataList, function(idx, item) {
 						if(document.cookie.match('(^|;)?style_popup_'+item.popupSq+'=([^;]*)(;|$)')==null) {
 							tag += '					<div class="swiper-slide">\n';
 							if(!gagajf.isNull(item.linkUrl1) && item.linkUrl1 !== "#"){
-							tag += '						<a href="'+ item.linkUrl1 +'"  target="_blank">\n';	
+								let linkTarget = "";
+								if ("N" == item.linkTarget){
+									linkTarget = "target=\"_blank\"";
+								}
+							tag += '						<a href="'+ item.linkUrl1 +'" '+linkTarget+' >\n';	
 							}
 							tag += '						<img src="'+ _imgUrl+'/'+item.imgUrl1+'" width="100%" alt="">\n';
 							if(!gagajf.isNull(item.linkUrl1) && item.linkUrl1 !== "#"){