Task:6887 | Изменение логики авторизации. Правки стилей и верстки поп-ап

pull/36/head
Your Name 2 months ago
parent db11843fca
commit b1c16bb1ea
  1. 9
      wp-content/themes/cosmopet/modules/footer/assets/css/gp-style-desktop.css
  2. 44
      wp-content/themes/cosmopet/modules/footer/assets/js/footer.js
  3. BIN
      wp-content/themes/cosmopet/static/img/people.png
  4. 4
      wp-content/themes/cosmopet/templates/modal/login.twig

@ -291,6 +291,15 @@
gap: 24px!important; gap: 24px!important;
} }
.login_inner img {
display: block;
margin: 40px auto;
}
.login_title {
text-align: center;
}
@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {
.footer_ae .footer__wrapper { .footer_ae .footer__wrapper {
width: 100%; width: 100%;

@ -4,14 +4,20 @@
const metaLocale = document.querySelector('meta[property="og:locale"]'); const metaLocale = document.querySelector('meta[property="og:locale"]');
const localeValue = metaLocale.getAttribute('content'); const localeValue = metaLocale.getAttribute('content');
// Login // Флаг для предотвращения множественной обработки
let isProcessing = false;
// Login
$('.login_popup').on('click', function(e){ $('.login_popup').on('click', function(e){
e.preventDefault(); e.preventDefault();
$('.login_modal').addClass('active'); $('.login_modal').addClass('active');
}); });
$('.login_close').on('click', function(){ $('.login_close').on('click', function(){
$('.login_modal').removeClass('active'); $('.login_modal').removeClass('active');
$('.login_forms').removeClass('hide');
$('.login_success').addClass('hide');
$('.login_auth').addClass('hide');
isProcessing = false; // Сбрасываем флаг при закрытии
}); });
$('.login_back').on('click', function(){ $('.login_back').on('click', function(){
if($(this).is('.disabled')) { if($(this).is('.disabled')) {
@ -49,9 +55,7 @@
} }
} }
}); });
} }
}); });
$('.js-repeat-code').on('click', function(){ $('.js-repeat-code').on('click', function(){
$('.login_input').removeClass('error'); $('.login_input').removeClass('error');
@ -87,31 +91,44 @@
$('.js-input-code input').on('input keydown keyup propertychange paste cut copy change', function(){ $('.js-input-code input').on('input keydown keyup propertychange paste cut copy change', function(){
var val = $(this).val(); var val = $(this).val();
var email = $('.js-input-email input').val(); var email = $('.js-input-email input').val();
if(val.length === 4) { if(val.length === 4 && !isProcessing) {
isProcessing = true; // Устанавливаем флаг, чтобы предотвратить повторную обработку
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: '/wp-admin/admin-ajax.php', url: '/wp-admin/admin-ajax.php',
data: {action: 'check_code', code: val, email: email}, data: {action: 'check_code', code: val, email: email},
success: function(data){ success: function(data){
console.log(data); console.log('Server response:', data); // Отладка ответа сервера
if(data['status'] == 'success_reg') { if(data['status'] === 'success_reg') {
$('.login_forms').addClass('hide'); $('.login_forms').addClass('hide');
$('.login_success').removeClass('hide'); $('.login_success').removeClass('hide');
$('.login_auth').addClass('hide'); // Гарантируем, что login_auth скрыт
if (typeof wc_checkout_params !== 'undefined') { 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_forms').addClass('hide');
$('.login_auth').removeClass('hide'); $('.login_auth').removeClass('hide');
$('.login_success').addClass('hide'); // Гарантируем, что login_success скрыт
if (typeof wc_checkout_params !== 'undefined') { 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').addClass('error');
$('.js-input-code .login_error').text(data['text']); $('.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
} }
}); });
} }
@ -131,12 +148,9 @@
} else { } else {
location.reload(); location.reload();
} }
} }
}); });
}); });
})(jQuery); })(jQuery);
function checkImage(imageSrc, good) { function checkImage(imageSrc, good) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

@ -42,7 +42,7 @@
<div class="login_subtitle">{% if site_region == 'ru' %}Теперь вы можете получать промокоды за покупки.{% elseif site_region == 'ae' %}Now you can receive promo codes for purchases.{% endif %}</div> <div class="login_subtitle">{% if site_region == 'ru' %}Теперь вы можете получать промокоды за покупки.{% elseif site_region == 'ae' %}Now you can receive promo codes for purchases.{% endif %}</div>
<img src="<?php bloginfo('template_url');?>/images/people.png" alt=""/> <img src="/wp-content/themes/cosmopet/static/img/people.png" alt=""/>
<a href="/my-account" class="login_btn account_link">{% if site_region == 'ru' %}Заполнить профиль{% elseif site_region == 'ae' %}Fill out profile{% endif %}</a> <a href="/my-account" class="login_btn account_link">{% if site_region == 'ru' %}Заполнить профиль{% elseif site_region == 'ae' %}Fill out profile{% endif %}</a>
</div> </div>
@ -52,7 +52,7 @@
<h2 class="login_title --text-center"> <h2 class="login_title --text-center">
{% if site_region == 'ru' %}Вы вошли в систему{% elseif site_region == 'ae' %}You have logged in{% endif %}</h2> {% if site_region == 'ru' %}Вы вошли в систему{% elseif site_region == 'ae' %}You have logged in{% endif %}</h2>
<img src="<?php bloginfo('template_url');?>/images/people.png" alt=""/> <img src="/wp-content/themes/cosmopet/static/img/people.png" alt=""/>
<a href="/my-account" class="login_btn account_link">{% if site_region == 'ru' %}Профиль{% elseif site_region == 'ae' %}Profile{% endif %}</a> <a href="/my-account" class="login_btn account_link">{% if site_region == 'ru' %}Профиль{% elseif site_region == 'ae' %}Profile{% endif %}</a>
</div> </div>

Loading…
Cancel
Save