<div class="layui-fluid layui-anim febs-anim" id="febs-product-buy" lay-title="用户预约记录"> 
 | 
    <div class="layui-row febs-container"> 
 | 
        <div class="layui-col-md12"> 
 | 
            <div class="layui-card"> 
 | 
                <div class="layui-card-body febs-table-full"> 
 | 
                    <form class="layui-form layui-table-form" lay-filter="user-table-form"> 
 | 
                        <div class="layui-row"> 
 | 
                            <div class="layui-col-md10"> 
 | 
                                <div class="layui-form-item"> 
 | 
                                    <div class="layui-inline"> 
 | 
                                        <label class="layui-form-label">登录账户:</label> 
 | 
                                        <div class="layui-input-inline"> 
 | 
                                            <input type="text" placeholder="登录账户" name="accountLogin" autocomplete="off" class="layui-input"> 
 | 
                                        </div> 
 | 
                                    </div> 
 | 
                                    <div class="layui-inline"> 
 | 
                                        <label class="layui-form-label">编号:</label> 
 | 
                                        <div class="layui-input-inline"> 
 | 
                                            <input type="text" placeholder="编号" name="orderNo" autocomplete="off" class="layui-input"> 
 | 
                                        </div> 
 | 
                                    </div> 
 | 
                                    <div class="layui-inline"> 
 | 
                                        <label class="layui-form-label">预约状态:</label> 
 | 
                                        <div class="layui-input-inline"> 
 | 
                                            <select name="state"> 
 | 
                                                <option value="">请选择</option> 
 | 
                                                <option value="0">失败</option> 
 | 
                                                <option value="1">进行中</option> 
 | 
                                                <option value="2">超时</option> 
 | 
                                                <option value="3">已完成</option> 
 | 
                                            </select> 
 | 
                                        </div> 
 | 
                                    </div> 
 | 
                                </div> 
 | 
                            </div> 
 | 
                            <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area"> 
 | 
<!--                                <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="add">--> 
 | 
<!--                                    新增--> 
 | 
<!--                                </div>--> 
 | 
                                <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query"> 
 | 
                                    <i class="layui-icon"></i> 
 | 
                                </div> 
 | 
                                <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset"> 
 | 
                                    <i class="layui-icon"></i> 
 | 
                                </div> 
 | 
                            </div> 
 | 
                        </div> 
 | 
                    </form> 
 | 
                    <table lay-filter="buyTable" lay-data="{id: 'buyTable'}" id="buyTable"></table> 
 | 
                </div> 
 | 
                <blockquote class="layui-elem-quote blue-border">用户预约打款记录</blockquote> 
 | 
                <div class="layui-card-body febs-table-full"> 
 | 
                    <table lay-filter="buyRecordTable"  lay-data="{id: 'buyRecordTable'}" id="buyRecordTable"></table> 
 | 
                </div> 
 | 
  
 | 
            </div> 
 | 
        </div> 
 | 
    </div> 
 | 
</div> 
 | 
<style> 
 | 
    .layui-table-cell { 
 | 
        height: auto; 
 | 
    } 
 | 
    .layui-form-onswitch { 
 | 
        background-color: #5FB878 !important; 
 | 
    } 
 | 
</style> 
 | 
<script type="text/html" id="isBuyState"> 
 | 
    {{# if(d.state === 0) { }} 
 | 
    <span class="layui-badge febs-bg-red">失败</span> 
 | 
    {{# } else if(d.state === 1) { }} 
 | 
    <span class="layui-badge febs-bg-blue">进行中</span> 
 | 
    {{# } else if(d.state === 2) { }} 
 | 
    <span class="layui-badge febs-bg-orange">超时</span> 
 | 
    {{# } else if(d.state === 3) { }} 
 | 
    <span class="layui-badge febs-bg-green">已完成</span> 
 | 
    {{# } else { }} 
 | 
    {{# } }} 
 | 
</script> 
 | 
<script type="text/html" id="isBuyMateState"> 
 | 
    {{# if(d.mateState === 0) { }} 
 | 
    <span class="layui-badge febs-bg-red">未转换</span> 
 | 
    {{# } else if(d.mateState === 1) { }} 
 | 
    <span class="layui-badge febs-bg-blue">已转换</span> 
 | 
    {{# } else if(d.mateState === 2) { }} 
 | 
    <span class="layui-badge febs-bg-orange">待支付</span> 
 | 
    {{# } else if(d.mateState === 3) { }} 
 | 
    <span class="layui-badge febs-bg-green">已支付</span> 
 | 
    {{# } else if(d.mateState === 4) { }} 
 | 
    <span class="layui-badge febs-bg-green">已确认</span> 
 | 
    {{# } else if(d.mateState === 5) { }} 
 | 
    <span class="layui-badge febs-bg-green">已完成</span> 
 | 
    {{# } else { }} 
 | 
    {{# } }} 
 | 
</script> 
 | 
<script type="text/html" id="isBuyRecordState"> 
 | 
    {{# if(d.state === 0) { }} 
 | 
    <span class="layui-badge febs-bg-red">失败</span> 
 | 
    {{# } else if(d.state === 1) { }} 
 | 
    <span class="layui-badge febs-bg-blue">匹配中</span> 
 | 
    {{# } else if(d.state === 2) { }} 
 | 
    <span class="layui-badge febs-bg-orange">待支付</span> 
 | 
    {{# } else if(d.state === 3) { }} 
 | 
    <span class="layui-badge febs-bg-green">已支付</span> 
 | 
    {{# } else if(d.state === 4) { }} 
 | 
    <span class="layui-badge febs-bg-green">已确认</span> 
 | 
    {{# } else if(d.state === 5) { }} 
 | 
    <span class="layui-badge febs-bg-green">已完成</span> 
 | 
    {{# } else if(d.state === 6) { }} 
 | 
    <span class="layui-badge febs-bg-red">投诉</span> 
 | 
    {{# } else { }} 
 | 
    {{# } }} 
 | 
</script> 
 | 
<!-- 表格操作栏 start --> 
 | 
<script type="text/html" id="user-option"> 
 | 
    <span shiro:lacksPermission="user:view,user:update,user:delete"> 
 | 
        <span class="layui-badge-dot febs-bg-orange"></span> 无权限 
 | 
    </span> 
 | 
    <a lay-event="edit" shiro:hasPermission="user:update"><i 
 | 
            class="layui-icon febs-edit-area febs-blue"></i></a> 
 | 
</script> 
 | 
<style> 
 | 
    .layui-form-onswitch { 
 | 
        background-color: #5FB878 !important; 
 | 
    } 
 | 
    .thead {background-color: rgba(255, 175, 16,0.2);text-align: center;} 
 | 
    .tbody { 
 | 
        background-color: rgba(255, 175, 16, 0.1); 
 | 
        text-align: center; 
 | 
        width:100px; 
 | 
    } 
 | 
</style> 
 | 
<!-- 表格操作栏 end --> 
 | 
<script data-th-inline="none" type="text/javascript"> 
 | 
    // 引入组件并初始化 
 | 
    layui.use([ 'jquery', 'form', 'table', 'febs'], function () { 
 | 
        var $ = layui.jquery, 
 | 
            febs = layui.febs, 
 | 
            form = layui.form, 
 | 
            table = layui.table, 
 | 
            $view = $('#febs-product-buy'), 
 | 
            $query = $view.find('#query'), 
 | 
            $reset = $view.find('#reset'), 
 | 
            $searchForm = $view.find('form'), 
 | 
            sortObject = {field: 'phone', type: null}, 
 | 
            buyRecordTable, 
 | 
            buyTable, 
 | 
            tableIns; 
 | 
  
 | 
        form.render(); 
 | 
  
 | 
        // 表格初始化 
 | 
        initBuyTable(); 
 | 
        initBuyTable(); 
 | 
  
 | 
        // 初始化表格操作栏各个按钮功能 
 | 
        table.on('tool(buyTable)', function (obj) { 
 | 
            var data = obj.data, 
 | 
                layEvent = obj.event; 
 | 
            if (layEvent === 'productSellPick') { 
 | 
                febs.modal.open('编辑', 'modules/news/productSellPick/' + data.id, { 
 | 
                    btn: ['提交', '取消'], 
 | 
                    yes: function (index, layero) { 
 | 
                        $('#product-sell-pick').find('#submit').trigger('click'); 
 | 
                    }, 
 | 
                    btn2: function () { 
 | 
                        layer.closeAll(); 
 | 
                    } 
 | 
                }); 
 | 
            } 
 | 
        }); 
 | 
  
 | 
        // 初始化表格操作栏各个按钮功能 
 | 
        table.on('tool(buyRecordTable)', function (obj) { 
 | 
            var data = obj.data, 
 | 
                layEvent = obj.event; 
 | 
            /** 
 | 
             *  +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="buyRecordPay" shiro:hasPermission="user:update">确认支付</button>' 
 | 
             +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="buyRecordConfirm" shiro:hasPermission="user:update">确认收款</button>' 
 | 
             +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="buyRecordImg" shiro:hasPermission="user:update">收款凭证</button>' 
 | 
             */ 
 | 
            if (layEvent === 'buyRecordCancel') { 
 | 
                febs.modal.confirm('取消', '是否确认取消?', function () { 
 | 
                    buyRecordCancel(data.id); 
 | 
                }); 
 | 
            } 
 | 
            if (layEvent === 'buyRecordPay') { 
 | 
                febs.modal.open('确认支付', 'modules/news/buyRecordPay/' + data.id, { 
 | 
                    btn: ['提交', '取消'], 
 | 
                    yes: function (index, layero) { 
 | 
                        $('#buyRecordPay-update').find('#submit').trigger('click'); 
 | 
                    }, 
 | 
                    btn2: function () { 
 | 
                        layer.closeAll(); 
 | 
                    } 
 | 
                }); 
 | 
            } 
 | 
            if (layEvent === 'buyRecordConfirm') { 
 | 
                febs.modal.confirm('确认收款', '是否确认收款?', function () { 
 | 
                    buyRecordConfirm(data.id); 
 | 
                }); 
 | 
            } 
 | 
            if (layEvent === 'buyRecordImg') { 
 | 
                if(data.nftImg == null || data.nftImg == ''){ 
 | 
                    febs.modal.warn('告警信息', '凭证未上传', function () { 
 | 
                        febs.alert.info("请上传凭证"); 
 | 
                    }); 
 | 
                    return false; 
 | 
                } 
 | 
                layer.open({ 
 | 
                    type: 1, 
 | 
                    title: "凭证", 
 | 
                    skin: 'layui-layer-rim', //加上边框 
 | 
                    area: ['80%', '80%'], //宽高 
 | 
                    shadeClose: true, //开启遮罩关闭 
 | 
                    end: function (index, layero) { 
 | 
                        return false; 
 | 
                    }, 
 | 
                    content: '<div style="text-align:center"><img src="' + data.nftImg + '" /></div>' 
 | 
                }); 
 | 
                // febs.modal.open('凭证', 'modules/news/buyRecordImg/' + data.id, { 
 | 
                //     btn2: function () { 
 | 
                //         layer.closeAll(); 
 | 
                //     } 
 | 
                // }); 
 | 
            } 
 | 
        }); 
 | 
        function buyRecordCancel(id) { 
 | 
            febs.get(ctx + 'admin/news/buyRecordCancel/' + id, null, function () { 
 | 
                febs.alert.success('操作成功'); 
 | 
                $query.click(); 
 | 
            }); 
 | 
        } 
 | 
        function buyRecordConfirm(id) { 
 | 
            febs.get(ctx + 'admin/news/buyRecordConfirm/' + id, null, function () { 
 | 
                febs.alert.success('操作成功'); 
 | 
                $query.click(); 
 | 
            }); 
 | 
        } 
 | 
  
 | 
        // 查询按钮 
 | 
        $query.on('click', function () { 
 | 
            var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type}); 
 | 
            buyRecordTable.reload({where: params, page: {curr: 1}}); 
 | 
            buyTable.reload({where: params, page: {curr: 1}}); 
 | 
        }); 
 | 
  
 | 
        // 刷新按钮 
 | 
        $reset.on('click', function () { 
 | 
            $searchForm[0].reset(); 
 | 
            sortObject.type = 'null'; 
 | 
            buyRecordTable.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject}); 
 | 
            buyTable.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject}); 
 | 
        }); 
 | 
  
 | 
        function initBuyTable() { 
 | 
            buyTable = febs.table.init({ 
 | 
                elem: $('#buyTable'), 
 | 
                url: ctx + 'admin/news/getBuyList', 
 | 
                cols: [[ 
 | 
                    {field: 'accountLogin', title: '登录账户', minWidth: 120,align:'center'}, 
 | 
                    {field: 'orderNo', title: '编号', minWidth: 200,align:'center'}, 
 | 
                    {field: 'nftTotal', title: '预约额度', minWidth: 100,align:'center'}, 
 | 
                    {field: 'nftAva', title: '可分配', minWidth: 100,align:'center'}, 
 | 
                    {field: 'payTime', title: '匹配时间', minWidth: 120,align:'center'}, 
 | 
                    {templet: '#isBuyState', title: '预约状态', minWidth: 100,align:'center'}, 
 | 
                    {templet: '#isBuyMateState', title: '匹配状态', minWidth: 100,align:'center'}, 
 | 
                    {title: '操作', 
 | 
                        templet: function (d) { 
 | 
                            if(d.state == 1){ 
 | 
                                return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="productSellPick" shiro:hasPermission="user:update">手动匹配</button>' 
 | 
                            }else{ 
 | 
                                return '' 
 | 
                            } 
 | 
                        },minWidth: 300,align:'center'} 
 | 
                ]] 
 | 
            }); 
 | 
            buyRecordTable = febs.table.init({ 
 | 
                elem: $('#buyRecordTable'), 
 | 
                url: ctx + 'admin/news/getBuyRecordList', 
 | 
                cols: [[ 
 | 
                    {field: 'id', title: '', minWidth: 120,align:'center'}, 
 | 
                    {field: 'accountLogin', title: '匹配用户', minWidth: 120,align:'center'}, 
 | 
                    {field: 'pickNftCnt', title: '支付金额', minWidth: 120,align:'center'}, 
 | 
                    {field: 'orderTime', title: '匹配时间', minWidth: 120,align:'center'}, 
 | 
                    {field: 'payTime', title: '支付时间', minWidth: 120,align:'center'}, 
 | 
                    {templet: '#isBuyRecordState', title: '支付状态', minWidth: 120,align:'center'}, 
 | 
                    {title: '操作', 
 | 
                        templet: function (d) { 
 | 
                            return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="buyRecordCancel" shiro:hasPermission="user:update">取消</button>' 
 | 
                            +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="buyRecordPay" shiro:hasPermission="user:update">确认支付</button>' 
 | 
                            +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="buyRecordConfirm" shiro:hasPermission="user:update">确认收款</button>' 
 | 
                            +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="buyRecordImg" shiro:hasPermission="user:update">收款凭证</button>' 
 | 
                        },minWidth: 300,align:'center'} 
 | 
                ]] 
 | 
            }); 
 | 
        } 
 | 
        // 获取查询参数 
 | 
        function getQueryParams() { 
 | 
            return { 
 | 
                accountLogin: $searchForm.find('input[name="accountLogin"]').val().trim(), 
 | 
                orderNo: $searchForm.find('input[name="orderNo"]').val().trim(), 
 | 
                state: $searchForm.find("select[name='state']").val(), 
 | 
            }; 
 | 
        } 
 | 
  
 | 
        form.on('switch(isState)', function (data) { 
 | 
            if (data.elem.checked) { 
 | 
                febs.post(ctx + 'admin/news/upNFT/' + data.value, null, function () { 
 | 
                    febs.alert.success('操作成功'); 
 | 
                    $query.click(); 
 | 
                }); 
 | 
            } else { 
 | 
                febs.post(ctx + 'admin/news/unUpNFT/' + data.value, null, function () { 
 | 
                    febs.alert.success('操作成功'); 
 | 
                    $query.click(); 
 | 
                }); 
 | 
            } 
 | 
        }) 
 | 
    }) 
 | 
</script> 
 |