@extends('vip.layouts')
@section('content')
<style type="text/css">
  .loss-input {
    /* display: block; */
    width: 100%;
    padding-left: 10px;
}
.loss-input {
    height: 38px;
    line-height: 1.3;
    line-height: 38px\9;
    border-width: 1px;
    border-style: solid;
    background-color: #fff;
    border-radius: 2px;
}
</style>
<form class="layui-form" action="{{ url()->full() }}" id="submitForm" name="submitForm" method="post" eventType=eventAjaxForm>
{!! csrf_field() !!}
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('lottery_money.name') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="name"   id="name"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($data) {{ $data['name'] }} @endisset" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
            <div class="layui-form-item">
              <label class="layui-form-label">{{ trans('lottery_money.give_type') }}：</label>
              <div class="layui-input-block">
                  <input type="radio" name="setup" value="1" checked="true" title="手动申请" @if(isset($setup) && $setup == 1) checked @endif>
                  <input type="radio" name="setup" value="2" title="自动计算" @if(isset($setup) && $setup == 2) checked @endif>
              </div>
            </div>
            <div class="layui-form-item">
            <label class="layui-form-label">彩金类型:</label>
            <div class="layui-input-block" style="width: 300px; float:left; margin-left: 0px;">
              <select name="sub_type" id="type" lay-filter="sub_type" autocomplete="off" class="layui-input" eventType=event-query>
                <option value="first_save" @if(isset($data['sub_type'])&&$data['sub_type']=='first_save')selected @endif >用户首冲</option>
                <option value="days" @if(isset($data['sub_type'])&&$data['sub_type']=='days')selected @endif >时间天数</option>
              </select>
              </div>
              <div class="layui-input-inline" style="width: 200px; margin-left: 20px; @isset($data['sub_type']) @if($data['sub_type']=='days') display: block; @else display: none; @endif @else display: none;  @endisset" id="days">
                <input type="text" name="daynumber"  lay-verify="" placeholder="请输入天数" autocomplete="off" value="@isset($daynumber) {{ $daynumber }} @endisset" class="layui-input">
            </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">限制金额:</label>
                <div class="layui-input-block" style="line-height: 36px;">
                <input type="text" name="give_type"   id="give_type"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($give_type) {{ $give_type }} @endisset" class="layui-input" style="width: 150px; float: left;"> &nbsp;&nbsp;
                </div>
            </div>

            <div class="layui-form-item">
            <label class="layui-form-label">{{ trans('lottery_money.grade') }}</label>
            <div class="layui-input-block">
              @foreach($User_grade as $k=>$v)
                <div style="float: left;margin-right: 20px; width: 150px;"><input type="checkbox" name="grade[]" value="{{$v['id']}}" @if(isset($v['active']) && $v['active'] == 1) checked @endif>{{$v['name']}}</div>
                <input type="text" name="number[]" lay-verify="" placeholder="请输入人数" autocomplete="off" value="@isset($v['number']) {{ $v['number'] }} @endisset" class="layui-input" style="width: 150px; float: left; margin-right: 20px;">
                <input type="text" name="prize[]" lay-verify="" placeholder="请输入彩金" autocomplete="off" value="@isset($v['prize']) {{ $v['prize'] }} @endisset" class="layui-input" style="width: 150px; float: left;margin-right: 20px;">
                <div style="clear: both;"></div>
              @endforeach
              </div>

            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">提款倍数:</label>
                <div class="layui-input-block">
                <input type="text" name="multiple"   id="multiple"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($multiple) {{ $multiple }} @endisset" class="layui-input">
                </div>
            </div>
            <input type="hidden" name="sort" value='1'>
            <input type="hidden" name="type" value='recommend'>
            
            


@if(S('ACTION')!='view')
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="submitForm">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-green">重置</button>
    </div>
  </div>
@endif
</form>

<script>
//Demo

  var condiloss_money = $('.loscon').html();
  var condilucky_money = $('.luccon').html();
var dt = '';

//添加条件
function addcondi(){
  var did = $('.addcondi').attr('data-id');
  if(did>=10){
    layer.msg('最多添加十项条件');
    return false;
  }
  var mat = parseInt(did)-1;
  var ac = $('.addcondi').attr('data-type');
  if(dt==''){
    if(ac=='loss_money'){
      condiloss_moneyt = condiloss_money.replace(/-0/g, "-"+did);
      $('.addbut').before(condiloss_moneyt);
    }else if(ac=='lucky_money'){
      condilucky_moneyt = condilucky_money.replace(/-0/g, "-"+did);
      $('.addbut').before(condilucky_moneyt);
    }
  }else if(dt=='loss_money'){
      condiloss_moneyt = condiloss_money.replace(/-0/g, "-"+did);
    $('.addbut').before(condiloss_moneyt);
  }else if(dt=='lucky_money'){
      condilucky_moneyt = condilucky_money.replace(/-0/g, "-"+did);
    $('.addbut').before(condilucky_moneyt);
  }
  $('.addcondi').attr('data-id',parseInt(did)+1);
}

//删除条件
function delcondi(){
  var did = $('.addcondi').attr('data-id');
  if(did<=1){
    layer.msg('至少包含一项条件');
    return false;
  }
  var mat = parseInt(did)-1;
  var dstr = '-'+mat;
  $("input[id$='"+dstr+"']").parent().parent().remove();
  
  $('.addcondi').attr('data-id',mat);
  $('.delcondi').attr('data-id',mat);
}

layui.use(['form'], function(){
  var form = layui.form;
  $('.loscon').remove();
  $('.luccon').remove();
  var codistr = '';
  form.on('select(testSelect)', function(data){
     console.log(data.value);
     dt = data.value;
     if (data.value=='join' || data.value=='month_join' || data.value=='week_join' || data.value=='loss_money'|| data.value=='day_join') {
          $('.single').show();
          // $('#labels').hide();
     }else{
         $('.single').hide();
         // $('#labels').show();
     }
     if(data.value=='sign_money'){
         $('.sign_money').show();
     }else{
         $('.sign_money').hide();
     }
     if(data.value=='night_join'){
        $('.night_join').show();
     }else{
        $('.night_join').hide();
     }
     
     if (data.value=='loss_money') {
          $('.loss_money').show();
          $('.extrcon').after(condiloss_money);
     }else{
         $('.condiloss_money').remove();
         $('.loss_money').hide();
     }
     if (data.value=='lucky_money') {
          $('.lucky_money').show();
          $('.extrcon').after(condilucky_money);
     }else{
          $('.condilucky_money').remove();
         $('.lucky_money').hide();
     }
     if (data.value=='lucky_money' || data.value=='loss_money') {
          $('.addcondi').show();
          $('.addbut').show();
          $('.extrcon').show();
     }else{
          $('.extrcon').hide();
          $('.addbut').hide();
         $('.addcondi').hide();
     }
  });

  //监听提交
  form.on('submit(submitForm)', function(data){
    return true;
  });
  form.on('select(sub_type)', function (data) {
      if(data.value =='days'){
          $("#days").show();
      }else{
          $("#days").hide();
      }
  });
});
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  //时间选择器
  laydate.render({
    elem: '#cd1-star_time'
    ,type: 'time'
  });

  //时间选择器
  laydate.render({
    elem: '#cd1-end_time'
    ,type: 'time'
  });
});
//时间类型筛选时间
            
/*lay('.test-item').each(function(){
    laydate.render({
        elem: this
        ,type: 'datetime'
        ,trigger: 'click'
    });
});*/
</script>
@endsection
