/**
|
* 角色管理的单例
|
*/
|
var VipChannel = {
|
id: "VipChannelTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
VipChannel.initColumn = function () {
|
var columns = [
|
{field: 'select_item', radio: true},
|
{title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
|
{title: '序号', field: 'id', align: 'center', valign: 'middle', width: '80px',
|
formatter: function (value, item, i) {
|
return (i+1);
|
}
|
},
|
{title: '渠道码类型', field: 'type', align: 'center', valign: 'middle', width: '200px',
|
formatter: function (value, row) {
|
return value == 1 ? '加油站渠道' : '其他渠道';
|
}
|
},
|
{title: '入会渠道', field: 'name', align: 'center', valign: 'middle', width: '100px'},
|
{title: '渠道点位', field: 'position', align: 'center', valign: 'middle', width: '200px',
|
formatter: function (value, row) {
|
value = typeof value == "undefined" ? "" : value;
|
return '<div title="' + value + '" style="width: 100%;white-space: normal;">' + value + '</div>';
|
}
|
},
|
{title: '入会油站', field: 'gasStation', align: 'center', valign: 'middle', width: '200px',
|
formatter: function (value, row) {
|
value = typeof value == "undefined" ? "" : value;
|
return '<div title="' + value + '" style="width: 100%;white-space: normal;">' + value + '</div>';
|
}
|
},
|
{title: '距离', field: 'distance', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value, row) {
|
return row.type == 1 ? (typeof value == "undefined" ? '' : value + 'KM') : '';
|
}
|
},
|
{title: '生成时间', field: 'createTime', align: 'center', valign: 'middle', width: '150px'},
|
{title: '二维码', field: 'id', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value, row) {
|
return '<a style="color: #337ab7;" onclick="VipChannel.showQRCode(\'' + row.id + '\',\'' + row.name + '\')">查看链接/二维码</a>';
|
}
|
},
|
{title: '操作', field: 'id', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value, row) {
|
return '<a style="color: #337ab7;" onclick="VipChannel.downloadQRCode(\'' + row.id + '\')">下载</a>';
|
}
|
}
|
]
|
return columns;
|
};
|
|
|
/**
|
* 检查是否选中
|
*/
|
VipChannel.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if (selected.length == 0) {
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
} else {
|
VipChannel.seItem = selected[0];
|
return true;
|
}
|
};
|
|
|
/**
|
* 添加
|
*/
|
VipChannel.addVipChannel = function(){
|
var index = layer.open({
|
type: 2,
|
title: '添加入会渠道',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/vipChannel/addVipChannel'
|
});
|
this.layerIndex = index;
|
}
|
|
|
VipChannel.editVipChannel = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '编辑入会渠道',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/vipChannel/editVipChannel?id=' + this.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
|
VipChannel.viewSubCodes = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '查看子码',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/vipChannel/viewSubCodes?id=' + this.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
|
/**
|
* 删除
|
*/
|
VipChannel.delVipChannel = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/vipChannel/delVipChannel", function (data) {
|
if(data.code == 200 ){
|
Feng.success("删除成功!");
|
VipChannel.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", VipChannel.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否刪除该入会渠道?", operation);
|
}
|
};
|
|
|
|
|
|
|
/**
|
* 查看二维码
|
*/
|
VipChannel.showQRCode = function (id, name) {
|
const str = '<div class="row">\n' +
|
' <div class="form-group" style="height: 50px;">\n' +
|
' <label class="col-sm-3 control-label">分享链接二维码</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <img id="qr" style="width: 250px;height: 250px;" src="' + Feng.ctxPath + '/vipChannel/getVipChannelQRCode?id=' + id + '&vipChannelType=1"/>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>'
|
layer.open({
|
type: 1
|
,title: '分享二维码'
|
,area: ['500px', '400px']
|
,offset: 'auto' //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset
|
,id: 'layerDemo' //防止重复弹出
|
,content: '<div style="padding: 20px">' + str + '</div>'
|
,btn: ['下载', '取消']
|
,btnAlign: 'c' //按钮居中
|
,shade: 0.5 //不显示遮罩
|
,yes: function(){
|
html2canvas(document.querySelector("#qr")).then(canvas => {
|
var a = document.createElement("a");
|
a.href= canvas.toDataURL("image/jpg");
|
a.download = name + ".jpg";
|
a.click();
|
layer.closeAll();
|
});
|
},
|
});
|
};
|
|
|
VipChannel.downloadQRCode = function(id){
|
window.location.href = Feng.ctxPath + "/vipChannel/downloadQRCodeZip?id=" + id + "&vipChannelType=1";
|
}
|
|
|
/**
|
* 搜索
|
*/
|
VipChannel.search = function () {
|
var queryData = {};
|
queryData['name'] = $("#name").val();
|
queryData['gasStation'] = $("#gasStation").val();
|
queryData['position'] = $('#position').val();
|
queryData['type'] = $('#type').val();
|
VipChannel.table.setQueryParams({});
|
VipChannel.table.refresh({query: queryData});
|
}
|
|
VipChannel.resetSearch = function () {
|
var queryData = {};
|
$("#name").val('');
|
$("#gasStation").val('');
|
$('#position').val('');
|
$('#type').val('');
|
VipChannel.table.setQueryParams({});
|
VipChannel.table.refresh({query: queryData});
|
}
|
|
|
$(function () {
|
var defaultColunms = VipChannel.initColumn();
|
var table = new BSTable(VipChannel.id, "/vipChannel/queryVipChannelList", defaultColunms);
|
table.setPaginationType("server");
|
VipChannel.table = table.init();
|
});
|