Vinoteca: модуль, шаблон и компоненты интернет-магазина вина на 1С-Битрикс
This commit is contained in:
commit
bb7d8af290
469 files changed
+26426
No files matched your search
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Bitrix\Main\Application;
|
||||
use Bitrix\Main\Engine\CurrentUser;
|
||||
use Bitrix\Main\Localization\Loc;
|
||||
use Jinove\Vinoteca\Redirect;
|
||||
|
||||
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
|
||||
die();
|
||||
}
|
||||
|
||||
Loc::loadMessages(__FILE__);
|
||||
|
||||
class JinoveAuthRegisterComponent extends CBitrixComponent
|
||||
{
|
||||
public function executeComponent(): array
|
||||
{
|
||||
$request = Application::getInstance()->getContext()->getRequest();
|
||||
$safeBack = Redirect::safe((string)$request->getQuery("back"));
|
||||
if ((int)CurrentUser::get()->getId() > 0) {
|
||||
LocalRedirect($safeBack !== "" ? $safeBack : SITE_DIR);
|
||||
}
|
||||
$GLOBALS["APPLICATION"]->SetTitle(Loc::getMessage("VINO_REG_PAGE_TITLE"));
|
||||
$GLOBALS["APPLICATION"]->SetPageProperty("description", Loc::getMessage("VINO_REG_PAGE_DESCRIPTION"));
|
||||
$GLOBALS["APPLICATION"]->SetPageProperty("vino_alternates", "N");
|
||||
$GLOBALS["APPLICATION"]->SetPageProperty("vino_schema", "N");
|
||||
$GLOBALS["APPLICATION"]->SetPageProperty("robots", "noindex, nofollow");
|
||||
$this->arResult = [
|
||||
"BACK" => $safeBack,
|
||||
"LOGIN_URL" => SITE_DIR . "login/" . ($safeBack !== "" ? "?back=" . rawurlencode($safeBack) : ""),
|
||||
];
|
||||
$this->includeComponentTemplate();
|
||||
|
||||
return $this->arResult;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$MESS["VINO_REG_PAGE_TITLE"] = "Create an account | Vinoteca";
|
||||
$MESS["VINO_REG_PAGE_DESCRIPTION"] = "Create a Vinoteca account: profile, order history and wine reviews on all devices.";
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$MESS["VINO_REG_PAGE_TITLE"] = "Rejestracja | Vinoteca";
|
||||
$MESS["VINO_REG_PAGE_DESCRIPTION"] = "Rejestracja w Vinoteca: profil, historia zamówień i opinie o winach na wszystkich urządzeniach.";
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$MESS["VINO_REG_PAGE_TITLE"] = "Регистрация | Vinoteca";
|
||||
$MESS["VINO_REG_PAGE_DESCRIPTION"] = "Регистрация в Vinoteca: профиль, история заказов и отзывы о винах на всех устройствах.";
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
$MESS["VINO_REG_KICKER"] = "My account";
|
||||
$MESS["VINO_REG_TITLE"] = "Create an account";
|
||||
$MESS["VINO_REG_LEAD"] = "Enter your name, e-mail and password.";
|
||||
$MESS["VINO_REG_NAME"] = "Name";
|
||||
$MESS["VINO_REG_EMAIL"] = "E-mail";
|
||||
$MESS["VINO_REG_PASSWORD"] = "Password";
|
||||
$MESS["VINO_REG_HINT"] = "At least 8 characters";
|
||||
$MESS["VINO_REG_SHOW"] = "Show";
|
||||
$MESS["VINO_REG_HIDE"] = "Hide";
|
||||
$MESS["VINO_REG_SUBMIT"] = "Create account";
|
||||
$MESS["VINO_REG_HAVE"] = "I already have an account";
|
||||
$MESS["VINO_REG_ERR_NAME"] = "Enter your name";
|
||||
$MESS["VINO_REG_ERR_EMAIL"] = "Enter a valid e-mail";
|
||||
$MESS["VINO_REG_ERR_PASSWORD"] = "Password must be at least 8 characters";
|
||||
$MESS["VINO_REG_ERR_CONSENT"] = "Consent to data processing is required";
|
||||
$MESS["VINO_REG_ERR_ALTCHA"] = "Verification failed. Please try again.";
|
||||
$MESS["VINO_REG_ERR_TOO_OFTEN"] = "Too many attempts, try again later";
|
||||
$MESS["VINO_REG_ERR_COMMON"] = "Failed. Check the details or sign in";
|
||||
$MESS["VINO_REG_CONSENT"] = 'By clicking “#BUTTON#”, I agree to the processing of my <a class="vino-consent__link" href="#URL#" target="_blank">personal data</a> on the terms and for the purposes set out in the <a class="vino-consent__link" href="#PRIVACY_URL#" target="_blank">Privacy Policy</a>.';
|
||||
$MESS["VINO_REG_ASIDE_TITLE"] = "After registering you will be able to";
|
||||
$MESS["VINO_REG_PERK_PROFILE"] = "Edit your profile and contact details";
|
||||
$MESS["VINO_REG_PERK_ORDERS"] = "View the history and status of orders";
|
||||
$MESS["VINO_REG_PERK_REVIEW"] = "Leave wine reviews";
|
||||
$MESS["VINO_REG_ERR_RETRY"] = "Please submit again";
|
||||
$MESS["VINO_REG_DEMO"] = "Registration is disabled on this demonstration site";
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
$MESS["VINO_REG_KICKER"] = "Moje konto";
|
||||
$MESS["VINO_REG_TITLE"] = "Rejestracja";
|
||||
$MESS["VINO_REG_LEAD"] = "Wpisz imię, e-mail i hasło.";
|
||||
$MESS["VINO_REG_NAME"] = "Imię";
|
||||
$MESS["VINO_REG_EMAIL"] = "E-mail";
|
||||
$MESS["VINO_REG_PASSWORD"] = "Hasło";
|
||||
$MESS["VINO_REG_HINT"] = "Co najmniej 8 znaków";
|
||||
$MESS["VINO_REG_SHOW"] = "Pokaż";
|
||||
$MESS["VINO_REG_HIDE"] = "Ukryj";
|
||||
$MESS["VINO_REG_SUBMIT"] = "Zarejestruj się";
|
||||
$MESS["VINO_REG_HAVE"] = "Mam już konto";
|
||||
$MESS["VINO_REG_ERR_NAME"] = "Wpisz imię";
|
||||
$MESS["VINO_REG_ERR_EMAIL"] = "Wpisz poprawny adres e-mail";
|
||||
$MESS["VINO_REG_ERR_PASSWORD"] = "Hasło musi mieć co najmniej 8 znaków";
|
||||
$MESS["VINO_REG_ERR_CONSENT"] = "Wymagana zgoda na przetwarzanie danych";
|
||||
$MESS["VINO_REG_ERR_ALTCHA"] = "Weryfikacja nieudana. Spróbuj ponownie.";
|
||||
$MESS["VINO_REG_ERR_TOO_OFTEN"] = "Zbyt wiele prób, spróbuj ponownie później";
|
||||
$MESS["VINO_REG_ERR_COMMON"] = "Błąd. Sprawdź dane lub zaloguj się";
|
||||
$MESS["VINO_REG_CONSENT"] = 'Klikając „#BUTTON#”, wyrażam zgodę na przetwarzanie moich <a class="vino-consent__link" href="#URL#" target="_blank">danych osobowych</a> na warunkach i w celach określonych w <a class="vino-consent__link" href="#PRIVACY_URL#" target="_blank">Polityce prywatności</a>.';
|
||||
$MESS["VINO_REG_ASIDE_TITLE"] = "Po rejestracji możesz";
|
||||
$MESS["VINO_REG_PERK_PROFILE"] = "Edytować profil i dane kontaktowe";
|
||||
$MESS["VINO_REG_PERK_ORDERS"] = "Przeglądać historię i status zamówień";
|
||||
$MESS["VINO_REG_PERK_REVIEW"] = "Dodawać opinie o winach";
|
||||
$MESS["VINO_REG_ERR_RETRY"] = "Wyślij ponownie";
|
||||
$MESS["VINO_REG_DEMO"] = "Na stronie demonstracyjnej rejestracja jest wyłączona";
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
$MESS["VINO_REG_KICKER"] = "Личный кабинет";
|
||||
$MESS["VINO_REG_TITLE"] = "Регистрация";
|
||||
$MESS["VINO_REG_LEAD"] = "Введите имя, e-mail и пароль.";
|
||||
$MESS["VINO_REG_NAME"] = "Имя";
|
||||
$MESS["VINO_REG_EMAIL"] = "E-mail";
|
||||
$MESS["VINO_REG_PASSWORD"] = "Пароль";
|
||||
$MESS["VINO_REG_HINT"] = "Не короче 8 символов";
|
||||
$MESS["VINO_REG_SHOW"] = "Показать";
|
||||
$MESS["VINO_REG_HIDE"] = "Скрыть";
|
||||
$MESS["VINO_REG_SUBMIT"] = "Зарегистрироваться";
|
||||
$MESS["VINO_REG_HAVE"] = "У меня уже есть аккаунт";
|
||||
$MESS["VINO_REG_ERR_NAME"] = "Введите имя";
|
||||
$MESS["VINO_REG_ERR_EMAIL"] = "Введите корректный e-mail";
|
||||
$MESS["VINO_REG_ERR_PASSWORD"] = "Пароль не короче 8 символов";
|
||||
$MESS["VINO_REG_ERR_CONSENT"] = "Нужно согласие на обработку данных";
|
||||
$MESS["VINO_REG_ERR_ALTCHA"] = "Проверка не пройдена. Повторите попытку.";
|
||||
$MESS["VINO_REG_ERR_TOO_OFTEN"] = "Слишком много попыток, повторите позже";
|
||||
$MESS["VINO_REG_ERR_COMMON"] = "Не удалось. Проверьте данные или войдите";
|
||||
$MESS["VINO_REG_CONSENT"] = 'Нажимая «#BUTTON#», я соглашаюсь на обработку <a class="vino-consent__link" href="#URL#" target="_blank">персональных данных</a> на условиях и для целей, определённых <a class="vino-consent__link" href="#PRIVACY_URL#" target="_blank">Политикой конфиденциальности</a>.';
|
||||
$MESS["VINO_REG_ASIDE_TITLE"] = "После регистрации вы сможете";
|
||||
$MESS["VINO_REG_PERK_PROFILE"] = "Редактировать профиль и контактные данные";
|
||||
$MESS["VINO_REG_PERK_ORDERS"] = "Просматривать историю и статус заказов";
|
||||
$MESS["VINO_REG_PERK_REVIEW"] = "Оставлять отзывы о винах";
|
||||
$MESS["VINO_REG_ERR_RETRY"] = "Повторите отправку";
|
||||
$MESS["VINO_REG_DEMO"] = "На демонстрационном сайте регистрация отключена";
|
||||
@@ -0,0 +1,89 @@
|
||||
(function () {
|
||||
function init() {
|
||||
var form = document.querySelector('[data-auth-register]');
|
||||
if (!form || !window.BX || !BX.ajax || !BX.ajax.runAction) return;
|
||||
var name = form.elements.name;
|
||||
var email = form.elements.email;
|
||||
var password = form.elements.password;
|
||||
var submit = form.querySelector('[type="submit"]');
|
||||
var err = form.querySelector('[data-auth-err]');
|
||||
var started = Date.now();
|
||||
var codes = { too_often: 'tooOften', altcha: 'altcha', retry: 'retry' };
|
||||
var guard = form.querySelector('altcha-widget');
|
||||
|
||||
function say(text) {
|
||||
err.textContent = text;
|
||||
}
|
||||
|
||||
function mark(field, bad) {
|
||||
field.classList.toggle('vino-inp--invalid', bad);
|
||||
field.setAttribute('aria-invalid', bad ? 'true' : 'false');
|
||||
}
|
||||
|
||||
function message(code) {
|
||||
var key = codes[code] || 'error';
|
||||
return form.dataset['msg' + key.charAt(0).toUpperCase() + key.slice(1)] || form.dataset.msgError;
|
||||
}
|
||||
|
||||
VinoAltcha.arm(guard);
|
||||
|
||||
|
||||
form.addEventListener('input', function (event) {
|
||||
if (event.target.classList.contains('vino-inp--invalid')) mark(event.target, false);
|
||||
});
|
||||
form.elements.consent.addEventListener('change', function () {
|
||||
form.querySelector('.vino-auth__consent').classList.remove('vino-consent--invalid');
|
||||
});
|
||||
|
||||
form.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
var nameValue = name.value.trim();
|
||||
var emailValue = email.value.trim();
|
||||
var badName = nameValue === '';
|
||||
var badEmail = !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(emailValue);
|
||||
var badPassword = password.value.length < 8;
|
||||
var badConsent = !form.elements.consent.checked;
|
||||
mark(name, badName);
|
||||
mark(email, badEmail);
|
||||
mark(password, badPassword);
|
||||
form.querySelector('.vino-auth__consent').classList.toggle('vino-consent--invalid', badConsent);
|
||||
form.elements.consent.setAttribute('aria-invalid', badConsent ? 'true' : 'false');
|
||||
if (badName || badEmail || badPassword || badConsent) {
|
||||
say(badName ? form.dataset.msgName : badEmail ? form.dataset.msgEmail : badPassword ? form.dataset.msgPassword : form.dataset.msgConsent);
|
||||
(badName ? name : badEmail ? email : badPassword ? password : form.elements.consent).focus();
|
||||
return;
|
||||
}
|
||||
say('');
|
||||
submit.disabled = true;
|
||||
VinoAltcha.armed(guard).then(function (ok) {
|
||||
if (!ok) return Promise.reject({ errors: [{ code: 'altcha' }] });
|
||||
return BX.ajax.runAction('jinove:vinoteca.register.create', {
|
||||
data: {
|
||||
name: nameValue,
|
||||
email: emailValue,
|
||||
password: password.value,
|
||||
consent: '1',
|
||||
back: form.dataset.back || '',
|
||||
lang: document.documentElement.lang || 'en',
|
||||
website: form.elements.website.value,
|
||||
elapsed: String(Date.now() - started),
|
||||
altcha: form.elements.altcha ? form.elements.altcha.value : ''
|
||||
}
|
||||
});
|
||||
}).then(function (response) {
|
||||
window.location.href = (response.data && response.data.redirect) || '/';
|
||||
}, function (response) {
|
||||
submit.disabled = false;
|
||||
VinoAltcha.reset(guard);
|
||||
var code = response && response.errors && response.errors[0] ? response.errors[0].code : '';
|
||||
say(message(code));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
use Bitrix\Main\Localization\Loc;
|
||||
|
||||
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
|
||||
die();
|
||||
}
|
||||
|
||||
Loc::loadMessages(__FILE__);
|
||||
$this->addExternalCss("/local/components/jinove/auth.login/templates/.default/style.css");
|
||||
$uid = "vino-reg";
|
||||
?>
|
||||
<section class="vino-auth">
|
||||
<div class="vino-auth__aside">
|
||||
<p class="vino-auth__aside-title"><?= Loc::getMessage("VINO_REG_ASIDE_TITLE") ?></p>
|
||||
<ul class="vino-auth__perks">
|
||||
<li class="vino-auth__perk"><svg class="vino-auth__perk-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 21a8 8 0 0 0-16 0M12 13a5 5 0 1 0 0-10 5 5 0 0 0 0 10Z"></path></svg><span class="vino-auth__perk-title"><?= Loc::getMessage("VINO_REG_PERK_PROFILE") ?></span></li>
|
||||
<li class="vino-auth__perk"><svg class="vino-auth__perk-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 2h12l2 4v14H4V6l2-4ZM4 6h16M9 10h6"></path></svg><span class="vino-auth__perk-title"><?= Loc::getMessage("VINO_REG_PERK_ORDERS") ?></span></li>
|
||||
<li class="vino-auth__perk"><svg class="vino-auth__perk-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a8 8 0 0 1-11.5 7.2L4 20.5l1.3-4.7A8 8 0 1 1 21 12Z"></path></svg><span class="vino-auth__perk-title"><?= Loc::getMessage("VINO_REG_PERK_REVIEW") ?></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="vino-auth__card">
|
||||
<p class="vino-auth__kicker"><?= Loc::getMessage("VINO_REG_KICKER") ?></p>
|
||||
<h1 class="vino-auth__title"><?= Loc::getMessage("VINO_REG_TITLE") ?></h1>
|
||||
<p class="vino-auth__lead"><?= Loc::getMessage("VINO_REG_LEAD") ?></p>
|
||||
<p class="vino-auth__demo" role="note"><?= Loc::getMessage("VINO_REG_DEMO") ?></p>
|
||||
<form class="vino-auth__form" method="post" novalidate data-auth-register data-back="<?= htmlspecialcharsbx($arResult["BACK"]) ?>"
|
||||
data-msg-name="<?= Loc::getMessage("VINO_REG_ERR_NAME") ?>"
|
||||
data-msg-email="<?= Loc::getMessage("VINO_REG_ERR_EMAIL") ?>"
|
||||
data-msg-password="<?= Loc::getMessage("VINO_REG_ERR_PASSWORD") ?>"
|
||||
data-msg-consent="<?= Loc::getMessage("VINO_REG_ERR_CONSENT") ?>"
|
||||
data-msg-altcha="<?= Loc::getMessage("VINO_REG_ERR_ALTCHA") ?>"
|
||||
data-msg-too-often="<?= Loc::getMessage("VINO_REG_ERR_TOO_OFTEN") ?>"
|
||||
data-msg-retry="<?= Loc::getMessage("VINO_REG_ERR_RETRY") ?>"
|
||||
data-msg-error="<?= Loc::getMessage("VINO_REG_ERR_COMMON") ?>"
|
||||
data-label-show="<?= Loc::getMessage("VINO_REG_SHOW") ?>"
|
||||
data-label-hide="<?= Loc::getMessage("VINO_REG_HIDE") ?>">
|
||||
<input type="text" name="website" class="vino-hp" tabindex="-1" autocomplete="off" aria-hidden="true">
|
||||
<div class="vino-auth__field">
|
||||
<label class="vino-auth__label" for="<?= $uid ?>-name"><?= Loc::getMessage("VINO_REG_NAME") ?></label>
|
||||
<input class="vino-inp vino-auth__input" id="<?= $uid ?>-name" type="text" name="name" autocomplete="name" maxlength="50" aria-describedby="<?= $uid ?>-err" required>
|
||||
</div>
|
||||
<div class="vino-auth__field">
|
||||
<label class="vino-auth__label" for="<?= $uid ?>-email"><?= Loc::getMessage("VINO_REG_EMAIL") ?></label>
|
||||
<input class="vino-inp vino-auth__input" id="<?= $uid ?>-email" type="email" name="email" autocomplete="email" inputmode="email" maxlength="254" aria-describedby="<?= $uid ?>-err" required>
|
||||
</div>
|
||||
<div class="vino-auth__field">
|
||||
<label class="vino-auth__label" for="<?= $uid ?>-password"><?= Loc::getMessage("VINO_REG_PASSWORD") ?></label>
|
||||
<span class="vino-auth__password">
|
||||
<input class="vino-inp vino-auth__input" id="<?= $uid ?>-password" type="password" name="password" autocomplete="new-password" minlength="8" maxlength="200" aria-describedby="<?= $uid ?>-hint <?= $uid ?>-err" required>
|
||||
<button type="button" class="vino-auth__toggle" data-password-toggle hidden aria-controls="<?= $uid ?>-password"><?= Loc::getMessage("VINO_REG_SHOW") ?></button>
|
||||
</span>
|
||||
<span class="vino-auth__hint" id="<?= $uid ?>-hint"><?= Loc::getMessage("VINO_REG_HINT") ?></span>
|
||||
</div>
|
||||
<label class="vino-consent vino-consent--sm vino-auth__consent"><input class="vino-consent__checkbox" type="checkbox" name="consent" value="1" aria-describedby="<?= $uid ?>-err" required><span class="vino-consent__text"><?= Loc::getMessage("VINO_REG_CONSENT", array("#BUTTON#" => Loc::getMessage("VINO_REG_SUBMIT"), "#URL#" => SITE_DIR . "consent/", "#PRIVACY_URL#" => SITE_DIR . "privacy/")) ?></span></label>
|
||||
<altcha-widget name="altcha" challenge="/bitrix/services/main/ajax.php?action=jinove:vinoteca.lead.challenge" auto="onload" display="invisible"></altcha-widget>
|
||||
<p class="vino-auth__err" id="<?= $uid ?>-err" role="alert" data-auth-err></p>
|
||||
<button class="vino-btn vino-auth__submit" type="submit"><?= Loc::getMessage("VINO_REG_SUBMIT") ?></button>
|
||||
<div class="vino-auth__links">
|
||||
<a class="vino-auth__link" href="<?= htmlspecialcharsbx($arResult["LOGIN_URL"]) ?>"><?= Loc::getMessage("VINO_REG_HAVE") ?></a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
Reference in new issue
Block a user