{include file="Application/Home/View/Public/header.blade.php"}
{include file="Application/Home/View/Public/userLeft.blade.php"}
<link rel="stylesheet" href="/Public/laydate/skins/yahui/laydate.css"/>
{literal}
<div class="member-content  ">
    <h3 class="memberTitle">账号明细</h3>
    <div class="asd">
        <p class="memberMinTitle">
            <span class="pad-left-20">用户ID</span>
            <span class="balance">余额：
							<span class="t-red" id="cx" v-text="vald.cash"></span>
						</span>
            <a href="#" class="btnInputCe" id="shuaxin">刷新</a>
            <a href="/Home/Recharge/Index" class="btnInputCe">充值</a>
            <a href="/Home-Account/AccountGetCash" class="btnInputCe">提现</a>
        </p>
        <table class="infor_h" border="0" cellspacing="0"  cellpadding="0" >
            <thead>
            <tr class="t_h">
                <th>可用金额</th>
                <th>总提现</th>
                <th>总充值</th>
                <th>总投注</th>
            </tr>
            </thead>
            <tbody>
            <tr class="t_h">
                <th v-text="vald.cash"></th>
                <th v-text="vald.rechargeMoney"></th>
                <th v-text="vald.withdrawalsMoney"></th>
                <th v-text="vald.betMoney"></th>
            </tr>

            </tbody>
        </table>
    </div>
    <div class="box-bor">
        <ul class="Tab-Control">
            <li>
                <a href="Index">交易记录</a>
            </li>
            <li>
                <a href="recharge">充值记录</a>
            </li>
            <li>
                <a href="withdrawals">提现记录</a>
            </li>
            <li>
                <a href="ReturnMoneys">返水记录</a>
            </li>
            <li class="active">
                <a href="BettingRecord">有效投注</a>
            </li>
        </ul>
    </div>
    <div class="Tab-Content">
        <div class="find">
            <form action="" method="post">
                <table border="0" cellspacing="5" cellpadding="2">
                    <tr>
                        <th>选择时间</th>
                    </tr>
                    <tr>
                        <td style="width: 500px;">
                            <input class="laydate-icon" id="start" placeholder="开始时间" style="width: 180px;"><span>至</span>
                            <input class="laydate-icon" id="end" placeholder="结束时间" style="width: 180px;">
                            <a href="javascript:;" id="today" style="margin-left: 5px;color: blue;">今天</a>
                            <a href="javascript:;" id="week" style="margin-left: 5px;color: blue;">本周</a>
                            <a href="javascript:;" id="month" style="margin-left: 5px;color: blue;">本月</a>
                        </td>
                        <td><input type="button" onclick="lookup()" value="查找" class="btnInputCe"/></td>
                    </tr>
                </table>
            </form>
            <div class="abs">
                <table border="0" cellspacing="0"  cellpadding="0" class="dataList">
                    <thead>
                    <tr>
                        <th>交易ID</th>
                        <th>投注时间</th>
                        <th>游戏名称</th>
                        <th>游戏期号</th>
                        <th>投注金额 </th>
                        <th>中奖金额</th>
                        <th>中奖状态 </th>
                    </tr>
                    </thead>
                    <tbody id="a">
                    <tr v-if="val"  v-for="v in val">
                        <td v-text="v.order_id"></td>
                        <td v-text="v.money_time"></td>
                        <td v-text="lang[v.game_name]"></td>
                        <td v-text="v.game_no"></td>
                        <td v-text="v.money"></td>
                        <td v-text="v.prize_money"></td>
                        <td v-if="v.game_status == 1">中奖</td>
                        <td v-else>未中奖</td>
                    </tr>
                    <!--<tr v-else>
                        <td colspan="7">没有数据</td>
                    </tr>-->
                    </tbody>
                </table>

                <!--分页--->

                <div class="page-number">
                    <div class="total" style="float: left;">
                        <div style="font-weight: bold;float: left;">总投注：</div>
                        <div style="font-weight: bold;float: left;color: red;" v-if="total_sum" v-text="'￥'+ total_sum"></div>
                        <div style="font-weight: bold;float: left;color: red;" v-else>￥0.00</div>

                        <div style="font-weight: bold;float: left;margin-left: 10px;">当前页投注：</div>
                        <div style="font-weight: bold;float: left;color: red;" v-if="current_total" v-text="'￥'+ current_total"></div>
                        <div style="font-weight: bold;float: left;color: red;" v-else>￥0.00</div>
                    </div>
                    <a href="#" id="first"></a>        <!--首页-->
                    <a href='#' v-text="value.count_page" id="upper"></a>     <!--上一页-->
                    <a style="border: 0;" href='' v-if="value" v-text="value" >  </a>        <!--显示页面数据页数--->
                    <a style="border: 0;" v-else href=''>0</a>        <!--显示页面数据页数--->
                    <a href='#' v-text="value.count_page" id="next"></a>    <!--下一页-->
                    <a href='#' id="last"></a>   <!--尾页-->
                    <input type="hidden" id="totalpage" value="">

                    <form action="" method="get">
                        <span>到</span>
                        <input class="id" type="text" name="" id="" value=""/>
                        <span>页</span>
                        <input type="button" value="GO" class="btnInputCe tiaohzan"/>
                    </form>
                </div>
            </div>
            <!---分页查询  js-->


        </div>
    </div>
</div>


{/literal}
{literal}
<script type="text/javascript" src="/Public/laydate/laydate.js"></script>
<script>
    !function () {
        var start = {
            elem: '#start',
            format: 'YYYY-MM-DD hh:mm:ss',
            min: "1999-01-01 00:00:00", //设定最小日期为当前日期
            max: '2999-12-30 23:59:59', //最大日期
            istime: true,
            istoday: false,
            choose: function(datas){
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };
        var end = {
            elem: '#end',
            format: 'YYYY-MM-DD hh:mm:ss',
            min: "1999-01-01 00:00:00", //设定最小日期为当前日期
            max: '2999-12-30 23:59:59', //最大日期
            istime: true,
            istoday: false,
            choose: function(datas){
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };
        laydate(start);
        laydate(end);

        //时间处理
        var now = new Date();
        var nowDayOfWeek = now.getDay() == 0 ? 7:now.getDay(); //今天本周的第几天,周日为7
        var nowDay = now.getDate(); //当前日
        var nowMonth = now.getMonth(); //当前月
        var nowYear = now.getYear(); //当前年
        nowYear += (nowYear < 2000) ? 1900 : 0; //
        if(nowDayOfWeek !=0)
        {
            nowDayOfWeek = nowDayOfWeek-1;
        }
        //默认最近三天
        var starts = getDay(-2) + " 00:00:00";
        $('#start').val(starts);
        $('#end').val(laydate.now("YYYY-MM-DD hh:mm:ss"));

        //今天
        $('#today').click(function(){
            var start = laydate.now("YYYY-MM-DD")+' 00:00:00';
            $('#start').val(start);
            $('#end').val(laydate.now("YYYY-MM-DD hh:mm:ss"));
            lookup();
        });
        //本周
        $('#week').click(function(){
            var start = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek).Format("yyyy-MM-dd HH:mm:ss");
            $('#start').val(start);
            $('#end').val(laydate.now("YYYY-MM-DD hh:mm:ss"));
            lookup();
        });
        //本月
        $('#month').click(function(){
            var start = new Date(nowYear, nowMonth, 1).Format("yyyy-MM-dd HH:mm:ss");
            $('#start').val(start);
            $('#end').val(laydate.now("YYYY-MM-DD hh:mm:ss"));
            lookup();
        });


        function getDay(day){
            var today = new Date();
            var targetday_milliseconds=today.getTime() + 1000*60*60*24*day;
            today.setTime(targetday_milliseconds);
            var tYear = today.getFullYear();
            var tMonth = today.getMonth();
            var tDate = today.getDate();
            tMonth = doHandleMonth(tMonth + 1);
            tDate = doHandleMonth(tDate);
            return tYear+"-"+tMonth+"-"+tDate;
        }
        function doHandleMonth(month){
            var m = month;
            if(month.toString().length == 1){
                m = "0" + month;
            }
            return m;
        }

        Date.prototype.Format = function(date){
            var o = {
                "M+" : this.getMonth()+1,                 //月份
                "d+" : this.getDate(),                    //日
                "H+" : this.getHours(),                   //小时
                "m+" : this.getMinutes(),                 //分
                "s+" : this.getSeconds(),                 //秒
                "q+" : Math.floor((this.getMonth()+3)/3), //季度
                "S"  : this.getMilliseconds()             //毫秒
            };
            if(/(y+)/.test(date))
                date = date.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
            for(var k in o)
                if(new RegExp("("+ k +")").test(date))
                    date = date.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
            return date;
        }

    }();

    // 刷新
    $('#shuaxin').on('click',function () {
        apiAjax("/Api-userDetails/PCNewMoney", {},function (data) {
            var val = data.data;

            var html = "";
            if (val != " ") {
                html += "<span class='t-red' id='cx'>"+val['cash']+"</span>";
            }
            $("#cx").html(html);
        }, "json");
    })


    var tabld=new Vue({
        el:'.asd',
        data:{
            vald:[],
        }
    });

    apiAjax("/Api-userDetails/PCNewMoney",{
    },function (data) {
        // console.log(data);
        tabld.vald=data.data;
        // console.log(tabld.val);
    });



    var table=new Vue({
        el:'.abs',
        data:{
            val:[],
            value:[],
            current_total:'',
            total_sum:'',
            lang:[]
        }
    });
    //首页页
    $('#first').on('click',function () {
        changePage(4);
    });
    //末页
    $('#last').on('click',function () {
        changePage(5);
    });
    //上一页
    $('#upper').on('click',function () {
        changePage(2);
    });
    //下一页
    $('#next').on('click',function () {
        changePage(1);
    });
    //跳转页数
    $(".tiaohzan").on('click',function () {
        var as=$(".id").val();
        if(as==''||as==null){
            alert('请填入页面');
        }
        changePage(3,as);
    });

    var upper = $("#upper").val();
    var next=$("#next").val();
    var start=$("#start").val();
    var end=$("#end").val();
    var tolpage='';
    var page=1;
    apiAjax("/Api-userDetails/BettingRecord",{
        start:start,
        end:end,
        page:page,
    },function (data) {
        if(data.data.code == -10009)
        {
            layer.msg('暂无数据');
        }
        table.lang = data.data.lang;
        table.current_total = data.data.current_total;
        table.total_sum = data.data.total_sum;
        table.val=data.data.data;
        table.value=data.data.page;
        page=table.value;//当前页
        tolpage=data.data.count_page;//总页数
    });

    function lookup() {
        var start=$("#start").val();
        var end=$("#end").val();
        //console.log($vals);
        apiAjax("/Api-userDetails/BettingRecord", {
                start:start,
                end:end,
                page:page,
            },
            function (data) {
                if(data.data.code == -10009)
                {
                    layer.msg('暂无数据');
                }
                table.lang = data.data.lang;
                table.current_total = data.data.current_total;
                table.total_sum = data.data.total_sum;
                table.val=data.data.data;
                table.value=data.data.page;//当前页
                page = table.value;//当前页
                tolpage=data.data.count_page;//总页数
                console.log('--------',page);
            });
    }

    //改变页码
    var  now ='';
    function changePage(type,now) {
        console.log('当前页---',page);
        var start=$("#start").val();
        var end=$("#end").val();
        if(type==1 && page<tolpage){
            //下一页
            page=parseInt(page)+1;
        }else if(type==2 && page > 1){
            //上一页
            page=page-1;
        }else if(type==3 && now<tolpage){
            //跳转
            page=now;
        }else if(type==4){
            page=1;
        }else if(type==5){
            page=tolpage;
        }else {
            alert('请输入正确页面');
        }
        apiAjax("/Api-userDetails/BettingRecord",{
            start:start,
            end:end,
            page:page,
        },function (data) {
            if(data.data.code == -10009)
            {
                layer.msg('没有数据');
            }
            table.lang = data.data.lang;
            table.current_total = data.data.current_total;
            table.total_sum = data.data.total_sum;
            table.val=data.data.data;//内容
            table.value=data.data.page;//当前页
            page=table.value;//当前页
            tolpage=data.data.count_page;//总页数
        });
    }


</script>
{/literal}
