<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>数据报表</title>
    </title>
    <!-- 引入 WeUI -->
    <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
    <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.css"/>
    <style>
        body, html {
            height: 100%;
            background-color: #f4f4f4;
            -webkit-tap-highlight-color: transparent;
        }

        .basic-color {
            background-color: #1E88E5;
            color: #FFFFFF;
        }

        .basic-weui-btn {
            background-color: #1E88E5;
            color: #FFFFFF;
        }

        .basic-weui-btn:hover {
            background-color: #1E88E5;
            color: #FFFFFF;
        }

        .basic-weui-btn:active {
            background-color: #1E88E5 !important;
            color: #FFFFFF;
        }

        footer {
            text-align: center;
            font-size: 14px;
            padding: 20px;
        }

        .weui-loadmore_line .weui-loadmore__tips {
            background-color: #f4f4f4;
        }

        footer a {
            color: #999;
            text-decoration: none;
        }

    </style>
</head>
<body ontouchstart="">
<div class="weui-cells__title weui-cell" style="margin: auto;">
    <div class="weui-cell__hd"><img src=""></div>
    <div class="weui-cell__bd" align="center">
        <select id="dayNum" onchange="change(this.options[this.options.selectedIndex].value)">
            <option value="6" th:text="${data_6}"></option>
            <option value="5" th:text="${data_5}"></option>
            <option value="4" th:text="${data_4}"></option>
            <option value="3" th:text="${data_3}"></option>
            <option value="2" th:text="${data_2}"></option>
            <option value="1">昨天数据</option>
            <option value="0" selected>当天数据</option>
        </select>
        <div id="dayNum1"></div>
    </div>
</div>
<div class="weui-cells" id="monitor-lists">
</div>
</div>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.js"></script>
<script type="text/javascript">

    $(function () {
        sendReq(0);
    });


    function change(val) {
        sendReq(val);
    }

    function getOsType() {
        var u = navigator.userAgent;
        if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 || u.indexOf('Windows Phone') > -1) {
            return 'Android';
        } else if (u.indexOf('iPhone') > -1) {
            return 'IOS';
        } else {
            return 'PC';
        }
    }

    function reqUrl(reqUri, params, callbackName) {
        reqUri = "/akaxin" + reqUri;
        var type = getOsType();
        if (type == 'Android') {
            Android.requestPost(reqUri, params, callbackName);
        } else if (type == 'IOS') {
            ios_requestPost(reqUri, params, callbackName);
        } else {
            $.toast('暂时不支持该设备');
        }
    }

    function reqHtml(reqUri, params) {
        reqUri = "/akaxin" + reqUri;
        var type = getOsType();
        if (type == 'Android') {
            Android.requestPage(reqUri, params)
        } else if (type == 'IOS') {
            ios_requestPage(reqUri, params);
        } else {
            $.toast('暂时不支持该设备');
        }
    }

    function toast(msg) {
        var type = getOsType();
        if (type == 'Android') {
            Android.showToast(msg);
        } else if (type == 'IOS') {
            $.toast(msg);
        } else {
            $.toast('暂时不支持该设备');
        }
    }

    $(document).on("click", ".OtherDay", function () {
        sendReq();
    });

    function sendReq(dayNum) {
        var url = '/monitor/refresh';
        var params = {
            "dayNum": dayNum.toString(),
        };
        reqUrl(url, JSON.stringify(params), 'doRefresh');
    }

    function doRefresh(results) {
        $("#monitor-lists").html("");
        var res = eval("(" + results + ")");
        var htmlTip1 = '<div class="weui-loadmore weui-loadmore_line"><span class="weui-loadmore__tips">当日数据</span></div>';
        var html1 = '<div class="weui-cell"><div class="weui-cell__bd"><p>当日注册用户数:</p></div><div class="weui-cell__ft">' + res.registerNum + '</div></div>';
        var html2 = '<div class="weui-cell"><div class="weui-cell__bd"><p>当日消息总量(个人+群组):</p></div><div class="weui-cell__ft">' + res.messageNum + '</div></div>';
        var html3 = '<div class="weui-cell"><div class="weui-cell__bd"><p>当日群组消息总量:</p></div><div class="weui-cell__ft">' + res.groupMsgNum + '</div></div>';
        var html4 = '<div class="weui-cell"><div class="weui-cell__bd"><p>当日个人消息总量:</p></div><div class="weui-cell__ft">' + res.u2MsgNum + '</div></div>';
        var htmlTip2 = '<div class="weui-loadmore weui-loadmore_line"><span class="weui-loadmore__tips">全部数据</span></div>';
        var html5 = '<div class="weui-cell"><div class="weui-cell__bd"><p>全部用户数量:</p></div><div class="weui-cell__ft">' + res.userNum + '</div></div>';
        var html6 = '<div class="weui-cell"><div class="weui-cell__bd"><p>全部群组数量:</p></div><div class="weui-cell__ft">' + res.groupNum + '</div></div>';
        var html7 = '<div class="weui-cell"><div class="weui-cell__bd"><p>全部好友对数(互为好友):</p></div><div class="weui-cell__ft">' + res.friendNum + '</div></div>';

        $("#monitor-lists").append(htmlTip1);
        $("#monitor-lists").append(html1);
        $("#monitor-lists").append(html2);
        $("#monitor-lists").append(html3);
        $("#monitor-lists").append(html4);
        $("#monitor-lists").append(htmlTip2);
        $("#monitor-lists").append(html5);
        $("#monitor-lists").append(html6);
        $("#monitor-lists").append(html7);
    }
</script>
</body>

</html>