@extends('vip.layouts')
@section('seo_title')
    {{ trans('menu.take_money') }}
@endsection
@section('content')

<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">用户名</label>
    <div class="layui-input-block">
      <input type="text" name="account_name" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input" value="{{isset(
      $data['agent_name'])?$data['agent_name']:''}}" disabled="disabled">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">订单号</label>
    <div class="layui-input-block">
    <input type="text" name="order_id"   lay-verify="" autocomplete="off" class="layui-input" value="{{isset($data['order_id'])?$data['order_id']:''}}" readonly="readonly">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">加款前余额</label>
    <div class="layui-input-inline">
      <input type="text" name="pre_money"   lay-verify="" autocomplete="off" class="layui-input" value="{{$data['pre_money']}}" disabled="disabled">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">金额</label>
    <div class="layui-input-inline">
      <!--<input type="text" name="money"   lay-verify="" autocomplete="off" class="layui-input" value="" disabled="disabled">-->
      <b  lay-verify="" autocomplete="off" class="layui-input money"  style="color: red;line-height: 38px;">{{$data['money']}}</b>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">加款前余额</label>
    <div class="layui-input-inline">
      <input type="text" name="last_money"   lay-verify="" autocomplete="off" class="layui-input" value="{{$data['last_money']}}" disabled="disabled">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">申请时间</label>
    <div class="layui-input-inline">
      <input type="text" name="apply_time"   lay-verify="" autocomplete="off" class="layui-input" value="{{$data['apply_time']}}" disabled="disabled">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">操作</label>
    <div class="layui-input-block">
      <input type="radio" name="type" value="2" title="通过" @if($data['status']!=3) checked  @endif @if($data['status']!=1) disabled="disabled" @endif>
      <input type="radio" name="type" value="3" title="不通过" @if($data['status']==3) checked @endif @if($data['status']!=1) disabled="disabled" @endif>
    </div>
  </div>

  {{--<div class="layui-form-item">--}}
    {{--<label class="layui-form-label">备注</label><span style="color: red">(选填项)</span>--}}
    {{--<div class="layui-input-inline">--}}
        {{--<textarea style="resize:none"   name="reason" cols="20" rows="2">{{$data['reason']}}</textarea>--}}
      {{--<input type="text" name="reason"   lay-verify="" autocomplete="off" class="layui-input" value="{{$data['reason']}}">--}}
    {{--</div>--}}
  {{--</div>--}}

  @if($data['status']==1)
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn sub" lay-submit lay-filter="submitForm">立即提交</button>
      <!-- <button type="reset" class="layui-btn layui-btn-normal">重置</button> -->
    </div>
  </div>
  @endif
</form>

<script>
//Demo
layui.use(['form'], function(){
  var form = layui.form;

  //监听提交
//  form.on('submit(submitForm)', function(data){
//    return true;
//  });

    $('.sub').on('click',function(){


        var name = $('input[name=account_name]').val();
        var type = $('input[name=type]:checked').val();
        var money = $('input[name=last_money]').val();
//        var balance = $('input[name=balance]').val();
        var peize_bate = $('.money').text();

        money = parseFloat(money);
        peize_bate = parseFloat(peize_bate);
        var reward = peize_bate * money / 100;
        var str = '';

        if (type === '2') {
            str += ' <div class="layui-form-item" style="margin-top: 15px">\n' +
                '            <label class="layui-form-label">用户名</label>\n' +
                '            <div class="layui-input-inline">\n' +
                '                <input type="text" class="layui-input"disabled="disabled" value="' + name + '">\n' +
                '            </div>\n' +
                '        </div>';

            str += ' <div class="layui-form-item">\n' +
                '            <label class="layui-form-label">取款金额</label>\n' +
                '            <div class="layui-input-inline">\n' +
                '                <input type="text" class="layui-input" disabled="disabled" value="' + peize_bate + '">\n' +
                '            </div>\n' +
                '        </div>';
            str += ' <div class="layui-form-item">\n' +
                '            <label class="layui-form-label">取款后余额</label>\n' +
                '            <div class="layui-input-inline">\n' +
                '                <input type="text" class="layui-input" disabled="disabled" value="' + (money) + '">\n' +
                '            </div>\n' +
                '        </div>';
        }else {
            str += ' <p style="line-height: 60px;height:60px;text-align: center;font-size: 18px;">不通过</p>';
        }



        layer.open({
            type: 1,
            btn: ['确定', '取消'],
            btnAlign: 'c',
            id:'box',
            content: str,  //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            yes:function (index, layero) {
                layer.close(index);
                $('#submitForm').submit();
            }
        });
        return false;
    })


});
function cbFormSuccess(data) {
	parent.window.updateNum();
    layer.alert(data.msg,{},function () {
        window.location.href='/admin/agentTake/index';
//        window.history.go(-1);//返回上一页
    });
}

</script>
@endsection
