(()=>{ const { EventManager } = ShopbySkin; EventManager.on('PAGE_LOAD_COMPLETED', (commonData) => { if ( ShopbySkin.utils.isSignIn() ) { ShopbySkin.actions.productRecentActions().getProfileRecentProducts() EventManager.on('QUERY_PROFILE_RECENT_PRODUCTS', (data) => { if ( data?.[0]?.imageUrlInfo?.[0]?.url ) { document.querySelector('#kmRecentThumb').src = data?.[0]?.imageUrlInfo?.[0]?.url; document.querySelector('#kmRecentThumb')?.classList.add('has-image'); } }); } else { const noArr = JSON.parse( localStorage.getItem('guestRecentProducts') ); if ( noArr && noArr?.length > 0 ) { const nos = encodeURIComponent( noArr.join(',') ); fetch('https://shop-api.e-ncp.com/guest/recent-products?mallProductNos=' + nos, { "headers" : { "version" : "1.0", "clientid" : commonData.clientid, "platform" : "MOBILE_WEB", }, }) .then((res)=>res.json()) .then((data)=>{ if ( data?.[0]?.imageUrlInfo?.[0]?.url ) { document.querySelector('#kmRecentThumb').src = data?.[0]?.imageUrlInfo?.[0]?.url; document.querySelector('#kmRecentThumb')?.classList.add('has-image'); } }); } } }); })();