/**
|
* 角色管理的单例
|
*/
|
var VipJurisdiction = {
|
id: "VipJurisdictionTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
VipJurisdiction.initColumn = function () {
|
var columns = [
|
{field: 'select_item', radio: true},
|
{title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
|
{title: 'ID', field: 'code', align: 'center', valign: 'middle', width: '100px'},
|
{title: '所属等级', field: 'vipLevel', align: 'center', valign: 'middle', width: '150px',
|
formatter: function (value) {
|
return '<span title="' + value + '">' + value + '</span>'
|
}
|
},
|
{title: '名称', field: 'name', align: 'center', valign: 'middle', width: '150px'},
|
{title: '预览', field: '', align: 'center', valign: 'middle', width: '150px',
|
formatter: function (value,row) {
|
return '<a onclick="VipJurisdiction.showQRCode(\'' + row.id + '\',\'' + row.name + '\')">预览主页</a>';
|
}
|
},
|
{title: '类型', field: 'type', align: 'center', valign: 'middle', width: '150px',
|
formatter: function (value) {
|
switch (value) {
|
case 0:
|
return '无';
|
case 1:
|
return '增加积分';
|
case 2:
|
return '发放优惠券';
|
case 3:
|
return '跳转类型';
|
}
|
|
}
|
},
|
{title: '跳转类型', field: 'jumpType', align: 'center', valign: 'middle', width: '150px',
|
formatter: function (value, row) {
|
if(row.type == 3){
|
switch (value) {
|
case 0:
|
return '不跳转';
|
case 1:
|
return '签到';
|
case 2:
|
return '会员权益';
|
case 3:
|
return '任务中心';
|
case 4:
|
return '我的';
|
case 5:
|
return '券包';
|
case 6:
|
return '促销活动';
|
case 7:
|
return '集点活动';
|
case 8:
|
return '积分商城';
|
case 9:
|
return '我的优惠券列表';
|
case 10:
|
return '加油站首页';
|
case 11:
|
return '外部H5';
|
case 12:
|
return '外部小程序';
|
case 13:
|
return '一键加油';
|
case 14:
|
return '开发票';
|
case 15:
|
return '领券活动';
|
case 16:
|
return '我的优惠券';
|
case 17:
|
return '我的任务';
|
case 18:
|
return '我的订单';
|
}
|
}else{
|
return '';
|
}
|
}},
|
{title: '排序', field: 'sort', align: 'center', valign: 'middle', width: '100px'},
|
{title: '图片', field: 'icon', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value) {
|
return '<img src="' + value + '" width="100%" onclick="showImg(this)"/>'
|
}
|
},
|
{title: '配置人', field: 'updateUser', align: 'center', valign: 'middle', width: '100px'},
|
{title: '配置时间', field: 'updateTime', align: 'center', valign: 'middle', width: '150px'},
|
{title: '说明', field: 'explain', align: 'center', valign: 'middle', width: '300px'},
|
{title: '状态', field: 'state', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value) {
|
switch (value) {
|
case 1:
|
return '已上架';
|
case 2:
|
return '已下架';
|
}
|
}
|
}
|
]
|
return columns;
|
};
|
|
|
/**
|
* 查看二维码
|
*/
|
VipJurisdiction.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 + '/QrCode/getPreviewQrCode?id=' + id + '&type=5&v=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(function(canvas) {
|
var a = document.createElement("a");
|
a.href= canvas.toDataURL("image/jpg");
|
a.download = name + ".jpg";
|
a.click();
|
});
|
layer.closeAll();
|
},
|
});
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
VipJurisdiction.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if (selected.length == 0) {
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
} else {
|
VipJurisdiction.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加菜单
|
*/
|
VipJurisdiction.openAddVipJurisdiction = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加会员权益',
|
area: ['60%', '90%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/vipJurisdiction/openAddVipJurisdiction'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 点击修改
|
*/
|
VipJurisdiction.openChangeVipJurisdiction = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '编辑会员权益',
|
area: ['60%', '90%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/vipJurisdiction/openChangeVipJurisdiction?id=' + this.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 删除
|
*/
|
VipJurisdiction.delVipJurisdiction = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/vipJurisdiction/delVipJurisdiction", function (data) {
|
if(data.code == 200 ){
|
Feng.success("删除成功!");
|
VipJurisdiction.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", VipJurisdiction.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否刪除该会员权益?", operation);
|
}
|
};
|
|
/**
|
* 上架
|
*/
|
VipJurisdiction.putVipJurisdiction = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/vipJurisdiction/putVipJurisdiction", function (data) {
|
if(data.code == 200 ){
|
Feng.success("上架成功!");
|
VipJurisdiction.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("上架失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", VipJurisdiction.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否确认上架?", operation);
|
}
|
};
|
|
/**
|
* 下架
|
*/
|
VipJurisdiction.offVipJurisdiction = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/vipJurisdiction/offVipJurisdiction", function (data) {
|
if(data.code == 200 ){
|
Feng.success("下架成功!");
|
VipJurisdiction.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("下架失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", VipJurisdiction.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否确认下架?", operation);
|
}
|
};
|
|
|
|
/**
|
* 拷贝
|
*/
|
VipJurisdiction.cloneVipJurisdiction = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/vipJurisdiction/cloneVipJurisdiction", function (data) {
|
if(data.code == 200 ){
|
Feng.success("克隆成功!");
|
VipJurisdiction.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("克隆失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", VipJurisdiction.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否确认克隆?", operation);
|
}
|
};
|
/**
|
* 搜索
|
*/
|
VipJurisdiction.search = function () {
|
var queryData = {};
|
queryData['name'] = $("#name").val();
|
queryData['vipLevelId'] = $("#vipLevelId").val();
|
queryData['createUser'] = $("#createUser").val();
|
VipJurisdiction.table.setQueryParams({});
|
VipJurisdiction.table.refresh({query: queryData});
|
}
|
|
/**
|
* 重置
|
*/
|
VipJurisdiction.resetSearch = function(){
|
var queryData = {};
|
$("#name").val('');
|
$("#vipLevelId").val('');
|
$("#createUser").val('');
|
VipJurisdiction.table.setQueryParams({});
|
VipJurisdiction.table.refresh({query: queryData});
|
}
|
|
|
$(function () {
|
var defaultColunms = VipJurisdiction.initColumn();
|
var table = new BSTable(VipJurisdiction.id, "/vipJurisdiction/queryVipJurisdictionList", defaultColunms);
|
table.setPaginationType("server");
|
VipJurisdiction.table = table.init();
|
|
});
|