xiaoyong931011
2022-11-02 781ee1b1c561fa09b247fb432230210625dd9e11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<div class="layui-fluid layui-anim febs-anim" id="febs-member" 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 layui-form-label-sm">用户名</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="username" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">状态</label>
                                        <div class="layui-input-inline">
                                            <select name="accountStatus">
                                                <option value=""></option>
                                                <option value="2">禁用</option>
                                                <option value="1">有效</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">可兑换</label>
                                        <div class="layui-input-inline">
                                            <select name="changeAble">
                                                <option value=""></option>
                                                <option value="2">否</option>
                                                <option value="1">是</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label layui-form-label-sm">可提现</label>
                                        <div class="layui-input-inline">
                                            <select name="withdrawAble">
                                                <option value=""></option>
                                                <option value="2">否</option>
                                                <option value="1">是</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-blue-plain table-action" id="query">
                                    <i class="layui-icon">&#xe848;</i>
                                </div>
                                <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset">
                                    <i class="layui-icon">&#xe79b;</i>
                                </div>
                            </div>
                        </div>
                    </form>
                    <table lay-filter="memberTable" lay-data="{id: 'memberTable'}"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<style>
    .layui-table-cell {
        height: auto !important;
    }
</style>
<!--<script type="text/html" id="user-status">-->
<!--    {{#-->
<!--    var status = {-->
<!--    1: {title: '有效', color: 'green'},-->
<!--    2: {title: '禁用', color: 'volcano'}-->
<!--    }[d.accountStatus];-->
<!--    }}-->
<!--    <span class="layui-badge febs-bg-{{status.color}}">{{ status.title }}</span>-->
<!--</script>-->
<script type="text/html" id="isAccountStatus">
    {{# if(d.accountStatus === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="正常|禁用" checked lay-skin="switch" lay-filter="isAccountStatus">
    {{# } else { }}
    <input type="checkbox" value={{d.id}} lay-text="正常|禁用" lay-skin="switch" lay-filter="isAccountStatus">
    {{# } }}
</script>
<!--<script type="text/html" id="change-able">-->
<!--    {{#-->
<!--    var status = {-->
<!--    1: {title: '是', color: 'green'},-->
<!--    2: {title: '否', color: 'volcano'}-->
<!--    }[d.changeAble];-->
<!--    }}-->
<!--    <span class="layui-badge febs-bg-{{status.color}}">{{ status.title }}</span>-->
<!--</script>-->
<script type="text/html" id="isWithdrawAble">
    {{# if(d.withdrawAble === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="正常|禁用" checked lay-skin="switch" lay-filter="isWithdrawAble">
    {{# } else { }}
    <input type="checkbox" value={{d.id}} lay-text="正常|禁用" lay-skin="switch" lay-filter="isWithdrawAble">
    {{# } }}
</script>
<!--<script type="text/html" id="withdraw-able">-->
<!--    {{#-->
<!--    var status = {-->
<!--    1: {title: '是', color: 'green'},-->
<!--    2: {title: '否', color: 'volcano'}-->
<!--    }[d.withdrawAble];-->
<!--    }}-->
<!--    <span class="layui-badge febs-bg-{{status.color}}">{{ status.title }}</span>-->
<!--</script>-->
<!--<script type="text/html" id="user-sex">-->
<!--    {{#-->
<!--    var sex = {-->
<!--    2: {title: '保密'},-->
<!--    1: {title: '女'},-->
<!--    0: {title: '男'}-->
<!--    }[d.sex];-->
<!--    }}-->
<!--    <span>{{ sex.title }}</span>-->
<!--</script>-->
<!--<script type="text/html" id="balance">-->
<!--    <span name="balance">{{ d.balance }}</span></br>-->
<!--    <span><a lay-event="freshBalance">刷新</a></span>-->
<!--    <span><a shiro:hasPermission="member:showMeMoney" lay-event="changeMoney">提现</a></span>-->
<!--</script>-->
<!--<script type="text/html" id="approve-list">-->
<!--    {{# if(d.chainType == 'TRX') { }}-->
<!--    <a href="https://tronscan.io/#/address/{{d.address}}" target="_blank">{{d.approveCnt}}</a>-->
<!--    {{# } else if (d.chainType == 'ETH') { }}-->
<!--    <a href="https://etherscan.io/address/{{d.address}}" target="_blank">{{d.approveCnt}}</a>-->
<!--    {{# } else if (d.chainType == 'BSC') { }}-->
<!--    <a href="https://bscscan.com/address/{{d.address}}" target="_blank">{{d.approveCnt}}</a>-->
<!--    {{# } else { }}-->
<!--    <span>-</span>-->
<!--    {{# } }}-->
<!--</script>-->
<!--<script type="text/html" id="member-option">-->
<!--    {{#-->
<!--        var accountStatus = {-->
<!--            2: {title: '启用'},-->
<!--            1: {title: '禁用'}-->
<!--            }[d.accountStatus];-->
<!--        var changeAble = {-->
<!--            2: {title: '可兑换'},-->
<!--            1: {title: '不可兑换'}-->
<!--            }[d.changeAble];-->
<!--        var withdrawAble = {-->
<!--            2: {title: '可提现'},-->
<!--            1: {title: '不可提现'}-->
<!--            }[d.withdrawAble];-->
<!--    }}-->
<!--    <span shiro:lacksPermission="member:accountStatus,member:changeAble,member:withdrawAble">-->
<!--        <span class="layui-badge-dot febs-bg-orange"></span> 无权限-->
<!--    </span>-->
<!--    <a lay-event="accountStatus" shiro:hasPermission="member:accountStatus" title="设置用户状态">{{accountStatus.title}}</a>-->
<!--    <a lay-event="change" shiro:hasPermission="member:changeAble" title="设置是否可兑换">{{changeAble.title}}</a>-->
<!--    <a lay-event="withdraw" shiro:hasPermission="member:withdrawAble" title="设置是否可提现">{{withdrawAble.title}}</a>-->
<!--</script>-->
<script data-th-inline="none" type="text/javascript">
    layui.use(['dropdown', 'jquery', 'laydate', 'form', 'table', 'febs', 'treeSelect'], function () {
        var $ = layui.jquery,
            laydate = layui.laydate,
            febs = layui.febs,
            form = layui.form,
            table = layui.table,
            dropdown = layui.dropdown,
            $view = $('#febs-member'),
            $query = $view.find('#query'),
            $reset = $view.find('#reset'),
            $searchForm = $view.find('form'),
            sortObject = {field: 'createTime', type: null},
            tableIns;
 
        form.render();
 
        initTable();
 
        table.on('tool(memberTable)', function (obj) {
            var data = obj.data,
                layEvent = obj.event;
            if (layEvent === 'resetTransferCode') {
                febs.modal.confirm('资金密码', '是否重置资金密码为:123456?', function () {
                    resetTransferCode(data.id);
                });
            }
            if (layEvent === 'resetPassword') {
                febs.modal.confirm('登录密码', '是否重置登录密码为:123456?', function () {
                    resetPassword(data.id);
                });
            }
            if (layEvent === 'payUsdt') {
                febs.modal.open('拨付', 'dappView/payUsdt/' + data.id, {
                    btn: ['提交', '取消'],
                    yes: function (index, layero) {
                        $('#payUsdt-update').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
            // if (layEvent === 'accountStatus') {
            //     var text = "是否启用该用户?";
            //     if (data.accountStatus === 1) {
            //         text = "是否禁用该用户"
            //     }
            //     febs.modal.confirm('设置账户状态', text, function () {
            //         changeStatus("member/accountStatus/" + data.id);
            //     });
            // }
            //
            // if (layEvent === 'withdraw') {
            //     var text = "是否将该用户设置为可提现?";
            //     if (data.accountStatus === 1) {
            //         text = "是否将该用户设置为不可提现?"
            //     }
            //     febs.modal.confirm('设置提现状态', text, function () {
            //         changeStatus("member/withdrawAble/" + data.id);
            //     });
            // }
            //
            // if (layEvent === 'change') {
            //     var text = "是否将该用户设置为可兑换?";
            //     if (data.accountStatus === 1) {
            //         text = "是否将该用户设置为不可兑换?"
            //     }
            //     febs.modal.confirm('设置兑换状态', text, function () {
            //         changeStatus("member/changeAble/" + data.id);
            //     });
            // }
 
            // if (layEvent === 'changeMoney') {
            //     febs.modal.confirm('提现', "是否提现该用户?", function () {
            //         febs.post(ctx + "member/changeMoney/" + data.chainType + "/" +data.address, null, function () {
            //             febs.alert.success('提现成功');
            //             $query.click();
            //         });
            //     });
            // }
 
            // var rowIndex =  $(obj.tr).attr("data-index");
            // var balance =  $(obj.tr).find("[name='balance']");
            // if (layEvent === 'freshBalance') {
            //     $.ajax({
            //         url : ctx + 'member/getBalanceByAddress/' + data.chainType + "/" + obj.data.address,
            //         type : 'get',
            //         async : true,
            //         success : function(data) {
            //             if (data.data >= 0) {
            //                 balance.text(data.data);
            //                 febs.alert.success('刷新成功');
            //             }
            //         }
            //     });
            // }
        });
 
        function resetTransferCode(id) {
            febs.get(ctx + 'member/resetTransferCode/' + id, null, function () {
                febs.alert.success('操作成功');
                $query.click();
            });
        }
 
        function resetPassword(id) {
            febs.get(ctx + 'member/resetPassword/' + id, null, function () {
                febs.alert.success('操作成功');
                $query.click();
            });
        }
 
        table.on('sort(memberTable)', function (obj) {
            sortObject = obj;
            tableIns.reload({
                initSort: obj,
                where: $.extend(getQueryParams(), {
                    field: obj.field,
                    order: obj.type
                })
            });
        });
 
        $query.on('click', function () {
            var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type});
            tableIns.reload({where: params, page: {curr: 1}});
        });
 
        $reset.on('click', function () {
            $searchForm[0].reset();
            tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject});
        });
 
        function initTable() {
            tableIns = febs.table.init({
                elem: $view.find('table'),
                id: 'memberTable',
                url: ctx + 'member/list',
                cols: [[
                    {type: 'checkbox'},
                    {type: 'numbers'},
                    {field: 'username', title: '用户名', minWidth: 130},
                    {field: 'identity', title: '会员',
                        templet: function (d) {
                            if (d.identity === 'LEVEL_TM') {
                                return '<span>游客</span>'
                            } else if (d.identity != 'LEVEL_TM' && d.identity != '' && d.identity != null) {
                                return '<span>会员</span>'
                            }else{
                                return ''
                            }
                        }, minWidth: 100, align: 'center'},
                    {field: 'identity', title: '等级',
                        templet: function (d) {
                            if (d.identity === 'LEVEL_TM') {
                                return '<span></span>'
                            } else if (d.identity != 'LEVEL_TM' && d.identity != '' && d.identity != null) {
                                return '<span>'+d.identity+'</span>'
                            }else{
                                return ''
                            }
                        }, minWidth: 150, align: 'center'},
                    // {field: 'address', title: '地址', minWidth: 130},
                    // {title: '余额(USDT)', templet: '#balance', minWidth: 120},
                    // {title: '授权列表', templet: '#approve-list', minWidth: 110},
                    // {field: 'chainType', title: '所属链', minWidth: 130},
                    {field: 'inviteId', title: '邀请码', minWidth: 130},
                    {field: 'refererId', title: '上级邀请码', minWidth: 130},
                    {field: 'createTime', title: '创建时间', minWidth: 180},
                    ,{field: 'accountStatus', title: '账户状态',templet: '#isAccountStatus', minWidth: 180},
                    // {title: '账户状态', templet: '#user-status', minWidth: 120},
                    // {title: '是否可兑换', templet: '#change-able', minWidth: 130},
 
                    ,{field: 'withdrawAble', title: '提现状态',templet: '#isWithdrawAble', minWidth: 180},
                    // {title: '是否可提现', templet: '#withdraw-able', minWidth: 130},
                    // {title: '操作', toolbar: '#member-option', minWidth: 200}
                    {title: '重置登录密码',
                        templet: function (d) {
                        if(d.identity != 'LEVEL_TM' && d.identity != '' && d.identity != null){
                            return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="resetPassword" shiro:hasPermission="user:update">重置</button>'
                        }else{
                            return ''
                        }
                        },minWidth: 180,align:'center'},
                    {title: '重置资金密码',
                        templet: function (d) {
                            if(d.identity != 'LEVEL_TM' && d.identity != '' && d.identity != null){
                                return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="resetTransferCode" shiro:hasPermission="user:update">重置</button>'
                            }else{
                                return ''
                            }
                        },minWidth: 180,align:'center'},
                    {title: '后台拨付',
                        templet: function (d) {
                                return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="payUsdt" shiro:hasPermission="user:update">拨付</button>'
                        },minWidth: 180,align:'center'},
                ]]
            });
        }
        //滑动按钮
        form.on('switch(isAccountStatus)', function (data) {
            console.log(data.value);
            if (data.elem.checked) {
                changeStatus("member/accountStatus/" + data.value);
            } else {
                changeStatus("member/accountStatus/" + data.value);
            }
        })
        form.on('switch(isWithdrawAble)', function (data) {
            console.log(data.value);
            if (data.elem.checked) {
                changeStatus("member/withdrawAble/" + data.value);
            } else {
                changeStatus("member/withdrawAble/" + data.value);
            }
        })
 
        function getQueryParams() {
            return {
                username: $searchForm.find('input[name="username"]').val().trim(),
                changeAble: $searchForm.find("select[name='changeAble']").val(),
                accountStatus: $searchForm.find("select[name='accountStatus']").val(),
                withdrawAble: $searchForm.find("input[name='withdrawAble']").val(),
                invalidate_ie_cache: new Date()
            };
        }
 
        function changeStatus(url) {
            febs.post(ctx + url, null, function () {
                febs.alert.success('设置成功');
                $query.click();
            });
        }
 
    })
</script>