first commit
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load static i18n i18n_tags %}
|
||||
|
||||
{% block breadcrumb %}{% include 'includes/breadcrumb.html' %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="section bg-white py-4">
|
||||
<div class="container">
|
||||
<div class="row g-5">
|
||||
<div class="col-lg-6">
|
||||
<div class="product-gallery">
|
||||
<div class="gallery-main">
|
||||
{% with gallery|first as first_img %}
|
||||
<img id="mainImage" src="{% if first_img %}{{ first_img.image.url }}{% elif product.main_image %}{{ product.main_image.url }}{% else %}{% static 'images/placeholder.png' %}{% endif %}" alt="{% ml_field product 'name' %}">
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% if gallery %}
|
||||
<div class="gallery-thumbs">
|
||||
{% for img in gallery %}
|
||||
<img src="{{ img.image.url }}" alt="{% ml_field img 'caption' %}" onclick="document.getElementById('mainImage').src='{{ img.image.url }}'">
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<h2>{% ml_field product 'name' %}</h2>
|
||||
{% if product.model %}<p class="text-secondary">{% trans '型号' %}: {{ product.model }}</p>{% endif %}
|
||||
<p class="lead">{% ml_field product 'summary' %}</p>
|
||||
{% if product.features_zh or product.features_en %}
|
||||
<h5 class="mt-4">{% trans '产品特点' %}</h5>
|
||||
<ul class="list-unstyled">
|
||||
{% for f in product.features_zh %}
|
||||
<li class="mb-2"><i class="fa fa-check text-primary me-2"></i>{{ f }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
<div class="mt-4 d-flex gap-2">
|
||||
<a href="{% url 'contact' %}" class="btn btn-primary">{% trans '咨询购买' %}</a>
|
||||
{% if product.download_file %}
|
||||
<a href="{{ product.download_file.url }}" class="btn btn-outline-primary"><i class="fa fa-download me-1"></i>{% trans '资料下载' %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if product.video_url or product.video_file %}
|
||||
<div class="mt-5">
|
||||
<h4>{% trans '产品视频' %}</h4>
|
||||
<div class="video-container mt-3">
|
||||
{% if product.video_file %}
|
||||
<video controls src="{{ product.video_file.url }}"></video>
|
||||
{% elif product.video_url %}
|
||||
{% if 'bilibili' in product.video_url or 'youtube' in product.video_url %}
|
||||
<iframe src="{{ product.video_url }}" allowfullscreen></iframe>
|
||||
{% else %}
|
||||
<video controls src="{{ product.video_url }}"></video>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="mt-5">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item"><a class="nav-link active" data-bs-toggle="tab" href="#desc">{% trans '产品描述' %}</a></li>
|
||||
{% if product.specs_zh %}<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#specs">{% trans '技术参数' %}</a></li>{% endif %}
|
||||
</ul>
|
||||
<div class="tab-content border border-top-0 p-4">
|
||||
<div class="tab-pane fade show active" id="desc">
|
||||
{{ product.description_zh|safe|default:product.description_en|safe }}
|
||||
</div>
|
||||
{% if product.specs_zh %}
|
||||
<div class="tab-pane fade" id="specs">
|
||||
<table class="table specs-table">
|
||||
<tbody>
|
||||
{% for k, v in product.specs_zh.items %}
|
||||
<tr><th>{{ k }}</th><td>{{ v }}</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if related %}
|
||||
<div class="mt-5">
|
||||
<h4>{% trans '相关产品' %}</h4>
|
||||
<div class="row g-4 mt-3">
|
||||
{% for p in related %}
|
||||
<div class="col-lg-3 col-md-4 col-6">
|
||||
<div class="card h-100">
|
||||
{% if p.main_image %}<img src="{{ p.main_image.url }}" class="card-img-top" alt="{% ml_field p 'name' %}" style="height: 140px; object-fit: cover;">{% endif %}
|
||||
<div class="card-body p-3">
|
||||
<h6 class="card-title small">{% ml_field p 'name' %}</h6>
|
||||
<a href="{% url 'product_detail' p.slug %}" class="btn btn-sm btn-outline-primary w-100">{% trans '查看' %}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,46 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load static i18n i18n_tags %}
|
||||
|
||||
{% block breadcrumb %}{% include 'includes/breadcrumb.html' %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="section bg-white py-4">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-3 mb-4 mb-lg-0">
|
||||
<div class="card p-3">
|
||||
<h6 class="mb-3">{% trans '产品分类' %}</h6>
|
||||
<div class="list-group list-group-flush">
|
||||
<a href="{% url 'product_list' %}" class="list-group-item list-group-item-action {% if not current_category %}active{% endif %} border-0 px-0">{% trans '全部产品' %}</a>
|
||||
{% for cat in categories %}
|
||||
<a href="?category={{ cat.slug }}" class="list-group-item list-group-item-action {% if current_category == cat.slug %}active{% endif %} border-0 px-0">{% ml_field cat 'name' %}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-9">
|
||||
<div class="row g-4">
|
||||
{% for product in page_obj %}
|
||||
<div class="col-lg-4 col-md-6">
|
||||
<div class="card h-100">
|
||||
{% if product.main_image %}
|
||||
<img src="{{ product.main_image.url }}" class="card-img-top" alt="{% ml_field product 'name' %}" style="height: 200px; object-fit: cover;">
|
||||
{% endif %}
|
||||
<div class="card-body">
|
||||
<h6 class="card-title">{% ml_field product 'name' %}</h6>
|
||||
{% if product.model %}<small class="text-secondary">{{ product.model }}</small>{% endif %}
|
||||
<p class="card-text text-secondary small mt-2">{% ml_field product 'summary' %}</p>
|
||||
<a href="{% url 'product_detail' product.slug %}" class="btn btn-sm btn-outline-primary">{% trans '查看详情' %}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% empty %}
|
||||
<div class="col-12 text-center py-5 text-secondary">{% trans '暂无产品数据' %}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% include 'includes/pagination.html' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user