(() => { const initialize = async (params, containerEl) => { if (params.usesProductSearch) { containerEl.setDisplayProductConfig(); return; } const { actions } = ShopbySkin; try { await actions?.getDisplayProductSectionById?.({ sectionsId: params?.sectionId, ...params?.apiOption?.displayProductSectionByIdQueryParams, }); } catch (e) { console.error(e); containerEl.setIsLoaded(true); } }; const { EventManager, utils, constants } = ShopbySkin; const sectionId = document.currentScript.getAttribute('shopby-section-id'); const containerEl = document.querySelector(`[shopby-section-id="${sectionId}"]`); const displayProductActionMap = { // NOTE: 좋아요버튼 클릭. PRODUCT_LIKE_BTN: ({ sectionId, event }) => { event?.preventDefault?.(); const btn = event.target.closest('[shopby-product-no]'); const productNo = Number(btn.getAttribute('shopby-product-no') ?? 0); utils.isSignIn() ? EventManager.fire('MUTATE_LIKE_PRODUCT', { productNo, sectionId, onSuccess: (like) => { const likeBtns = document.querySelectorAll(`[shopby-product-no="${productNo}"]`); likeBtns?.forEach((btn) => { 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}/pages/sign-in/sign-in.html`; location.href = `${nextUrl}?from=${encodeURIComponent(location.href)}`; }, }); }, OPEN_PRODUCT_OPTION_MODAL: ({ event }) => { event?.preventDefault?.(); const btn = event.target.closest('[shopby-product-no]'); const productNo = Number(btn.getAttribute('shopby-product-no') ?? 0); const isSoldOut = utils.convertStringBooleanToBoolean(btn.getAttribute('shopby-is-sold-out')); if (isSoldOut) { return; } if (!utils.isAdultVerified(event)) { EventManager.fire('MODAL_CONFIRM_OPEN', { message: '성인인증이 필요한 상품입니다.', noticeType: constants.NOTICE_MODAL_TYPE.CAUTION, onConfirm: () => { const nextUrl = `${location.origin}/pages/sign-in/sign-in.html`; location.href = `${nextUrl}?from=${encodeURIComponent(location.href)}`; }, }); return; } EventManager.fire('OPEN_LAYER_MODAL', { name: 'select-product-option', title: '옵션 선택', isFull: false, modalAddClass: 'select-product-option-modal', data: { productNo, }, }); }, MOVE_PRODUCT_DETAIL: ({ event }) => { if (!utils.isAdultVerified(event)) { EventManager.fire('MODAL_CONFIRM_OPEN', { message: '성인인증이 필요한 상품입니다.', noticeType: 'CAUTION', onConfirm: () => { location.href = '/pages/intro/adult-certification.html?go-back=true'; }, }); } }, }; const clickEventListener = (e) => { const btn = e.target.closest('[shopby-action]') || e.target.parentElement.closest('[shopby-action]'); const action = btn?.getAttribute('shopby-action'); displayProductActionMap[action]?.({ sectionId, event: e, }); }; //'https://shop-api.e-ncp.com/display/sections/ids/MAINDIS01?includeStopProduct=false&hasOptionValues=true&hasTotalCount=false&pageSize=10&pageNumber=1 //&saleStatus=ONSALE&soldout=false&by=ADMIN_SETTING'; initialize({ sectionId, apiOption: { displayProductSectionByIdQueryParams: { includeStopProduct:false, saleStatus:'ONSALE', hasTotalCount:true, pageSize:10, pageNumber:1, by:'ADMIN_SETTING', soldout: false, hasOptionValues: true, }, }, }); //----------------- 다중옵션일 경우 사이즈만 추출하여 다시 설정 S 2025.02.10 S ----------------- EventManager.on('QUERY_SEARCH_PRODUCTS_BY', () => { //console.log(containerEl); let option_btn = containerEl.querySelectorAll('.option_btn'); option_btn.forEach((button) => { setTimeout(() => { let arrVal = new Array(); const Arritem = button.querySelectorAll('div'); for (let a = 0; a < Arritem.length; a++){ arrVal.push(Arritem[a].innerText.split('|')[0]); } arrVal = [...new Set(arrVal)]; //중복제거 let strHtml = ''; for (let b = 0; b < arrVal.length; b++){ strHtml += '
'+ arrVal[b] +'
'; } button.innerHTML = strHtml; }, 100); }); }); //----------------- 다중옵션일 경우 사이즈만 추출하여 다시 설정 S 2025.02.10 E ----------------- containerEl.addEventListener('click', clickEventListener); containerEl.removeEventListener('unload', clickEventListener); })(); function clickTab(target, target2){ target.hide(); target2.show(); target2.find('.displaySectionProducts').css({opacity:0}); target2.find('.displaySectionProducts').animate({opacity:1}, 500); }