263 lines
12 KiB
HTML
263 lines
12 KiB
HTML
{{define "product.html"}}
|
||
<!DOCTYPE html>
|
||
<html lang="ru">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>{{.Product.Name}} — Shop</title>
|
||
<link rel="stylesheet" href="/static/css/style.css">
|
||
<link rel="stylesheet" href="/static/css/shop.css">
|
||
</head>
|
||
<body>
|
||
{{template "shop_header" .}}
|
||
<main class="shop-page container">
|
||
<nav class="breadcrumb">
|
||
<a href="/">Главная</a>
|
||
{{if .Product.CategorySlug}}
|
||
<span>/</span>
|
||
<a href="/category/{{.Product.CategorySlug}}">{{.Product.Category}}</a>
|
||
{{end}}
|
||
<span>/</span>
|
||
<span>{{.Product.Name}}</span>
|
||
</nav>
|
||
|
||
{{if .Success}}<div class="shop-alert shop-alert--ok">{{.Success}}</div>{{end}}
|
||
{{if .Error}}<div class="shop-alert shop-alert--error">{{.Error}}</div>{{end}}
|
||
|
||
{{if .ReservedByOther}}
|
||
<div class="shop-alert shop-alert--warn">
|
||
Товар забронирован до {{.Reservation.ExpiresAt.Format "02.01.2006 15:04"}}
|
||
</div>
|
||
{{else if .Reservation}}
|
||
<div class="shop-alert shop-alert--ok">
|
||
Вы забронировали этот товар до {{.Reservation.ExpiresAt.Format "02.01.2006 15:04"}}
|
||
</div>
|
||
{{end}}
|
||
|
||
<div class="product-detail">
|
||
<div class="product-detail__gallery">
|
||
<img src="{{.Product.ImageURL}}" alt="{{.Product.Name}}" class="product-detail__main">
|
||
{{if .Product.Images}}
|
||
<div class="product-detail__thumbs">
|
||
{{range .Product.Images}}
|
||
<img src="{{.FilePath}}" alt="">
|
||
{{end}}
|
||
</div>
|
||
{{end}}
|
||
</div>
|
||
<div class="product-detail__info">
|
||
{{if .Product.CategorySlug}}
|
||
<a href="/category/{{.Product.CategorySlug}}" class="product-detail__cat">{{.Product.Category}}</a>
|
||
{{end}}
|
||
<h1>{{.Product.Name}}</h1>
|
||
<div class="price-block price-block--lg">
|
||
{{if .Product.HasSale}}
|
||
<span class="price-block__old">{{printf "%.0f" .Product.Price}} ₽</span>
|
||
<span class="price-block__sale">{{printf "%.0f" .Product.SalePrice}} ₽</span>
|
||
<span class="price-block__badge">-{{.Product.DiscountPercent}}%</span>
|
||
{{else}}
|
||
<span class="price-block__current">{{printf "%.0f" .Product.Price}} ₽</span>
|
||
{{end}}
|
||
</div>
|
||
|
||
{{$specs := .Product.Specs}}
|
||
{{if $specs}}
|
||
<dl class="product-specs">
|
||
{{range $specs}}
|
||
<div class="product-specs__row">
|
||
<dt>{{.Label}}</dt>
|
||
<dd>{{.Value}}</dd>
|
||
</div>
|
||
{{end}}
|
||
</dl>
|
||
{{end}}
|
||
|
||
<p class="product-detail__short">{{plain .Product.Description}}</p>
|
||
|
||
<div class="product-actions">
|
||
<form method="POST" action="/buy" class="product-actions__form">
|
||
<input type="hidden" name="product_id" value="{{.Product.ID}}">
|
||
<input type="number" name="quantity" value="1" min="1" max="99" class="qty-input">
|
||
<button type="submit" class="btn btn--primary btn--lg">Купить</button>
|
||
</form>
|
||
<form method="POST" action="/cart/add" class="product-actions__form">
|
||
<input type="hidden" name="product_id" value="{{.Product.ID}}">
|
||
<input type="hidden" name="quantity" value="1">
|
||
<button type="submit" class="btn btn--ghost btn--lg">В корзину</button>
|
||
</form>
|
||
</div>
|
||
|
||
{{if not .ReservedByOther}}
|
||
<form method="POST" action="/product/{{.Product.ID}}/reserve" class="product-reserve">
|
||
<p class="shop-hint">Забронировать на 24 часа — товар будет отложен для вас</p>
|
||
<div class="product-reserve__row">
|
||
<input type="text" name="name" placeholder="Имя" class="shop-input">
|
||
<input type="tel" name="phone" placeholder="Телефон" class="shop-input">
|
||
<button type="submit" class="btn btn--secondary">Забронировать на 24 ч</button>
|
||
</div>
|
||
</form>
|
||
{{end}}
|
||
|
||
<div class="product-compare">
|
||
<form method="POST" action="/compare/add" class="product-compare__form">
|
||
<input type="hidden" name="product_id" value="{{.Product.ID}}">
|
||
<input type="hidden" name="redirect" value="/compare">
|
||
<button type="submit" class="btn btn--ghost btn--sm">⊕ Добавить к сравнению</button>
|
||
</form>
|
||
{{if .CompareProducts}}
|
||
<form method="POST" action="/compare/add" class="product-compare__form">
|
||
<input type="hidden" name="product_id" value="{{.Product.ID}}">
|
||
<select name="other_id" class="shop-input shop-input--sm" required>
|
||
<option value="">Сравнить с другим товаром…</option>
|
||
{{range .CompareProducts}}
|
||
<option value="{{.ID}}">{{.Name}} — {{printf "%.0f" .EffectivePrice}} ₽</option>
|
||
{{end}}
|
||
</select>
|
||
<input type="hidden" name="redirect" value="/compare">
|
||
<button type="submit" class="btn btn--ghost btn--sm">Сравнить</button>
|
||
</form>
|
||
{{end}}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
{{if .PriceHistory}}
|
||
<section class="shop-card product-price-history">
|
||
<h2>История цены</h2>
|
||
<div class="price-history-chart">
|
||
{{range .PriceHistory}}
|
||
<div class="price-history-chart__bar" title="{{.RecordedAt.Format "02.01.2006"}} — {{printf "%.0f" .Price}} ₽">
|
||
<div class="price-history-chart__fill" style="height: {{historyBarPct .Price $.MaxHistoryPrice}}%"></div>
|
||
<span class="price-history-chart__value">{{printf "%.0f" .Price}} ₽</span>
|
||
<span class="price-history-chart__label">{{.RecordedAt.Format "02.01"}}</span>
|
||
</div>
|
||
{{end}}
|
||
</div>
|
||
<table class="price-history-table">
|
||
<thead>
|
||
<tr><th>Дата</th><th>Цена</th><th>Со скидкой</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
{{range .PriceHistory}}
|
||
<tr>
|
||
<td>{{.RecordedAt.Format "02.01.2006"}}</td>
|
||
<td>{{printf "%.0f" .Price}} ₽</td>
|
||
<td>{{if gt .SalePrice 0}}{{printf "%.0f" .SalePrice}} ₽{{else}}—{{end}}</td>
|
||
</tr>
|
||
{{end}}
|
||
</tbody>
|
||
</table>
|
||
</section>
|
||
{{end}}
|
||
|
||
{{if .Product.Details}}
|
||
<section class="product-detail__content shop-card">
|
||
<h2>Описание</h2>
|
||
<div class="product-detail__html">{{safeHTML .Product.Details}}</div>
|
||
</section>
|
||
{{end}}
|
||
</main>
|
||
</body>
|
||
</html>
|
||
{{end}}
|
||
|
||
{{define "compare.html"}}
|
||
<!DOCTYPE html>
|
||
<html lang="ru">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Сравнение товаров — Shop</title>
|
||
<link rel="stylesheet" href="/static/css/style.css">
|
||
<link rel="stylesheet" href="/static/css/shop.css">
|
||
</head>
|
||
<body>
|
||
{{template "shop_header" .}}
|
||
<main class="shop-page container">
|
||
<h1>Сравнение товаров</h1>
|
||
{{if .Products}}
|
||
<div class="compare-table-wrap">
|
||
<table class="compare-table">
|
||
<thead>
|
||
<tr>
|
||
<th></th>
|
||
{{range .Products}}
|
||
<th>
|
||
<a href="/product/{{.ID}}">{{.Name}}</a>
|
||
<form method="POST" action="/compare/remove" class="compare-table__remove">
|
||
<input type="hidden" name="product_id" value="{{.ID}}">
|
||
<button type="submit" class="btn btn--ghost btn--sm">Убрать</button>
|
||
</form>
|
||
</th>
|
||
{{end}}
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>Фото</td>
|
||
{{range .Products}}
|
||
<td><img src="{{.ImageURL}}" alt="" class="compare-table__img"></td>
|
||
{{end}}
|
||
</tr>
|
||
<tr>
|
||
<td>Цена</td>
|
||
{{range .Products}}
|
||
<td>
|
||
{{if .HasSale}}
|
||
<span class="price-block__old">{{printf "%.0f" .Price}} ₽</span>
|
||
<strong>{{printf "%.0f" .SalePrice}} ₽</strong>
|
||
{{else}}
|
||
<strong>{{printf "%.0f" .Price}} ₽</strong>
|
||
{{end}}
|
||
</td>
|
||
{{end}}
|
||
</tr>
|
||
<tr>
|
||
<td>Категория</td>
|
||
{{range .Products}}<td>{{.Category}}</td>{{end}}
|
||
</tr>
|
||
<tr class="compare-table__spec">
|
||
<td>Бренд</td>
|
||
{{range .Products}}<td>{{if .AttrBrand}}{{.AttrBrand}}{{else}}—{{end}}</td>{{end}}
|
||
</tr>
|
||
<tr class="compare-table__spec">
|
||
<td>Размер</td>
|
||
{{range .Products}}<td>{{if .AttrSize}}{{.AttrSize}}{{else}}—{{end}}</td>{{end}}
|
||
</tr>
|
||
<tr class="compare-table__spec">
|
||
<td>Цвет</td>
|
||
{{range .Products}}<td>{{if .AttrColor}}{{.AttrColor}}{{else}}—{{end}}</td>{{end}}
|
||
</tr>
|
||
<tr class="compare-table__spec">
|
||
<td>Материал</td>
|
||
{{range .Products}}<td>{{if .AttrMaterial}}{{.AttrMaterial}}{{else}}—{{end}}</td>{{end}}
|
||
</tr>
|
||
<tr class="compare-table__spec">
|
||
<td>Вес</td>
|
||
{{range .Products}}<td>{{if .AttrWeight}}{{.AttrWeight}}{{else}}—{{end}}</td>{{end}}
|
||
</tr>
|
||
<tr>
|
||
<td></td>
|
||
{{range .Products}}
|
||
<td>
|
||
<form method="POST" action="/buy">
|
||
<input type="hidden" name="product_id" value="{{.ID}}">
|
||
<input type="hidden" name="quantity" value="1">
|
||
<button type="submit" class="btn btn--primary btn--sm">Купить</button>
|
||
</form>
|
||
</td>
|
||
{{end}}
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
{{else}}
|
||
<p class="shop-hint">Добавьте до 2 товаров для сравнения со страницы товара.</p>
|
||
<a href="/" class="btn btn--primary">В каталог</a>
|
||
{{end}}
|
||
</main>
|
||
</body>
|
||
</html>
|
||
{{end}}
|
||
|
||
{{define "category.html"}} |