@extends('theme::template')

@section('banner')
	<div class="nbanner">
		<img src="{{ inject('ad')->single(4, 0, 'img') }}" alt="{{ inject('ad')->single(4, 0, 'title') }}">
	</div>
@stop

@section('anchor')
<div id="anchor">
	<div class="container-fluid">
		<span class="anchor">
			<a href="{{ url('/') }}">{{ inject('setting')->langs('system', 'home') }}</a> > {{ inject('setting')->langs('system', 'message') }}
		</span>
	</div>
</div>
@stop

@section('left')
@stop

@section('right')
@stop

@section('content')
<style>
	#page-wrap {
		display: none;
	}
	.nei-template-wrap{
		display: none;
	}
</style>
{!! Form::open(['route' => 'message.store', 'class'=>'form-horizontal mt-50 pb-50 form-submit', 'novalidate' => true]) !!}
<div class="container-fluid">
	@if($product)
	<input type="hidden" name="product_id" value="{{ $product->id }}">
	<div class="clearfix message-product">
		<div class="mb-20 col-sm-2 pl-10 pr-10">
			<img class="img" src="{{ $product->description->present()->image('300*300') }}" alt="{{ $product->description->title ?? '' }}">
		</div>
		<div class="mb-20 col-sm-10 pl-10 pr-10">
			<div class="message-product-title">{{ $product->description->title ?? '' }}</div>
			<div class="message-product-summary">{{ $product->description->summary ?? '' }}</div>
			<a class="message-product-href mt-15" href="{{ $product->present()->url }}">{{ inject('setting')->langs('system', 'click_detail') }}</a>
		</div>    
	</div>
	@endif
	<div class="clearfix">
		<div class="mb-20 col-md-12 pl-10 pr-10">
			<div class="form-input">
				@if($product)
					<input class="form-control len-full subject" name="subject" type="text" value="{{ $product->description->title ?? '' }}">
				@else
			 		{!! Form::text('subject', '', ['class'=>'form-control len-full subject', 'placeholder'=>inject('setting')->langs('web', 'subject')]) !!}
				@endif
			</div>
		</div>
		<div class="mb-20 col-md-6 pl-10 pr-10">
			<div class="form-input">
			 	{!! Form::text('name', '', ['class'=>'form-control len-full name', 'placeholder'=>inject('setting')->langs('web', 'name')]) !!}
			</div>
		</div>
		<div class="mb-20 col-md-6 pl-10 pr-10">
			<div class="form-input">
			 	{!! Form::text('phone', '', ['class'=>'form-control len-full phone', 'placeholder'=>inject('setting')->langs('web', 'phone')]) !!}
			</div>
		</div>
	</div>
	<div class="clearfix">
		<div class="mb-20 col-md-6 pl-10 pr-10">
			<div class="form-input">
			 	{!! Form::email('email', '', ['class'=>'form-control len-full email', 'placeholder'=>inject('setting')->langs('web', 'email') . '*', 'required' => true]) !!}
        <div class="invalid-feedback">
          {{ inject('setting')->langs('system', 'valid_email') }}
        </div>
			</div>
		</div>
		<div class="mb-20 col-md-6 pl-10 pr-10">
			<div class="form-input">
			 	{!! Form::text('company', '', ['class'=>'form-control len-full company', 'placeholder'=>inject('setting')->langs('web', 'company')]) !!}
			</div>
		</div>
	</div>
	<div class="mb-20 pl-10 pr-10">
		<div class="form-input">
		 	{!! Form::textarea('content', '', ['class'=>'form-control len-full content', 'rows'=>8, 'placeholder'=>inject('setting')->langs('web', 'inquiry_tips')]) !!}
		</div>
	</div>
    <div class="clearfix">
    {{-- 人机验证和验证切换渲染html结构 --}}
    @include('theme::common.grecaptcha', ['key' => 'message'])
    </div>
	<div class="mb-15 mt-20 pl-10 text-center">
		<button type="submit" id="subBtn_message" class="btn btn-primary">{{ inject('setting')->langs('system', 'send_inquiry') }}</button>
	</div>
</div>
{!! Form::close() !!}
@stop

@section('foot')
  <script>
      (function() {
          'use strict';
          window.addEventListener('load', function() {
              var forms = document.getElementsByClassName('form-submit');
              var validation = Array.prototype.filter.call(forms, function(form) {
                  form.addEventListener('submit', function(event) {
                      if (form.checkValidity() === false) {
                          event.preventDefault();
                          event.stopPropagation();
                      }
                      form.classList.add('was-validated');
                  }, false);
              });
          }, false);
      })();
  </script>
@stop