layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function () {
    let $ = layui.jquery,
        form = layui.form,
        table = layui.table,
        layer = layui.layer,
        xmSelect = layui.xmSelect,
        miniTab = layui.miniTab;

    /**** index begin ***/
    //index页面
    if ($('.location-index-page').length > 0) {
        miniTab.listen();

        // 渲染表格
        let listUrl = $('#table-container').data('url');
        let insTb = table.render({
            elem: '#table-container',
            toolbar: '#toolbar-tpl',
            defaultToolbar: [{ //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
                title: '搜索'
                , layEvent: 'search'
                , icon: 'layui-icon-search'
            }],
            url: listUrl,
            method: 'post',
            even: true,
            limits: [10,20,50,100,200,500,1000],
            request: {
                pageName: 'page',
                limitName: 'size',
            },
            parseData: function (res) {
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.list //解析数据列表
                };
            },
            page: true,
            cols: [[
                // {type: 'checkbox'},
                {field:"basiness_id",  width: 80, title: 'ID'},
                {templet: '#row-cover',  title: '头像',  style: 'height: 90px;'},
                {field:"account_nick_name",  title: '昵称'},
                {field: "business_name" ,title: '商家名称'},
                {field: 'coupon_total_count',  title: '签到券总数量'},
                {field: 'coupon_doing_count',  title: '进行中签到券数量'},
                {field: 'coupon_receive_count',  title: '已领取签到券数量'},
                {field: 'coupon_be_overdue_count',  title: '过期未使用签到券数量'},
                {field: 'coupon_used_count', title: '已使用优惠数量'},
                {field: 'coupon_profit_count', title: '为平台提供的总收益'},

                {field: 'balance',title: '商家余额'},
                {field: 'recharge_total_money', title: '充值总额'},
                {templet: '#row-operate', minWidth: 350, field: 'right', align: 'center', title: '操作', }
            ]],
            done: function () {
                Tools.setInsTb(insTb);
            }
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            table.reload('table-container', {
                page: {curr: 1}
                , where: data.field
            }, 'data');

            return false;
        });

    }
    /*** index end ***/

});