class ServiceMenu extends ShopbySkin.modules.MyMenu { constructor() { super(); } async setup() { super.setup(); const getEnvironment = async () => { return fetch('/environment.json').then(function (res) { return res.json(); }); }; const { clientId } = await getEnvironment(); const shopApiUrl = 'https://shop-api.e-ncp.com'; const settings = { crossDomain: true, url: shopApiUrl + '/malls', method: 'GET', headers: { version: '1.0', clientId: clientId, platform: 'PC', 'content-type': 'application/json', }, data: null, }; const mallInfo = await $.ajax(settings).done( function (res, textStatus, xhr) { return { result: res, statusCode: xhr.status, }; }, ); const serviceMenuElement = document.querySelector('.l-service-menu'); this.store.setState((prev) => ({ ...prev, mallInfo: mallInfo, customMenuTitle: serviceMenuElement.getAttribute('shopby-menu-title'), // 서비스 메뉴 타이틀 상태값이 업데이트가 안돼서 상태값 추가 })); // [Jay] mallInfo 키값에 접근 this.store.attach('mallInfo', (state) => //[Jay] boardConfig state 값 업데이트 this.updateSlot(state, 'boardConfig'), ); $('.acc-tit').on('click', function () { if ($(this).next('.acc-cont').is(':visible')) { $(this).next('.acc-cont').slideUp(); $(this).addClass('active'); } else { $(this).next('.acc-cont').slideDown(); $(this).removeClass('active'); } }); } } customElements.define('service-menu', ServiceMenu); (async () => { const EventManager = ShopbySkin.EventManager; $(document).on('click', '.acc-tit', function () { if ($(this).next('.acc-cont').is(':visible')) { $(this).next('.acc-cont').slideUp(); $(this).addClass('active'); } else { $(this).next('.acc-cont').slideDown(); $(this).removeClass('active'); } }); // [KR] 결제 혜택 EventManager.on('QUERY_BOARD_CONFIGURATION', async (data) => { // [Jay] 무이자 혜택 게시글 조회 const cardEventParams = { queryString: { pageNumber: 1, pageSize: 1, direction: 'DESC', }, }; const { result: cardEventList } = await callShopApi( `/boards/282634/articles?`, 'GET', cardEventParams, ); setTimeout(() => { if (document.querySelector('#cardEventBenefit')) { document.querySelector('#cardEventBenefit').href = `/pages/service/post-detail.html?boardNo=282634&articleNo=${cardEventList.items[0].articleNo}&menutitle=결제혜택 안내`; } }, 500); }); })();