/**
|
* 用户管理管理初始化
|
*/
|
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);
|
}
|