xiaoyong931011
2023-09-01 5772ee39bd00b83ecca16b0b472d86e945d8c0ea
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
<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">地址邀请码:</label>
                                        <div class="layui-input-inline"><input type="text" name="inviteId" autocomplete="off" placeholder="输入地址或邀请码"  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="accountType">-->
<!--                                                <option value=""></option>-->
<!--                                                <option value="MEMBER">MEMBER</option>-->
<!--                                                <option value="NODE_1">NODE_1</option>-->
<!--                                                <option value="NODE_2">NODE_2</option>-->
<!--                                                <option value="NODE_3">NODE_3</option>-->
<!--                                                <option value="NODE_4">NODE_4</option>-->
<!--                                                <option value="NODE_5">NODE_5</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="switchChangeAble">
    {{# if(d.changeAble === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="是|否" checked lay-skin="switch" lay-filter="switchChangeAble">
    {{# } else { }}
    <input type="checkbox" value={{d.id}} lay-text="是|否" lay-skin="switch" lay-filter="switchChangeAble">
    {{# } }}
</script>
<script type="text/html" id="switchActiveStatus">
    {{# if(d.activeStatus === 1) { }}
    <input type="checkbox" value={{d.id}} lay-text="是|否" checked lay-skin="switch" lay-filter="switchActiveStatus">
    {{# } else { }}
    <input type="checkbox" value={{d.id}} lay-text="是|否" lay-skin="switch" lay-filter="switchActiveStatus">
    {{# } }}
</script>
<script type="text/html" id="tableMemberBar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="agentLevel:view" lay-event="coinAmount">拨付余额</button>
        <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="agentLevel:view" lay-event="scoreAmount">拨付赠送积分</button>
        <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="agentLevel:view" lay-event="balance">拨付资产包</button>
        <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="agentLevel:view" lay-event="balanceSystem">资产强制卖出</button>
    </div>
</script>
 
<script type="text/html" id="mallmember-option">
    <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="agentLevel:view" lay-event="agentLevel">设置会员级别</button>
    <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="agentLevel:view" lay-event="memberFlow">个人流水</button>
</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 === 'agentLevel') {
                febs.modal.open('设置代理级别', 'dappView/agentLevel/' + data.id, {
                    btn: ['确认', '取消'],
                    yes: function (index, layero) {
                        $('#agent-level-set').find('#submit').trigger('click');
                    },
                    btn2: function () {
                        layer.closeAll();
                    }
                });
            }
 
            if (layEvent === 'memberFlow') {
                febs.modal.open( '订单流水', 'dappView/memberFlow/' + data.id, {
                    maxmin: true,
                });
            }
        });
 
        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});
        });
 
        form.on('switch(switchChangeAble)', function (data) {
            if (data.elem.checked) {
                changeAbleYes(data.value);
            } else {
                changeAbleNo(data.value);
            }
        })
        function changeAbleYes(id) {
            febs.get(ctx + 'member/changeAbleYes/' + id, null, function () {
                febs.alert.success('操作成功');
                $query.click();
            });
        }
        function changeAbleNo(id) {
            febs.get(ctx + 'member/changeAbleNo/' + id, null, function () {
                febs.alert.success('操作成功');
                $query.click();
            });
        }
 
        form.on('switch(switchActiveStatus)', function (data) {
            if (data.elem.checked) {
                insideWithYes(data.value);
            } else {
                insideWithNo(data.value);
            }
        })
        function insideWithYes(id) {
            febs.get(ctx + 'member/insideWithYes/' + id, null, function () {
                febs.alert.success('操作成功');
                $query.click();
            });
        }
        function insideWithNo(id) {
            febs.get(ctx + 'member/insideWithNo/' + id, null, function () {
                febs.alert.success('操作成功');
                $query.click();
            });
        }
 
        function initTable() {
            tableIns = febs.table.init({
 
                elem: $view.find('table'),
                id: 'memberTable',
                url: ctx + 'member/list',
                toolbar:"#tableMemberBar",
                totalRow: true ,// 开启合计行
                cols: [[
                    {type: 'checkbox'},
                    {field:'', title: '序号', width: 80, type:'numbers'},
                    // {title: '代理级别',
                    //     templet: function (d) {
                    //         return '<span class="layui-btn layui-btn-normal layui-btn-xs">'+d.accountType+'</span>'
                    //     },minWidth: 130,align:'center'},
                    {field: 'address', title: '地址', minWidth: 400, totalRowText: '合计'},
                    {field: 'refererId', title: '上级邀请码', minWidth: 100},
                    {field: 'inviteId', title: '邀请码', minWidth: 100},
                    {field: 'coinAmount', title: '余额', minWidth: 130},
                    {field: 'scoreAmount', title: '赠送积分', minWidth: 130},
                    {field: 'balance', title: '资产包', minWidth: 130},
                    {field: 'withdrawAmount', title: '累计提现', minWidth: 130},
                    {field: 'myTeamAchieve', title: '团队业绩', minWidth: 130},
                    {field: 'myShareAchieve', title: '共享业绩', minWidth: 130},
                    {field: 'activeStatus', title: '是否激活', templet:'#switchActiveStatus', minWidth: 120},
                    {field: 'changeAble', title: '是否冻结', templet:'#switchChangeAble', minWidth: 120},
                    {field: 'accountType', title: '会员级别', minWidth: 130},
                    // {field: 'directProfit', title: '直推收益', minWidth: 100, totalRow: true},
                    {field: 'chainType', title: '所属链', minWidth: 130},
                    {field: 'createTime', title: '创建时间', minWidth: 180},
                    {title: '操作', minWidth: 300 ,toolbar: '#mallmember-option',align:'left', fixed:'right'}
                ]]
            });
        }
        table.on('toolbar(memberTable)', function(obj){
            var data = obj.data,
                layEvent = obj.event;
 
            if (layEvent === 'coinAmount') {
                var checkData = table.checkStatus('memberTable').data;
                if (checkData.length <= 0) {
                    febs.alert.warn('请选择需要的用户');
                    return;
                }
                if (checkData.length > 1) {
                    febs.alert.warn('请选择一个用户');
                    return;
                }
                systemPay("余额", checkData[0].id, 1);
            }
 
            if (layEvent === 'scoreAmount') {
                var checkData = table.checkStatus('memberTable').data;
                if (checkData.length <= 0) {
                    febs.alert.warn('请选择需要的用户');
                    return;
                }
                if (checkData.length > 1) {
                    febs.alert.warn('请选择一个用户');
                    return;
                }
                systemPay("赠送积分", checkData[0].id, 2);
            }
 
            if (layEvent === 'balance') {
                var checkData = table.checkStatus('memberTable').data;
                if (checkData.length <= 0) {
                    febs.alert.warn('请选择需要的用户');
                    return;
                }
                if (checkData.length > 1) {
                    febs.alert.warn('请选择一个用户');
                    return;
                }
                systemPay("资产包", checkData[0].id, 3);
            }
 
            if (layEvent === 'balanceSystem') {
                febs.get(ctx + 'member/balanceSystem/', null, function () {
                    febs.alert.success('操作成功');
                    $query.click();
                });
            }
        });
 
        function systemPay(text, id, type) {
            febs.modal.open(text, 'dappView/mallSystemPay/' + type +'/'+ id, {
                btn: ['确认', '取消'],
                yes: function (index, layero) {
                    $('#systemPay-update').find('#submit').trigger('click');
                },
                btn2: function () {
                    layer.closeAll();
                }
            });
        }
 
        function getQueryParams() {
            return {
                inviteId: $searchForm.find('input[name="inviteId"]').val().trim(),
                accountType: $searchForm.find("select[name='accountType']").val(),
                withdrawAble: $searchForm.find("select[name='withdrawAble']").val(),
                invalidate_ie_cache: new Date()
            };
        }
 
        function changeStatus(url) {
            febs.post(ctx + url, null, function () {
                febs.alert.success('设置成功');
                $query.click();
            });
        }
 
    })
</script>