<%@ page contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="renderer" content="webkit">
    <!-- 移动设备 viewport -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <jsp:include page="../../common.jsp"/>
    <style>
        .layui-btn+.layui-btn {
            margin-left: -4px;
        }
        .active{
            color: #fff !important;
            background-color: #009688;
            border: 0;
        }
        .layui-inline,.layui-input-block{
            padding: 0 20px;
        }
        .layui-input-block{
            margin: 10px 0 0 0;
        }
        .layui-form-item{
            margin-bottom:10px;
        }
    </style>
</head>
<body>
<div class="row animated fadeInRight" style="margin: 0;">
    <div class="wrapper wrapper-content mt5 right-content ml5 mr5">
        <div class="toolbar-panel bdd">
            <div class="toolbar-box">
                <div class="toolbar-head clearfix lgraybg pt5 pb10 pl10 bdbd">
                    <!-- 顶部按钮 -->
                    <div class="fl">
                        查询条件
                    </div>
                    <div class="tools fr">
                        <a href="javascript:void(0);" class="collapse dblock f14 dgray mr5">
                            <i class="fa-2x fa fa-angle-double-up"></i>
                        </a>
                    </div>
                </div>
            </div>
            <!--搜索条件 -->
            <div class="toolbar-body">
                <form class="layui-form" id="form1" action="" style="margin-top: 10px">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <button class="layui-btn layui-btn-primary check-btn active" data-v="1" type="button" >活跃商户</button>
                            <button class="layui-btn layui-btn-primary check-btn" data-v="-1" type="button" >沉默商户</button>
                        </div>
                        <div class="layui-input-block">
                            <button class="layui-btn layui-btn-sm layui-btn-primary check-date-btn layui-border-green" data-v="7" type="button" >近7日</button>
                            <button class="layui-btn layui-btn-sm layui-btn-primary check-date-btn" data-v="15" type="button" >近15天</button>
                            <button class="layui-btn layui-btn-sm layui-btn-primary check-date-btn" data-v="30" type="button" >近30天</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="mb50 mt10">
        <div class="whitebg pl10 pr10">
            <table class="layui-hide" id="mercActiveDataTab" lay-filter="mercActiveDataTab"></table>
        </div>
    </div>
</div>
<script type="text/html" id="leftBar">
    <a class="layui-btn layui-btn-sm" lay-event="search">
        <i class="layui-icon layui-icon-search"></i>查询
    </a>
</script>

<script>
    layui.use(['table', 'layer'], function () {
        let table = layui.table;
        $(".check-btn").click(function (event){
            $(".check-btn").each(function (index,e){
                $(e).removeClass("active")
            })
            $(event.target).addClass("active");
        })
        $(".check-date-btn").click(function (event){
            $(".check-date-btn").each(function (index,e){
                $(e).removeClass("layui-border-green")
            })
            $(event.target).addClass("layui-border-green");
        })
        var tableIns = table.render({
            elem: '#mercActiveDataTab'
            , url: '${ctx}/mercData/activePage'
            , id: 'mercActiveData'
            , where: {}
            , response: {
                statusName: 'code' //数据状态的字段名称，默认：code
                , countName: 'count' //数据总数的字段名称，默认：count
                , dataName: 'data' //默数据列表的字段名称，认：data
                , statusCode: 200
            }
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.count, //解析数据长度
                    "data": res.data.data //解析数据列表
                };
            }
            , toolbar: '#leftBar' //开启头部工具栏，并为其绑定左侧模板
            , defaultToolbar: ['filter']
            , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                , layEvent: 'LAYTABLE_TIPS'
                , icon: 'layui-icon-tips'
            }]
            , title: '商户活跃度数据统计'
            , cols: [[
                {type: 'checkbox', fixed: 'left', hidden: true}
                , {field: 'numbers', title: '序号', fixed: 'left', unresize: true, width: 80, type: 'numbers'}
                , {field: 'userId', title: '用户ID'}
                , {field: 'alias', title: '商户名称'}
            ]]
            , request: {
                pageName: 'current' //页码的参数名称，默认：page
                , limitName: 'size' //每页数据量的参数名，默认：limit
            }
            , page: true
        });
    });
</script>
</body>
</html>
