/**
|
* 角色管理的单例
|
*/
|
var PointActivity = {
|
id: "PointActivityTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
PointActivity.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: '150px'},
|
{title: '活动名称', field: 'name', align: 'center', valign: 'middle', width: '200px'},
|
{title: '预览主页', field: 'name', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value, row) {
|
return '<a href="#" onclick="PointActivity.openPointActivityInfo(\'' + row.id + '\')" title="' + value + '">' + value + '</a>';
|
}
|
},
|
{title: '活动时间周期', field: 'time', align: 'center', valign: 'middle', width: '300px'},
|
{title: '任务数', field: 'taskNum', align: 'center', valign: 'middle', width: '80px',
|
formatter: function (value, row) {
|
return '<a href="#" onclick="PointActivity.openTaskList(\'' + row.id + '\')">' + value + '</a>'
|
}
|
},
|
{title: '奖品数', field: 'prizeNum', align: 'center', valign: 'middle', width: '80px',
|
formatter: function (value, row) {
|
return '<a href="#" onclick="PointActivity.openPrizeList(\'' + row.id + '\')">' + value + '</a>'
|
}
|
},
|
{title: '活动报名人数', field: 'signNum', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value, row) {
|
return '<a href="#" onclick="PointActivity.openClickUser(\'' + row.id + '\',1)">' + value + '</a>'
|
}
|
},
|
{title: '领奖人数', field: 'awardPeople', align: 'center', valign: 'middle', width: '80px',
|
formatter: function (value, row) {
|
return '<a href="#" onclick="PointActivity.openClickUser(\'' + row.id + '\',2)">' + value + '</a>'
|
}
|
},
|
{title: '领取奖品数', field: 'awardNumber', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value, row) {
|
return '<a href="#" onclick="PointActivity.openReceivePrizeList(\'' + row.id + '\')">' + value + '</a>'
|
}
|
},
|
{title: '奖品类型', field: 'prizeType', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value, row) {
|
if(value!=null){
|
var val="";
|
if(value.search("1") != -1){
|
val+="优惠券 ";
|
}
|
if(value.search("2") != -1){
|
val+="积分";
|
}
|
return val;
|
}
|
}
|
},
|
{title: '发放数量', field: 'couponNumber', align: 'center', valign: 'middle', width: '80px'},
|
{title: '发放积分', field: 'integralNumber', align: 'center', valign: 'middle', width: '80px'},
|
{title: '配置人', field: 'updateUser', align: 'center', valign: 'middle', width: '80px'},
|
{title: '配置时间', field: 'updateTime', align: 'center', valign: 'middle', width: '150px'},
|
{title: '状态', field: 'state', align: 'center', valign: 'middle', width: '80px',
|
formatter: function (value) {
|
switch (value) {
|
case 1:
|
return '已上架';
|
case 2:
|
return '已下架';
|
}
|
}
|
},
|
{title: '操作', field: 'forwardState', align: 'center', valign: 'middle', width: '150px',
|
formatter: function (value, row) {
|
let str = '<select onchange="PointActivity.updateForwardShareState(\'' + row.id + '\',this)">';
|
if(value == 1){
|
str += '<option value="1" selected>开启转发</option><option value="0">关闭转发</option></select>';
|
}
|
if(value == 0){
|
str += '<option value="1">开启转发</option><option value="0" selected>关闭转发</option></select>';
|
}
|
return str;
|
}
|
}
|
]
|
return columns;
|
};
|
|
|
/**
|
* 检查是否选中
|
*/
|
PointActivity.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if (selected.length == 0) {
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
} else {
|
PointActivity.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加
|
*/
|
PointActivity.openAddPointActivity = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加活动',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/pointActivity/openAddPointActivity'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 点击修改
|
*/
|
PointActivity.openChangePointActivity = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '编辑券包',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/pointActivity/openChangePointActivity?id=' + this.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 删除
|
*/
|
PointActivity.delPointActivity = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/pointActivity/delPointActivity", function (data) {
|
if(data.code == 200 ){
|
Feng.success("删除成功!");
|
PointActivity.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", PointActivity.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否刪除该集点活动?", operation);
|
}
|
};
|
|
/**
|
* 上架
|
*/
|
PointActivity.putPointActivity = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/pointActivity/putPointActivity", function (data) {
|
if(data.code == 200 ){
|
Feng.success("上架成功!");
|
PointActivity.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("上架失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", PointActivity.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否确认上架?", operation);
|
}
|
};
|
|
/**
|
* 下架
|
*/
|
PointActivity.offPointActivity = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/pointActivity/offPointActivity", function (data) {
|
if(data.code == 200 ){
|
Feng.success("下架成功!");
|
PointActivity.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("下架失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", PointActivity.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否确认下架?", operation);
|
}
|
};
|
|
|
|
/**
|
* 导出
|
*/
|
PointActivity.exportPointActivity = function(){
|
if(this.check()){
|
var ajax = new $ax(Feng.ctxPath + "/gasStation/queryList", function (data) {
|
if (data.code == 200) {
|
let gasStation = "";
|
const d = data.data;
|
for (var i in d) {
|
gasStation += '<option value="' + d[i].id + '">' + d[i].name + '</option>'
|
}
|
const str = '<div class="row">\n' +
|
'<form name="input" action="' + Feng.ctxPath + '/pointActivity/importData" method="post" enctype="multipart/form-data" target="_self">' +
|
'<input type="text" style="display: none;" id="id" name="id" value="' + PointActivity.seItem.id + '">' +
|
' <div class="form-group" style="height: 50px;">\n' +
|
' <label class="col-sm-3 control-label">加油站选择</label>\n' +
|
' <div class="col-sm-6">\n' +
|
' <select id="gasStation" class="selectpicker show-tick form-control" multiple data-live-search="true" data-style="btn-info" title="选择加油站">' + gasStation + '</select>\n' +
|
' </div>\n' +
|
' <div class="col-sm-3">\n' +
|
' <input type="button" class="form-control" id="excel" onclick="PointActivity.importData()" value="excel导入"/>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="form-group" style="height: 50px;">\n' +
|
' <label class="col-sm-3 control-label">excel</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <span id="excelName"></span>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="form-group" style="height: 50px;">\n' +
|
' <label class="col-sm-3 control-label">其他</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="text" class="form-control" id="params" placeholder="参数值1;参数值2">\n' +
|
' </div>\n' +
|
' </div>\n' +
|
'<input type="file" style="display: none;" id="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" name="file">' +
|
'<input type="submit" style="display: none;" id="submit" value="Submit">' +
|
'</form>' +
|
' </div>'
|
layer.open({
|
type: 1
|
, title: ''
|
, area: ['500px', '300px']
|
, 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 () {
|
if($('#file')[0].files.length == 0){
|
if(!$('#gasStation').val()){
|
Feng.error("加油站不能为空");
|
return
|
}
|
window.location.href = Feng.ctxPath + "/pointActivity/downloadQRCodeZip?id=" + PointActivity.seItem.id + "&ids=" + $('#gasStation').val() + "¶ms=" + $('#params').val()
|
}else{
|
$('#submit').click();
|
$('#file').val('')
|
}
|
layer.closeAll();
|
},
|
});
|
$('#gasStation').selectpicker();
|
} else {
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("获取失败!" + data.responseJSON.message + "!");
|
});
|
ajax.start();
|
|
}
|
}
|
|
|
PointActivity.importData = function(){
|
$('#file').val('');
|
$('#file').click();
|
$('#file').on('change', function () {
|
const file = $('#file')[0].files[0]
|
$('#excelName').text(file.name);
|
})
|
}
|
|
|
/**
|
* 点击用户列表
|
*/
|
PointActivity.openClickUser = function(id, type){
|
if(type == 1){
|
var title = "活动报名人数"
|
}
|
if(type == 2){
|
var title = "领奖人数"
|
}
|
var index = layer.open({
|
type: 2,
|
title: title,
|
area: ['80%', '90%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/pointActivity/openClickUser?id=' + id + "&type=" + type
|
});
|
this.layerIndex = index;
|
}
|
|
|
PointActivity.openTaskList = function(id){
|
var index = layer.open({
|
type: 2,
|
title: '任务列表',
|
area: ['80%', '90%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/pointActivity/openTaskList?id=' + id
|
});
|
this.layerIndex = index;
|
}
|
|
|
PointActivity.openPrizeList = function(id){
|
var index = layer.open({
|
type: 2,
|
title: '奖品列表',
|
area: ['80%', '90%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/pointActivity/openPrizeList?id=' + id
|
});
|
this.layerIndex = index;
|
}
|
|
|
|
PointActivity.openReceivePrizeList = function(id){
|
var index = layer.open({
|
type: 2,
|
title: '领取奖品列表',
|
area: ['80%', '90%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/pointActivity/openReceivePrizeList?id=' + id
|
});
|
this.layerIndex = index;
|
}
|
|
|
PointActivity.openPointActivityInfo = function(id){
|
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=3&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>'
|
,btnAlign: 'c' //按钮居中
|
,shade: 0.5 //不显示遮罩
|
});
|
}
|
|
|
/**
|
* 拷贝
|
*/
|
PointActivity.clonePointActivity = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/pointActivity/clonePointActivity", function (data) {
|
if(data.code == 200 ){
|
Feng.success("克隆成功!");
|
PointActivity.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("克隆失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", PointActivity.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否确认克隆?", operation);
|
}
|
};
|
|
|
|
/**
|
* 修改转发状态
|
* @param id
|
* @param s
|
*/
|
PointActivity.updateForwardShareState = function(id, s){
|
var ajax = new $ax(Feng.ctxPath + "/pointActivity/updateForwardShareState", function (data) {
|
if(data.code == 200 ){
|
Feng.success("修改成功!");
|
PointActivity.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", id);
|
ajax.set("forwardShareState", $(s).val());
|
ajax.start();
|
}
|
|
|
/**
|
* 查看二维码
|
*/
|
PointActivity.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' +
|
' <div id="qr" style="width: 250px;height: 250px;"></div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>'
|
const uri = "/pages-activity-task/pages/index?id=" + id
|
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();
|
},
|
});
|
$("#qr").qrcode({
|
width: 250,
|
height: 250,
|
text: uri
|
});
|
|
};
|
|
|
|
/**
|
* 搜索
|
*/
|
PointActivity.search = function () {
|
var queryData = {};
|
queryData['code'] = $("#code").val();
|
queryData['name'] = $("#name").val();
|
queryData['state'] = $("#state").val();
|
queryData['createUser'] = $("#createUser").val();
|
queryData['prizeType'] = $("#prizeType").val();
|
PointActivity.table.setQueryParams({});
|
PointActivity.table.refresh({query: queryData});
|
}
|
|
/**
|
* 重置
|
*/
|
PointActivity.resetSearch = function(){
|
var queryData = {};
|
$("#code").val('');
|
$("#name").val('');
|
$("#state").val('');
|
$("#createUser").val('');
|
$("#prizeType").val('');
|
PointActivity.table.setQueryParams({});
|
PointActivity.table.refresh({query: queryData});
|
}
|
|
|
|
$(function () {
|
var defaultColunms = PointActivity.initColumn();
|
var table = new BSTable(PointActivity.id, "/pointActivity/queryPointActivityList", defaultColunms);
|
table.setPaginationType("server");
|
PointActivity.table = table.init();
|
|
$(document).click(function (e) {
|
$(document).on("click","#qrcodeMask",function () {
|
$("#qrcodeMask").hide();
|
$("#qrcode").hide();
|
$('#qrcodeCanvas').html('');
|
})
|
})
|
});
|