@extends('Public.index')
@section('admin')

<div class="content-wrapper" style="min-height: 810px;">
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h4>购买须知</h4>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="/admin/index">首页</a></li>
              <li class="breadcrumb-item active">商品管理</li>
              <li class="breadcrumb-item active">购买须知</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

        <div class="form-group col-md-12">
            <label for="name" class="col-sm-2 control-label"> 选择门店</label>
                <div class="col-sm-3">
                    <select class="form-control" id="cate">
                        @foreach($md as $key => $val)
                        <option value="{{ $val -> id }}" @if($md_id == $val -> id) selected @endif> {{ $val -> md_name }}</option>
                        @endforeach
                    </select>
                </div>
        </div>

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-6">
          <input type="hidden" class="contentid" value="{{ isset($goods_notes -> id)? $goods_notes -> id : ''}}">
                <div class="form-group">
                    <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">须知内容</font></font></label>
                    <textarea class="form-control contents" rows="11" placeholder="Enter ...">{{ isset($goods_notes -> content)?$goods_notes -> content:'' }}</textarea>
                </div>
                <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">是否显示</font></font></label>
                <div class="form-group">
                    <label class="radio-inline">
                    <input type="radio" name="notesStatus" id="inlineRadio1" value="1" @if(isset($goods_notes -> status) == 1) checked @endif> 是
                    </label>
                    　　
                    <label class="radio-inline">
                    <input type="radio" name="notesStatus" id="inlineRadio2" value="0" @if(isset($goods_notes -> status) == 0) checked @endif> 否
                    </label>
                </div>
                
                <button class="btn btn-info save">保存</button>
                <button class="btn btn-danger clear">清空</button>
          </div>
        </div>
    </section>
  </div>
  <script src="/admin/plugins/jquery/jquery.min.js"></script>
  <script src="/admin/layer-v3.1.1/layer/layer.js"></script>
  <script>
    $('#cate').change(function(){
        var id = $('#cate option:selected').val();
        window.location.href="/admin/goodscate/notes?id="+id;
    })
    $('.clear').click(function(){
        $('.contents').val('');
    });
    $('.save').click(function(){
        var content = $('.contents').val();
        var id = $('.contentid').val();
        var status = $('input:radio:checked').val();
        var md = $('#cate').val();
        if(!content || !md){
            layer.alert('内容不能为空');
            return false;
        }
        $.get('/admin/goodscate/notesSave',{id:id,content:content,status:status,md:md},function(res){
            if(res.code == '1000'){
                layer.alert(res.msg);
            }else{
                layer.alert(res.msg);
            }
        })
    })
  </script>
@endsection
@section('title','购买须知')
@section('goods','menu-open')
@section('goods2','active')
@section('xuzhi','active')