173 lines
8.7 KiB
Plaintext
173 lines
8.7 KiB
Plaintext
@page
|
||
@model WebApp.Pages.IndexModel
|
||
@{
|
||
ViewData["Title"] = "Catalog Page";
|
||
}
|
||
|
||
<!-- Шапка -->
|
||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||
<div class="container">
|
||
<a asp-page="Index" class="navbar-brand">Catalog</a>
|
||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||
<span class="navbar-toggler-icon"></span>
|
||
</button>
|
||
<div class="collapse navbar-collapse" id="navbarNav">
|
||
|
||
<form class="d-flex" method="get">
|
||
<input asp-for="ProductsModel" type="search" placeholder="Поиск" name="search" value="" id="search">
|
||
<button class="btn btn-outline-success" type="submit"><i class="fas fa-search"></i></button>
|
||
</form>
|
||
|
||
<div class="dropdown">
|
||
<form class="form-group" method="get">
|
||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||
Фильтр
|
||
</a>
|
||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownMenuLink">
|
||
<input type="hidden" name="search" id="search_hidden">
|
||
<div class="d-flex align-items-center">
|
||
<input type="range" step="1" min="0" max="100" value="0" class="custom-range me-2" id="priceFrom">
|
||
От: <input type="number" name="pricefrom" step="0.01" id="priceLabelFrom"> руб.
|
||
</div>
|
||
<div class="d-flex align-items-center">
|
||
<input type="range" step="1" min="0" max="100" value="100" class="custom-range me-2" id="priceTo">
|
||
До: <input type="number" name="priceto" step="0.01" id="priceLabelTo"> руб.
|
||
</div>
|
||
<li><input type="radio" name="category" value="Pistol" class="dropdown-item">Pistol</li>
|
||
<li><input type="radio" name="category" value="Rifle" class="dropdown-item">Rifle</li>
|
||
<li><input type="radio" name="category" value="Revolver" class="dropdown-item">Revolver</li>
|
||
<button class="btn btn-outline-success" type="submit">Применить</i></button>
|
||
</ul>
|
||
|
||
</form>
|
||
</div>
|
||
</div>
|
||
|
||
@* АКЦИИ *@
|
||
<div class="container mt-4">
|
||
<div class="row">
|
||
@foreach (var sale in Model.SalesModel)
|
||
{
|
||
<div class="col-12 col-md-6 mb-4">
|
||
<div class="card h-100 border-0 shadow-sm rounded-lg overflow-hidden">
|
||
<div class="row g-0">
|
||
<div class="col-md-4">
|
||
<img src="~/big-sale.png" class="card-img" alt="@sale.Name">
|
||
</div>
|
||
<div class="col-md-8">
|
||
<div class="card-body">
|
||
<h5 class="card-title">@sale.Name</h5>
|
||
<p class="card-text small text-muted">@sale.Description</p>
|
||
<a asp-page="Details" asp-route-id="@sale.Id" class="btn btn-primary stretched-link" data-toggle="modal" data-target="#saleDetailModal">Подробнее</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="modal fade" id="saleDetailModal" tabindex="-1" role="dialog" aria-labelledby="saleDetailModalLabel" aria-hidden="true">
|
||
<div class="modal-dialog" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title" id="saleDetailModalLabel">Подробная информация об акции</h5>
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||
<span aria-hidden="true">×</span>
|
||
</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
@sale.FullDescription
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Закрыть</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
}
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</nav>
|
||
|
||
@* КАРТОЧКИ ТОВАРОВ *@
|
||
<div id="Row">
|
||
<div class="row row-cols-1 row-cols-md-3 g-5">
|
||
@foreach (var weapon in @Model.ProductsModel)
|
||
{
|
||
<div class="col mb-4">
|
||
<div class="card h-100">
|
||
<img src="data:image/png;base64,@Convert.ToBase64String(Model.GetMediaByProduct(weapon))" class="card-img-top" alt="@weapon.Name">
|
||
<div class="card-body">
|
||
<h5 class="card-title">@weapon.Name</h5>
|
||
<p class="card-text">
|
||
|
||
@foreach (var sale in Model.SalesModel)
|
||
if (sale.Category == weapon.Category)
|
||
{
|
||
<span>Цена: <del>@weapon.Price руб.</del> </span>
|
||
<span style="color:red;">@(weapon.Price / 100 * (100 - sale.Value)) руб.</span>
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
<span>Цена: @weapon.Price руб.</span>
|
||
}
|
||
</p>
|
||
|
||
|
||
<div class="star-rating">
|
||
@for (int i = 0; i < (int)Math.Round(@weapon.Rate); i++)
|
||
{
|
||
<span class="filled-star">★</span>
|
||
}
|
||
@for (int i = 0; i < 5 - (int)Math.Round(@weapon.Rate); i++)
|
||
{
|
||
<span class="empty-star">★</span>
|
||
}
|
||
(@weapon.Rate)
|
||
</div>
|
||
|
||
<a asp-page="ProductPage" asp-route-id="@weapon.Id" class="btn btn-success">Подробнее</a>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
}
|
||
</div>
|
||
</div>
|
||
|
||
@section Scripts {
|
||
<script>
|
||
// СЛАЙДЕРЫ
|
||
document.getElementById("priceFrom").addEventListener("input", function () {
|
||
var price = this.value;
|
||
document.getElementById("priceLabelFrom").value = price + " р.";
|
||
});
|
||
|
||
document.getElementById("priceTo").addEventListener("input", function () {
|
||
var price = this.value;
|
||
document.getElementById("priceLabelTo").value = price + " р.";
|
||
});
|
||
|
||
document.getElementById("search").addEventListener("input", function () {
|
||
var text = this.value;
|
||
document.getElementById("search_hidden").value = text;
|
||
});
|
||
|
||
$('#saleDetailModal').on('show.bs.modal', function (event) {
|
||
var button = $(event.relatedTarget); // Кнопка, которая активировала модальное окно
|
||
var saleId = button.data('sale-id'); // Экземпляр saleId из атрибута data-sale-id кнопки
|
||
|
||
// Загрузка данных о продаже с сервера (пример с использованием AJAX)
|
||
$.ajax({
|
||
url: '/api/sales/' + saleId, // URL API для получения данных о продаже
|
||
type: 'GET',
|
||
success: function (data) {
|
||
var modal = $(this);
|
||
modal.find('.modal-title').text('Дата проведения акции: ' + data.date);
|
||
modal.find('.modal-body').text('Описание акции: ' + data.description);
|
||
}
|
||
});
|
||
});
|
||
</script>
|
||
} |