feat: initial phone store application
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}Phone Store{% endblock %} — Интернет-магазин смартфонов</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<!-- Шапка сайта -->
|
||||
<header class="header">
|
||||
<div class="container header-inner">
|
||||
<a href="{{ url_for('index') }}" class="logo">
|
||||
<span class="logo-icon">📱</span>
|
||||
<span class="logo-text">Phone<span class="logo-accent">Store</span></span>
|
||||
</a>
|
||||
|
||||
<nav class="nav">
|
||||
<a href="{{ url_for('index') }}" class="nav-link">Каталог</a>
|
||||
<a href="{{ url_for('cart') }}" class="nav-link cart-link">
|
||||
Корзина
|
||||
{% if cart_count > 0 %}
|
||||
<span class="cart-badge" id="cart-badge">{{ cart_count }}</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Сообщения (flash) -->
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
<div class="flash-container">
|
||||
{% for category, message in messages %}
|
||||
<div class="flash flash-{{ category }}">
|
||||
<span>{{ message }}</span>
|
||||
<button class="flash-close" onclick="this.parentElement.remove()">×</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<!-- Основной контент -->
|
||||
<main class="main">
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<!-- Подвал -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<div class="footer-content">
|
||||
<div class="footer-brand">
|
||||
<span class="logo-text">Phone<span class="logo-accent">Store</span></span>
|
||||
<p>Ваш надёжный магазин смартфонов</p>
|
||||
</div>
|
||||
<div class="footer-info">
|
||||
<p>© 2024 Phone Store. Учебный проект.</p>
|
||||
<p>Все цены указаны в рублях.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="{{ url_for('static', filename='js/script.js') }}"></script>
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,73 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Корзина{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="cart-section">
|
||||
<div class="container">
|
||||
<h1 class="page-title">Корзина</h1>
|
||||
|
||||
{% if items %}
|
||||
<div class="cart-layout">
|
||||
<div class="cart-items">
|
||||
{% for item in items %}
|
||||
<div class="cart-item">
|
||||
<div class="cart-item-image">
|
||||
<img src="{{ url_for('static', filename='images/' + item.image) }}"
|
||||
alt="{{ item.name }}"
|
||||
onerror="this.src='https://via.placeholder.com/100x100?text=Phone'">
|
||||
</div>
|
||||
<div class="cart-item-info">
|
||||
<h3>{{ item.name }}</h3>
|
||||
<p class="cart-item-price">{{ "{:,.0f}".format(item.price).replace(',', ' ') }} ₽</p>
|
||||
</div>
|
||||
<div class="cart-item-qty">
|
||||
<form action="{{ url_for('update_cart', product_id=item.id) }}" method="POST" class="qty-form">
|
||||
<input type="hidden" name="action" value="decrease">
|
||||
<button type="submit" class="qty-btn">−</button>
|
||||
</form>
|
||||
<span class="qty-value">{{ item.quantity }}</span>
|
||||
<form action="{{ url_for('update_cart', product_id=item.id) }}" method="POST" class="qty-form">
|
||||
<input type="hidden" name="action" value="increase">
|
||||
<button type="submit" class="qty-btn">+</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="cart-item-total">
|
||||
{{ "{:,.0f}".format(item.price * item.quantity).replace(',', ' ') }} ₽
|
||||
</div>
|
||||
<form action="{{ url_for('update_cart', product_id=item.id) }}" method="POST">
|
||||
<input type="hidden" name="action" value="remove">
|
||||
<button type="submit" class="btn-remove" title="Удалить">×</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="cart-summary">
|
||||
<h3>Итого</h3>
|
||||
<div class="summary-row">
|
||||
<span>Товаров:</span>
|
||||
<span>{{ cart_count }}</span>
|
||||
</div>
|
||||
<div class="summary-row total-row">
|
||||
<span>Сумма:</span>
|
||||
<span class="total-price">{{ "{:,.0f}".format(total).replace(',', ' ') }} ₽</span>
|
||||
</div>
|
||||
<a href="{{ url_for('checkout') }}" class="btn btn-primary btn-large btn-block">
|
||||
Оформить заказ
|
||||
</a>
|
||||
<form action="{{ url_for('clear_cart') }}" method="POST" style="margin-top: 12px;">
|
||||
<button type="submit" class="btn btn-outline btn-block">Очистить корзину</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<div class="empty-icon">🛒</div>
|
||||
<p>Ваша корзина пуста</p>
|
||||
<a href="{{ url_for('index') }}" class="btn btn-primary">Перейти в каталог</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,61 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Оформление заказа{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="checkout-section">
|
||||
<div class="container">
|
||||
<h1 class="page-title">Оформление заказа</h1>
|
||||
|
||||
<div class="checkout-layout">
|
||||
<div class="checkout-form-wrapper">
|
||||
<form method="POST" class="checkout-form" id="checkout-form">
|
||||
<div class="form-group">
|
||||
<label for="name">Имя покупателя *</label>
|
||||
<input type="text" id="name" name="name" required
|
||||
value="{{ name or '' }}"
|
||||
placeholder="Иван Иванов"
|
||||
minlength="2">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="phone">Номер телефона *</label>
|
||||
<input type="tel" id="phone" name="phone" required
|
||||
value="{{ phone or '' }}"
|
||||
placeholder="+7 (999) 123-45-67"
|
||||
minlength="10">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="address">Адрес доставки *</label>
|
||||
<textarea id="address" name="address" required
|
||||
rows="3"
|
||||
placeholder="Город, улица, дом, квартира"
|
||||
minlength="5">{{ address or '' }}</textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-large btn-block">
|
||||
Подтвердить заказ
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="order-summary">
|
||||
<h3>Ваш заказ</h3>
|
||||
<ul class="order-items">
|
||||
{% for item in items %}
|
||||
<li>
|
||||
<span>{{ item.name }} × {{ item.quantity }}</span>
|
||||
<span>{{ "{:,.0f}".format(item.price * item.quantity).replace(',', ' ') }} ₽</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="order-total">
|
||||
<span>Итого:</span>
|
||||
<span>{{ "{:,.0f}".format(total).replace(',', ' ') }} ₽</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,130 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Каталог{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<!-- Hero-блок -->
|
||||
<section class="hero">
|
||||
<div class="container">
|
||||
<div class="hero-content">
|
||||
<h1>Смартфоны для каждого</h1>
|
||||
<p>Большой выбор моделей от ведущих производителей. Быстрая доставка и гарантия качества.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Преимущества -->
|
||||
<section class="advantages">
|
||||
<div class="container">
|
||||
<div class="advantages-grid">
|
||||
<div class="advantage-card">
|
||||
<div class="advantage-icon">🚚</div>
|
||||
<h3>Быстрая доставка</h3>
|
||||
<p>Доставим заказ в течение 1–3 дней</p>
|
||||
</div>
|
||||
<div class="advantage-card">
|
||||
<div class="advantage-icon">✅</div>
|
||||
<h3>Официальная гарантия</h3>
|
||||
<p>Все товары с гарантией производителя</p>
|
||||
</div>
|
||||
<div class="advantage-card">
|
||||
<div class="advantage-icon">💳</div>
|
||||
<h3>Удобная оплата</h3>
|
||||
<p>Оплата при получении или онлайн</p>
|
||||
</div>
|
||||
<div class="advantage-card">
|
||||
<div class="advantage-icon">🔄</div>
|
||||
<h3>Легкий возврат</h3>
|
||||
<p>14 дней на возврат без вопросов</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Каталог -->
|
||||
<section class="catalog">
|
||||
<div class="container">
|
||||
<div class="catalog-header">
|
||||
<h2>Каталог смартфонов</h2>
|
||||
</div>
|
||||
|
||||
<!-- Фильтры и поиск -->
|
||||
<form class="filters" method="GET" action="{{ url_for('index') }}">
|
||||
<div class="filter-group search-group">
|
||||
<input type="text" name="search" placeholder="Поиск по названию или бренду..."
|
||||
value="{{ search }}" class="search-input">
|
||||
</div>
|
||||
|
||||
<div class="filter-group">
|
||||
<select name="brand" class="filter-select">
|
||||
<option value="">Все бренды</option>
|
||||
{% for b in brands %}
|
||||
<option value="{{ b.brand }}" {% if selected_brand == b.brand %}selected{% endif %}>
|
||||
{{ b.brand }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="filter-group">
|
||||
<select name="sort" class="filter-select">
|
||||
<option value="">Сортировка</option>
|
||||
<option value="price_asc" {% if sort == 'price_asc' %}selected{% endif %}>
|
||||
Цена: по возрастанию
|
||||
</option>
|
||||
<option value="price_desc" {% if sort == 'price_desc' %}selected{% endif %}>
|
||||
Цена: по убыванию
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Применить</button>
|
||||
{% if search or selected_brand or sort %}
|
||||
<a href="{{ url_for('index') }}" class="btn btn-outline">Сбросить</a>
|
||||
{% endif %}
|
||||
</form>
|
||||
|
||||
<!-- Сетка товаров -->
|
||||
{% if products %}
|
||||
<div class="products-grid">
|
||||
{% for product in products %}
|
||||
<article class="product-card">
|
||||
<a href="{{ url_for('product_detail', product_id=product.id) }}" class="product-image-link">
|
||||
<div class="product-image">
|
||||
<img src="{{ url_for('static', filename='images/' + product.image) }}"
|
||||
alt="{{ product.name }}"
|
||||
onerror="this.src='https://via.placeholder.com/300x300?text={{ product.brand }}'">
|
||||
</div>
|
||||
</a>
|
||||
<div class="product-info">
|
||||
<span class="product-brand">{{ product.brand }}</span>
|
||||
<a href="{{ url_for('product_detail', product_id=product.id) }}" class="product-name">
|
||||
{{ product.name }}
|
||||
</a>
|
||||
<div class="product-specs">
|
||||
<span>{{ product.storage }}</span>
|
||||
<span>{{ product.ram }} ОЗУ</span>
|
||||
<span>{{ product.screen }}</span>
|
||||
</div>
|
||||
<div class="product-footer">
|
||||
<span class="product-price">{{ "{:,.0f}".format(product.price).replace(',', ' ') }} ₽</span>
|
||||
<form action="{{ url_for('add_to_cart', product_id=product.id) }}" method="POST">
|
||||
<input type="hidden" name="next" value="{{ request.url }}">
|
||||
<button type="submit" class="btn btn-cart" title="Добавить в корзину">
|
||||
В корзину
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<p>По вашему запросу ничего не найдено</p>
|
||||
<a href="{{ url_for('index') }}" class="btn btn-primary">Показать все товары</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,72 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ product.name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="product-detail">
|
||||
<div class="container">
|
||||
<nav class="breadcrumb">
|
||||
<a href="{{ url_for('index') }}">Каталог</a>
|
||||
<span>/</span>
|
||||
<span>{{ product.name }}</span>
|
||||
</nav>
|
||||
|
||||
<div class="product-detail-grid">
|
||||
<div class="product-detail-image">
|
||||
<img src="{{ url_for('static', filename='images/' + product.image) }}"
|
||||
alt="{{ product.name }}"
|
||||
onerror="this.src='https://via.placeholder.com/500x500?text={{ product.brand }}'">
|
||||
</div>
|
||||
|
||||
<div class="product-detail-info">
|
||||
<span class="product-brand">{{ product.brand }}</span>
|
||||
<h1 class="product-title">{{ product.name }}</h1>
|
||||
<div class="product-price-large">
|
||||
{{ "{:,.0f}".format(product.price).replace(',', ' ') }} ₽
|
||||
</div>
|
||||
|
||||
<div class="product-description">
|
||||
<p>{{ product.description }}</p>
|
||||
</div>
|
||||
|
||||
<div class="specs-table">
|
||||
<h3>Характеристики</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Производитель</td>
|
||||
<td>{{ product.brand }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Память</td>
|
||||
<td>{{ product.storage }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Оперативная память</td>
|
||||
<td>{{ product.ram }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Диагональ экрана</td>
|
||||
<td>{{ product.screen }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Аккумулятор</td>
|
||||
<td>{{ product.battery }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Особенности</td>
|
||||
<td>{{ product.features }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<form action="{{ url_for('add_to_cart', product_id=product.id) }}" method="POST" class="add-to-cart-form">
|
||||
<input type="hidden" name="next" value="{{ url_for('product_detail', product_id=product.id) }}">
|
||||
<button type="submit" class="btn btn-primary btn-large">
|
||||
Добавить в корзину
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user