var Webflow = Webflow || []; Webflow.push(function() { const DATA_URL = `https://myprofile-api-prod.remoteapi.ge/myprofileportal/api/PropertyHouse/GetPolicyInfo`; /* const isTablet = window.innerWidth < 992;*/ /*if (isTablet) initPayLimit();*/ const isProduction = true; const SMS_URL_TEST = 'https://myprofile-api-test.remoteapi.ge/myprofileportal/api/PropertyHouse/SendSmsEMail'; const SMS_URL_PROD = 'https://myprofile-api-prod.remoteapi.ge/myprofileportal/api/PropertyHouse/SendSmsEMail'; const SMS_URL = isProduction ? SMS_URL_PROD : SMS_URL_TEST; const isDesktop = window.innerWidth >= 992; const isMobile = 768 > window.innerWidth; initPayLimit(); initMenu(); var urlParams = new URLSearchParams(window.location.search); let policyId = urlParams.has('pid') ? urlParams.get('pid') : ''; let contrahentId = urlParams.has('cid') ? urlParams.get('cid') : ''; const REQ_PARAMS = { "SecretUserName":"landingInfo", "SecretPassword":"!DH2Zfdje^-$Ka2>VZV9", 'Requester': 'MyProfilePortal', 'UserId': null, 'SessionID': '559e670a22874755b351a465dccf4134', // 'PolicyId': 416732, // 'ContrahentID': 468872, 'PolicyId': policyId, 'ContrahentID': contrahentId, }; loadData(policyId, contrahentId); // $('.s-loading').addClass('is--done'); // --------------------------------------------------------------------------------------------------------------------------------------- $('body').css('overflow', 'hidden'); // $('.c-page-wrapper').css('position', 'relative'); // $('.c-page-wrapper').css('overflow', 'hidden'); // $('.c-page-wrapper').css('min-height', '100vh'); async function loadData(policyId, contrahentId) { const resp = await fetch(DATA_URL, { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({ 'SecretUserName': 'landingInfo', 'SecretPassword': '!DH2Zfdje^-$Ka2>VZV9', 'Requester': 'MyProfilePortal', 'UserId': null, 'SessionID': '559e670a22874755b351a465dccf4134', // 'PolicyId': 423662, // 'ContrahentID': 468872, 'PolicyId': policyId, 'ContrahentID': contrahentId, }), }); const data = await resp.json(); console.log('DATA: ', data); if (data.isSuccess && data.getPolicyForPropertyHouseModelsResponse !== null) { processData(data.getPolicyForPropertyHouseModelsResponse, data); } else { showNotFound(); if (data.status == 1) { // console.log('status1'); $('#status1').show(); $('#status2').hide(); } else if (data.status == 2) { // console.log('status2'); $('#status1').hide(); $('#status2').show(); }; } console.log(data.status); setTimeout(() => { $('body').css('overflow', 'visible'); // $('.c-page-wrapper').css('overflow', 'visible'); // $('.c-page-wrapper').css('position', 'static'); // $('.c-page-wrapper').css('min-height', 'auto'); $('.s-loading').addClass('is--done'); }, 1000); } function processData(data, fullData) { $('[contrahentFirstName]').text(data['contrahentFirstName']); $('[propertyDeductible]').text(data['propertyDeductible']); $('[propertyTplDeductible]').text(data['propertyTplDeductible']); $('[policyInformationUrl]').attr('href', data['policyInformationUrl']); $('[policyInformationUrl]').attr('target', '_blank'); $('[policyWordingUrl]').attr('href', data['policyWordingUrl']); $('[policyWordingUrl]').attr('target', '_blank'); $('[earthquakeDeductible]').text(data['earthquakeDeductible']); $('[propertyDeductible]').text(data['propertyDeductible']); $('[deductibleComment]').text(data['deductibleComment']); $('[wording]').text(data['wording']); // let deductibe = 1; // let yearofBuilding = 0; let deductible = data['deductible']; let yearofBuilding = data['yearofBuilding']; if (data['isRental'] === true) { // console.log(true) // $('#last').show(); $('#last-line-card').show(); $('#is-rental').show(); $('#is-rental-big').show(); } else { // $('#last').hide(); $('#last-line-card').hide(); $('#is-rental').hide(); $('#is-rental-big').hide(); // console.log(false) }; if (data['hail'] === false) { $('#hail').hide(); $('#hail-mobile').hide(); } else { $('#hail').show(); $('#hail-mobile').show(); }; if (data['robbery'] === false) { $('#robbery').hide(); $('#robbery-guns').hide(); $('#robbery-mobile').hide(); $('#robbery-guns-mobile').hide(); } else { $('#robbery').show(); $('#robbery-guns').show(); $('#robbery-mobile').show(); $('#robbery-guns-mobile').show(); }; if (data['fire'] === false) { $('#fire').hide(); $('#fire-mobile').hide(); } else { $('#fire').show(); $('#fire-mobile').show(); }; if (data['electricalfailure'] === false) { $('#electrical-failure').hide(); $('#electrical-failure-mobile').hide(); } else { $('#electrical-failure').show(); $('#electrical-failure-mobile').show(); }; if (data['transportCollision'] === false) { $('#transport-collision').hide(); $('#transport-collision-mobile').hide(); } else { $('#transport-collision').show(); $('#transport-collision-mobile').show(); }; if (deductible === 1) { // console.log('deductible=1'); $('#first-deductible').show(); $('#second-deductible').show(); $('#fran-damage-title-large').show(); $('#fran-damage-title-small').hide(); $('#third-deductible').show(); $('#last-deductible').hide(); } else if (deductible === 2) { // console.log('deductible=2'); $('#first-deductible').show(); $('#second-deductible').show(); $('#fran-damage-title-large').show(); $('#fran-damage-title-small').hide(); $('#third-deductible').hide(); $('#last-deductible').hide(); } else if (deductible === 3) { // console.log('deductible=3'); $('#first-deductible').hide(); $('#second-deductible').show(); $('#fran-damage-title-large').hide(); $('#fran-damage-title-small').show(); $('#third-deductible').show(); $('#last-deductible').hide(); } else if (deductible === 4) { // console.log('deductible=4'); $('#first-deductible').hide(); $('#second-deductible').show(); $('#fran-damage-title-large').hide(); $('#fran-damage-title-small').show(); $('#third-deductible').hide(); $('#last-deductible').hide(); } else if (deductible === 5) { // console.log('deductible=5'); $('#first-deductible').hide(); $('#second-deductible').hide(); $('#fran-damage-title-large').hide(); $('#fran-damage-title-small').show(); $('#third-deductible').hide(); $('#last-deductible').show(); } else { // console.log('deductible'); $('#first-deductible').show(); $('#second-deductible').show(); $('#fran-damage-title-large').show(); $('#fran-damage-title-small').hide(); $('#third-deductible').show(); $('#last-deductible').hide(); }; if (yearofBuilding === 19) { // console.log('yearofBuilding=19'); $('#first-yearofBuilding').show(); $('#second-yearofBuilding').hide(); } else { // console.log('yearofBuilding'); $('#first-yearofBuilding').hide(); $('#second-yearofBuilding').show(); } // if (data['firstPayment'] === true) { // // console.log(true) // $('#btn-desibled').attr('disabled' , true); // } else { // $('#btn-desibled').attr('disabled' , false); // // console.log(false) // }; if (data['firstPayment'] === true) { // console.log(true); $(".pay-limit-cta").attr('disabled','disabled'); $(".pay-limit-cta").addClass('is--disabled'); }; if (data['propertyTplSumInsured'] > 0) { // console.log('show') $('#first-violet-card').show(); $('#second-violet-card').hide(); $('#nav-link-tpl').show(); $('#section3').show(); $('.pay-limit__item-last').show(); $('#last').show(); $('#last-nav-pay-item').show(); $('#mobile-last-nav-pay-item').show(); } else { $('#first-violet-card').hide(); $('#second-violet-card').show(); $('#nav-link-tpl').hide(); $('#section3').hide(); $('.pay-limit__item-last').hide(); $('#last').hide(); $('#last-nav-pay-item').hide(); $('#mobile-last-nav-pay-item').hide(); // console.log('hide') }; const mp = data['motorPolicy']; // -------------- info car -------------------------- // $('[makeName]').text(mp['makeName']); // $('[modelName]').text(mp['modelName']); // $('[vehicleYear]').text(`${mp['vehicleYear']}წ`); // --------------------------- const CURRENCY = data['premiumCurrency'] == 'USD' ? '$' : data['premiumCurrency'] == 'EUR' ? '€' : data['premiumCurrency'] == 'GEL' ? '₾' : ''; // const CURRENCY = 'USD' ? '$' : ''; /* let cascoSumInsured = mp['cascoSumInsured']; let mtplSumInsured = mp['mtplSumInsured']; let mpaSumInsured = mp['mpaSumInsured']; */ //----------Start Rounding the amount--------------------------- function num(e) { return (e % 1) === 0 ? e.toFixed(0) : e.toFixed(2); } // console.log(num(28.335)); //----------End Rounding the amount--------------------------- let propertySumInsured1M2 = data['propertySumInsured1M2']; let sumInsuredForFurniture = data['sumInsuredForFurniture']; let propertyTplSumInsured = data['propertyTplSumInsured']; let premium = num(data['premium'] / data['instalmentNumber']); let sumInsured = data['sumInsured']; let sumInsuredForInterior = data['sumInsuredForInterior']; // let sumInsuredForInterior = 15050; let sumInsuredForStructuralElements = data['sumInsuredForStructuralElements']; // let sumInsuredForStructuralElements = 36500; // let sumInsured = $('[sumInsured]').text(data['sumInsured']); // let sumInsuredForFurniture = $('[sumInsuredForFurniture]').text(data['sumInsuredForFurniture']); // let propertyTplSumInsured = mp['propertyTplSumInsured']; let sumsNum = 0; if (propertySumInsured1M2 <= 0) { $('[propertySumInsured1M2]').hide(); } else { //console.log(propertySumInsured1M2); propertySumInsured1M2 = new Intl.NumberFormat('fr-FR').format(propertySumInsured1M2); $('[propertysuminsured1m2]').text(`${propertySumInsured1M2} ${CURRENCY}`); sumsNum++; } if (sumInsuredForFurniture <= 0) { $('[sumInsuredForFurniture]').hide(); } else { sumInsuredForFurniture = new Intl.NumberFormat('fr-FR').format(sumInsuredForFurniture); $('[sumInsuredForFurniture]').text(`${sumInsuredForFurniture} ${CURRENCY}`); sumsNum++; } if (sumInsuredForInterior <= 0) { $('[sumInsuredForInterior]').hide(); } else { sumInsuredForInterior = new Intl.NumberFormat('fr-FR').format(sumInsuredForInterior); $('[sumInsuredForInterior]').text(`${sumInsuredForInterior} ${CURRENCY}`); sumsNum++; } if (sumInsuredForStructuralElements <= 0) { $('[sumInsuredForStructuralElements]').hide(); } else { sumInsuredForStructuralElements = new Intl.NumberFormat('fr-FR').format(sumInsuredForStructuralElements); $('[sumInsuredForStructuralElements]').text(`${sumInsuredForStructuralElements} ${CURRENCY}`); sumsNum++; } if (propertyTplSumInsured <= 0) { $('[propertyTplSumInsured]').hide(); } else { propertyTplSumInsured = new Intl.NumberFormat('fr-FR').format(propertyTplSumInsured); $('[propertyTplSumInsured]').text(`${propertyTplSumInsured} ${CURRENCY}`); sumsNum++; } if (premium <= 0) { $('[premium]').hide(); } else { premium = new Intl.NumberFormat('fr-FR').format(premium); $('[premium]').text(`${premium} ${CURRENCY}`); sumsNum++; } if (sumInsured <= 0) { $('[sumInsured]').hide(); } else { sumInsured = new Intl.NumberFormat('fr-FR').format(sumInsured); $('[sumInsured]').text(`${sumInsured} ${CURRENCY}`); sumsNum++; } const classFix = (sumsNum == 3) ? 'col-3' : (sumsNum == 2) ? 'col-2' : ''; $('.violet-cards').addClass(classFix); // --------------------------- const policyCta = $('.c-policy-popup__cta'); $("[policyNumberLinkAccepted]").on("click", async (e) => { let loading = true; if (loading) { $(".s-pre-loading").css("display", "flex"); $("body").css("overflow", "hidden"); } if (fullData.description == "Ok" && fullData.status == 0) { // console.log("loading"); //window.open(`https://on.tbcinsurance.ge/pay?policy=${data["policyNumber"]}`, '_blank' ); // e.preventDefault(); try { const resp = await fetch(SMS_URL, { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify(REQ_PARAMS), }); const repsData = await resp.json(); // console.log('>> ', repsData); if (repsData.description == 'Ok' && repsData.status == 0) { loading = false; // window.open(`https://on.tbcinsurance.ge/pay?policy=${data["policyNumber"]}` ); $(location).attr( "href", `https://on.tbcinsurance.ge/pay?policy=${data["policyNumber"]}`); setTimeout(function(){ console.log('setTimeout'); $(".s-pre-loading").css("display", "none"); }, 3000); } else { $(".s-pre-loading").css("display", "none"); $(".s-error-not-found").css("display", "flex"); $("body").css("overflow", "hidden"); // console.error(e); } // console.log('>> ', repsData); } catch (e) { $(".s-pre-loading").css("display", "none"); $(".s-error-not-found").css("display", "flex"); $("body").css("overflow", "hidden"); // console.error(e); } } }); // ------------------------------------------ // $('[policyNumberLinkAccepted]').attr('href', `https://on.tbcinsurance.ge/pay?policy=${data['policyNumber']}`); // $('[policyNumberLinkAccepted]').attr('target', `_blank`); $('.c-policy-popup [policyWordingUrl]').text(`დაზღვევის პირობებს #${data['wording']}`); // $('[policyNumberLink]').on('click', () => { // showAcceptPopup(true); // }); // ------------------------------------------ $("[policyNumberLink]").on("click", () => { if ( data["firstPayment"] === false && data["policyStatus"] === 0 ) { //console.log(false); //window.open(`https://on.tbcinsurance.ge/pay?policy=${data["policyNumber"]}` ); $("[policyNumberLink]").attr("href", `https://on.tbcinsurance.ge/pay?policy=${data["policyNumber"]}`); $("[policyNumberLink]").attr("target", `_blank`); // $(location).attr( "href", `https://on.tbcinsurance.ge/pay?policy=${data["policyNumber"]}`); } else { showAcceptPopup(true); } //showAcceptPopup(true); }); // ------------------------------------------ $('.c-policy-popup__close, .c-popups-holder__bg').on('click', () => { showAcceptPopup(false); }); $('.c-policy-popup__chb').on('change', () => { policyCta.toggleClass('is--disabled'); }); policyCta.addClass('is--disabled'); function showAcceptPopup(st) { if (st) $('.c-popups-holder').addClass('is--active'); else $('.c-popups-holder').removeClass('is--active'); } // --------------------------- $('[instalmentName]').text(data['instalmentName']); const instalmentNumber = data['premium'] / data['instalmentNumber']; $('[instalmentNumber]').text(new Intl.NumberFormat('fr-FR').format(instalmentNumber.toFixed(2)) + ' ' + CURRENCY); // --------------------------- // --------------------------- const deductibleId = data['deductibleId']; let deductibleId_1, deductibleId_2, deductibleTitleId_1, deductibleTitleId_2, propertyDeductible; $('[franchiseAddPlate]').hide(); // --------------------------- const benefits = data['benefits']; if (benefits && benefits.length > 0) { let str = ''; const len = benefits.length; benefits.forEach((benefit, i) => { // console.log(`${benefit.id} - ${benefit.description}`); const perc = benefit.description.includes('15%') ? '15%' : benefit.description.includes('20%') ? '20%' : '50%'; str += `
`; }); str += ` `; // $('.sld-discount__slide').remove(); $('.sld-discount__mask').empty(); $('.sld-discount__mask').append(str); Webflow.require('slider').redraw(); } else { $('[benefits]').hide(); } if (!benefits || benefits.length == 0) $('[unlim-car-wash]').hide(); // init anims AFTER we've constructed everything initScrollAnims(); } function showNotFound() { $('.s-not-found').css('display', 'flex'); $('body').css('overflow', 'hidden'); } function initMenu() { const navbar = $('.c-navbar'); const navBtn = navbar.find('.nav-menu-btn'); const links = navbar.find('.nav-link'); // const navMenu = navbar.find('.nav-menu'); navBtn.on('click', () => { const isOpen = navbar.hasClass('is--open'); $('body').css('overflow', 'hidden'); $('.c-page-wrapper').css('position', 'relative'); $('.c-page-wrapper').css('overflow', 'hidden'); $('.c-page-wrapper').css('height', '100vh'); if (isOpen) { navbar.removeClass('is--open'); $('body').css('overflow', 'visible'); $('.c-page-wrapper').css('overflow', 'visible'); $('.c-page-wrapper').css('position', 'static'); $('.c-page-wrapper').css('height', 'auto'); // console.log('menustop'); } else { navbar.addClass('is--open'); } }); links.on('click', () => { navbar.removeClass('is--open'); $('body').css('overflow', 'visible'); $('.c-page-wrapper').css('overflow', 'visible'); $('.c-page-wrapper').css('position', 'static'); $('.c-page-wrapper').css('height', 'auto'); }); } function initPayLimit() { const payLimits = $('.pay-limits-dd'); payLimits.each((i, el) => { limitInitDD(el); }); //const payLimitStatic = $(payLimits[0]); const payLimitStatic = isDesktop ? $('.s-drv-group') : $(payLimits[0]); const payLimitFixed = $(payLimits[1]); const payLimitFixed_DD = payLimitFixed.find('.pay-limits__dropdown'); let isPlOpen = false; window.addEventListener('scroll', () => { const plTop = payLimitStatic.offset().top; const scroll = window.scrollY; if (!isPlOpen && scroll > plTop) { isPlOpen = true; payLimitFixed.addClass('is--open'); } else if (isPlOpen && scroll < plTop) { isPlOpen = false; payLimitFixed.removeClass('is--open'); payLimitFixed_DD.removeClass('is--open'); } }); function limitInitDD(el) { const pl = $(el); const buttons = pl.find('.pay-limits__btn-text, .pay-limits__btn-arrow'); const dropdown = pl.find('.pay-limits__dropdown'); const arrowButtons = pl.find('.pay-limits__btn-arrow'); buttons.each((i, el) => { const $el = $(el); $el.on('click', toggleDD); }) function toggleDD() { const isOpen = dropdown.hasClass('is--open'); if (isOpen) { dropdown.removeClass('is--open'); arrowButtons.removeClass('is--up-arrow'); } else { dropdown.addClass('is--open'); arrowButtons.addClass('is--up-arrow'); } } } } function initScrollAnims() { const REVEAL_START = "top 70%"; const REVEAL_FROM_Y = 100; const REVEAL_DURATION = .7; const REVEAL_EASE = 'power3.out'; const REVEAL_STAGGER = .07; // ----- sections reveal //------------add new animation------------- ScrollTrigger.create({ trigger: '.s-section-2 .cards', animation: gsap.timeline().from('.s-section-2__wrap > *', { alpha: 0, y: REVEAL_FROM_Y, duration: REVEAL_DURATION, ease: REVEAL_EASE, stagger: REVEAL_STAGGER, }), start: REVEAL_START, // start: "top 90%", }); //------------------------------------------- ScrollTrigger.create({ trigger: '.s-section-2', animation: gsap.timeline().from('.s-section-2 .c-section-title, .s-section-2 .p-general, .s-section-2 .violet-cards > *', { alpha: 0, y: REVEAL_FROM_Y, duration: REVEAL_DURATION, ease: REVEAL_EASE, stagger: REVEAL_STAGGER, }), start: REVEAL_START, // start: "top 90%", }); //----------------------------------------------------- // const sec = $($('.s-section-2__wrap .pay-limits')[isDesktop ? 0 : 1]); //----------------------------------------------------- ScrollTrigger.create({ trigger: '.s-section-2 .pay-limits', animation: gsap.timeline().from('.s-section-2 .pay-limits > *', { alpha: 0, y: REVEAL_FROM_Y, duration: REVEAL_DURATION, ease: REVEAL_EASE, stagger: REVEAL_STAGGER, }), start: REVEAL_START, // start: "top 90%", }); ScrollTrigger.create({ trigger: '.s-drv-group .drv-group', animation: gsap.timeline().from('.s-drv-group .drv-group > *', { alpha: 0, y: REVEAL_FROM_Y, duration: REVEAL_DURATION, ease: REVEAL_EASE, stagger: REVEAL_STAGGER, }), start: REVEAL_START, // start: "top 90%", }); ScrollTrigger.create({ trigger: '.s-franchise .franchise', animation: gsap.timeline().from('.s-franchise .franchise > *', { alpha: 0, y: REVEAL_FROM_Y, duration: REVEAL_DURATION, ease: REVEAL_EASE, stagger: REVEAL_STAGGER, }), start: REVEAL_START, // start: "top 90%", }); ScrollTrigger.create({ trigger: '.s-major-exc', animation: gsap.timeline().from('.s-major-exc__wrap > *', { alpha: 0, y: REVEAL_FROM_Y, duration: REVEAL_DURATION, ease: REVEAL_EASE, stagger: REVEAL_STAGGER, }), start: REVEAL_START, // start: "top 90%", }); ScrollTrigger.create({ trigger: '.s-make-call', animation: gsap.timeline().from('.s-make-call__wrap > *', { alpha: 0, y: REVEAL_FROM_Y, duration: REVEAL_DURATION, ease: REVEAL_EASE, stagger: REVEAL_STAGGER, }), start: REVEAL_START, // start: "top 90%", }); ScrollTrigger.create({ trigger: '.s-advantages', animation: gsap.timeline().from('.s-advantages__wrap > *', { alpha: 0, y: REVEAL_FROM_Y, duration: REVEAL_DURATION, ease: REVEAL_EASE, stagger: REVEAL_STAGGER, }), start: REVEAL_START, // start: "top 90%", }); ScrollTrigger.create({ trigger: '.s-faq', animation: gsap.timeline().from('.s-faq .c-section-title, .s-faq .faq-list > *', { alpha: 0, y: REVEAL_FROM_Y, duration: REVEAL_DURATION, ease: REVEAL_EASE, stagger: REVEAL_STAGGER, }), start: REVEAL_START, // start: "top 90%", }); } });