{#
This file is part of EC-CUBE
Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
http://www.ec-cube.co.jp/
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'default_frame.twig' %}
{% set body_class = 'product_page' %}
{% block stylesheet %}
<style>
.slick-slider {
margin-bottom: 30px;
}
.slick-dots {
position: absolute;
bottom: -45px;
display: block;
width: 100%;
padding: 0;
list-style: none;
text-align: center;
}
.slick-dots li {
position: relative;
display: inline-block;
width: 20px;
height: 20px;
margin: 0 5px;
padding: 0;
cursor: pointer;
}
.slick-dots li button {
font-size: 0;
line-height: 0;
display: block;
width: 20px;
height: 20px;
padding: 5px;
cursor: pointer;
color: transparent;
border: 0;
outline: none;
background: transparent;
}
.slick-dots li button:hover,
.slick-dots li button:focus {
outline: none;
}
.slick-dots li button:hover:before,
.slick-dots li button:focus:before {
opacity: 1;
}
.slick-dots li button:before {
content: " ";
line-height: 20px;
position: absolute;
top: 0;
left: 0;
width: 12px;
height: 12px;
text-align: center;
opacity: .25;
background-color: black;
border-radius: 50%;
}
.slick-dots li.slick-active button:before {
opacity: .75;
background-color: black;
}
.slick-dots li button.thumbnail img {
width: 0;
height: 0;
}
#form1 > div:nth-child(12) {
visibility:hidden;
}
#downloadSpinners {
display: block;
position: absolute;
left: 256px;
top: 256px;
}
#uchiwaCanvas {
background-color: #cccccc;
}
</style>
{% endblock %}
{% block javascript %}
<script>
eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
// 規格2に選択肢を割り当てる。
function fnSetClassCategories(form, classcat_id2_selected) {
var $form = $(form);
var product_id = $form.find('input[name=product_id]').val();
var $sele1 = $form.find('select[name=classcategory_id1]');
var $sele2 = $form.find('select[name=classcategory_id2]');
eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
}
{% if form.classcategory_id2 is defined %}
fnSetClassCategories(
$('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
);
{% elseif form.classcategory_id1 is defined %}
eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
{% endif %}
</script>
<script>
$(function() {
// bfcache無効化
$(window).bind('pageshow', function(event) {
if (event.originalEvent.persisted) {
location.reload(true);
}
});
// Core Web Vital の Cumulative Layout Shift(CLS)対策のため
// img タグに width, height が付与されている.
// 630px 未満の画面サイズでは縦横比が壊れるための対策
// see https://github.com/EC-CUBE/ec-cube/pull/5023
// $('.ec-grid2__cell').hide();
var removeSize = function () {
$('.slide-item').height('');
$('.slide-item img')
.removeAttr('width')
.removeAttr('height')
.removeAttr('style');
};
var slickInitial = function(slick) {
$('.ec-grid2__cell').fadeIn(1500);
var baseHeight = $(slick.target).height();
var baseWidth = $(slick.target).width();
var rate = baseWidth / baseHeight;
$('.slide-item').height(baseHeight * rate); // 余白を削除する
// transform を使用することでCLSの影響を受けないようにする
$('.slide-item img')
.css(
{
'transform-origin': 'top left',
'transform': 'scaleY(' + rate + ')',
'transition': 'transform .1s'
}
);
// 正しいサイズに近くなったら属性を解除する
setTimeout(removeSize, 500);
};
$('.item_visual').on('init', slickInitial);
// リサイズ時は CLS の影響を受けないため属性を解除する
$(window).resize(removeSize);
$('.item_visual').slick({
dots: false,
arrows: false,
responsive: [{
breakpoint: 768,
settings: {
dots: true
}
}]
});
$('.slideThumb').on('click', function() {
var index = $(this).attr('data-index');
$('.item_visual').slick('slickGoTo', index, false);
})
});
</script>
<script>
$(function() {
$('.add-cart').on('click', function(event) {
// console.log('set canvas image');
//
// const c = document.getElementById('uchiwaCanvas');
//
// c.toBlob(function(blob) {
// const imgFile = new File([blob], 'trimedfileupload.png', {type: "image/png"});
// const dt = new DataTransfer();
// dt.items.add(imgFile);
// const fileInput = document.getElementById("file");
// fileInput.files = dt.files;
// });
// console.log('data is : ', c);
// const imgUrl = c.toDataURL();
// console.log('image is : ', imgUrl);
//
// let fd = new FormData($('#form1').get(0))
// fd.delete("file")
// fd.append("file", imgUrl )
// document.getElementById('file').value = imgUrl;
{% if form.classcategory_id1 is defined %}
// 規格1フォームの必須チェック
if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
$('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
return true;
} else {
$('#classcategory_id1')[0].setCustomValidity('');
}
{% endif %}
{% if form.classcategory_id2 is defined %}
// 規格2フォームの必須チェック
if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
$('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
return true;
} else {
$('#classcategory_id2')[0].setCustomValidity('');
}
{% endif %}
// 個数フォームのチェック
if ($('#quantity').val() < 1) {
$('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
return true;
} else {
$('#quantity')[0].setCustomValidity('');
}
event.preventDefault();
const $form = $('#form1');
const formData = new FormData($form.get(0));
$.ajax({
url: $form.attr('action'),
type: $form.attr('method'),
// data: $form.serialize(),
data: formData,
processData: false,
// contentType: 'multipart/form-data',
contentType: false,
dataType: 'json',
// async: false,
beforeSend: function(xhr, settings) {
// Buttonを無効にする
$('.add-cart').prop('disabled', true);
}
}).done(function(data) {
// レスポンス内のメッセージをalertで表示
$.each(data.messages, function() {
$('#ec-modal-header').text(this);
});
$('.ec-modal').show()
// カートブロックを更新する
$.ajax({
url: "{{ url('block_cart') }}",
type: 'GET',
dataType: 'html'
}).done(function(html) {
$('.ec-headerRole__cart').html(html);
});
}).fail(function(data) {
alert('{{ 'カートへの追加に失敗しました。'|trans }}');
}).always(function(data) {
// Buttonを有効にする
$('.add-cart').prop('disabled', false);
});
});
});
$('.ec-modal-wrap').on('click', function(e) {
// モーダル内の処理は外側にバブリングさせない
e.stopPropagation();
});
$('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
$('.ec-modal').hide()
});
const sheet_size = '{{ Product.sheet_size }}';
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "{{ Product.name }}",
"image": [
{% for img in Product.ProductImage %}
"{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
{% else %}
"{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
{% endfor %}
],
"description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
{% if Product.code_min %}
"sku": "{{ Product.code_min }}",
{% endif %}
"offers": {
"@type": "Offer",
"url": "{{ url('product_detail', {'id': Product.id}) }}",
"priceCurrency": "{{ eccube_config.currency }}",
"price": {{ Product.getPrice02IncTaxMin ? Product.getPrice02IncTaxMin : 0}},
"availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
}
}
</script>
{% endblock %}
{% block main %}
{% set hasCategory = false %}
{% for ProductCategory in Product.ProductCategories %}
{% if ProductCategory.Category.id == 21 or ProductCategory.Category.id == 22 %}
{% set hasCategory = true %}
{% endif %}
{% endfor %}
<div class="ec-productRole">
<div class="ec-grid2">
<div class="ec-grid2__cell">
<div class="product-image">
{% if hasCategory == false %}
<div class="uchiwa_img_wrapper" style="width:50%;margin: 20px">
<canvas id="uchiwaCanvas" class="img_canvas" height="512" width="512"></canvas>
</div>
<div id="downloadSpinners"><svg class="q-spinner text-primary" width="4em" height="4em" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient x1="8.042%" y1="0%" x2="65.682%" y2="23.865%" id="a"><stop stop-color="currentColor" stop-opacity="0" offset="0%"></stop><stop stop-color="currentColor" stop-opacity=".631" offset="63.146%"></stop><stop stop-color="currentColor" offset="100%"></stop></linearGradient></defs><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><path d="M36 18c0-9.94-8.06-18-18-18" stroke="url(#a)" stroke-width="2"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.9s" repeatCount="indefinite"></animateTransform></path><circle fill="currentColor" cx="36" cy="18" r="1"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.9s" repeatCount="indefinite"></animateTransform></circle></g></svg><!----></div>
{% endif %}
{# {{ dump(Product) }}#}
{# {{ dump(form) }}#}
{# {% for choice in form.order_color1.choices %} #}
{# {{ dump(choice) }} #}
{# {% endfor %} #}
</div>
<div class="ec-sliderItemRole">
{% if hasCategory %}
<div class="item_visual">
{% for ProductImage in Product.ProductImage %}
<div class="slide-item"><img src="{{ asset(ProductImage, 'save_image') }}"
alt="{{ loop.first ? Product.name : '' }}" width="550"
height="550"{% if loop.index > 1 %} loading="lazy"{% endif %}>
</div>
{% else %}
<div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}"
alt="{{ loop.first ? Product.name : '' }}" width="550"
height="550"></div>
{% endfor %}
</div>
<div class="item_nav">
{% for ProductImage in Product.ProductImage %}
<div class="slideThumb" data-index="{{ loop.index0 }}"><img
src="{{ asset(ProductImage, 'save_image') }}" alt="" width="133" height="133"
loading="lazy"></div>
{% endfor %}
</div>
{% endif %}
</div>
<div style="margin-top: 120px;">
<p>上の文字と下の文字は空白で左右の位置を調整できます</p>
<h4>ご注意</h4>
<p>実際の商品は、仕上がりイメージと若干異なる場合があります</p>
<p>ひらがななどで全体が一枚でつながらない場合には、背景でつながるげることがあります</p>
</div>
<div>
<img class="material__img" src="/ecshop/html/user_data/assets/img/material/color_basic1.jpg" alt="カラー一覧"><br>
<img class="material__img" src="/ecshop/html/user_data/assets/img/material/color_basic2.jpg" alt="カラー一覧"><br>
<img class="material__img" src="/ecshop/html/user_data/assets/img/material/color_basic3.jpg" alt="カラー一覧">
</div>
</div>
<div class="ec-grid2__cell">
<div class="ec-productRole__profile">
{# 商品名 #}
<div class="ec-productRole__title">
<h2 class="ec-headingTitle">{{ Product.name }}</h2>
</div>
{# <div style="width: 50%;margin: 20px;display:none;"> #}
{# <input type="text" id="uchiwa_up_text" name="uchiwa_up_text" value="未来"/><br/> #}
{# <input type="text" id="uchiwa_main_text" name="uchiwa_main_text" value="看" #}
{# style="width:100%;"/><br> #}
{# <input type="text" id="uchiwa_low_text" name="uchiwa_lo_text" value="板"/><br/> #}
{# <button id="uchiwa_set" type="button">再作画</button> #}
{# <br/> #}
{# 一番外側の色: #}
{# <select id="uchiwa_back_color1" name="back_color1"> #}
{# </select> #}
{# <br/> #}
{# フチの外枠: #}
{# <select id="uchiwa_back_color2" name="back_color2"> #}
{# </select> #}
{# <br/> #}
{# フチの中: #}
{# <select id="uchiwa_back_color3" name="back_color3"> #}
{# </select> #}
{# <br/> #}
{# 文字の色: #}
{# <select id="uchiwa_back_color4" name="back_color4"> #}
{# </select> #}
{# <br/> #}
{# </div> #}
{# タグ #}
<ul class="ec-productRole__tags">
{% for Tag in Product.Tags %}
<li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
{% endfor %}
</ul>
{# 通常価格 #}
{% if Product.hasProductClass -%}
<div class="ec-productRole__priceRegular">
{% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %}
<span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span
class="price01-default">{{ Product.getPrice01IncTaxMin|price }}</span></span>
<span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
{% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %}
<span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:<span
class="price01-default">{{ Product.getPrice01IncTaxMin|price }}~ {{ Product.getPrice01IncTaxMax|price }}</span></span>
<span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
{% endif %}
</div>
{% else %}
{% if Product.getPrice01Max is not null %}
<span class="ec-productRole__priceRegularPrice">{{ '通常価格'|trans }}:{{ Product.getPrice01IncTaxMin|price }}</span>
<span class="ec-productRole__priceRegularTax">{{ '税込'|trans }}</span>
{% endif %}
{% endif %}
{# 販売価格 #}
<div class="ec-productRole__price">
{% if Product.hasProductClass -%}
{% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
<div class="ec-price">
<span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
<span class="ec-price__tax">{{ '税込'|trans }}</span>
</div>
{% else %}
<div class="ec-price">
<span class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span>
<span class="ec-price__tax">{{ '税込'|trans }}</span>
</div>
{% endif %}
{% else %}
<div class="ec-price">
<span class="ec-price__price">{{ Product.getPrice02IncTaxMin|price }}</span>
<span class="ec-price__tax">{{ '税込'|trans }}</span>
</div>
{% endif %}
</div>
{# 商品コード #}
{% if Product.code_min is not empty %}
<div class="ec-productRole__code">
{{ '商品コード'|trans }}: <span
class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
</div>
{% endif %}
{# 関連カテゴリ #}
{% if Product.ProductCategories is not empty %}
<div class="ec-productRole__category">
<div>{{ '関連カテゴリ'|trans }}</div>
{% for ProductCategory in Product.ProductCategories %}
<ul>
<li>
{% for Category in ProductCategory.Category.path %}
<a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> {%- if loop.last == false %}
<span>></span>{% endif -%}
{% endfor %}
</li>
</ul>
{% endfor %}
</div>
{% endif %}
<form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1"
enctype="multipart/form-data">
{% if Product.stock_find %}
<div class="ec-productRole__actions">
{% if form.classcategory_id1 is defined %}
<div class="ec-select">
{{ form_row(form.classcategory_id1) }}
{{ form_errors(form.classcategory_id1) }}
</div>
{% if form.classcategory_id2 is defined %}
<div class="ec-select">
{{ form_row(form.classcategory_id2) }}
{{ form_errors(form.classcategory_id2) }}
</div>
{% endif %}
{% endif %}
{# <div class="ec-numberInput"><span>文字</span> #}
{# {{ form_widget(form.order_text1) }} #}
{# {{ form_errors(form.order_text1) }} #}
{# </div> #}
{# <div class="ec-numberInput"><span>上文字</span> #}
{# {{ form_widget(form.order_text1) }} #}
{# {{ form_errors(form.order_text1) }} #}
{# </div> #}
{# <div class="ec-numberInput"><span>文字</span> #}
{# {{ form_widget(form.order_text2) }} #}
{# {{ form_errors(form.order_text2) }} #}
{# </div> #}
{# <div class="ec-numberInput"><span>下文字</span> #}
{# {{ form_widget(form.order_text3) }} #}
{# {{ form_errors(form.order_text3) }} #}
{# </div> #}
{# <div class="ec-numberInput"><span>外枠の色</span> #}
{# {{ form_widget(form.order_color1) }} #}
{# {{ form_errors(form.order_color1) }} #}
{# </div> #}
{# <div class="ec-numberInput"><span>文字の色</span> #}
{# {{ form_widget(form.order_color2) }} #}
{# {{ form_errors(form.order_color2) }} #}
{# </div> #}
{# <div class="ec-numberInput"><span>書体</span> #}
{# {{ form_widget(form.order_font) }} #}
{# {{ form_errors(form.order_font) }} #}
{# </div> #}
{# <div class="ec-numberInput"><span>{{ '数量'|trans }}</span> #}
{# {{ form_widget(form.quantity) }} #}
{# {{ form_errors(form.quantity) }} #}
{# </div> #}
</div>
{{ form_rest(form) }}
<div class="ec-productRole__btn">
<button id="add-cart-button" type="submit" class="ec-blockBtn--action add-cart" disabled>
{{ 'カートに入れる'|trans }}
</button>
</div>
{% else %}
<div class="ec-productRole__btn">
<button type="button" class="ec-blockBtn--action" disabled="disabled">
{{ 'ただいま品切れ中です。'|trans }}
</button>
</div>
{% endif %}
{# <div style="display: none"><input type="text" name="file" id="image_file"></div>#}
</form>
<div class="ec-modal">
<div class="ec-modal-overlay">
<div class="ec-modal-wrap">
<span class="ec-modal-close"><span class="ec-icon"><img
src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
<div id="ec-modal-header" class="text-center">{{ 'カートに追加しました。'|trans }}</div>
<div class="ec-modal-box">
<div class="ec-role">
<span class="ec-inlineBtn--cancel">{{ 'お買い物を続ける'|trans }}</span>
<a href="{{ url('cart') }}"
class="ec-inlineBtn--action">{{ 'カートへ進む'|trans }}</a>
</div>
</div>
</div>
</div>
</div>
{% if BaseInfo.option_favorite_product %}
<form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
<div class="ec-productRole__btn">
{% if is_favorite == false %}
<button type="submit" id="favorite" class="ec-blockBtn--cancel">
{{ 'お気に入りに追加'|trans }}
</button>
{% else %}
<button type="submit" id="favorite" class="ec-blockBtn--cancel"
disabled="disabled">{{ 'お気に入りに追加済です。'|trans }}
</button>
{% endif %}
</div>
</form>
{% endif %}
<div class="ec-productRole__description">{{ Product.description_detail|raw|nl2br }}
</div>
</div>
</div>
</div>
{% if Product.freearea %}
<div class="ec-productRole__description">
{{ include(template_from_string(Product.freearea)) }}
</div>
{% endif %}
</div>
<script>
// https://mirai-kanban.com/ecshop/html/user_data/assets/js/test2.html
const product_color_type1 = '{{ Product.product_color_type1 }}'
const product_color_type2 = '{{ Product.product_color_type2 }}'
</script>
<script src="{{ asset('assets/js/mirai.js') }}"></script>
{% endblock %}