xuhy
2023-08-11 8a16c45b3508dd2c0b53312b6d929f7bf8a5066d
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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
/**
 * 用户管理管理初始化
 */
var TUser = {
    id: "TUserTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
/**
 * 鼠标悬停提示框 class .toolTip 为无效样式,作用于个别选择器使用
 */
TUser.tooltip = function(){
    $(".toolTip").tooltip();
};
 
/**
 * 初始化表格的列
 */
TUser.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '注册时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle',width:'10%',
            formatter: function (value, row) {
                var btn = "";
                if(row.insertTime != '' && row.insertTime != null) {
                    var time = row.insertTime.replace(" ",'<br>');
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.insertTime + '" onfocus="TUser.tooltip()">' + time + '</p>']
                }
                return btn;
            }
        },
        {title: '用户ID', field: 'id', visible: true, align: 'center', valign: 'middle',width:'8%'},
       /* {title: '注册地IP', field: 'registIp', visible: true, align: 'center', valign: 'middle',width:'5%',
            formatter: function (value, row) {
                var btn = "";
                if(row.registIp != '' && row.registIp != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.registIp + '" onfocus="TUser.tooltip()">' + row.registIp + '</p>']
                }
                return btn;
            }
        },*/
        {title: '注册地所<br/>属分公司ID', field: 'companyId', visible: false, align: 'center', valign: 'middle',width:'8%'},
        {title: '注册地所<br/>属分公司', field: 'companyName', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.companyName != '' && row.companyName != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.companyName + '" onfocus="TUser.tooltip()">' + row.companyName + '</p>']
                }
                return btn;
            }
        },
        {title: '昵称', field: 'nickName', visible: true, align: 'center', valign: 'middle',width:'10%',
            formatter: function (value, row) {
                var btn = "";
                if(row.nickName != '' && row.nickName != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.nickName + '" onfocus="TUser.tooltip()">' + row.nickName + '</p>']
                }
                return btn;
            }
        },
        {title: '手机号', field: 'phone', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.phone != '' && row.phone != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + decryptAES(row.phone) + '" onfocus="TUser.tooltip()">' + decryptAES(row.phone) + '</p>']
                }
                return btn;
            }
        },
        {title: '紧急联系人<br/>姓名', field: 'emergencyContact', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.emergencyContact != '' && row.emergencyContact != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.emergencyContact + '" onfocus="TUser.tooltip()">' + row.emergencyContact + '</p>']
                }
                return btn;
            }
        },
        {title: '紧急联系人<br/>电话', field: 'emergencyContactNumber', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.emergencyContactNumber != '' && row.emergencyContactNumber != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.emergencyContactNumber + '" onfocus="TUser.tooltip()">' + row.emergencyContactNumber + '</p>']
                }
                return btn;
            }
        },
        {title: '是否实<br/>名认证', field: 'isAuth', visible: true, align: 'center', valign: 'middle',width:'5%',
            formatter: function (value, row) {
                var btn = "";
                if(row.isAuth != '' && row.isAuth != null) {
                    if (row.isAuth == 1){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="否" onfocus="TUser.tooltip()">否</p>']
                    } else if (row.isAuth == 2){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="是" onfocus="TUser.tooltip()">是</p>']
                    }
                }
                return btn;
            }
        },
        {title: '历史出<br/>行次数', field: 'historyNum', visible: true, align: 'center', valign: 'middle',width:'5%',
            formatter: function (value, row) {
                var btn = "";
                if(row.historyNum != '' && row.historyNum != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.historyNum + '" onfocus="TUser.tooltip()">' + row.historyNum + '</p>']
                }else {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="0" onfocus="TUser.tooltip()">0</p>']
                }
                return btn;
            }
        },
        {title: '历史消费', field: 'consumptionNum', visible: true, align: 'center', valign: 'middle',width:'5%',
            formatter: function (value, row) {
                var btn = "";
                if(row.consumptionNum != '' && row.consumptionNum != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="¥' + row.consumptionNum + '" onfocus="TUser.tooltip()">¥' + row.consumptionNum + '</p>']
                }else {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="¥0.00" onfocus="TUser.tooltip()">¥0.00</p>']
                }
                return btn;
            }
        },
        {title: '积分', field: 'integral', visible: true, align: 'center', valign: 'middle',width:'5%',
            formatter: function (value, row) {
                var btn = "";
                if(row.integral != '' && row.integral != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.integral + '" onfocus="TUser.tooltip()">' + row.integral + '</p>']
                }else {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="0" onfocus="TUser.tooltip()">0</p>']
                }
                return btn;
            }
        },
        {title: '备注', field: 'remark', visible: true, align: 'center', valign: 'middle',width:'10%',
            formatter: function (value, row) {
                var btn = "";
                if(row.remark != '' && row.remark != null){
                    var str = row.remark;
                    if (row.remark.length > 10){
                        str = row.remark.substring(0,10)+"...";
                    }
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.remark + '" onfocus="TUser.tooltip()">' + str + '</p>']
                }
                return btn;
            }
        },
        {title: '状态', field: 'state', visible: true, align: 'center', valign: 'middle',width:'5%',
            formatter: function (value, row) {
                var btn = "";
                if(row.state != '' && row.state != null) {
                    if (row.state == 1){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: #0d8ddb;" title="正常" onfocus="TUser.tooltip()">正常</p>']
                    } else if (row.state == 2){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: red;" title="冻结" onfocus="TUser.tooltip()">冻结</p>']
                    }
                }
                return btn;
            }
        }
    ];
};
 
/**
 * 检查是否选中
 */
TUser.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TUser.seItem = selected[0];
        return true;
    }
};
 
/**
 * 修改余额
 */
TUser.updateBalance = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '修改余额',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tUser/tUser_updateBalance/'+ TUser.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 修改密码
 */
TUser.updatePassword = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '修改密码',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tUser/tUser_updatePassword/'+ TUser.seItem.id
        });
        this.layerIndex = index;
    }
};
 
/**
 * 打开查看用户管理详情
 */
TUser.userDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '用户详情',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tUser/tUser_userDetail/' + TUser.seItem.id
        });
        this.layerIndex = index;
    }
};
 
/**
 * 冻结用户
 */
TUser.freezeUser = function () {
    if (this.check()) {
        var nickname = TUser.seItem.nickName;
        if (nickname == "" || nickname == null || nickname == undefined) {
            nickname = "该用户";
        } else {
            nickname = "【" + nickname + "】";
        }
        if (TUser.seItem.state != 1) {
            swal("冻结失败", "【正常】状态下才能执行此操作", "warning");
            return;
        } else {
            var index = layer.open({
                type: 2,
                title: '冻结用户',
                area: ['800px', '420px'], //宽高
                fix: false, //不固定
                maxmin: true,
                content: Feng.ctxPath + '/tUser/tUser_optUser/' + TUser.seItem.id +"/"+1
            });
            this.layerIndex = index;
        }
    }
};
/**
 * 解冻用户
 */
TUser.trawUser = function () {
    if (this.check()) {
        var nickname = TUser.seItem.nickName;
        if (nickname == "" || nickname == null || nickname == undefined) {
            nickname = "该用户";
        } else {
            nickname = "【" + nickname + "】";
        }
        if (TUser.seItem.state != 2) {
            swal("启用失败", "【冻结】状态下才能执行此操作", "warning");
            return;
        } else {
            var index = layer.open({
                type: 2,
                title: '解冻用户',
                area: ['800px', '420px'], //宽高
                fix: false, //不固定
                maxmin: true,
                content: Feng.ctxPath + '/tUser/tUser_optUser/' + TUser.seItem.id +"/"+2
            });
            this.layerIndex = index;
        }
    }
};
 
var key = CryptoJS.enc.Utf8.parse("xqT86jictTPpHMem");
var iv = CryptoJS.enc.Utf8.parse("xqT86jicxqT86jic");
 
//aes加密
function encryptAES(context) {
    if(null == context || '' == context){
        return context;
    }
    var encrypted = '';
    if (typeof(context) == 'string') {
 
    }else if(typeof(context) == 'object'){
        context = JSON.stringify(context);
    }
    var srcs = CryptoJS.enc.Utf8.parse(context);
    encrypted = CryptoJS.AES.encrypt(srcs, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });
    return encrypted.toString();
}
// aes解密
function decryptAES(context) {
    if(null == context || '' == context){
        return context;
    }
    var decrypt = CryptoJS.AES.decrypt(context, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });
    var decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
    return decryptedStr.toString();
}
 
 
 
/**
 * 查询用户管理列表
 */
TUser.search = function () {
    var queryData = {};
    queryData['insertTime'] = $("#insertTime").val();
    queryData['id'] = $("#id").val();
    queryData['nickName'] = $("#nickName").val();
    queryData['phone'] = encryptAES($("#phone").val());
    queryData['isAuth'] = $("#isAuth").val();
    queryData['state'] = $("#state").val();
    TUser.table.refresh({query: queryData});
};
TUser.resetSearch = function () {
    $("#insertTime").val("");
    $("#id").val("");
    $("#nickName").val("");
    $("#phone").val("");
    $("#isAuth").val("");
    $("#state").val("");
    TUser.search();
};
 
$(function () {
    var defaultColunms = TUser.initColumn();
    var table = new BSTable(TUser.id, "/tUser/list", defaultColunms);
    // 设置物理分页server(逻辑分页client)
    table.setPaginationType("server");
    TUser.table = table.init();
});
 
/**
 * 下载模板
 */
TUser.uploadUserModel = function () {
    window.location.href = Feng.ctxPath + "/tUser/uploadUserModel";
}
 
var agreement = function(){
    this.init = function(){
        //模拟上传excel  
        $("#uploadEventBtn").unbind("click").bind("click",function(){
            $("#uploadEventFile").click();
        });
    };
}
/**
 * 导入合同
 */
TUser.exportUser = function () {
    var uploadEventFile = $("#uploadEventFile").val();
    if(uploadEventFile == ''){
        Feng.info("请选择Excel,再上传");
    }else if(uploadEventFile.lastIndexOf(".xls")<0){//可判断以.xls和.xlsx结尾的excel  
        Feng.info("只能上传Excel文件");
    }else{
        var url = Feng.ctxPath + '/tUser/exportUser';
        var file = document.querySelector('input[name=file]').files[0];
        var reader = new FileReader();
        if (file) {
            var formData = new FormData();
            formData.append("myfile", file);
            this.sendAjaxRequest(url, 'POST', formData);
        }
    }
}
TUser.sendAjaxRequest = function(url,type,data){
    $.ajax({
        url : url,
        type : type,
        data : data,
        success : function(result) {
            if(result.code==500) {
                Feng.info(result.message);
            }else {
                Feng.success("导入成功!");
            }
            TUser.table.refresh();
        },
        error : function() {
            Feng.error("excel上传失败!");
        },
        cache : false,
        contentType : false,
        processData : false
    });
};
 
var agreement;
$(function(){
    agreement = new agreement();
    agreement.init();
});
 
/**
 * 导出车辆操作
 */
TUser.outUser = function () {
    var operation = function() {
        window.location.href = Feng.ctxPath + "/tUser/outUser";
    };
    Feng.confirm("是否确认导出用户信息?", operation);
}