diff --git a/wp-content/themes/cosmopet/modules/footer/assets/css/gp-style-desktop.css b/wp-content/themes/cosmopet/modules/footer/assets/css/gp-style-desktop.css index c791931..8e32830 100644 --- a/wp-content/themes/cosmopet/modules/footer/assets/css/gp-style-desktop.css +++ b/wp-content/themes/cosmopet/modules/footer/assets/css/gp-style-desktop.css @@ -291,6 +291,15 @@ gap: 24px!important; } +.login_inner img { + display: block; + margin: 40px auto; +} + +.login_title { + text-align: center; +} + @media screen and (max-width: 768px) { .footer_ae .footer__wrapper { width: 100%; diff --git a/wp-content/themes/cosmopet/modules/footer/assets/js/footer.js b/wp-content/themes/cosmopet/modules/footer/assets/js/footer.js index eeedb76..4e62de6 100644 --- a/wp-content/themes/cosmopet/modules/footer/assets/js/footer.js +++ b/wp-content/themes/cosmopet/modules/footer/assets/js/footer.js @@ -4,14 +4,20 @@ const metaLocale = document.querySelector('meta[property="og:locale"]'); const localeValue = metaLocale.getAttribute('content'); + // Флаг для предотвращения множественной обработки + let isProcessing = false; + // Login - $('.login_popup').on('click', function(e){ e.preventDefault(); $('.login_modal').addClass('active'); }); $('.login_close').on('click', function(){ $('.login_modal').removeClass('active'); + $('.login_forms').removeClass('hide'); + $('.login_success').addClass('hide'); + $('.login_auth').addClass('hide'); + isProcessing = false; // Сбрасываем флаг при закрытии }); $('.login_back').on('click', function(){ if($(this).is('.disabled')) { @@ -49,9 +55,7 @@ } } }); - } - }); $('.js-repeat-code').on('click', function(){ $('.login_input').removeClass('error'); @@ -59,62 +63,75 @@ }); function send_code(){ - $('.login_timer').show(); - $('.js-repeat-code').hide(); - $('.login_back').addClass('disabled'); - // Timer - var seconds = 15; - var interval = setInterval(function() { - if (seconds > 0) { - seconds--; - $('.seconds').text(seconds); - } else { - clearInterval(interval); - $('.login_timer').hide(); - $('.js-repeat-code').show(); - $('.login_back').removeClass('disabled'); - $('.seconds').text(15); - } - }, 1000); - //Ajax отправка кода - $.ajax({ - type: 'POST', - url: '/wp-admin/admin-ajax.php', - data: {action: 'send_code', email: $('.js-input-email input').val()} - }); + $('.login_timer').show(); + $('.js-repeat-code').hide(); + $('.login_back').addClass('disabled'); + // Timer + var seconds = 15; + var interval = setInterval(function() { + if (seconds > 0) { + seconds--; + $('.seconds').text(seconds); + } else { + clearInterval(interval); + $('.login_timer').hide(); + $('.js-repeat-code').show(); + $('.login_back').removeClass('disabled'); + $('.seconds').text(15); + } + }, 1000); + // Ajax отправка кода + $.ajax({ + type: 'POST', + url: '/wp-admin/admin-ajax.php', + data: {action: 'send_code', email: $('.js-input-email input').val()} + }); } // Проверка кода и регистрация/авторизация $('.js-input-code input').on('input keydown keyup propertychange paste cut copy change', function(){ var val = $(this).val(); var email = $('.js-input-email input').val(); - if(val.length === 4) { - $.ajax({ + if(val.length === 4 && !isProcessing) { + isProcessing = true; // Устанавливаем флаг, чтобы предотвратить повторную обработку + $.ajax({ type: 'POST', url: '/wp-admin/admin-ajax.php', data: {action: 'check_code', code: val, email: email}, success: function(data){ - console.log(data); - if(data['status'] == 'success_reg') { + console.log('Server response:', data); // Отладка ответа сервера + if(data['status'] === 'success_reg') { $('.login_forms').addClass('hide'); $('.login_success').removeClass('hide'); + $('.login_auth').addClass('hide'); // Гарантируем, что login_auth скрыт if (typeof wc_checkout_params !== 'undefined') { - location.reload() + location.reload(); } - } - if(data['status'] == 'success_auth') { + } else if(data['status'] === 'success_auth' && !$('.login_success').is(':visible')) { $('.login_forms').addClass('hide'); $('.login_auth').removeClass('hide'); + $('.login_success').addClass('hide'); // Гарантируем, что login_success скрыт if (typeof wc_checkout_params !== 'undefined') { - location.reload() + location.reload(); } - } - if(data['status'] == 'error') { + } else if(data['status'] === 'error') { $('.js-input-code').addClass('error'); $('.js-input-code .login_error').text(data['text']); - } + isProcessing = false; // Сбрасываем флаг при ошибке + } else { + console.error('Unexpected status:', data['status']); + $('.js-input-code').addClass('error'); + $('.js-input-code .login_error').text(localeValue == 'en_US' ? 'Unexpected error occurred' : 'Произошла непредвиденная ошибка'); + isProcessing = false; // Сбрасываем флаг при неожиданном статусе + } + }, + error: function(xhr, status, error) { + console.error('AJAX error:', error); // Отладка ошибок AJAX + $('.js-input-code').addClass('error'); + $('.js-input-code .login_error').text(localeValue == 'en_US' ? 'Server error' : 'Ошибка сервера'); + isProcessing = false; // Сбрасываем флаг при ошибке AJAX } }); - } + } }); $('.email_link_form').on('submit', function(e){ @@ -131,12 +148,9 @@ } else { location.reload(); } - } }); }); - - })(jQuery); function checkImage(imageSrc, good) { diff --git a/wp-content/themes/cosmopet/static/img/people.png b/wp-content/themes/cosmopet/static/img/people.png new file mode 100644 index 0000000..d1388e7 Binary files /dev/null and b/wp-content/themes/cosmopet/static/img/people.png differ diff --git a/wp-content/themes/cosmopet/templates/modal/login.twig b/wp-content/themes/cosmopet/templates/modal/login.twig index 1ebb67c..8b00e47 100644 --- a/wp-content/themes/cosmopet/templates/modal/login.twig +++ b/wp-content/themes/cosmopet/templates/modal/login.twig @@ -42,7 +42,7 @@
{% if site_region == 'ru' %}Теперь вы можете получать промокоды за покупки.{% elseif site_region == 'ae' %}Now you can receive promo codes for purchases.{% endif %}
- + {% if site_region == 'ru' %}Заполнить профиль{% elseif site_region == 'ae' %}Fill out profile{% endif %} @@ -52,7 +52,7 @@

{% if site_region == 'ru' %}Вы вошли в систему{% elseif site_region == 'ae' %}You have logged in{% endif %}

- + {% if site_region == 'ru' %}Профиль{% elseif site_region == 'ae' %}Profile{% endif %}