@extends('vip.layouts')
@section('seo_title')
    {{ trans('menu.betRecord') }}
@endsection
@section('content')
    <style>
        .layui-laydate-range {
            width: auto;
        }

        .menu {
            position: fixed;
            left: 0px;
            top: 20px;
            height: 500px;
            overflow: auto;
        }


        .red {
            color: red;
        }

        .blue {
            color: #1E9FFF;
        }

        .green {
            color: green;
        }

        .yellow {
            color: #ffca10;
        }

        .menu {
            width: 140px;
        }

        /*.text {*/
            /*width: 88%;*/
        /*}*/
    </style>
    @push('dataTableJS')
        var menu = [];
        $.ajax({
        type: 'get',
        url: '/admin/game/GameList',
        data: {},
        dataType: 'json',
        async: false,
        success: function (json) {
        menu = json;
        }
        });
        //获取表头
        var tit=function (game){
        var header=[];
        $.ajax({
        type: 'post',
        url: '/admin/game/index?data=1&game='+ game,
        data: {},
        dataType: 'json',
        async: false,
        success: function (json) {
        header=json.data.dataCols
        }
        });
        return header;
        }

        /*var active = {
        reload: function(){
        //执行重载
        table.reload('{{ $dataId }}', {
        page: {
        curr: 1 //重新从第 1 页开始
        }
        ,where: {
            account_name:$("#form_account_name").val(),
            order_id:$('#form_order_id').val(),
            name:$('#form_name').val(),
            game_no:$('#form_game_no').val(),
            bet_small:$('#form_bet_small').val(),
            bet_big:$('#form_bet_big').val(),
            winfail_small:$('#form_winfail_small').val(),
            winfail_big:$('#form_winfail_big').val(),
            money_big:$('#form_money_big').val(),
            money_small:$('#form_money_small').val(),
            game_status:$('#form_game_status').val(),
            star_time:$('#form_star_time').val(),
            end_time:$('#form_end_time').val(),
        }
        });
        }
        };
        $('.lay-btn-diy').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
        });*/

        {{--$(document).on('click','.user',function(){--}}
        {{--var type = $(this).data('type');--}}
        {{--var search=$(this).data('odds')--}}
        {{--var value=$(this).text();--}}
        {{--$("#form_game_no").val('');--}}
        {{--$("#form_account_name").val('');--}}
        {{--$('#form_'+search).val(value);--}}
        {{--active[type] ? active[type].call(this) : '';--}}
        {{--})--}}


        //重置表单
        $('.reset').on('click',function(){
        var game=$('#form_name').val();
        $('input').val('');
        $('#name').val(game);
        form.render('select', 'test2');
        //console.log($('#name').find("option[value="+game+"]"));
        //$('#name').find("option[value="+game+"]").attr("selected","selected");
        $('#trade_type').val('');
//        var type = $(this).data('type');
//        active[type] ? active[type].call(this) : '';
        });

        //刷新表单
//        $('.set').on('click',function(){
//        $('input').val('');
//        $('#type').val('');
//        var type = $(this).data('type');
//        active[type] ? active[type].call(this) : '';
//        });


        var height = document.documentElement.clientHeight;
        $('.menu').css({height: (height-30)});

        function dataTableLoadFinished(res,curr,count){
        var str='';
        if(document.getElementById("statistics")){

        }else{
        $('.layui-table-page').after('<div id="statistics"></div>');
        }
        $('[eventType=event-view]').attr('win-width','950px');



        var datau=res.data;
        var total_bet_money=0,win_money=0;
        for(var i=0;i<datau.length;i++){
        total_bet_money+=parseFloat(datau[i].money);
        win_money+=parseFloat(datau[i].get_money);
        }
        str+='<p>当页总投注金额：<span class="blue">'+total_bet_money+'</span>,当页平台赢取金额：';
        if(win_money<0){
            str+='<span class="red">'+ (-1*win_money)+'</span></p>';
        }else{
            str+='<span class="green">'+ (-1*win_money)+'</span></p>';
        }
        $.ajax({
        type: 'get',
        url: '',
        data: {where:res.extras},
        dataType: 'json',
        //async: false,
        success: function (data) {
        var data=data.data;
        str+='<p>总投注金额：<span class="blue">'+data.bet_money+'</span>,平台总输赢结果：'
        if(data.get_money>0){
            str+=' <span class="red">'+data.get_money+'</span>';
        }else{
            str+=' <span class="green">'+data.get_money+'</span>';
        }

            $('#statistics').html(str);
            var height1=$('.layui-table-view').height();
            var height2=$('#statistics').height();
            $('.layui-table-view').css({height:(height1+height2)});
            }
            });


            }

            @endpush


            <!---注单管理-->
        <div class="layui-row">
            <div class="layui-col-sm12 layui-col-md12 text" >

                <form class="layui-form rewrite" eventType=eventForm>
                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('gamemenu.bet_area') }}</label>
                            <div class="layui-input-inline" style="width: 100px;">
                                <input type="text" name="bet_small" id="form_bet_small" value="{{$bet_small}}" placeholder="0" autocomplete="off" class="layui-input" eventType=event-query>
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline" style="width: 100px;">
                                <input type="text" name="bet_big" id="form_bet_big" value="{{$bet_big}}" placeholder="0" autocomplete="off"
                                       class="layui-input" eventType=event-query>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('gamemenu.winfail_area') }}</label>
                            <div class="layui-input-inline" style="width: 100px;">
                                <input type="text" name="winfail_small" id="form_winfail_small" placeholder="0"
                                       autocomplete="off" class="layui-input" value="{{$winfail_small}}" eventType=event-query >
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline" style="width: 100px;">
                                <input type="text" name="winfail_big" id="form_winfail_big" placeholder="0"
                                       autocomplete="off" value="{{$winfail_big}}"
                                       class="layui-input" eventType=event-query>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <!--用户名-->
                            <label class="layui-form-label">{{ trans('gamemenu.master') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="master" id="form_master" lay-verify="required"
                                       autocomplete="off" class="layui-input" value="{{$master}}" eventType="event-query">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <!--用户名-->
                            <label class="layui-form-label">{{ trans('gamemenu.guster') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="guster" id="form_guster" lay-verify="required"
                                       autocomplete="off" class="layui-input" value="{{$guster}}" eventType="event-query">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('gamemenu.star_time') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="star_time" id="form_star_time" placeholder=" - " lay-verify=""
                                       autocomplete="off" class="layui-input test-item" eventType=event-query
                                       value="{{$star_time}}">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('gamemenu.end_time') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="end_time" id="form_end_time" placeholder=" - " lay-verify=""
                                       autocomplete="off" class="layui-input test-item" eventType=event-query
                                       value="{{$end_time}}">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <a class="layui-btn layui-btn-sm lay-btn-diy" data-type="reload"  eventType=event-query-submit
                               style="opacity: 1; pointer-events: auto;">提交</a>
                            <a class="layui-btn   layui-btn-sm  layui-btn-normal reset" data-type="reload"
                               style="opacity: 1; pointer-events: auto;">重置</a>
                            <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload"
                               style="opacity: 1; pointer-events: auto;" href="javascript:window.location.reload()">
                                <i class="layui-icon">ဂ</i>
                            </a>
                        </div>
                    </div>
                </form>
                @include('vip.datatable')
            </div>
        </div>


        <script>
            /**
             *
             * @param url
             * @param title
             */
            function shutOrder(url,name) {
                layer.confirm('是否确认作废用户'+name+'的该条订单？', {
                    btn: ['确认', '取消'] //按钮
                }, function() {
                    $.getJSON(url, function(data, textStatus) {
                        if (data.status == '1') {
                            layer.msg('作废成功');
                            reloadDataTable();
                        } else {
                            layer.msg(data.msg);
                        }
                    });
                }, function() {
                });
            }

            function exportWord(){
    //          var data = setData();
                $.post("/admin/Game/checkPwd",$("form").serialize(),function(data1){
                var url = data1.data; //回调函数，返回值是地址，data
                console.log(url);
                window.location.href=url;
    //          $('#submitForm').submit(url);
            });
        }
        </script>
@endsection
