window.fundiin = {productDetail: null}; window.fundiin.productDetail = {installmentPlan: {revolving: false, twoPhases: false, threePhases: false, bnplPlus: true}, bannerDescription: 'Giảm đến 50K khi thanh toán qua Fundiin.
', promotions: [{logo: '', name: 'Giảm 20% tối đa 30K', code: 'XINCHAO20', shortDescription: 'Dành cho khách hàng lần đầu thanh toán Fundiin
'}, {logo: '', name: 'Giảm 10% tối đa 15K', code: 'FUNDAY', shortDescription: 'Dành cho khách hàng đã từng thanh toán Fundiin
Mỗi khách hàng được dùng 1 lần/tháng
'}, {logo: '', name: 'Giảm 3% tối đa 50K', code: 'XINCHAO3', shortDescription: 'Dành cho khách hàng lần đầu thanh toán Fundiin
'}, {logo: '', name: 'Giảm 0,2% cho mọi đơn hàng', code: 'CASHBACK02', shortDescription: 'Không giới hạn số lần sử dụng
'}]};const generateProductDetailLogo = () => { return ` `; }; const generateProductDetailPromotions = (promotions = []) => { const generatePromotionWidgetStyle = () => { return ` `; }; const generatePromotionList = () => { let result = ''; for (let promotion of promotions) { result += ` `; } return result; }; return ` ${generatePromotionWidgetStyle()} `; }; const onPromotionModalOpened = (modal, promotions = []) => { const promotionTrigger = document.getElementById('fundiin-promotions-widget'); if (!promotionTrigger) { return; } promotionTrigger.addEventListener('click', event => { event.preventDefault(); document.querySelector('.fundiin-modal-content').innerHTML = generateProductDetailPromotions(promotions); modal.style.display = 'block'; document.body.style.overflow = 'hidden'; }); }; const detailTrackingScript = () => {
window.dataLayer = window.dataLayer || [];
const fundiinContentV2 = document.querySelector('#script-general-container > .fundiin-wrapper');
const fundiinContentV1 = document.querySelector('#script-product-detail > .fundiin-wrapper');
if (!fundiinContentV2 && !fundiinContentV1) {
return;
}
window.dataLayer.push({
event: 'view_product_detail',
event_category: 'mx_site',
event_action: 'view',
event_label: 'mx_detail_logo',
});
document.querySelector('#fundiin-promotions-widget').addEventListener('click', () => {
window.dataLayer.push({
event: 'click_see_more',
event_category: 'mx_site',
event_action: 'click',
event_label: 'mx_see_more',
});
});
};
(function () { const trackingScript = document.createElement('script'); trackingScript.type = 'text/javascript'; trackingScript.innerHTML = ` (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-TP47LP6K'); `; document.head.appendChild(trackingScript); })(); const generateProductDetailStyle = () => { return ` .fundiin-wrapper { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 0.2rem; font-size: 14px; font-weight: 400; line-height: 24px; p { margin-top: 0; margin-bottom: 0; } .fundiin-title { display: flex; align-items: center; gap: 0.5rem; color: #9b9b9b; svg { cursor: pointer; } } .fundiin-banner { max-width: 370px; padding: 10px 8px; border-radius: 5px; background: linear-gradient(to right, #06decd, #744def); font-weight: 500; color: #fff; display: flex; align-items: center; gap: 8px; .fundiin-banner__text { i { text-decoration: underline; cursor: pointer; } } } } .fundiin-overlay { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: hidden; background-color: rgba(0,0,0,0.4); .fundiin-modal { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; height: auto; border-radius: 16px; background-color: #fefefe; .fundiin-modal__close { position: absolute; top: 4px; right: 12px; color: #aaa; font-size: 20px; font-weight: bold; } .fundiin-modal__close:hover, .fundiin-modal__close:focus { color: #000; cursor: pointer; } } @media (min-width: 768px) { .fundiin-modal { width: 70%; } } @media (min-width: 1024px) { .fundiin-modal { width: 600px; } } } `; }; const onIntroductionModalOpened = (modal) => { const introductionTrigger = document.getElementById('fundiin-introduction'); if (!introductionTrigger) { return; } introductionTrigger.addEventListener('click', event => { event.preventDefault(); document.querySelector('.fundiin-modal-content').innerHTML = `
`; modal.style.display = 'block'; document.body.style.overflow = 'hidden'; }); }; const generateActionHandler = (promotions) => { /* Start attaching events to template */ const modal = document.getElementById('fundiin-modal'); const modalClose = document.querySelector('.fundiin-modal__close'); const modalContent = document.querySelector('.fundiin-modal-content'); if (!modal || !modalClose || !modalContent) { return; } const onModalClosed = event => { event.preventDefault(); modal.style.display = 'none'; document.body.style.overflowY = 'auto'; modalContent.innerHTML = ''; }; /* Start closing modal */ modalClose.addEventListener('click', onModalClosed); window.onclick = event => { if (event.target === modal) { onModalClosed(event); } }; /* End closing modal */ /* Start information modal */ onIntroductionModalOpened(modal); /* End information modal */ /* Start promotions widget */ if (promotions && promotions.length > 0 && typeof generateProductDetailPromotions === 'function' && typeof onPromotionModalOpened === 'function') { onPromotionModalOpened(modal, promotions); } /* End promotions widget */ /* End attaching events to template */ }; (function () { if (!window.fundiin && !window.fundiin?.productDetail) { return; } const stylesheet = document.createElement('style'); stylesheet.innerHTML = generateProductDetailStyle(); document.head.appendChild(stylesheet); const mainFunction = () => { const containerV2 = document.getElementById('script-general-container'); const containerV1 = document.getElementById('script-product-detail'); if (!containerV2 && !containerV1) { return; } const container = !!containerV2 ? containerV2 : containerV1; let totalPrice = 0; if (typeof fundiinDetailConfig !== 'undefined' && !!fundiinDetailConfig?.data && !!fundiinDetailConfig?.data?.amount) { totalPrice = fundiinDetailConfig?.data?.amount; } if (typeof price !== 'undefined') { totalPrice = price; } const { productDetail } = window.fundiin; const { bannerDescription = '', installmentPlan = undefined, promotions = [], } = productDetail; /* Start creating content of template */ const generateDescription = price => { const comparedPrice = 200000; const convertCurrency = result => Math.floor(result).toLocaleString('vi-VN', { style: 'currency', currency: 'VND' }); if (price <= comparedPrice && installmentPlan?.revolving) { return `Mua trả sau ${convertCurrency(0)} với`; } if (installmentPlan?.twoPhases) { return `Trả sau ${convertCurrency(price / 2)} x2 kỳ với`; } if (installmentPlan?.threePhases) { return `Trả sau ${convertCurrency(price / 3)} x3 kỳ với`; } if (installmentPlan?.bnplPlus) { return 'Trả sau đến 12 tháng với'; } return 'Thanh toán ngay với'; }; container.innerHTML = ` ${generateDescription(totalPrice)}
${typeof generateProductDetailLogo === 'function' ? generateProductDetailLogo() : '
Fundiin
'}
${!!bannerDescription ? bannerDescription : 'Trả sau thoải mái, ít thủ tục, xét duyệt nhanh!'} ${!!promotions && promotions.length > 0 && typeof generateProductDetailPromotions === 'function' && typeof onPromotionModalOpened === 'function' ? `Xem thêm` : ''}
`; /* End creating content of template */ generateActionHandler(promotions); if (typeof detailTrackingScript === 'function') { detailTrackingScript(); } }; window.addEventListener('load', mainFunction); window.addEventListener('beforeunload', () => { window.removeEventListener('load', mainFunction); }); })();