var Webflow = Webflow || []; Webflow.push(function () { const DATA_URL = `https://myprofile-api-prod.remoteapi.ge/myprofileportal/api/life-critical/GetPolicyInfo`; const isMobile = 768 > window.innerWidth; initPayLimit(); initMenu(); var urlParams = new URLSearchParams(window.location.search); let proposaId = 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", "ProposalId": proposaId, "ContrahentId": contrahentId // 'SecretUserName': 'landingInfo', // 'SecretPassword': 'E3@`{L-Mf%dx', // 'Requester': 'MyProfilePortal', // 'UserId': null, // 'SessionID': '559e670a22874755b351a465dccf4134', // // 'PolicyId': 423938, // // 'ContrahentID': 468872 // 'PolicyId': policyId, // 'ContrahentID': contrahentId }; //$('.s-loading').css('display', 'none'); loadData(proposaId, contrahentId); // $('.s-loading').addClass('is--done'); // --------------------------------------------------------------------------------------------------------------------------------------- async function loadData(proposaId, contrahentId) { let data; try { const resp = await fetch(DATA_URL, { method: "POST", headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify(REQ_PARAMS), }); data = await resp.json(); } catch (error) { // --none this function---- showNotFound(); console.log(error); } finally { $('.s-loading').css('display', 'none'); } console.log("DATA: ", data); if (data.isSuccess && data.proposalInfo !== null) { if (data.proposalInfo.getProposalForLifeCriticalModelsResponse.productId === 1) { console.log('Life'); $(window).scrollTop(0); processData(data.proposalInfo.getProposalForLifeCriticalModelsResponse, data); $('.nav-links__wrap-critical-life').hide(); $('.nav-links__wrap-critical').hide(); $('.nav-links__wrap-life').show(); $('.pay-limit__item.critical').hide(); $('.pay-limit__item.critical-life').hide(); $('.pay-limit__item.life').show(); $('.header__left-critical-life').hide(); $('.header__left-life').show(); $('.header__left-life').css('display', 'flex'); $('.header__left-critical').hide(); $('.auth-drivers__critical-life').hide(); $('.auth-drivers__life').show(); $('.auth-drivers__life').css('display', 'flex'); $('.auth-drivers__critical').hide(); $('.s-major-exc__wrap-critical-life').hide(); $('.s-major-exc__wrap-life').show(); $('.s-major-exc__wrap-critical').hide(); $('#card_life').show(); $('#title-cards-life').show(); $('#title-cards-critical-life').hide(); $('#card_critical_life').hide(); $('#card_critical').hide(); $('.s-section-2__wrap-critical-life').hide(); $('.s-section-2__wrap-life').show(); $('.s-section-2__wrap-critical').hide(); $('.s-make-call').hide(); $('.s-section-white').hide(); $('#life_info').show(); $('.auth.second-life_info').css('display', 'flex'); $('#life-info').show(); $('#critical-info').hide(); $('#critical-life-info').hide(); $('.s-major-exc__critical-life').hide(); $('.s-major-exc__life').show(); $('.s-major-exc__critical').hide(); // $('.s-section-2__info-critical-life').hide(); $('.s-section-2__info-life').show(); $('.card__text.sld-critical-life').hide(); $('.card__text.sld-life').show(); $('.s-section-white-last').show(); $('.s-faq__wrap-critical-life').hide(); $('.s-faq__wrap-life').show(); $('.s-faq__wrap-critical').hide(); // $('.s-loading').css('display', 'block'); } else if (data.proposalInfo.getProposalForLifeCriticalModelsResponse.productId === 2) { console.log('Critical'); $(window).scrollTop(0); processData(data.proposalInfo.getProposalForLifeCriticalModelsResponse, data); $('.nav-links__wrap-critical-life').hide(); $('.nav-links__wrap-critical').show(); $('.nav-links__wrap-life').hide(); $('.pay-limit__item.critical').show(); $('.pay-limit__item.critical-life').show(); $('.pay-limit__item.life').hide(); $('.header__left-critical-life').hide(); $('.header__left-life').hide(); $('.header__left-critical').show(); $('.header__left-critical').css('display', 'flex'); $('.auth-drivers__critical-life').hide(); $('.auth-drivers__life').hide(); $('.auth-drivers__critical').show(); $('.auth-drivers__critical').css('display', 'flex'); $('.s-major-exc__wrap-critical-life').hide(); $('.s-major-exc__wrap-life').hide(); $('.s-major-exc__wrap-critical').show(); $('#card_life').hide(); $('#card_critical_life').hide(); $('#title-cards-life').hide(); $('#title-cards-critical-life').show(); $('#card_critical').show(); $('#card_critical').css("display", "flex"); $('.s-section-2__wrap-critical-life').hide(); $('.s-section-2__wrap-life').hide(); $('.s-section-2__wrap-critical').show(); $('.s-make-call').show(); $('.s-section-white').hide(); $('#life-info').hide(); $('#critical-info').show(); $('#critical-life-info').hide(); $('.s-major-exc__critical-life').hide(); $('.s-major-exc__life').hide(); $('.s-major-exc__critical').show(); $('.s-section-2__info-critical-life').hide(); $('.s-section-2__info-life').hide(); $('.s-section-white-last').hide(); $('.s-faq__wrap-critical-life').hide(); $('.s-faq__wrap-life').hide(); $('.s-faq__wrap-critical').show(); // $('.s-loading').css('display', 'block'); } else if (data.proposalInfo.getProposalForLifeCriticalModelsResponse.productId === 3) { console.log('Life-critical'); $(window).scrollTop(0); processData(data.proposalInfo.getProposalForLifeCriticalModelsResponse, data); $('.nav-links__wrap-critical-life').show(); $('.nav-links__wrap-critical').hide(); $('.nav-links__wrap-life').hide(); $('.pay-limit__item.critical').show(); $('.pay-limit__item.critical-life').show(); $('.pay-limit__item.life').show(); $('.header__left-critical-life').show(); $('.header__left-critical-life').css('display', 'flex'); $('.header__left-life').hide(); $('.header__left-critical').hide(); $('.auth-drivers__critical-life').show(); $('.auth-drivers__critical-life').css('display', 'flex'); $('.auth-drivers__life').hide(); $('.auth-drivers__critical').hide(); $('.s-major-exc__wrap-critical-life').show(); $('.s-major-exc__wrap-life').hide(); $('.s-major-exc__wrap-critical').hide(); $('#card_life').hide(); $('#card_critical_life').show(); $('#title-cards-life').hide(); $('#title-cards-critical-life').show(); $('#card_critical_life').css("display", "flex"); $('#card_critical').hide(); $('.s-section-2__wrap-critical-life').show(); $('.s-section-2__wrap-life').hide(); $('.s-section-2__wrap-critical').hide(); $('.s-make-call').show(); $('.s-section-white').show(); $('#life-info').hide(); $('#critical-info').hide(); $('#critical-life-info').show(); $('.s-major-exc__critical-life').show(); $('.s-major-exc__life').hide(); $('.s-major-exc__critical').hide(); $('.s-section-2__info-critical-life').show(); $('.s-section-2__info-life').hide(); $('.card__text.sld-critical-life').show(); $('.card__text.sld-life').hide(); $('.s-section-white-last').show(); $('.s-faq__wrap-critical-life').show(); $('.s-faq__wrap-life').hide(); $('.s-faq__wrap-critical').hide(); // $('.s-loading').css('display', 'block'); } } else { showNotFound(); // console.log(data.description); // if (data.description == "Offer not Found") { // // console.log(data.description); // $('#status1').show(); // $('#status2').hide(); // } else if (data.description == "Offer Is Expired") { // // console.log(data.description); // $('#status1').hide(); // $('#status2').show(); // }; } // setTimeout(() => { // $(".s-loading").addClass("is--done"); // }, 300); } function processData(data, fullData) { $("[contrahentFirstName]").text(data["contrahentFirstName"]); $("[policyInformationUrl]").attr("href", data["policyInformationUrl"]); $("[policyInformationUrl]").attr("target", "_blank"); $("[policyWordingUrl]").attr("href", data["policyWordingUrl"]); $("[policyWordingUrl]").attr("target", "_blank"); $("[policyAge]").text(data["policyAge"]); $("[productId]").text(data["productId"]); $("[effectiveDate]").text(data["effectiveDate"]); $("[wording]").text(data["wording"]); $("[appLink]").text(data["appLink"]); $("[shortPolicyWordingUrl]").text(data["shortPolicyWordingUrl"]); $("[policyInformationUrl]").text(data["policyInformationUrl"]); $(".pay-limit-cta-2").attr("href", data["onLink"]); $(".pay-limit-cta-2").attr("target", "_blank"); $(".pay-limit-cta").attr("href", data["onLink"]); $(".pay-limit-cta").attr("target", "_blank"); $("[lifeSumInsured]").text(data["lifeSumInsured"]); $("[criticalSumInsured]").text(data["criticalSumInsured"]); $("[criticalPreInvasumInsured]").text(data["criticalPreInvasumInsured"]); $("[limitCurrency]").text(data["limitCurrency"]); $("[premium]").text(data["premium"]); $("[averagePremium]").text(data["averagePremium"]); $("[instalmentName]").text(data["instalmentName"]); $("[instalmentNumber]").text(data["instalmentNumber"]); $("[premiumCurrency]").text(data["premiumCurrency"]); $("[deductibleId]").text(data["deductibleId"]); $("[contrahentId]").text(data["contrahentId"]); $("[contrahentFirstName]").text(data["contrahentFirstName"]); $("[hasPolicy]").text(data["hasPolicy"]); $("[createdOn]").text(data["createdOn"]); $("[firstPayment]").text(data["firstPayment"]); $("[offerExpired]").text(data["offerExpired"]); // if (data['firstPayment'] === true) { // // console.log(true); // $(".pay-limit-cta").attr('disabled','disabled'); // $(".pay-limit-cta").addClass('is--disabled'); // }; // const mp = data["motorPolicy"]; // $("[makeName]").text(mp["makeName"]); // $("[modelName]").text(mp["modelName"]); // $("[vehicleYear]").text(`${mp["vehicleYear"]}წ`); // --------------------------- const CURRENCY = data["premiumCurrency"] == "USD" ? "$" : data["premiumCurrency"] == "EUR" ? "€" : data["premiumCurrency"] == "GEL" ? "₾" : ""; let sumsNum = 0; // $("[lifeSumInsured]").text(data["lifeSumInsured"]); const lifeSumInsured = data["lifeSumInsured"]; // const sumInsured = data["premium"] / data["sumInsured"]; $("[lifeSumInsured]").text( new Intl.NumberFormat("fr-FR").format(lifeSumInsured.toFixed(2)) + " " + CURRENCY ); const averagePremium = data["averagePremium"]; // const sumInsured = data["premium"] / data["sumInsured"]; $("[averagePremium]").text( new Intl.NumberFormat("fr-FR").format(averagePremium.toFixed(2)) + " " + CURRENCY ); const criticalSumInsured = data["criticalSumInsured"]; // const sumInsured = data["premium"] / data["sumInsured"]; $("[criticalSumInsured]").text( new Intl.NumberFormat("fr-FR").format(criticalSumInsured.toFixed(2)) + " " + CURRENCY ); const criticalPreInvasumInsured = data["criticalPreInvasumInsured"]; // const sumInsured = data["premium"] / data["sumInsured"]; $("[criticalPreInvasumInsured]").text( new Intl.NumberFormat("fr-FR").format(criticalPreInvasumInsured.toFixed(2)) + " " + CURRENCY ); // $("[sumInsured]").text( // `${CURRENCY}` // ); sumsNum++; const classFix = sumsNum == 3 ? "col-3" : sumsNum == 2 ? "col-2" : ""; $(".violet-cards").addClass(classFix); // --------------------------- const policyCta = $(".c-policy-popup__cta"); //---------------------------------------------------------------- //$('[policyNumberLinkAccepted]').attr('href', `https://on.tbcinsurance.ge/pay?policy=${data['policyNumber']}`); // $("[policyNumberLinkAccepted]").attr("target", `_blank`); $(".c-policy-popup [policyWordingUrl]").text( `დაზღვევის პირობებს #${data["wording"]}` ); //-------------------------------------------------------------------- $(".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 ); $(".auth-drivers__any").hide(); $(".auth-drivers__named").show(); // --------------------------------------- //$('.violet-card.new').css("display", "flex"); //$('.violet-card').css("display", "none"); } // --------------------------- // const deductibleId = data["deductibleId"]; let deductibleId_1, deductibleId_2, deductibleTitleId_1, deductibleTitleId_2; $("[franchiseAddPlate]").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"); if (isOpen) { navbar.removeClass("is--open"); if(window.matchMedia('(max-width: 768px)').matches) { $("body").css("overflow", "visible"); } } else { navbar.addClass("is--open"); if(window.matchMedia('(max-width: 768px)').matches) { $("body").css("overflow", "hidden"); } if(window.matchMedia('(min-width: 769px)').matches) { $("body").css("overflow", "visible"); } } }); links.on("click", () => { navbar.removeClass("is--open"); if(window.matchMedia('(max-width: 768px)').matches) { $("body").css("overflow", "visible"); } }); } 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"); 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"); } else { dropdown.addClass("is--open"); } } } } function initScrollAnims() { const REVEAL_START = "top 70%"; const REVEAL_FROM_Y = 100; const REVEAL_DURATION = 0.7; const REVEAL_EASE = "power3.out"; const REVEAL_STAGGER = 0.07; // ----- sections reveal // 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%", // }); } });