(() => { const { EventManager, pageHelper, utils, constants } = ShopbySkin; const { initialize } = pageHelper.displayDetailHelper(); const param = utils.getQueryParams(); initialize({ sectionsId: param.sectionId, by: param.sortType, }); const displayDetailItemsEl = document.querySelector('display-detail-items'); const displayDetailActionMap = { // NOTE: 좋아요버튼 클릭 PRODUCT_LIKE_BTN: ({ event, btn }) => { event?.preventDefault?.(); const productNo = Number(btn.getAttribute('shopby-product-no') ?? 0); utils.isSignIn() ? EventManager.fire('MUTATE_LIKE_PRODUCT', { productNo, onSuccess: (like) => { like ? btn.classList.add('is-active') : btn.classList.remove('is-active'); }, }) : EventManager.fire('MODAL_CONFIRM_OPEN', { message: `로그인하셔야 본 서비스를 이용하실 수 있습니다.`, noticeType: constants.NOTICE_MODAL_TYPE.WARNING, onConfirm: () => { const nextUrl = `${location.origin}${constants.PAGE.SIGN_IN}`; utils.moveTo({ url: `${nextUrl}?from=${encodeURIComponent(location.href)}`, }); }, }); }, // NOTE: 더보기 SEARCH_MORE_PRODUCT: () => { EventManager.fire('SEARCH_MORE_PRODUCT', {}); // 외부스크립트 등록 기능. 삭제금지 ShopbyExternalScript?.setPageScriptType('DISPLAY_SECTION', true); }, // NOTE: 상품터치시 상품상세로 이동전 성인상품인지 확인을 위한 이벤트 MOVE_PRODUCT_DETAIL: ({ event }) => { if (!utils.isAdultVerified(event)) { EventManager.fire('MODAL_CONFIRM_OPEN', { message: '성인인증이 필요한 상품입니다.', noticeType: 'CAUTION', onConfirm: () => { const productNo = event.target.closest('[shopby-product-no]')?.getAttribute('shopby-product-no'); const nextUrl = encodeURIComponent( `${location.origin}${constants.PAGE.PRODUCT_DETAIL}?productNo=${productNo}` ); utils.moveTo({ url: `${location.origin}${constants.PAGE.ADULT_CERTIFICATION}?go-back=true&from=${nextUrl}`, }); }, }); } }, }; const clickEventListener = (event) => { const btn = event.target.closest('[shopby-action]'); const action = btn?.getAttribute('shopby-action'); displayDetailActionMap[action]?.({ btn, event, }); }; const setHeading = (data) => { EventManager.fire('CHANGE_SUB_TITLE', { subTitle: data.label, }); }; EventManager.on('QUERY_DISPLAY_SECTIONS_IDS_SECTIONID', (data) => { setHeading(data); // 외부스크립트 등록 기능. 삭제금지 ShopbyExternalScript?.setGlobalObjectSb({ displaySection: { ...data } }); }); EventManager.on('PAGE_LOAD_COMPLETED', () => { // 외부스크립트 등록 기능. 삭제금지 ShopbyExternalScript?.setPageScriptType('DISPLAY_SECTION'); }); EventManager.on('PRODUCTS_SORT_TYPE', () => { // 정렬 시 페이지 스크립트 재로드 // 외부스크립트 등록 기능. 삭제금지 ShopbyExternalScript?.setPageScriptType('DISPLAY_SECTION', true); }); displayDetailItemsEl.addEventListener('click', clickEventListener); (function() { const urlParams = new URLSearchParams(window.location.search); const sectionId = urlParams.get('sectionId'); const bannerImages = { 'SCMO0001': '/assets/images/bestbanner2.jpg', 'SCMO0004': '/assets/images/salebanner2.jpg', 'SCMO0006': '/assets/images/recombanner2.jpg', 'SCMO0007': '/assets/images/newbanner2.jpg' }; const hideBannerSections = ['SCMO0002','SCMO0003','SCMO0005','SCMO0008']; const showBannerSections = ['SCMO0001','SCMO0004','SCMO0007','SCMO0006']; const style = document.createElement('style'); if (hideBannerSections.includes(sectionId)) { style.innerHTML = ` figure[shopby-section-banner] { display: none !important; } .product-section__title { display: block !important; } `; } else if (showBannerSections.includes(sectionId)) { style.innerHTML = ` figure[shopby-section-banner] { display: block !important; } .list-banner { display: block !important; width: 100% !important; } .list-banner img { width: 100% !important; height: auto !important; display: block !important; } .product-section__title { display: none !important; } `; const observer = new MutationObserver(() => { const banner = document.querySelector('.list-banner'); if (banner) { if (!banner.querySelector('img')) { const img = document.createElement('img'); img.src = bannerImages[sectionId]; banner.appendChild(img); } observer.disconnect(); } }); observer.observe(document.body, { childList: true, subtree: true }); } if (style.innerHTML) { document.head.appendChild(style); } })(); // 찜 수정 // document.querySelectorAll('.sc-like-button').forEach(btn => { // btn.addEventListener('click', function(e) { // e.stopPropagation(); // e.preventDefault(); // // 좋아요 처리 로직 // }); // }); })();