@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['account_name'])?$data['account_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="bank_info" lay-verify="" autocomplete="off" class="layui-input" value="{{$data['bank_info']}}" disabled="disabled">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">卡号</label>
            <div class="layui-input-inline">
                <input type="text" name="bank_no" lay-verify="" autocomplete="off" class="layui-input" value="{{$data['bank_no']}}" disabled="disabled">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">开户姓名</label>
            <div class="layui-input-inline">
                <input type="text" name="bank_user" lay-verify="" autocomplete="off" class="layui-input" value="{{$data['bank_user']}}" disabled="disabled">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">开户地址</label>
            <div class="layui-input-inline">
                <input type="text" name="bank_address" lay-verify="" autocomplete="off" class="layui-input" value="{{$data['bank_address']}}"
                       disabled="disabled">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
      <textarea disabled="disabled" style="width: 550px;height: 105px;" cols="80" rows="8">{{$data['user_remark']}}
      </textarea>
            </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-inline">
                <input type="text" name="bettingMoney" lay-verify="" autocomplete="off" class="layui-input" value="{{$data['bettingMoney']}}"
                       disabled="disabled">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">目标流水</label>
            <div class="layui-input-inline">
                <input type="text" name="needBettingMoney" lay-verify="" autocomplete="off" class="layui-input" value="{{$data['needBettingMoney']}}"
                       disabled="disabled">
            </div>
            <div class="layui-input-inline">
                <input class="layui-btn" id="freshMoney" type="button" value="刷新流水"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">操作</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="已支付" @if($data['status']!=2) checked
                       @endif @if($data['status']!=0) disabled="disabled" @endif>
                <input type="radio" name="status" value="2" title="未支付" @if($data['status']==2) checked
                       @endif @if($data['status']!=0) disabled="disabled" @endif>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">用于活动</label>
            <div class="layui-input-block">
                <input type="radio" name="active" value="12" title="是" @if($data['active']==12) checked
                       @endif @if($data['status']!=0) disabled="disabled" @endif>
                <input type="radio" name="active" value="5" title="否" @if($data['active']==5) checked
                       @endif @if($data['status']!=0) 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>


        <div class="layui-form-item">
            <label class="layui-form-label">提示</label>
            <div class="layui-input-inline">
      <textarea disabled="disabled" style="width: 550px;height: 105px;" cols="80" rows="8">今日成功提款次数：{{$data['today_take']}}，总成功提款次数：{{$data['take_count']}}。
最后一笔存款时间：{{$data['last_recharge_time']}},最后一笔存款金额：{{$data['last_recharge_money']}}。最后一笔存款之后的投注总金额：{{$data['total_bet_money']}}。
（该数据仅供参考，请核对会员数据再进行提款操作。）
      </textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">更多</label>
            <div class="layui-input-inline">
                <div class="layui-form-mid layui-word-aux">查看财务，资金流水</div>
            </div>
        </div>
        @if($data['status']==0)
            <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
        $('#freshMoney').on('click', function () {
            //ajax请求刷新获取流水数据，接口地址：/admin/Take/checkMoney,
            //var money = $('input[name=bettingMoney]').val();
            //var needmoney = $('input[name=needBettingMoney]').val();
            $('input[name=bettingMoney]').val('重新计算中');
            $('input[name=needBettingMoney]').val('重新计算中');
            $.ajax({
                type: 'get',
                url: '/admin/Take/checkMoney',
                data: {
                    'account_identity': '{{$data['account_identity']}}'
                },
                dataType: 'json',
                async: false,
                success: function (json) {
                    var ret;
                    if (!json == 0) {
                        //$ret = JSON.stringify(json);
                        var bet=json.bettingMoney;
                        var need=json.needBettingMoney;
                        //console.log(bet);
                        //console.log(need);
                        setTimeout(function () {

                            $('input[name=bettingMoney]').val(bet);
                            $('input[name=needBettingMoney]').val(need);
                        },500)

                    }
                }
            });

        });

        layui.use(['form'], function () {
            var form = layui.form;

            //监听提交

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


                var name = $('input[name=account_name]').val();
                var type = $('input[name=status]: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 === '1') {
                    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/take/index';
//        window.history.go(-1);//返回上一页
            });
        }

    </script>
@endsection
