<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>欢迎页面-X-admin2.0</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
        <link rel="stylesheet" href="./static/css/font.css">
        <link rel="stylesheet" href="./static/css/xadmin.css">
        <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
        <script src="http://code.highcharts.com/highcharts.js"></script>
    </head>
    <body onload="InitParams({{.Player_id}}, {{.Player_name}})">
    <div class="x-body layui-anim layui-anim-up">
        <blockquote class="layui-elem-quote">
          玩家ID:<input id="player_id" type="text" />

          玩家昵称:<input id="player_name" type="text" />
          <br>
          开始时间:<input type="date" id="start_time" name="trip-start" value={{.Start_time}} min="2018-01-01 00:00:00" max="2018-12-31 00:00:00" />
              
          结束时间:<input type="date" id="end_time" name="trip-start" value={{.End_time}} min="2018-01-01 23:59:59" max="2018-12-31 23:59:59" />
          <br>
          <h1 id="today_charge"  value = "">
            <span id ="cur_charge" style="font-size:20px;"> 当日充值 : 0 </span>
          </h1>
          <h1 id="total_charge"  value = "">
            <span id ="tol_charge" style="font-size:20px;"> 累计充值 : 0 </span>
          </h1>
          <br>
          <input class="layui-btn" type="button" onclick="submitUpdate()" value=查询>

          <input class="layui-btn" type="button" onclick="submitDownload()" value=下载>
        </blockquote>
    </div>
    <table border="1">
      <thead>
        <th style="width:256px;">时间</th>
        <th style="width:128px;">玩家ID</th>
        <th style="width:128px;">玩家昵称</th>
        <th style="width:256px;">订单ID</th>
        <th style="width:150px;">商品ID</th>
        <th style="width:150px;">价格(美分)</th>
        <th style="width:128px;">购买数量</th>
      </thead>
      <tbody>
        {{range .Events}}
          <tr>
            <td style = "text-align:center;">{{.EventTime}}</td>
            <td style = "text-align:center;">{{.Uid}}</td>
            <td style = "text-align:center;">{{.Name}}</td>
            <td style = "text-align:center;">{{.OrderId}}</td>
            <td style = "text-align:center;">{{.GoodsId}}</td>
            <td style = "text-align:center;">{{.Price}}</td>
            <td style = "text-align:center;">{{.BuyCount}}</td>
          </tr>
        {{end}}
      </tbody>
    </table>
    
    <script language="JavaScript">
    
      var TodayCharge = {{.Cur_charge}};
      var TotalCharge = {{.Tol_charge}};
      updateCharge(TodayCharge,TotalCharge)
      
      function InitParams(PlayerId, PlayerName) {
        if (PlayerId == 0) {
          PlayerId = "1000000"
        }
        document.getElementById("player_id").value = PlayerId;
        if (PlayerName.length > 0) {
            document.getElementById("player_name").value = PlayerName;
        }
      }
    
      function submitUpdate () {
        var uid = document.getElementById("player_id").value;
        var name = document.getElementById("player_name").value;
        var start_time = document.getElementById("start_time").value;
        var end_time = document.getElementById("end_time").value;
        var text = "uid=" + encodeURI(uid) + "&name=" + encodeURI(name) + "&start_time=" + encodeURI(start_time) + "&end_time=" + encodeURI(end_time) + "&action=query";
        
        $.ajax({
          type:"get",
          url:"/orderquery?" + text,
          success:function (data) {
            // alert(data.status);
            if (data.status){
              window.location.href="/orderquery?"+text;
              if (data.info){
                layer.msg(data.info,{icon:1,time:1000});
              }
            }else{
              if (data.info){
                alert(data.info);
              }else{
                window.location.href="/orderquery?"+text;
              }
            }
          }
        });
      }
      function submitDownload () {
        var uid = document.getElementById("player_id").value;
        var name = document.getElementById("player_name").value;
        var start_time = document.getElementById("start_time").value;
        var end_time = document.getElementById("end_time").value;
        var text = "uid=" + encodeURI(uid) + "&name=" + encodeURI(name) + "&start_time=" + encodeURI(start_time) + "&end_time=" + encodeURI(end_time) + "&querydata=orderquery";
        
        $.ajax({
          type:"get",
          url:"/orderquery?" + text,
          success:function (data) {
            // alert(data.status);
            if (data.status){
              window.location.href="/orderquery?"+text;
              if (data.info){
                layer.msg(data.info,{icon:1,time:1000});
              }
            }else{
              if (data.info){
                alert(data.info);
              }else{
                window.location.href="/orderquery?"+text;
              }
            }
          }
        });
      }
      function updateCharge (today,total) {
        document.getElementById('cur_charge').innerText="当日充值: "+today+"美分";
        document.getElementById('tol_charge').innerText="累计充值: "+total+"美分";
      }
    </script>
    </body>
</html>