<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<style>
    .num {
        color: #FF5722;
        text-decoration: underline;
    }
</style>
<div>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>商户关联信息</legend>
    </fieldset>
    <blockquote class="layui-elem-quote layui-text" style="margin-top: 15px;">
        身份信息关联（进件成功的）商户数量
    </blockquote>
    <form class="layui-form">
        <div class="layui-form-item" style="margin-left: 20px;">
            <a id="countCert">
                <label class="layui-form-label-col">实名身份证 <span class="num">${countCert}</span></label>
            </a>

            <a id="countAccount">
                <label class="layui-form-label-col">结算身份证 <span class="num">${countAccount}</span></label>
            </a>

            <a id="countMbiName">
                <label class="layui-form-label-col">同名商户&emsp; <span class="num">${countMbiName}</span></label>
            </a>
        </div>
    </form>
    <blockquote class="layui-elem-quote layui-text" style="margin-top: 15px;">
        用户IP记录
    </blockquote>
    <table id="tableIpData" lay-filter="tableIpData"></table>
</div>

<script>
    let table;
    layui.use(['table',], function () {
        table = layui.table;

        //执行一个 table 实例
        table.render({
            elem: '#tableIpData'
            , id: 'tableIpData'
            , url: ctx + '/promoter/userIpPage?userId=${userId}' //数据接口
            , autoSort: false
            , response: {
                statusCode: 200
            }
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.records //解析数据列表
                };
            }
            , request: {
                pageName: 'current' //页码的参数名称，默认：page
                , limitName: 'size' //每页数据量的参数名，默认：limit
            }
            , even: true
            , title: 'IP关联信息'
            , page: true //开启分页
            , cols: [[ //表头
                {field: 'ip', title: 'IP地址', width: 130, align: "left"}
                , {
                    title: "地区", minWidth: 150, align: "left", templet: function (d) {
                        let result = "";
                        if (d.country != null && d.country != '') {
                            result = result + d.country + "-";
                        }

                        if (d.province != null && d.province != '') {
                            result = result + d.province + "-";
                        }

                        if (d.city != null && d.city != '') {
                            result = result + d.city + "-";
                        }

                        if (d.county != null && d.county != '') {
                            result = result + d.county + "-";
                        }

                        if (result.length > 0) {
                            result = result.substring(0, result.length - 1);
                        }

                        return result;
                    }
                }
                , {field: 'remark', title: '操作', minWidth: 121, align: "left"}
                , {field: 'count', title: '同IP', width: 60, align: "left"}
                , {
                    field: 'createTime',
                    title: '操作时间',
                    width: 141,
                    align: "left",
                    templet: "<div>{{layui.util.toDateString(d.createTime,'yyyy-MM-dd HH:mm')}}</div>"
                }
            ]]
        })

        $('#countCert').click(function () {
            parent.layui.element.tabAdd('layadmin-layout-tabs', {
                title: '消息通知'
                , content: ctx + "/notification/index"
                , id: ctx + "/notification/index"
            });
        })
    })
</script>