diff --git a/components/checkout/checkout.html b/components/checkout/checkout.html index 67b74ff..b404fbc 100644 --- a/components/checkout/checkout.html +++ b/components/checkout/checkout.html @@ -5,6 +5,24 @@ if(count($_SESSION['CART']) <= 0) { header("location: /acquistare"); } + + if($_POST['login_usr'] && $_POST['login_pwd']) { + $q = mysqli_query($conn, "SELECT * FROM users WHERE email = '".trim($_POST['login_usr'])."' AND + password = '".md5(trim($_POST['login_pwd']))."'"); + $r = mysqli_fetch_array($q); + + if(mysqli_num_rows($q)) { + $_SESSION['AUTH'] = $r; + } else { + unset($_SESSION['AUTH']); + } + } + + if($getQ[1] == 'logout') { + unset($_SESSION['AUTH']); + header("location: /checkout"); + } + ?> @@ -14,55 +32,101 @@
Dettagli fatturazione - Sei già nostro cliente? + + Sei già nostro cliente? + + + +
+
+
+ E-mail + +
+
+ Password + +
+
+ +
+
+
-
+
Nome * - + required>
Cognome * - + required>
E-mail * - + required>
Telefono - + >
Indirizzo * - + required>
Città * - + required>
CAP * - + required>
Provincia * - required> $p) { - echo ""; + echo ""; } ?> +
-
+
Scegli una password * - + > deve essere di almeno 8 caratteri contenere almeno un numero, un carattere maiuscolo, uno minuscolo
-
+
Conferma password * - + >
Vuoi spedire ad un indirizzo diverso? diff --git a/components/checkout/checkout.js b/components/checkout/checkout.js index 60875c1..35098ff 100644 --- a/components/checkout/checkout.js +++ b/components/checkout/checkout.js @@ -8,9 +8,12 @@ $(document).ready( () => { const place = component.find('.place-order') const extraAddress = component.find('.different-address') const extraAddressRadio = component.find('input[name="other_address"]') - const toggleLogin = $('.toggle-login') + const toggleLogin = component.find('.toggle-login') + const toggleQuestion = component.find('.question') + const loginForm = component.find('.login-form') + const newUserForm = component.find('.new-user-form') let hasExtraAddress = false - let isNewUser = true + let isNewUser = newUserForm.hasClass('logged') ? false : true place.off('.click').on('click.click', () => { checkForm() @@ -18,6 +21,25 @@ $(document).ready( () => { toggleLogin.off('.click').on('click.click', () => { isNewUser = !isNewUser + + if(isNewUser) { + toggleLogin.html('Accedi') + toggleQuestion.html('Sei già nostro cliente?') + loginForm.fadeOut( () => { + newUserForm.slideDown({ + start: () => { newUserForm.css({ display: "flex" }) } + }) + }) + + } else { + toggleLogin.html('Registrati') + toggleQuestion.html('Non sei nostro cliente?') + newUserForm.fadeOut( () => { + loginForm.slideDown({ + start: () => { loginForm.css({ display: "flex" }) } + }) + }) + } }) extraAddressRadio.off('.click').on('click.click', (e) => { @@ -116,6 +138,8 @@ $(document).ready( () => { const placeOrder = (profile, isNewUser) => { + window.Spinner('show') + Apis.getCart().then( (data) => { const cartItems = data.cart let amount = 0 diff --git a/components/checkout/checkout.scss b/components/checkout/checkout.scss index 68f6175..6a848d6 100644 --- a/components/checkout/checkout.scss +++ b/components/checkout/checkout.scss @@ -23,6 +23,13 @@ cursor: pointer; } + .login-form { + display: none; + padding-top: 50px; + width: 80%; + margin: auto; + } + .label { display: block; @include font-style($font-sans, 700, $font-16); @@ -65,6 +72,10 @@ &.error { border: 1px solid $red; } + + &:disabled { + opacity: .5; + } } .different-address { diff --git a/pages/index.ejs b/pages/index.ejs index c272622..8af0b47 100644 --- a/pages/index.ejs +++ b/pages/index.ejs @@ -44,5 +44,9 @@ ${require('../components/footer/footer.html')} + +
+ +
diff --git a/src/js/index.js b/src/js/index.js index 974847b..eaa09fa 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -26,6 +26,14 @@ window.siteUrl = ENV.SITE_URL window.Apis = window.Apis || {} +window.Spinner = (action = 'show') => { + if(action == 'hide') { + $('body .loader').fadeOut() + } else { + $('body .loader').fadeIn() + } +} + window.Apis.addToCart = (pid, price, qty) => { return new Promise((resolve, reject) => { $.post(apiUrl + `/cart_add.php?buster=${new Date().getTime()}`, {pid: pid, price: price, qty: qty}).done( (data) => { diff --git a/src/scss/global.scss b/src/scss/global.scss index f0bce2d..8094303 100644 --- a/src/scss/global.scss +++ b/src/scss/global.scss @@ -7,6 +7,26 @@ body { background: $light-gray; color: $dark-gray; overflow-x: hidden; + + .loader { + display: none; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(255, 255, 255, 0.9); + z-index: 200; + + .spinner { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 250px; + animation: spinner 2s linear infinite; + } + } } @@ -138,6 +158,12 @@ button { } +@keyframes spinner { + 0% {opacity: 1;} + 50% {opacity: 0;} + 100% {opacity: 1;} +} + .debug-border { border: 1px solid red; }