Add the customer storefront on Django templates
Pages are rendered server-side (SEO, no build step), the interactive parts talk to the existing REST API from the browser: - home: banners, categories, hits and new arrivals - catalog: filters (category, brand, price, stock), search, sorting, pagination, filter chips with one-click removal - product card: gallery, price with discount, stock, characteristics, related products - cart: localStorage, quantity controls, live totals - checkout: contacts, delivery, promo code, bonuses, order submission with Idempotency-Key, success screen - login: OTP by phone (debug code shown in dev) and phone/password - account: profile, orders, addresses, bonuses through the API with JWT - static pages from the admin Supporting pieces: - apps/storefront app with views, urls, templates and static CSS/JS - money/discount/attribute template filters - seed_demo management command with demo catalog, banners and pages - Cyrillic search fallback for SQLite: local DB does not fold case for non-ASCII, production PostgreSQL does Tests: 16 storefront cases (pages, filters, search, ordering, 404s, filters formatting); the suite is 61 passing.
This commit is contained in:
1 parent
b18e3ea703
commit
37d5d7b366
29 files changed
+2822
-7
No files matched your search
@@ -0,0 +1,40 @@
|
||||
{% load storefront %}
|
||||
<article class="product-card">
|
||||
<a href="{% url 'product' product.slug %}" class="product-media" aria-label="{{ product.name }}">
|
||||
<div class="product-badges">
|
||||
{% if product.is_hit %}<span class="badge badge-hit">Хит</span>{% endif %}
|
||||
{% if product.is_new %}<span class="badge badge-new">Новинка</span>{% endif %}
|
||||
</div>
|
||||
{% if product.main_image %}
|
||||
<img src="{{ product.main_image }}" alt="{{ product.name }}" loading="lazy">
|
||||
{% else %}
|
||||
<span class="placeholder">{{ product.name|slice:":1" }}</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
<div class="product-body">
|
||||
{% if product.brand %}<span class="product-brand">{{ product.brand }}</span>{% endif %}
|
||||
<h3 class="product-name"><a href="{% url 'product' product.slug %}">{{ product.name }}</a></h3>
|
||||
<div class="product-price">
|
||||
<span class="price-now">{{ product.price|money }} ₽</span>
|
||||
{% if product.old_price %}
|
||||
<span class="price-old">{{ product.old_price|money }} ₽</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="product-actions">
|
||||
{% if product.stock > 0 %}
|
||||
<button class="btn btn-outline btn-block btn-sm"
|
||||
data-add-to-cart
|
||||
data-id="{{ product.id }}"
|
||||
data-slug="{{ product.slug }}"
|
||||
data-name="{{ product.name }}"
|
||||
data-price="{{ product.price }}"
|
||||
data-image="{{ product.main_image|default:'' }}"
|
||||
data-stock="{{ product.stock }}">
|
||||
В корзину
|
||||
</button>
|
||||
{% else %}
|
||||
<button class="btn btn-outline btn-block btn-sm" disabled>Нет в наличии</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</article>
|
||||
@@ -0,0 +1,110 @@
|
||||
{% extends "storefront/base.html" %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}Личный кабинет — {{ site.site_name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-head" style="display:flex;justify-content:space-between;align-items:center;gap:16px;flex-wrap:wrap">
|
||||
<div>
|
||||
<h1>Личный кабинет</h1>
|
||||
<p data-account-hello>Загрузка…</p>
|
||||
</div>
|
||||
<button class="btn btn-outline" type="button" data-logout>Выйти</button>
|
||||
</div>
|
||||
|
||||
<div class="account-layout">
|
||||
<nav class="account-nav">
|
||||
<button type="button" class="active" data-panel="orders">Мои заказы</button>
|
||||
<button type="button" data-panel="profile">Профиль</button>
|
||||
<button type="button" data-panel="addresses">Адреса доставки</button>
|
||||
<button type="button" data-panel="bonus">Бонусы</button>
|
||||
</nav>
|
||||
|
||||
<section>
|
||||
<div class="account-panel" data-panel-body="orders">
|
||||
<div class="panel-head"><h2>Мои заказы</h2></div>
|
||||
<div data-orders-list><p class="form-note">Загрузка…</p></div>
|
||||
</div>
|
||||
|
||||
<div class="account-panel" data-panel-body="profile" hidden>
|
||||
<div class="panel-head"><h2>Профиль</h2></div>
|
||||
<form data-profile-form>
|
||||
<div class="field-row">
|
||||
<div class="field">
|
||||
<label for="first_name">Имя</label>
|
||||
<input id="first_name" name="first_name" autocomplete="given-name">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="last_name">Фамилия</label>
|
||||
<input id="last_name" name="last_name" autocomplete="family-name">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="middle_name">Отчество</label>
|
||||
<input id="middle_name" name="middle_name">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="profile_phone">Телефон</label>
|
||||
<input id="profile_phone" disabled>
|
||||
<div class="form-note">Телефон изменить нельзя — это логин для входа.</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="profile_email">Email</label>
|
||||
<input id="profile_email" name="email" type="email" autocomplete="email">
|
||||
</div>
|
||||
<button class="btn btn-accent" type="submit">Сохранить</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="account-panel" data-panel-body="addresses" hidden>
|
||||
<div class="panel-head"><h2>Адреса доставки</h2></div>
|
||||
<div data-addresses-list><p class="form-note">Загрузка…</p></div>
|
||||
|
||||
<h3 style="margin-top:24px;font-size:17px">Добавить адрес</h3>
|
||||
<form data-address-form>
|
||||
<div class="field-row">
|
||||
<div class="field">
|
||||
<label for="city">Город *</label>
|
||||
<input id="city" name="city" required>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="street">Улица *</label>
|
||||
<input id="street" name="street" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field-row">
|
||||
<div class="field">
|
||||
<label for="house">Дом</label>
|
||||
<input id="house" name="house">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="apartment">Квартира</label>
|
||||
<input id="apartment" name="apartment">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="title">Название (например, «Дом»)</label>
|
||||
<input id="title" name="title">
|
||||
</div>
|
||||
<label class="form-note" style="display:block;margin-bottom:14px">
|
||||
<input type="checkbox" name="is_default"> Сделать основным
|
||||
</label>
|
||||
<button class="btn btn-accent" type="submit">Добавить адрес</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="account-panel" data-panel-body="bonus" hidden>
|
||||
<div class="panel-head"><h2>Бонусы</h2></div>
|
||||
<div class="balance-card">
|
||||
<div class="form-note">Доступно бонусов</div>
|
||||
<div class="value" data-bonus-amount>0 ₽</div>
|
||||
</div>
|
||||
<div data-bonus-history><p class="form-note">Загрузка…</p></div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{% static 'storefront/js/account-page.js' %}" defer></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,86 @@
|
||||
{% load static storefront %}<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% block title %}{{ site.site_name }}{% endblock %}</title>
|
||||
<meta name="description" content="{% block description %}{{ site.site_name }} — одежда и аксессуары{% endblock %}">
|
||||
{% block meta %}{% endblock %}
|
||||
<link rel="stylesheet" href="{% static 'storefront/css/storefront.css' %}">
|
||||
<meta name="csrf-token" content="{{ csrf_token }}">
|
||||
</head>
|
||||
<body>
|
||||
<header class="site-header">
|
||||
<div class="container">
|
||||
<div class="header-top">
|
||||
<a class="logo" href="{% url 'home' %}">HOMM<span>.</span></a>
|
||||
<nav class="header-nav">
|
||||
<a href="{% url 'catalog' %}">Каталог</a>
|
||||
{% for category in menu_categories|slice:":5" %}
|
||||
<a href="{% url 'catalog' %}?category={{ category.slug }}">{{ category.name }}</a>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
<div class="header-actions">
|
||||
<a href="{% url 'account' %}" data-account-link>Кабинет</a>
|
||||
<a href="{% url 'cart' %}">Корзина
|
||||
<span class="cart-badge" data-cart-count hidden>0</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-search">
|
||||
<form action="{% url 'catalog' %}" method="get" role="search">
|
||||
<input type="search" name="search" placeholder="Поиск по каталогу: название, артикул, бренд"
|
||||
value="{{ filters.search|default:'' }}" aria-label="Поиск по каталогу">
|
||||
<button class="btn" type="submit">Найти</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="container">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="site-footer">
|
||||
<div class="container">
|
||||
<div class="footer-grid">
|
||||
<div>
|
||||
<h4>{{ site.site_name }}</h4>
|
||||
{% if site.address %}<p>{{ site.address }}</p>{% endif %}
|
||||
{% if site.phone %}<p><a href="tel:{{ site.phone }}">{{ site.phone }}</a></p>{% endif %}
|
||||
{% if site.email %}<p><a href="mailto:{{ site.email }}">{{ site.email }}</a></p>{% endif %}
|
||||
{% if site.working_hours %}<p>{{ site.working_hours }}</p>{% endif %}
|
||||
</div>
|
||||
<div>
|
||||
<h4>Покупателям</h4>
|
||||
<a href="{% url 'catalog' %}">Каталог</a>
|
||||
<a href="{% url 'cart' %}">Корзина</a>
|
||||
<a href="{% url 'account' %}">Личный кабинет</a>
|
||||
{% for page in footer_pages %}
|
||||
<a href="{% url 'page' page.slug %}">{{ page.title }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div>
|
||||
<h4>Связь</h4>
|
||||
{% if site.telegram_url %}<a href="{{ site.telegram_url }}" rel="noopener">Telegram</a>{% endif %}
|
||||
{% if site.vk_url %}<a href="{{ site.vk_url }}" rel="noopener">ВКонтакте</a>{% endif %}
|
||||
{% if site.whatsapp_url %}<a href="{{ site.whatsapp_url }}" rel="noopener">WhatsApp</a>{% endif %}
|
||||
{% if site.free_delivery_threshold %}
|
||||
<p>Бесплатная доставка от {{ site.free_delivery_threshold|money }} ₽</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer-bottom">
|
||||
<span>© {% now "Y" %} {{ site.site_name }}</span>
|
||||
<span>Цены и наличие обновляются из 1С</span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<div class="toast-stack" data-toasts></div>
|
||||
<script src="{% static 'storefront/js/site.js' %}" defer></script>
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,34 @@
|
||||
{% extends "storefront/base.html" %}
|
||||
{% load static storefront %}
|
||||
|
||||
{% block title %}Корзина — {{ site.site_name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-head">
|
||||
<h1>Корзина</h1>
|
||||
</div>
|
||||
|
||||
<div class="cart-layout" data-cart-root>
|
||||
<div>
|
||||
<div class="cart-list" data-cart-list></div>
|
||||
<div class="empty-state" data-cart-empty hidden>
|
||||
<h2>Корзина пуста</h2>
|
||||
<p>Добавьте товары из каталога — они сохранятся в этом браузере.</p>
|
||||
<a class="btn btn-accent" href="{% url 'catalog' %}">Перейти в каталог</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<aside class="summary">
|
||||
<h3>Итого</h3>
|
||||
<div class="summary-row"><span>Товары</span><span data-subtotal>0 ₽</span></div>
|
||||
<div class="summary-row"><span>Доставка</span><span data-delivery>рассчитаем при оформлении</span></div>
|
||||
<div class="summary-row total"><span>К оплате</span><span data-total>0 ₽</span></div>
|
||||
<a class="btn btn-accent btn-block" href="{% url 'checkout' %}" data-checkout-link>Оформить заказ</a>
|
||||
<button class="btn btn-ghost btn-block" type="button" data-clear-cart>Очистить корзину</button>
|
||||
</aside>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{% static 'storefront/js/cart-page.js' %}" defer></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,136 @@
|
||||
{% extends "storefront/base.html" %}
|
||||
{% load storefront %}
|
||||
|
||||
{% block title %}{% if selected_category %}{{ selected_category.name }}{% else %}Каталог{% endif %} — {{ site.site_name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="breadcrumbs">
|
||||
<a href="{% url 'home' %}">Главная</a> /
|
||||
{% if selected_category %}
|
||||
<a href="{% url 'catalog' %}">Каталог</a> / <span>{{ selected_category.name }}</span>
|
||||
{% else %}
|
||||
<span>Каталог</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="page-head">
|
||||
<h1>{% if selected_category %}{{ selected_category.name }}{% elif filters.search %}Поиск: {{ filters.search }}{% else %}Каталог{% endif %}</h1>
|
||||
{% if selected_category.description %}<p>{{ selected_category.description }}</p>{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="catalog-layout">
|
||||
<aside class="filters">
|
||||
<form method="get" action="{% url 'catalog' %}">
|
||||
<div class="filter-group">
|
||||
<h4>Категория</h4>
|
||||
<select name="category">
|
||||
<option value="">Все категории</option>
|
||||
{% for category in categories %}
|
||||
<option value="{{ category.slug }}"
|
||||
{% if filters.category == category.slug %}selected{% endif %}>{{ category.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="filter-group">
|
||||
<h4>Цена, ₽</h4>
|
||||
<div class="filter-price">
|
||||
<input type="number" name="price_min" min="0" inputmode="numeric"
|
||||
placeholder="{{ price_bounds.low|money|default:'0' }}"
|
||||
value="{{ filters.price_min|default:'' }}">
|
||||
<input type="number" name="price_max" min="0" inputmode="numeric"
|
||||
placeholder="{{ price_bounds.high|money|default:'—' }}"
|
||||
value="{{ filters.price_max|default:'' }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if brands %}
|
||||
<div class="filter-group">
|
||||
<h4>Бренд</h4>
|
||||
<select name="brand">
|
||||
<option value="">Любой бренд</option>
|
||||
{% for brand in brands %}
|
||||
<option value="{{ brand }}" {% if filters.brand == brand %}selected{% endif %}>{{ brand }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="filter-group">
|
||||
<label class="form-note">
|
||||
<input type="checkbox" name="in_stock" value="1"
|
||||
{% if filters.in_stock == '1' %}checked{% endif %}>
|
||||
Только в наличии
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{% if filters.search %}<input type="hidden" name="search" value="{{ filters.search }}">{% endif %}
|
||||
<input type="hidden" name="ordering" value="{{ selected_ordering }}">
|
||||
|
||||
<div class="filter-actions">
|
||||
<button class="btn btn-block" type="submit">Применить</button>
|
||||
<a class="btn btn-outline btn-block" href="{% url 'catalog' %}">Сбросить</a>
|
||||
</div>
|
||||
</form>
|
||||
</aside>
|
||||
|
||||
<div>
|
||||
<div class="catalog-toolbar">
|
||||
<span class="count">{% if total %}Найдено товаров: {{ total }}{% else %}Ничего не найдено{% endif %}</span>
|
||||
<form method="get" action="{% url 'catalog' %}">
|
||||
{% for key, value in filters.items %}
|
||||
{% if key != 'ordering' %}<input type="hidden" name="{{ key }}" value="{{ value }}">{% endif %}
|
||||
{% endfor %}
|
||||
<select name="ordering" onchange="this.form.submit()" aria-label="Сортировка">
|
||||
{% for value, label in ordering_choices %}
|
||||
<option value="{{ value }}" {% if selected_ordering == value %}selected{% endif %}>{{ label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% if chips %}
|
||||
<div class="chips">
|
||||
{% for chip in chips %}
|
||||
<span class="chip">
|
||||
{{ chip.label }}{% if chip.value %}: {{ chip.value }}{% endif %}
|
||||
<a href="{% url 'catalog' %}{% if chip.qs %}?{{ chip.qs }}{% endif %}" aria-label="Убрать фильтр">×</a>
|
||||
</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if products %}
|
||||
<div class="product-grid">
|
||||
{% for product in products %}
|
||||
{% include "storefront/_product_card.html" %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% if page.paginator.num_pages > 1 %}
|
||||
<nav class="pagination" aria-label="Страницы">
|
||||
{% if page.has_previous %}
|
||||
<a href="?{{ querystring }}&page={{ page.previous_page_number }}">←</a>
|
||||
{% endif %}
|
||||
{% for number in page.paginator.page_range %}
|
||||
{% if number == page.number %}
|
||||
<span class="current">{{ number }}</span>
|
||||
{% elif number > page.number|add:"-3" and number < page.number|add:"3" %}
|
||||
<a href="?{{ querystring }}&page={{ number }}">{{ number }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if page.has_next %}
|
||||
<a href="?{{ querystring }}&page={{ page.next_page_number }}">→</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<h2>Товары не найдены</h2>
|
||||
<p>Попробуйте изменить фильтры или сбросить их.</p>
|
||||
<a class="btn btn-outline" href="{% url 'catalog' %}">Сбросить фильтры</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,115 @@
|
||||
{% extends "storefront/base.html" %}
|
||||
{% load static storefront %}
|
||||
|
||||
{% block title %}Оформление заказа — {{ site.site_name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-head">
|
||||
<h1>Оформление заказа</h1>
|
||||
</div>
|
||||
|
||||
<div class="cart-layout" data-checkout
|
||||
data-free-threshold="{{ site.free_delivery_threshold|default:'0' }}"
|
||||
data-delivery-cost="{{ site.default_delivery_cost|default:'0' }}"
|
||||
data-bonus-limit="{{ site.bonus_max_payment_percent|default:'0' }}">
|
||||
|
||||
<div>
|
||||
<form data-checkout-form novalidate>
|
||||
<div class="account-panel" style="margin-bottom:20px">
|
||||
<h2 style="font-size:20px">Контакты</h2>
|
||||
<div class="field-row">
|
||||
<div class="field">
|
||||
<label for="customer_name">Имя и фамилия *</label>
|
||||
<input id="customer_name" name="customer_name" required autocomplete="name">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="phone">Телефон *</label>
|
||||
<input id="phone" name="phone" required autocomplete="tel" placeholder="+7 900 123-45-67">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="email">Email</label>
|
||||
<input id="email" name="email" type="email" autocomplete="email" placeholder="для чека и уведомлений">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="account-panel" style="margin-bottom:20px">
|
||||
<h2 style="font-size:20px">Доставка</h2>
|
||||
<div class="field">
|
||||
<label for="delivery_method">Способ получения</label>
|
||||
<select id="delivery_method" name="delivery_method">
|
||||
<option value="courier">Курьером</option>
|
||||
<option value="pickup">Самовывоз</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field" data-address-field>
|
||||
<label for="delivery_address">Адрес</label>
|
||||
<textarea id="delivery_address" name="delivery_address"
|
||||
placeholder="Город, улица, дом, квартира"></textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="comment">Комментарий к заказу</label>
|
||||
<textarea id="comment" name="comment" placeholder="Например: позвонить за час"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="account-panel" style="margin-bottom:20px">
|
||||
<h2 style="font-size:20px">Оплата</h2>
|
||||
<div class="field">
|
||||
<label for="payment_method">Способ оплаты</label>
|
||||
<select id="payment_method" name="payment_method">
|
||||
<option value="card">Картой онлайн</option>
|
||||
<option value="sbp">СБП</option>
|
||||
<option value="cash">При получении</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="account-panel">
|
||||
<h2 style="font-size:20px">Скидки</h2>
|
||||
<div class="field">
|
||||
<label for="promo_code">Промокод</label>
|
||||
<div class="field-row">
|
||||
<input id="promo_code" name="promo_code" placeholder="Например, WINTER15">
|
||||
<button class="btn btn-outline" type="button" data-apply-promo>Применить</button>
|
||||
</div>
|
||||
<div class="form-note" data-promo-note></div>
|
||||
</div>
|
||||
<div class="field" data-bonus-field hidden>
|
||||
<label for="bonus_amount">Списать бонусы (доступно: <span data-bonus-balance>0</span>)</label>
|
||||
<input id="bonus_amount" name="bonus_amount" type="number" min="0" step="1" value="0">
|
||||
<div class="form-note">Бонусами можно оплатить не более {{ site.bonus_max_payment_percent|floatformat:0 }}% заказа.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-error" data-checkout-error hidden></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<aside class="summary">
|
||||
<h3>Ваш заказ</h3>
|
||||
<div data-checkout-items></div>
|
||||
<div class="summary-row"><span>Товары</span><span data-subtotal>0 ₽</span></div>
|
||||
<div class="summary-row"><span>Скидка по промокоду</span><span data-discount>0 ₽</span></div>
|
||||
<div class="summary-row"><span>Бонусы</span><span data-bonus>0 ₽</span></div>
|
||||
<div class="summary-row"><span>Доставка</span><span data-delivery>0 ₽</span></div>
|
||||
<div class="summary-row total"><span>К оплате</span><span data-total>0 ₽</span></div>
|
||||
<button class="btn btn-accent btn-block" type="button" data-submit-order>Подтвердить заказ</button>
|
||||
<p class="form-note" style="margin-top:10px">
|
||||
Нажимая кнопку, вы соглашаетесь с условиями обработки персональных данных.
|
||||
</p>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="account-panel" data-order-success hidden style="margin-top:24px">
|
||||
<h2>Заказ оформлен</h2>
|
||||
<p>Номер заказа: <strong data-order-number></strong></p>
|
||||
<p class="form-note">Мы свяжемся с вами для подтверждения. Статус заказа виден в личном кабинете.</p>
|
||||
<a class="btn btn-accent" href="{% url 'account' %}">Перейти в кабинет</a>
|
||||
<a class="btn btn-outline" href="{% url 'catalog' %}">Вернуться в каталог</a>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{% static 'storefront/js/checkout-page.js' %}" defer></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,79 @@
|
||||
{% extends "storefront/base.html" %}
|
||||
{% load storefront %}
|
||||
|
||||
{% block title %}{{ site.site_name }} — одежда и аксессуары{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if banners %}
|
||||
<div class="hero">
|
||||
{% with banner=banners.0 %}
|
||||
{% if banner.image_url %}<img class="hero-image" src="{{ banner.image_url }}" alt="">{% endif %}
|
||||
<h1>{{ banner.title }}</h1>
|
||||
<p>{{ site.site_name }}: одежда, обувь и аксессуары. Ассортимент и наличие синхронизированы с 1С.</p>
|
||||
{% if banner.link_url %}
|
||||
<a class="btn btn-accent" href="{{ banner.link_url }}">Смотреть</a>
|
||||
{% else %}
|
||||
<a class="btn btn-accent" href="{% url 'catalog' %}">Смотреть каталог</a>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="hero">
|
||||
<h1>{{ site.site_name }} — вещи, которые носят годами</h1>
|
||||
<p>Одежда, обувь и аксессуары. Цены и наличие обновляются из 1С в реальном времени.</p>
|
||||
<a class="btn btn-accent" href="{% url 'catalog' %}">Смотреть каталог</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if categories %}
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2>Категории</h2>
|
||||
<a href="{% url 'catalog' %}">Весь каталог</a>
|
||||
</div>
|
||||
<div class="category-grid">
|
||||
{% for category in categories %}
|
||||
<a class="category-tile" href="{% url 'catalog' %}?category={{ category.slug }}">
|
||||
{% if category.image_url %}<img src="{{ category.image_url }}" alt="">{% endif %}
|
||||
<span>{{ category.name }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
{% if hits %}
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2>Хиты продаж</h2>
|
||||
<a href="{% url 'catalog' %}?ordering=-is_hit">Все хиты</a>
|
||||
</div>
|
||||
<div class="product-grid">
|
||||
{% for product in hits %}
|
||||
{% include "storefront/_product_card.html" %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
{% if new %}
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2>Новинки</h2>
|
||||
<a href="{% url 'catalog' %}?ordering=-created_at">Все новинки</a>
|
||||
</div>
|
||||
<div class="product-grid">
|
||||
{% for product in new %}
|
||||
{% include "storefront/_product_card.html" %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
{% if not hits and not new %}
|
||||
<div class="empty-state">
|
||||
<h2>Каталог пока пуст</h2>
|
||||
<p>Товары появятся после первой синхронизации с 1С.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,60 @@
|
||||
{% extends "storefront/base.html" %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}Вход — {{ site.site_name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div style="max-width:460px;margin:0 auto">
|
||||
<div class="page-head">
|
||||
<h1>Вход в личный кабинет</h1>
|
||||
<p>Войдите по номеру телефона — код придёт в SMS. Пароль нужен, только если вы его задавали.</p>
|
||||
</div>
|
||||
|
||||
<div class="account-panel">
|
||||
<div class="account-nav" style="flex-direction:row;gap:8px;margin-bottom:20px">
|
||||
<button type="button" class="active" data-tab="otp">Код из SMS</button>
|
||||
<button type="button" data-tab="password">Телефон и пароль</button>
|
||||
</div>
|
||||
|
||||
<form data-otp-form>
|
||||
<div class="field">
|
||||
<label for="otp_phone">Номер телефона</label>
|
||||
<input id="otp_phone" name="phone" required autocomplete="tel" placeholder="+7 900 123-45-67">
|
||||
</div>
|
||||
<button class="btn btn-accent btn-block" type="button" data-request-code>Получить код</button>
|
||||
|
||||
<div data-code-block hidden>
|
||||
<div class="field" style="margin-top:16px">
|
||||
<label for="otp_code">Код из SMS</label>
|
||||
<input id="otp_code" name="code" inputmode="numeric" autocomplete="one-time-code"
|
||||
placeholder="4 цифры" maxlength="8">
|
||||
</div>
|
||||
<button class="btn btn-accent btn-block" type="submit">Войти</button>
|
||||
<div class="form-note" data-code-note></div>
|
||||
</div>
|
||||
<div class="form-error" data-otp-error hidden></div>
|
||||
</form>
|
||||
|
||||
<form data-password-form hidden>
|
||||
<div class="field">
|
||||
<label for="login_phone">Номер телефона</label>
|
||||
<input id="login_phone" name="phone" required autocomplete="username">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="login_password">Пароль</label>
|
||||
<input id="login_password" name="password" type="password" required autocomplete="current-password">
|
||||
</div>
|
||||
<button class="btn btn-accent btn-block" type="submit">Войти</button>
|
||||
<div class="form-error" data-password-error hidden></div>
|
||||
</form>
|
||||
|
||||
<p class="form-note" style="margin-top:18px">
|
||||
Нет аккаунта? Он создастся автоматически при первом входе по коду.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{% static 'storefront/js/login-page.js' %}" defer></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,12 @@
|
||||
{% extends "storefront/base.html" %}
|
||||
|
||||
{% block title %}{{ page.seo_title|default:page.title }} — {{ site.site_name }}{% endblock %}
|
||||
{% block description %}{{ page.seo_description|default:page.title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="breadcrumbs">
|
||||
<a href="{% url 'home' %}">Главная</a> / <span>{{ page.title }}</span>
|
||||
</div>
|
||||
<h1>{{ page.title }}</h1>
|
||||
<div class="product-desc" style="max-width:820px">{{ page.content|linebreaks }}</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,151 @@
|
||||
{% extends "storefront/base.html" %}
|
||||
{% load storefront %}
|
||||
|
||||
{% block title %}{{ product.name }} — {{ site.site_name }}{% endblock %}
|
||||
{% block description %}{{ product.short_description|default:product.name|truncatechars:160 }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="breadcrumbs">
|
||||
<a href="{% url 'home' %}">Главная</a> /
|
||||
<a href="{% url 'catalog' %}">Каталог</a> /
|
||||
{% if product.category %}
|
||||
<a href="{% url 'catalog' %}?category={{ product.category.slug }}">{{ product.category.name }}</a> /
|
||||
{% endif %}
|
||||
<span>{{ product.name }}</span>
|
||||
</div>
|
||||
|
||||
<div class="product-layout">
|
||||
<div>
|
||||
<div class="gallery-main" data-gallery-main>
|
||||
{% if images %}
|
||||
<img src="{{ images.0.url }}" alt="{{ product.name }}" data-main-image>
|
||||
{% else %}
|
||||
<span class="placeholder">{{ product.name|slice:":1" }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if images|length > 1 %}
|
||||
<div class="gallery-thumbs">
|
||||
{% for image in images %}
|
||||
<button type="button" data-thumb="{{ image.url }}"
|
||||
class="{% if forloop.first %}active{% endif %}"
|
||||
aria-label="Фото {{ forloop.counter }}">
|
||||
<img src="{{ image.url }}" alt="{{ image.alt|default:product.name }}" loading="lazy">
|
||||
</button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="product-info">
|
||||
{% if product.brand %}<span class="product-brand">{{ product.brand }}</span>{% endif %}
|
||||
<h1>{{ product.name }}</h1>
|
||||
<div class="product-sku">Артикул: {{ product.sku }}</div>
|
||||
|
||||
<div class="product-price-lg">
|
||||
<span class="price-now">{{ product.price|money }} ₽</span>
|
||||
{% if product.old_price %}
|
||||
<span class="price-old">{{ product.old_price|money }} ₽</span>
|
||||
<span class="badge badge-new">−{{ product.price|discount_percent:product.old_price }}%</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if product.stock > 0 %}
|
||||
<div class="stock"><span class="dot"></span> В наличии: {{ product.stock }} шт.</div>
|
||||
{% elif product.stock_status == 'preorder' %}
|
||||
<div class="stock out"><span class="dot"></span> Под заказ</div>
|
||||
{% else %}
|
||||
<div class="stock out"><span class="dot"></span> Нет в наличии</div>
|
||||
{% endif %}
|
||||
|
||||
{% if product.short_description %}
|
||||
<p class="product-desc">{{ product.short_description }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% if product.stock > 0 %}
|
||||
<div class="buy-row">
|
||||
<div class="qty">
|
||||
<button type="button" data-qty-minus aria-label="Меньше">−</button>
|
||||
<input type="number" value="1" min="1" max="{{ product.stock }}"
|
||||
data-qty-input aria-label="Количество">
|
||||
<button type="button" data-qty-plus aria-label="Больше">+</button>
|
||||
</div>
|
||||
<button class="btn btn-accent btn-block"
|
||||
data-add-to-cart
|
||||
data-id="{{ product.id }}"
|
||||
data-slug="{{ product.slug }}"
|
||||
data-name="{{ product.name }}"
|
||||
data-price="{{ product.price }}"
|
||||
data-image="{{ product.main_image|default:'' }}"
|
||||
data-stock="{{ product.stock }}"
|
||||
data-qty-source="[data-qty-input]">
|
||||
Добавить в корзину
|
||||
</button>
|
||||
</div>
|
||||
<a class="btn btn-outline btn-block" href="{% url 'cart' %}">Перейти в корзину</a>
|
||||
{% else %}
|
||||
<button class="btn btn-outline btn-block" disabled>Нет в наличии</button>
|
||||
{% endif %}
|
||||
|
||||
{% if product.description %}
|
||||
<div class="product-desc">{{ product.description|linebreaks }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if attributes %}
|
||||
<section class="section" style="margin-top:48px">
|
||||
<h2>Характеристики</h2>
|
||||
<table class="specs">
|
||||
{% for name, value in attributes.items %}
|
||||
<tr><td>{{ name }}</td><td>{{ value|attr_value }}</td></tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
{% if related %}
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2>Похожие товары</h2>
|
||||
{% if product.category %}
|
||||
<a href="{% url 'catalog' %}?category={{ product.category.slug }}">Вся категория</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="product-grid">
|
||||
{% for item in related %}
|
||||
{% include "storefront/_product_card.html" with product=item %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
document.querySelectorAll('[data-thumb]').forEach(function (button) {
|
||||
button.addEventListener('click', function () {
|
||||
var main = document.querySelector('[data-main-image]');
|
||||
if (!main) { return; }
|
||||
main.src = button.dataset.thumb;
|
||||
document.querySelectorAll('[data-thumb]').forEach(function (other) {
|
||||
other.classList.toggle('active', other === button);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
(function () {
|
||||
var input = document.querySelector('[data-qty-input]');
|
||||
if (!input) { return; }
|
||||
var minus = document.querySelector('[data-qty-minus]');
|
||||
var plus = document.querySelector('[data-qty-plus]');
|
||||
var max = parseInt(input.max || '999', 10);
|
||||
|
||||
function clamp(value) {
|
||||
return Math.max(1, Math.min(max, value || 1));
|
||||
}
|
||||
minus.addEventListener('click', function () { input.value = clamp(parseInt(input.value, 10) - 1); });
|
||||
plus.addEventListener('click', function () { input.value = clamp(parseInt(input.value, 10) + 1); });
|
||||
input.addEventListener('change', function () { input.value = clamp(parseInt(input.value, 10)); });
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user