Most Popular
0 Product
Sorry, there are no products in this collection.
(function(){ class SPZCustomCollectionSubscript extends SPZ.BaseElement { constructor(element) { super(element); this.payResult = null; } isLayoutSupported(layout) { return layout === SPZCore.Layout.LOGIC; } buildCallback(){ this.registerAction('update', (invocation) => { this.updateListSubscript(); }); } updateListSubscript(){ async function showSubscript(){ const imageDoms =[]; const productIds = []; const listItems = document.querySelectorAll('.collection-list>.shoplazza-product-snippet'); /* console.info('[listItems]', listItems); */ listItems.forEach(item=>{ const img = item.querySelector('spz-img.product-snippet__img:not(:has(.custom_subscript_item))'); if(img){ imageDoms.push(img); productIds.push(item.getAttribute('product-id')); } }); if(productIds.length ==0) return; let result = []; try{ const res = await fetch(location.origin+"/apps/best-short/api/v1/subscript", { method:"POST", body: JSON.stringify({ type:'skit', resource_ids: productIds })}) .then(res=>res.json()); result = res?.data || []; }catch(e){ console.warn('[subscript get error]', e); } result.forEach(ele=>{ const index = productIds.indexOf(ele.id); if(index>=0 && ele.styles?.length>0){ const listItem = imageDoms[index]; ele.styles.forEach(style=>{ const _item = document.createElement('div'); _item.classList.add('custom_subscript_item'); _item.classList.add('custom_position_'+style.position); _item.classList.add(style.icon); const _span = document.createElement('span'); _span.classList.add('custom_subscript_item_text'); _span.innerHTML = style.content; _item.appendChild(_span); listItem.appendChild(_item.cloneNode(true)); }) } }) } setTimeout(showSubscript, 200); } } SPZ.defineElement('spz-custom-collection-subscript', SPZCustomCollectionSubscript); })()
(function(){ class SPZCustomRecentlyViewSubscript extends SPZ.BaseElement { constructor(element) { super(element); this.payResult = null; } isLayoutSupported(layout) { return layout === SPZCore.Layout.LOGIC; } buildCallback(){ this.registerAction('update', (invocation) => { this.updateRecentlyViewSubscript(); }); } updateRecentlyViewSubscript(){ async function showSubscript(){ const imageDoms =[]; const productIds = []; const listItems = document.querySelectorAll('spz-carousel.recently_view_carousel .spz-carousel-slide'); /* console.info('[listItems]', listItems); */ listItems.forEach(item=>{ const img = item.querySelector('spz-img.product-snippet__img:not(:has(.custom_subscript_item))'); if(img){ imageDoms.push(img); productIds.push(item.getAttribute('key')); } }); if(productIds.length ==0) return; let result = []; try{ const res = await fetch(location.origin+"/apps/best-short/api/v1/subscript", { method:"POST", body: JSON.stringify({ type:'skit', resource_ids: productIds })}) .then(res=>res.json()); result = res?.data || []; }catch(e){ console.warn('[subscript get error]', e); } result.forEach(ele=>{ const index = productIds.indexOf(ele.id); if(index>=0 && ele.styles?.length>0){ const listItem = imageDoms[index]; ele.styles.forEach(style=>{ const _item = document.createElement('div'); _item.classList.add('custom_subscript_item'); _item.classList.add('custom_position_'+style.position); _item.classList.add(style.icon); const _span = document.createElement('span'); _span.classList.add('custom_subscript_item_text'); _span.innerHTML = style.content; _item.appendChild(_span); listItem.appendChild(_item.cloneNode(true)); }) } }) } setTimeout(showSubscript, 200); } } SPZ.defineElement('spz-custom-recently-view-subscript', SPZCustomRecentlyViewSubscript); })()