@extends('vip.layouts')
@section('seo_title')
    {{ trans('menu.bet') }}
@endsection
@section('content')
    <style>
        .layui-laydate-range {
            width: auto;
        }
        .menu {
            position: fixed;
            left: 0px;
            top: 20px;
            height: 500px;
            overflow: auto;
        }
        .layui-table-cell {
            line-height: 15px;
        }


        .red{
            color: red;
        }
        .blue{
            color: #1E9FFF;
        }
        .green{
            color: green;
        }
        .yellow{
            color: #ffca10;
        }
    </style>
    @push('dataTableJS')
        //获取表头
        var tit=function (game){
        var header=[];
        $.ajax({
        type: 'post',
        url: '/admin/gameOrder/index?data=1&game='+ game,
        data: {},
        dataType: 'json',
        async: false,
        success: function (json) {
        header=json.data.dataCols
        }
        });
        return header;
        }

//        $('.lay-btn-diy').on('click', function(){
//        var type = $(this).data('type');
//        active[type] ? active[type].call(this) : '';
//        });

        //重置表单
        $('.reset').on('click',function(){
        $('input').val('');
        $('#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){

            $('[eventType=event-view]').attr('win-width','955px');
            $('[eventType=event-view]').attr('win-height','460px');
            var str='';

            if(document.getElementById("statistics")){

            }else{
                $('.layui-table-page').after('<div id="statistics"></div>');
            }
            var data=res.data;

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

            })


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



    @endpush
    <script type="text/html" id="account">
    <a href="/admin/gameOrder/index?name=@{{d.account_name}}&star_time=&end_time=" class="">@{{d.account_name}}</a>
    <br>
                <span style="color:#afafaf;">@{{ d.remark }}</span>
    </script>

    <script type="text/html" id="tool">
        <a class="layui-btn layui-btn-primary layui-btn-xs layui-bg-blue" lay-event="detail" href="/admin/gameOrder/view/?id=@{{d.id}}&game_no=@{{ d.game_no }}&game_name=@{{ d.game_name }}" style="margin-bottom:5px;margin-left:0px;"> 查看 </a>
    </script>


    <script type="text/html" id="game_no">
        <span style="word-break:break-all"><a href="/admin/gameOrder/index?game=@{{d.game_name}}&no=@{{d.game_no}}" class="">@{{d.game_no}}</a>
        </span>
    </script>
    <script type="text/html" id="name">
        <a style="color: #00C0F7"  class="">@{{d.name}}</a>
    </script>

    <script type="text/html" id="after">
                @{{#if(d.game_status=="中奖"){ }}
                <p style="color:red;">@{{d.game_status}}</p>
                @{{#}else{ }}
                @{{#if(d.game_status=="未中奖"){ }}
                 <p style="color:green;">@{{d.game_status}}</p>
                @{{#}else{ }}
                @{{#if(d.game_status=="待开奖"){ }}
                 <p style="color:blue;">@{{d.game_status}}</p>
                 @{{#}else{ }}
                  <p style="color:#6959CD;">@{{d.game_status}}</p>
                @{{#} }}
                @{{#} }}
                @{{#} }}


            </script>

            <script type="text/html" id="money">
                @{{#if(d.get_money>0){ }}
                <p style="color:red;">@{{d.get_money}}</p>
                @{{#}else{ }}
                 <p style="color:#32CD32;">@{{d.get_money}}</p>
                @{{#} }}
            </script>
            <script type="text/html" id="moneynew">
               @{{d.money}}
            </script>
    <!---注单管理-->
    <div class="layui-row">

        <!--<div class="layui-col-sm1 layui-col-md1 menu">

            <ul id="tree" class="tree-table-tree-box"></ul>
        </div>-->
        <div class="layui-col-sm12 layui-col-md12" style="float: right">

            <form class="layui-form rewrite" action="" 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" placeholder="￥0" autocomplete="off"
                                   class="layui-input" value="{{$bet_small}}" 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" placeholder="￥0" autocomplete="off"
                                   class="layui-input" value="{{$bet_big}}" 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"
                                   class="layui-input" value="{{$winfail_big}}" eventType=event-query>
                        </div>

                    </div>
                    <div class="layui-inline">
                        <!--用户名-->
                        <label class="layui-form-label">{{ trans('gamemenu.account_name') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="account_name" id="form_account_name" lay-verify="required"
                                   autocomplete="off" class="layui-input" value="{{Request::get('name')?Request::get('name'):$account_name}}" eventType=event-query>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('gamemenu.order_id') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="order_id" id="form_order_id" lay-verify="" autocomplete="off"
                                   class="layui-input" value="{{$order_id}}" eventType=event-query>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('gamemenu.name') }}</label>
                        <div class="layui-input-inline" style="width: 125px">
                            <select name="game" id="form_game" lay-verify="" autocomplete="off" class="layui-input" eventType="event-query">
                                <option value="">{{ trans('gamemenu.select_game') }}</option>
                                {{--@foreach(trans('gamemenu.game_type') as $k=>$v):
									@if(checkRriv('/bet/game/'.$k))
                                        @if($game==$k)
                                            <option value="{{$k}}" selected="selected">{{$v}}</option>
                                        @else
                                            <option value="{{$k}}">{{$v}}</option>
                                        @endif
									@endif
                                @endforeach--}}
                                @foreach($gameList as $k=>$v):
                                @if(checkRriv('/bet/game/'.$v['gameCode']))
                                    @if($game==$v['gameCode'])
                                        <option value="{{$v['gameCode']}}" selected="selected">{{$v['name']}}</option>
                                    @else
                                        <option value="{{$v['gameCode']}}">{{$v['name']}}</option>
                                    @endif
                                @endif
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('gamemenu.game_status') }}</label>
                        <div class="layui-input-inline" style="width: 125px">
                            <select name="game_status" id="form_game_status" lay-verify="" autocomplete="off"
                                    class="layui-input" eventType=event-query>
                                <option value="-1">{{ trans('gamemenu.select_status') }}</option>
                                @foreach(trans('status.money_buy.game_status') as $k=>$v)
                                    @if($game_status==$k){
                                    <option value="{{$k}}" selected>{{$v}}</option>
                                    @else
                                        <option value="{{$k}}">{{$v}}</option>
                                    @endif
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                            <label class="layui-form-label">投注点</label>
                            <div class="layui-input-inline" style="width: 125px">
                                <select name="game_point" id="game_point" lay-verify="" autocomplete="off"
                                        class="layui-input" eventType=event-query>
                                    <option value="">请选择</option>
                                    <option value="1001" @if(Request::get('game_point') == 1001) selected @endif>pc投注</option>
                                    <option value="1002" @if(Request::get('game_point') == 1002) selected @endif>wap投注</option>
                                    <option value="1003" @if(Request::get('game_point') == 1003) selected @endif>长龙投注</option>
                                </select>
                            </div>
                        </div>
                    <div class="layui-inline">

                        <label class="layui-form-label">{{ trans('gamemenu.game_no') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="game_no" id="form_game_no" lay-verify="" autocomplete="off"
                                   class="layui-input" value="{{Request::get('no')?Request::get('no'):$game_no}}" 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"
                           style="opacity: 1; pointer-events: auto;" eventType=event-query-submit>提交</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;">
                               <i class="layui-icon" >ဂ</i></a>
                        @if(checkRriv('/admin/GameOrder/checkPwd'))<a  class="layui-btn layui-btn-sm" data-type="reload" style="opacity: 1; pointer-events: auto;" onclick="exportWord()">导出</a>@endif
                    </div>

                </div>
            </form>
            @include('vip.datatable')
        </div>
    </div>


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