/**
|
* 用户详情对话框(可用于添加和修改对话框)
|
*/
|
var PointActivityInfo = {
|
info: {},
|
task: [],
|
prize: [],
|
layerIndex: -1,
|
exposureCrowd: $('#exposureCrowd').val()
|
};
|
let element = null;
|
let editor = null;
|
let editorhtml = null;
|
let num = 1;
|
|
/**
|
* 关闭此对话框
|
*/
|
PointActivityInfo.close = function () {
|
parent.layer.close(window.parent.PointActivity.layerIndex);
|
};
|
|
|
PointActivityInfo.look = function(){
|
const name = $('#name').val();
|
const dateTime = $('#dateTime').val();
|
const signBackgroundImg = $('#signBackgroundImg').val();
|
const successImg = $('#successImg').val();
|
const setPointName = $('#setPointName').val();
|
const setPointImg = $('#setPointImg').val();
|
|
|
const prizeImgType = $('#prizeImgType').val();
|
const prizeImgDirection = $('#prizeImgDirection').val();
|
|
if(null == name || '' == name){
|
Feng.error("活动名称不能为空");
|
return
|
}
|
if(null == dateTime || '' == dateTime){
|
Feng.error("活动时间周期不能为空");
|
return
|
}
|
if(null == signBackgroundImg || '' == signBackgroundImg){
|
Feng.error("报名背景图片不能为空");
|
return
|
}
|
// if(null == successImg || '' == successImg){
|
// Feng.error("报名成功弹框图不能为空");
|
// return
|
// }
|
if(null == setPointName || '' == setPointName){
|
Feng.error("集点对象名称不能为空");
|
return
|
}
|
if(null == setPointImg || '' == setPointImg){
|
Feng.error("集点对象图标不能为空");
|
return
|
}
|
if(null == PointActivityInfo.info.homePageBackgroundImg || '' == PointActivityInfo.info.homePageBackgroundImg){
|
Feng.error("主页背景图不能为空");
|
return
|
}
|
if(null == PointActivityInfo.info.ruleDescription || '' == PointActivityInfo.info.ruleDescription){
|
Feng.error("规则说明不能为空");
|
return
|
}
|
if(null == PointActivityInfo.info.exchangeButtonText || '' == PointActivityInfo.info.exchangeButtonText){
|
Feng.error("兑换/查看按钮文案不能为空");
|
return
|
}
|
|
if(PointActivityInfo.task.length == 0){
|
Feng.error("活动任务不能为空");
|
return
|
}
|
if(PointActivityInfo.prize.length == 0){
|
Feng.error("活动奖品不能为空");
|
return
|
}
|
PointActivityInfo.info['id'] = $('#id').val();
|
PointActivityInfo.info['name'] = name;
|
PointActivityInfo.info['startTime'] = dateTime.split(' - ')[0];
|
PointActivityInfo.info['endTime'] = dateTime.split(' - ')[1];
|
PointActivityInfo.info['signBackgroundImg'] = signBackgroundImg;
|
PointActivityInfo.info['successImg'] = successImg;
|
PointActivityInfo.info['setPointName'] = setPointName;
|
PointActivityInfo.info['setPointImg'] = setPointImg;
|
PointActivityInfo.info['prizeImgType'] = prizeImgType;
|
PointActivityInfo.info['prizeImgDirection'] = prizeImgDirection;
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/pointActivity/savePointActivity", function (data) {
|
if(data.code == 200){
|
$('#id').val(data.data);
|
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 //不显示遮罩
|
});
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(PointActivityInfo.info);
|
ajax.set('task', JSON.stringify(PointActivityInfo.task));
|
ajax.set('prize', JSON.stringify(PointActivityInfo.prize));
|
ajax.set('type', 1);
|
ajax.set('exposureCrowd', PointActivityInfo.exposureCrowd);
|
ajax.start();
|
}
|
|
/**
|
* 提交添加
|
*/
|
PointActivityInfo.addSubmit = function () {
|
const name = $('#name').val();
|
const dateTime = $('#dateTime').val();
|
const signBackgroundImg = $('#signBackgroundImg').val();
|
const successImg = $('#successImg').val();
|
const setPointName = $('#setPointName').val();
|
const setPointImg = $('#setPointImg').val();
|
|
|
const prizeImgType = $('#prizeImgType').val();
|
const prizeImgDirection = $('#prizeImgDirection').val();
|
|
if(null == name || '' == name){
|
Feng.error("活动名称不能为空");
|
return
|
}
|
if(null == dateTime || '' == dateTime){
|
Feng.error("活动时间周期不能为空");
|
return
|
}
|
if(null == signBackgroundImg || '' == signBackgroundImg){
|
Feng.error("报名背景图片不能为空");
|
return
|
}
|
// if(null == successImg || '' == successImg){
|
// Feng.error("报名成功弹框图不能为空");
|
// return
|
// }
|
if(null == setPointName || '' == setPointName){
|
Feng.error("集点对象名称不能为空");
|
return
|
}
|
if(null == setPointImg || '' == setPointImg){
|
Feng.error("集点对象图标不能为空");
|
return
|
}
|
if(null == PointActivityInfo.info.homePageBackgroundImg || '' == PointActivityInfo.info.homePageBackgroundImg){
|
Feng.error("主页背景图不能为空");
|
return
|
}
|
if(null == PointActivityInfo.info.ruleDescription || '' == PointActivityInfo.info.ruleDescription){
|
Feng.error("规则说明不能为空");
|
return
|
}
|
if(null == PointActivityInfo.info.exchangeButtonText || '' == PointActivityInfo.info.exchangeButtonText){
|
Feng.error("兑换/查看按钮文案不能为空");
|
return
|
}
|
|
if(PointActivityInfo.task.length == 0){
|
Feng.error("活动任务不能为空");
|
return
|
}
|
if(PointActivityInfo.prize.length == 0){
|
Feng.error("活动奖品不能为空");
|
return
|
}
|
PointActivityInfo.info['id'] = $('#id').val();
|
PointActivityInfo.info['name'] = name;
|
PointActivityInfo.info['startTime'] = dateTime.split(' - ')[0];
|
PointActivityInfo.info['endTime'] = dateTime.split(' - ')[1];
|
PointActivityInfo.info['signBackgroundImg'] = signBackgroundImg;
|
PointActivityInfo.info['successImg'] = successImg;
|
PointActivityInfo.info['setPointName'] = setPointName;
|
PointActivityInfo.info['setPointImg'] = setPointImg;
|
PointActivityInfo.info['prizeImgType'] = prizeImgType;
|
PointActivityInfo.info['prizeImgDirection'] = prizeImgDirection;
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/pointActivity/savePointActivity", function (data) {
|
if(data.code == 200){
|
Feng.success("添加成功!");
|
window.parent.PointActivity.table.refresh();
|
PointActivityInfo.close();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(PointActivityInfo.info);
|
ajax.set('task', JSON.stringify(PointActivityInfo.task));
|
ajax.set('prize', JSON.stringify(PointActivityInfo.prize));
|
ajax.set('type', 2);
|
ajax.set('exposureCrowd', PointActivityInfo.exposureCrowd);
|
ajax.start();
|
};
|
|
/**
|
* 提交修改
|
*/
|
PointActivityInfo.editSubmit = function () {
|
const name = $('#name').val();
|
const dateTime = $('#dateTime').val();
|
const signBackgroundImg = $('#signBackgroundImg').val();
|
const successImg = $('#successImg').val();
|
const setPointName = $('#setPointName').val();
|
const setPointImg = $('#setPointImg').val();
|
|
|
const prizeImgType = $('#prizeImgType').val();
|
const prizeImgDirection = $('#prizeImgDirection').val();
|
|
if(null == name || '' == name){
|
Feng.error("活动名称不能为空");
|
return
|
}
|
if(null == dateTime || '' == dateTime){
|
Feng.error("活动时间周期不能为空");
|
return
|
}
|
if(null == signBackgroundImg || '' == signBackgroundImg){
|
Feng.error("报名背景图片不能为空");
|
return
|
}
|
// if(null == successImg || '' == successImg){
|
// Feng.error("报名成功弹框图不能为空");
|
// return
|
// }
|
if(null == setPointName || '' == setPointName){
|
Feng.error("集点对象名称不能为空");
|
return
|
}
|
if(null == setPointImg || '' == setPointImg){
|
Feng.error("集点对象图标不能为空");
|
return
|
}
|
if(null == PointActivityInfo.info.homePageBackgroundImg || '' == PointActivityInfo.info.homePageBackgroundImg){
|
Feng.error("主页背景图不能为空");
|
return
|
}
|
if(null == PointActivityInfo.info.ruleDescription || '' == PointActivityInfo.info.ruleDescription){
|
Feng.error("规则说明不能为空");
|
return
|
}
|
if(null == PointActivityInfo.info.exchangeButtonText || '' == PointActivityInfo.info.exchangeButtonText){
|
Feng.error("兑换/查看按钮文案不能为空");
|
return
|
}
|
|
if(PointActivityInfo.task.length == 0){
|
Feng.error("活动任务不能为空");
|
return
|
}
|
if(PointActivityInfo.prize.length == 0){
|
Feng.error("活动奖品不能为空");
|
return
|
}
|
PointActivityInfo.info['id'] = $('#id').val();
|
PointActivityInfo.info['name'] = name;
|
PointActivityInfo.info['startTime'] = dateTime.split(' - ')[0];
|
PointActivityInfo.info['endTime'] = dateTime.split(' - ')[1];
|
PointActivityInfo.info['signBackgroundImg'] = signBackgroundImg;
|
PointActivityInfo.info['successImg'] = successImg;
|
PointActivityInfo.info['setPointName'] = setPointName;
|
PointActivityInfo.info['setPointImg'] = setPointImg;
|
PointActivityInfo.info['prizeImgType'] = prizeImgType;
|
PointActivityInfo.info['prizeImgDirection'] = prizeImgDirection;
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/pointActivity/savePointActivity", function (data) {
|
if(data.code == 200){
|
Feng.success("编辑成功!");
|
window.parent.PointActivity.table.refresh();
|
PointActivityInfo.close();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("编辑失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(PointActivityInfo.info);
|
ajax.set('task', JSON.stringify(PointActivityInfo.task));
|
ajax.set('prize', JSON.stringify(PointActivityInfo.prize));
|
ajax.set('type', 3);
|
ajax.set('exposureCrowd', PointActivityInfo.exposureCrowd);
|
ajax.start();
|
};
|
|
|
PointActivityInfo.showExposureCrowd = function(){
|
var index = layer.open({
|
type: 2,
|
title: '用户标签设置',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/exposureCrowd/showExposureCrowd?objectType=4&id=' + $('#id').val() + "&page=PointActivityInfo"
|
});
|
this.layerIndex = index;
|
}
|
|
|
PointActivityInfo.setConfig = function (e) {
|
let taskType = $(e).parents('.layui-colla-item').find('#taskType').val();
|
let type = null;
|
if(taskType == 1){
|
type = $(e).parents('.layui-colla-item').find('#cqrw #type').val();
|
}
|
if(taskType == 2){
|
type = $(e).parents('.layui-colla-item').find('#bdsrw #type').val();
|
}
|
|
let str = '';
|
let size = '';
|
const taskConfig = $(e).parents('.layui-colla-item').find('#taskConfig').val();
|
const array = ('' == taskConfig ? [] : JSON.parse(taskConfig));
|
if(taskType == 1 && type == 2){
|
size = ['620px', '530px'];
|
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' +
|
' <input type="text" class="layui-input" id="dateTime1" value="' + (array.length > 0 ? array[0] + ' - ' + array[1] : '') + '">' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group" style="height: 50px;">\n' +
|
' <label class="col-sm-3 control-label">星期</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <select class="selectpicker show-tick form-control" id="week" multiple data-live-search="true" data-style="btn-info" title="请选择">\n' +
|
' <option value="" ' + (array.length > 0 && array[2] == '' ? 'selected' : '') + '>请选择</option>\n' +
|
' <option value="1" ' + (array.length > 0 && array[2] == '1' ? 'selected' : '') + '>星期一</option>\n' +
|
' <option value="2" ' + (array.length > 0 && array[2] == '2' ? 'selected' : '') + '>星期二</option>\n' +
|
' <option value="3" ' + (array.length > 0 && array[3] == '1' ? 'selected' : '') + '>星期三</option>\n' +
|
' <option value="4" ' + (array.length > 0 && array[2] == '4' ? 'selected' : '') + '>星期四</option>\n' +
|
' <option value="5" ' + (array.length > 0 && array[2] == '5' ? 'selected' : '') + '>星期五</option>\n' +
|
' <option value="6" ' + (array.length > 0 && array[2] == '6' ? 'selected' : '') + '>星期六</option>\n' +
|
' <option value="7" ' + (array.length > 0 && array[2] == '7' ? 'selected' : '') + '>星期七</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <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="number" min="0" id="times" class="form-control" value="' + (array.length > 0 ? array[3] : '') + '"/>\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="number" min="0" id="price" class="form-control" value="' + (array.length > 0 ? array[4] : '') + '"/>\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' +
|
' <select class="selectpicker show-tick form-control" id="oilType" multiple data-live-search="true" data-style="btn-info" title="请选择">\n' +
|
' <option value="" ' + (array.length > 0 && array[5] == '' ? 'selected' : '') + '>请选择</option>\n' +
|
' <option value="-10" ' + (array.length > 0 && array[5] == '-10' ? 'selected' : '') + '>-10#柴油</option>\n' +
|
' <option value="0" ' + (array.length > 0 && array[5] == '0' ? 'selected' : '') + '>0#柴油</option>\n' +
|
' <option value="92" ' + (array.length > 0 && array[5] == '92' ? 'selected' : '') + '>92#汽油</option>\n' +
|
' <option value="95" ' + (array.length > 0 && array[5] == '95' ? 'selected' : '') + '>95#汽油</option>\n' +
|
' <option value="98" ' + (array.length > 0 && array[5] == '98' ? 'selected' : '') + '>98#汽油</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group" style="height: 50px;">\n' +
|
' <label class="col-sm-3 control-label">是否使用一键加油</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <select class="form-control" id="cheer">\n' +
|
' <option value="" ' + (array.length > 0 && array[6] == '' ? 'selected' : '') + '>请选择</option>\n' +
|
' <option value="0" ' + (array.length > 0 && array[6] == '0' ? 'selected' : '') + '>否</option>\n' +
|
' <option value="1" ' + (array.length > 0 && array[6] == '1' ? 'selected' : '') + '>是</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <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="number" min="0" id="liters" class="form-control" value="'+ (array.length >= 7 ? array[7] : '') +'"/>\n' +
|
' </div>\n' +
|
' </div>\n' ;
|
' </div>'
|
}
|
if(taskType == 1 && type == 3){
|
size = ['620px', '500px'];
|
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' +
|
' <input type="text" class="layui-input" id="dateTime1" value="' + (array.length > 0 ? array[0] + ' - ' + array[1] : '') + '">' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group" style="height: 50px;">\n' +
|
' <label class="col-sm-3 control-label">星期</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <select class="selectpicker show-tick form-control" id="week" multiple data-live-search="true" data-style="btn-info" title="请选择">\n' +
|
' <option value="" ' + (array.length > 0 && array[2] == '' ? 'selected' : '') + '>请选择</option>\n' +
|
' <option value="1" ' + (array.length > 0 && array[2] == '1' ? 'selected' : '') + '>星期一</option>\n' +
|
' <option value="2" ' + (array.length > 0 && array[2] == '2' ? 'selected' : '') + '>星期二</option>\n' +
|
' <option value="3" ' + (array.length > 0 && array[3] == '1' ? 'selected' : '') + '>星期三</option>\n' +
|
' <option value="4" ' + (array.length > 0 && array[2] == '4' ? 'selected' : '') + '>星期四</option>\n' +
|
' <option value="5" ' + (array.length > 0 && array[2] == '5' ? 'selected' : '') + '>星期五</option>\n' +
|
' <option value="6" ' + (array.length > 0 && array[2] == '6' ? 'selected' : '') + '>星期六</option>\n' +
|
' <option value="7" ' + (array.length > 0 && array[2] == '7' ? 'selected' : '') + '>星期七</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <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="number" min="0" id="times" class="form-control" value="' + (array.length > 0 ? array[3] : '') + '"/>\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="number" min="0" id="price" class="form-control" value="' + (array.length > 0 ? array[4] : '') + '"/>\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 id="goods" class="form-control" placeholder="商品ID,多个用英文分号分隔" value="' + (array.length > 0 ? array[5] : '') + '"/>\n' +
|
' </div>\n' +
|
' </div>' +
|
' </div>'
|
}
|
if(taskType == 1 && type == 4){
|
size = ['620px', '500px'];
|
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' +
|
' <input type="text" class="layui-input" id="dateTime1" value="' + (array.length > 0 ? array[0] + ' - ' + array[1] : '') + '">' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group" style="height: 50px;">\n' +
|
' <label class="col-sm-3 control-label">星期</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <select class="selectpicker show-tick form-control" id="week" multiple data-live-search="true" data-style="btn-info" title="请选择">\n' +
|
' <option value="" ' + (array.length > 0 && array[2] == '' ? 'selected' : '') + '>请选择</option>\n' +
|
' <option value="1" ' + (array.length > 0 && array[2] == '1' ? 'selected' : '') + '>星期一</option>\n' +
|
' <option value="2" ' + (array.length > 0 && array[2] == '2' ? 'selected' : '') + '>星期二</option>\n' +
|
' <option value="3" ' + (array.length > 0 && array[3] == '1' ? 'selected' : '') + '>星期三</option>\n' +
|
' <option value="4" ' + (array.length > 0 && array[2] == '4' ? 'selected' : '') + '>星期四</option>\n' +
|
' <option value="5" ' + (array.length > 0 && array[2] == '5' ? 'selected' : '') + '>星期五</option>\n' +
|
' <option value="6" ' + (array.length > 0 && array[2] == '6' ? 'selected' : '') + '>星期六</option>\n' +
|
' <option value="7" ' + (array.length > 0 && array[2] == '7' ? 'selected' : '') + '>星期七</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <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="number" min="0" id="times" class="form-control" value="' + (array.length > 0 ? array[3] : '') + '"/>\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="number" min="0" id="price" class="form-control" value="' + (array.length > 0 ? array[4] : '') + '"/>\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 id="goods" class="form-control" placeholder="商品ID,多个用英文分号分隔" value="' + (array.length > 0 ? array[5] : '') + '" />\n' +
|
' </div>\n' +
|
' </div>' +
|
' </div>'
|
}
|
if(taskType == 2 && type == 5){
|
size = ['550px', '350px'];
|
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' +
|
' <select class="form-control" id="jumpType">\n' +
|
' <option value="8" ' + (array.length > 0 && array[0] == '8' ? 'selected' : '') + '>积分商城</option>\n' +
|
' <option value="9" ' + (array.length > 0 && array[0] == '9' ? 'selected' : '') + '>我的优惠券列表</option>\n' +
|
' <option value="11" ' + (array.length > 0 && array[0] == '11' ? 'selected' : '') + '>外部H5</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div id="link1" ' + (array.length > 0 && array[0] == '11' ? '' : 'hidden') + ' style="height: 50px;">\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">链接路径</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input class="form-control" id="address" value="' + (array.length > 0 ? array[1] : '') + '">\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div id="dataCode" ' + (array.length == 0 || (array.length > 0 && array[0] == '8') ? '' : 'hidden') + ' style="height: 50px;">\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">商品编码</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input class="form-control" id="objecCode" value="' + (array.length > 0 ? array[2] : '') + '">\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group" style="height: 50px;">\n' +
|
' <label class="col-sm-3 control-label">浏览时间>=</label>\n' +
|
' <div class="col-sm-7">\n' +
|
' <input type="number" min="0" id="duration" class="form-control" value="' + (array.length > 0 ? array[3] : '') + '"/>\n' +
|
' </div>\n' +
|
' <label class="col-sm-1 control-label">秒</label>\n' +
|
' </div>\n' +
|
' </div>'
|
}
|
if(taskType == 2 && type == 6){
|
size = ['500px', '270px'];
|
var ajax = new $ax(Feng.ctxPath + "/coupon/queryAll", function (data) {
|
if(data.code == 200){
|
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' +
|
' <select class="selectpicker show-tick form-control" id="coupon" multiple data-live-search="true" data-style="btn-info" title="请选择">\n'+
|
' <option value="0">请选择券包</option>\n';
|
let arr = data.data;
|
for(const i in arr){
|
str += '<option value="' + arr[i].id + '" ' + (array.length > 0 && array[0] == arr[i].id ? 'selected' : '') + '>' + arr[i].name + '</option>';
|
}
|
str += ' </select>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>'
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("获取失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set({});
|
ajax.start();
|
|
}
|
if(taskType == 2 && type == 7){
|
size = ['500px', '270px'];
|
var ajax = new $ax(Feng.ctxPath + "/pointActivity/queryAll", function (data) {
|
if(data.code == 200){
|
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' +
|
' <select class="selectpicker show-tick form-control" id="pointActivity" multiple data-live-search="true" data-style="btn-info" title="请选择">\n';
|
let arr = data.data;
|
for(const i in arr){
|
str += '<option value="' + arr[i].id + '" ' + (array.length > 0 && array[0] == arr[i].id ? 'selected' : '') + '>' + arr[i].name + '</option>';
|
}
|
str += ' </select>\n' +
|
' </div>\n' +
|
' </div>\n';
|
|
var ajax = new $ax(Feng.ctxPath + "/salesPromotion/queryAll", function (data) {
|
if(data.code == 200){
|
str +=
|
' <div class="form-group" style="height: 50px;">\n' +
|
' <label class="col-sm-3 control-label">访问促销活动</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <select class="selectpicker show-tick form-control" id="salesPromotion" multiple data-live-search="true" data-style="btn-info" title="请选择">\n';
|
let arr = data.data;
|
for(const i in arr){
|
str += '<option value="' + arr[i].id + '" ' + (array.length > 0 && array[1] == arr[i].id ? 'selected' : '') + '>' + arr[i].name + '</option>';
|
}
|
str += ' </select>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>'
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("获取失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set({});
|
ajax.start();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("获取失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set({});
|
ajax.start();
|
}
|
if(taskType == 2 && type == 8){
|
size = ['500px', '270px'];
|
str = '<div class="row">\n' +
|
' <div class="form-group" style="height: 50px;">\n' +
|
' <label class="col-sm-1 control-label">近</label>\n' +
|
' <div class="col-sm-3">\n' +
|
' <input type="number" min="0" id="day" class="form-control" value="' + (array.length > 0 ? array[0] : '') + '"/>\n' +
|
' </div>\n' +
|
' <label class="col-sm-2 control-label">天 >=</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <input type="number" min="0" id="times" class="form-control" value="' + (array.length > 0 ? array[1] : '') + '"/>\n' +
|
' </div>\n' +
|
' <label class="col-sm-1 control-label">次</label>\n' +
|
' </div>\n' +
|
' </div>'
|
}
|
if(taskType == 2 && type == 9){
|
size = ['550px', '350px'];
|
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' +
|
' <select class="form-control" id="jumpType">\n' +
|
' <option value="1" ' + (array.length > 0 && array[0] == '1' ? 'selected' : '') + '>签到</option>\n' +
|
' <option value="2" ' + (array.length > 0 && array[0] == '2' ? 'selected' : '') + '>会员权益</option>\n' +
|
' <option value="3" ' + (array.length > 0 && array[0] == '3' ? 'selected' : '') + '>任务中心</option>\n' +
|
' <option value="16" ' + (array.length > 0 && array[0] == '16' ? 'selected' : '') + '>我的优惠券</option>\n' +
|
' <option value="17" ' + (array.length > 0 && array[0] == '17' ? 'selected' : '') + '>我的任务</option>\n' +
|
' <option value="18" ' + (array.length > 0 && array[0] == '18' ? 'selected' : '') + '>我的订单</option>\n' +
|
' <option value="5" ' + (array.length > 0 && array[0] == '5' ? 'selected' : '') + '>券包</option>\n' +
|
' <option value="6" ' + (array.length > 0 && array[0] == '6' ? 'selected' : '') + '>促销活动</option>\n' +
|
' <option value="7" ' + (array.length > 0 && array[0] == '7' ? 'selected' : '') + '>集点活动</option>\n' +
|
' <option value="10" ' + (array.length > 0 && array[0] == '10' ? 'selected' : '') + '>加油站首页</option>\n' +
|
' <option value="12" ' + (array.length > 0 && array[0] == '12' ? 'selected' : '') + '>外部小程序</option>\n' +
|
' <option value="13" ' + (array.length > 0 && array[0] == '13' ? 'selected' : '') + '>一键加油</option>\n' +
|
' <option value="14" ' + (array.length > 0 && array[0] == '14' ? 'selected' : '') + '>开发票</option>\n' +
|
' <option value="15" ' + (array.length > 0 && array[0] == '15' ? 'selected' : '') + '>领券活动</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div id="link1" ' + (array.length > 0 && array[0] == '12' ? '' : 'hidden') + ' style="height: 50px;">\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">链接路径</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input class="form-control" id="address" value="' + (array.length > 0 ? array[1] : '') + '">\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div id="dataCode" ' + (array.length > 0 && (array[0] == '5' || array[0] == '6' || array[0] == '7' || array[0] == '15') ? '' : 'hidden') + ' style="height: 50px;">\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">' + (array.length > 0 && ( array[0] == '6' || array[0] == '7') ? '<span style="color: red">*</span>' : '') + '数据ID</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input class="form-control" id="objecCode" value="' + (array.length > 0 ? array[2] : '') + '">\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div id="appidDiv" ' + (array.length > 0 && array[0] == '12' ? '' : 'hidden') + ' style="height: 50px;">\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">APPID</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input class="form-control" id="appid" value="' + (array.length > 0 ? array[3] : '') + '">\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div id="durationDiv" class="form-group" ' + (array.length == 0 || (array[0] != '10' && array[0] != '12' && array[0] != '13' && array[0] != '14') ? 'hidden' : '') + ' style="height: 50px;">\n' +
|
' <label class="col-sm-3 control-label">浏览次数>=</label>\n' +
|
' <div class="col-sm-7">\n' +
|
' <input type="number" min="0" id="duration" class="form-control" value="' + (array.length > 0 ? array[4] : '') + '"/>\n' +
|
' </div>\n' +
|
' <label class="col-sm-1 control-label">次</label>\n' +
|
' </div>\n' +
|
' </div>'
|
}
|
layer.open({
|
type: 1
|
,title: '设置条件'
|
,area: size
|
,offset: 'auto' //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset
|
,id: 'layerDemo1' //防止重复弹出
|
,content: '<div style="padding: 20px">' + str + '</div>'
|
,btn: ['确定', '取消']
|
,btnAlign: 'c' //按钮居中
|
,shade: 0.5 //不显示遮罩
|
,yes: function(index, layero){
|
if(taskType == 1 && type == 2){
|
const dateTime1 = $('#dateTime1').val();
|
const week = $('#week').val();
|
const times = $('#times').val();
|
const price = $('#price').val();
|
const oilType = $('#oilType').val();
|
const cheer = $('#cheer').val();
|
const liters = $('#liters').val();
|
if('' == dateTime1 || null == dateTime1){
|
Feng.error("时间周期不能为空");
|
return false;
|
}
|
if('' == times && '' == price && '' == cheer && '' == liters){
|
Feng.error("请填写正确配置");
|
return false;
|
}
|
$(e).parents('.layui-colla-item').find('#taskConfig').val(JSON.stringify([dateTime1.split(' - ')[0], dateTime1.split(' - ')[1], (null == week ? "" : week), times, price, (null == oilType ? "" : oilType), cheer,liters]));
|
}
|
if(taskType == 1 && type == 3){
|
const dateTime1 = $('#dateTime1').val();
|
const week = $('#week').val();
|
const times = $('#times').val();
|
const price = $('#price').val();
|
const goods = $('#goods').val();
|
if('' == dateTime1 || null == dateTime1){
|
Feng.error("时间周期不能为空");
|
return false;
|
}
|
if('' == times && '' == price && '' == goods){
|
Feng.error("请填写正确配置");
|
return false;
|
}
|
$(e).parents('.layui-colla-item').find('#taskConfig').val(JSON.stringify([dateTime1.split(' - ')[0], dateTime1.split(' - ')[1], (null == week ? "" : week), times, price, goods]));
|
}
|
if(taskType == 1 && type == 4){
|
const dateTime1 = $('#dateTime1').val();
|
const week = $('#week').val();
|
const times = $('#times').val();
|
const price = $('#price').val();
|
const goods = $('#goods').val();
|
if('' == dateTime1 || null == dateTime1){
|
Feng.error("时间周期不能为空");
|
return false;
|
}
|
if('' == times && '' == price && '' == goods){
|
Feng.error("请填写正确配置");
|
return false;
|
}
|
$(e).parents('.layui-colla-item').find('#taskConfig').val(JSON.stringify([dateTime1.split(' - ')[0], dateTime1.split(' - ')[1], (null == week ? "" : week), times, price, goods]));
|
}
|
if(taskType == 2 && type == 5){
|
let jumpType = $('#jumpType').val();
|
const address = $('#address').val();
|
let objecCode = $('#objecCode').val();
|
const duration = $('#duration').val();
|
if(jumpType == 11 && (null == address || '' == address)){
|
Feng.error("链接路径不能为空");
|
return false;
|
}
|
if(null == duration || '' == duration){
|
Feng.error("浏览时间不能为空");
|
return false;
|
}
|
$(e).parents('.layui-colla-item').find('#taskConfig').val(JSON.stringify([jumpType, address, objecCode, duration]));
|
}
|
if(taskType == 2 && type == 6){
|
const coupon = $('#coupon').val();
|
if(0 == coupon.length){
|
Feng.error("请选择券包");
|
return false;
|
}
|
$(e).parents('.layui-colla-item').find('#taskConfig').val(JSON.stringify([coupon]));
|
}
|
if(taskType == 2 && type == 7){
|
const pointActivity = $('#pointActivity').val();
|
const salesPromotion = $('#salesPromotion').val();
|
if((null != pointActivity && 0 == pointActivity.length) || (null != salesPromotion && 0 == salesPromotion.length)){
|
Feng.error("请填写正确配置");
|
return false;
|
}
|
if(null == pointActivity && null == salesPromotion){
|
Feng.error("请填写正确配置");
|
return false;
|
}
|
$(e).parents('.layui-colla-item').find('#taskConfig').val(JSON.stringify([pointActivity, salesPromotion]));
|
}
|
if(taskType == 2 && type == 8){
|
const day = $('#day').val();
|
const times = $('#times').val();
|
if(null == day || '' == day){
|
Feng.error("浏览天数不能为空");
|
return false;
|
}
|
if(null == times || '' == times){
|
Feng.error("浏览次数不能为空");
|
return false;
|
}
|
$(e).parents('.layui-colla-item').find('#taskConfig').val(JSON.stringify([day, times]));
|
}
|
if(taskType == 2 && type == 9){
|
let jumpType = $('#jumpType').val();
|
const address = $('#address').val();
|
let objecCode = $('#objecCode').val();
|
let appid = $('#appid').val();
|
const duration = $('#duration').val();
|
if((jumpType == 6 || jumpType == 7) && (null == objecCode || '' == objecCode)){
|
Feng.error("数据ID不能为空");
|
return false;
|
}
|
if(jumpType == 12 && (null == address || '' == address)){
|
Feng.error("链接路径不能为空");
|
return false;
|
}
|
if(jumpType == 12 && (null == appid || '' == appid)){
|
Feng.error("APPID不能为空");
|
return false;
|
}
|
if((jumpType == 10 || jumpType == 12 || jumpType == 13 || jumpType == 14) && (null == duration || '' == duration)){
|
Feng.error("浏览次数不能为空");
|
return false;
|
}
|
$(e).parents('.layui-colla-item').find('#taskConfig').val(JSON.stringify([jumpType, address, objecCode, appid, duration]));
|
}
|
layer.close(index);
|
},
|
});
|
$('.selectpicker').selectpicker();
|
if(taskType == 1 && type == 2){
|
$('#week').selectpicker('val', array[2]);
|
$('#week').selectpicker('refresh');
|
$('#oilType').selectpicker('val', array[5]);
|
$('#oilType').selectpicker('refresh');
|
}
|
if(taskType == 1 && type == 3){
|
$('#week').selectpicker('val', array[2]);
|
$('#week').selectpicker('refresh');
|
}
|
if(taskType == 1 && type == 4){
|
$('#week').selectpicker('val', array[2]);
|
$('#week').selectpicker('refresh');
|
}
|
if(taskType == 2 && type == 6){
|
$('#coupon').selectpicker('val', array[0]);
|
$('#coupon').selectpicker('refresh');
|
}
|
if(taskType == 2 && type == 7){
|
$('#pointActivity').selectpicker('val', array[0]);
|
$('#pointActivity').selectpicker('refresh');
|
$('#salesPromotion').selectpicker('val', array[1]);
|
$('#salesPromotion').selectpicker('refresh');
|
}
|
layui.use('laydate', function() {
|
var laydate = layui.laydate;
|
laydate.render({
|
elem: '#dateTime1'
|
, type: 'datetime'
|
, range: true
|
});
|
});
|
|
$('#jumpType').on('change', function () {
|
const v = $(this).val();
|
if(v == 0 || v == 1 || v == 2 || v == 3 || v == 4 || v == 9){
|
$('#link1').hide();
|
$('#appidDiv').hide();
|
$('#dataCode').hide();
|
$('#durationDiv').hide();
|
$('#durationDiv input').val('');
|
$('#link1 #address').val('');
|
$('#dataCode input').val('');
|
$('#appidDiv input').val('');
|
}
|
if(v == 5 || v == 6 || v == 7 || v == 15){
|
$('#link1').hide();
|
$('#appidDiv').hide();
|
$('#dataCode').show();
|
$('#durationDiv').hide();
|
$('#durationDiv input').val('');
|
$('#link1 #address').val('');
|
$('#appidDiv input').val('');
|
if(v == 6 || v == 7){
|
$('#dataCode').find('label').empty().append('<span style="color: red">*</span>数据ID');
|
}else {
|
$('#dataCode').find('label').text('数据ID');
|
}
|
}
|
if(v == 10 || v == 13 || v == 14){
|
$('#link1').hide();
|
$('#appidDiv').hide();
|
$('#dataCode').hide();
|
$('#durationDiv').show();
|
$('#link1 #address').val('');
|
$('#dataCode input').val('');
|
$('#appidDiv input').val('');
|
}
|
if(v == 11){
|
$('#link1').show();
|
$('#appidDiv').hide();
|
$('#dataCode').hide();
|
$('#durationDiv').hide();
|
$('#durationDiv input').val('');
|
$('#appidDiv input').val('');
|
$('#dataCode input').val('');
|
$('#durationDiv')
|
}
|
if(v == 12){
|
$('#link1').show();
|
$('#appidDiv').show();
|
$('#durationDiv').show();
|
$('#dataCode').hide();
|
$('#dataCode input').val('');
|
}
|
if(v == 8){
|
$('#link1').hide();
|
$('#appidDiv').hide();
|
$('#dataCode').show();
|
$('#durationDiv').hide();
|
$('#durationDiv input').val('');
|
$('#link1 #address').val('');
|
$('#appidDiv input').val('');
|
$('#dataCode').find('label').text('商品编码');
|
}
|
})
|
|
};
|
|
/**
|
* 删除任务
|
* @param e
|
*/
|
PointActivityInfo.deleteTask = function(e){
|
$(e).parents('.layui-colla-item').remove();
|
}
|
|
|
PointActivityInfo.initTask = function(){
|
let html = '';
|
PointActivityInfo.task.forEach(function (item, index) {
|
html += '' +
|
' <div class="layui-colla-item tasks">\n' +
|
' <h2 class="layui-colla-title"><span>' + item['name'] + '</span><i class="layui-icon layui-icon-close" style="color: red;position: absolute; right: 15px; top: 0; font-size: 20px; font-weight: 800;" onclick="PointActivityInfo.deleteTask(this)"></i></h2>\n' +
|
' <div class="layui-colla-content layui-show">\n' +
|
' <div class="row">' +
|
' <input type="hidden" id="taskConfig" value=\'' + item['taskConfig'] + '\'>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">任务名称</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="text" class="form-control" id="name" value="' + item['name'] + '">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">可获得集点数</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="number" min="0" class="form-control" id="points" value="' + item['pointsNum'] + '">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">说明</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <textarea class="form-control" id="explain">' + item['explain'] + '</textarea>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">任务类型</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <select class="form-control" id="taskType">\n' +
|
' <option value="1" ' + (item['taskType'] == 1 ? 'selected' : '' ) + '>长期任务</option>\n' +
|
' <option value="2" ' + (item['taskType'] == 2 ? 'selected' : '' ) + '>不定时任务</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div id="cqrw" ' + (item['taskType'] == 1 ? '' : 'hidden') + '>\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">类型</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <select class="form-control" id="type">\n' +
|
' <option value="1" ' + (item['type'] == 1 ? 'selected' : '' ) + '>关注公众号</option>\n' +
|
' <option value="2" ' + (item['type'] == 2 ? 'selected' : '' ) + '>油品订单</option>\n' +
|
' <option value="3" ' + (item['type'] == 3 ? 'selected' : '' ) + '>非油品订单</option>\n' +
|
' <option value="4" ' + (item['type'] == 4 ? 'selected' : '' ) + '>积分兑换</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' <div class="col-sm-3">\n' +
|
' <button '+ (item['type'] == 1 ? 'hidden' : '' ) + ' style="height: 35px;line-height: 25px;width: 100px;background-color: #0E6828;color: #ffffff;" id="config" onclick="PointActivityInfo.setConfig(this)">设置条件</button>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div id="gzhdz" ' + (item['type'] == 1 ? '' : 'hidden' ) + '>\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">跳转链接</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input class="form-control" id="link" value="' + JSON.parse(item['taskConfig'])[0] + '">\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div id="bdsrw" ' + (item['taskType'] == 2 ? '' : 'hidden') + '>\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">跳转类型</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <select class="form-control" id="type">\n' +
|
' <option value="5" ' + (item['type'] == 5 ? 'selected' : '' ) + '>浏览外部网页</option>\n' +
|
' <option value="9" ' + (item['type'] == 9 ? 'selected' : '' ) + '>浏览小程序</option>\n' +
|
' <option value="6" ' + (item['type'] == 6 ? 'selected' : '' ) + '>券包购买</option>\n' +
|
' <option value="7" ' + (item['type'] == 7 ? 'selected' : '' ) + '>参与活动</option>\n' +
|
' <option value="8" ' + (item['type'] == 8 ? 'selected' : '' ) + '>访问首页</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' <div class="col-sm-3">\n' +
|
' <button style="height: 35px;line-height: 25px;width: 100px;background-color: #0E6828;color: #ffffff;" id="config" onclick="PointActivityInfo.setConfig(this)">设置条件</button>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' </div>' +
|
' </div>\n' +
|
' </div>' ;
|
});
|
return html;
|
}
|
|
PointActivityInfo.initPrise = function(){
|
let html = '';
|
var ajax = new $ax(Feng.ctxPath + "/coupon/queryThirdCount", function (data) {
|
if(data.code == 200){
|
const arr = data.data;
|
|
PointActivityInfo.prize.forEach(function (item, index) {
|
index++;
|
html += ' ' +
|
' <div class="layui-colla-item prizes">\n' +
|
' <h2 class="layui-colla-title"><span>'+ item['name'] +'</span><i class="layui-icon layui-icon-close" style="color: red;position: absolute; right: 15px; top: 0; font-size: 20px; font-weight: 800;" onclick="PointActivityInfo.deleteTask(this)"></i></h2>\n' +
|
' <div class="layui-colla-content layui-show">\n' +
|
' <div class="row">' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">奖品名称</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="text" class="form-control" id="name" value="' + (item['name']) + '">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">奖品类型</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <select class="form-control type' + index + '" id="type">' +
|
' <option value="1" '+(item['type']== '1' ? 'selected' : '')+'>优惠券</option>' +
|
' <option value="2" '+(item['type']== '2' ? 'selected' : '')+'>积分</option>' +
|
' </select>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">消耗集点数</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="number" min="0" class="form-control" id="pointsNum" value="' + (item['pointsNum']) + '">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">总数</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="number" min="0" class="form-control" id="total" value="' + (item['total']) + '">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">每人兑换次数限制</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="number" min="0" class="form-control" id="limitTimes" placeholder="一次只能兑换一个" value="' + (item['limitTimes']) + '">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group" id="codeDiv' + index + '">\n' +
|
' <label class="col-sm-2 control-label">券模板ID</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <select class="form-control" id="code">';
|
html += '<option value="">请选择</option>';
|
for(const i in arr){
|
html += '<option value="' + arr[i].couponTemplateCode + '" ' + (item['code'] == arr[i].couponTemplateCode ? 'selected' : '') + '>' + arr[i].couponTemplateName + '</option>'
|
}
|
html +=
|
' </select>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="form-group" id="codeNumberDiv' + index + '">'+
|
' <label class="col-sm-2 control-label">发放数量</label>'+
|
' <div class="col-sm-8">'+
|
' <input class="form-control" id="number" placeholder="单次单人发放的数量" value="'+(item['number']) +'" onBlur="inputInteger(this)">'+
|
' </div>'+
|
' </div>'+
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label head-scu-label">奖品图</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <div id="prizeImg' + index + 'PreId">\n' +
|
' <div><img width="100px" height="100px" src="' + (item['prizeImg']) + '"></div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="col-sm-2">\n' +
|
' <div class="head-scu-btn upload-btn" id="prizeImg' + index + 'BtnId">\n' +
|
' <i class="fa fa-upload"></i> 上传\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <input type="hidden" id="prizeImg' + index + '" class="prizeImg" value="' + (item['prizeImg']) + '"/>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label head-scu-label"></label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <div style="color: red;" id="size">推荐尺寸:544px * 158px(宽*高)<br/>推荐大小:不超过300K</div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">奖品描述</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <textarea class="form-control" id="prizeDescribe">' + (item['prizeDescribe']) + '</textarea>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">剩余数量字体颜色</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="color" class="form-control" id="surplusColor" value="' + (item['surplusColor']) + '">\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label head-scu-label">不可兑换icon</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <div id="inconvertibilityIcon' + index + 'PreId">\n' +
|
' <div><img width="100px" height="100px" src="' + (item['inconvertibilityIcon']) + '"></div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="col-sm-2">\n' +
|
' <div class="head-scu-btn upload-btn" id="inconvertibilityIcon' + index + 'BtnId">\n' +
|
' <i class="fa fa-upload"></i> 上传\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <input type="hidden" id="inconvertibilityIcon' + index + '" class="inconvertibilityIcon" value="' + (item['inconvertibilityIcon']) + '"/>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label head-scu-label"></label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <div style="color: red;" id="size">推荐尺寸:30px * 30px(宽*高)<br/>推荐大小:不超过300K</div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label head-scu-label">可兑换icon</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <div id="convertibleIcon' + index + 'PreId">\n' +
|
' <div><img width="100px" height="100px" src="' + (item['convertibleIcon']) + '"></div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="col-sm-2">\n' +
|
' <div class="head-scu-btn upload-btn" id="convertibleIcon' + index + 'BtnId">\n' +
|
' <i class="fa fa-upload"></i> 上传\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <input type="hidden" id="convertibleIcon' + index + '" class="convertibleIcon" value="' + (item['convertibleIcon']) + '"/>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label head-scu-label"></label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <div style="color: red;" id="size">推荐尺寸:30px * 30px(宽*高)<br/>推荐大小:不超过300K</div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">奖品排序</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="number" min="0" class="form-control" id="sort" value="' + (item['sort']) + '">\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' </div>\n' +
|
' </div>' ;
|
num = index;
|
})
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("获取失败!" + data.responseJSON.message + "!");
|
});
|
ajax.start();
|
return html;
|
}
|
|
|
|
$(function () {
|
layui.use('element', function(){
|
element = layui.element;
|
|
//…
|
});
|
$(document).click(function (e) {
|
$(document).on("click","#qrcodeMask",function () {
|
$("#qrcodeMask").hide();
|
$("#qrcode").hide();
|
$('#qrcodeCanvas').html('');
|
})
|
})
|
|
|
if(null != $("#id").val() && '' != $("#id").val()){
|
var homeConfig = JSON.parse($('#homeConfigInfo').val());
|
PointActivityInfo.info['homePageBackgroundImg'] = homeConfig.homePageBackgroundImg;
|
PointActivityInfo.info['ruleDescription'] = homeConfig.ruleDescription;
|
PointActivityInfo.info['exchangeButtonText'] = homeConfig.exchangeButtonText;
|
PointActivityInfo.info['exchangeButtonColor'] = homeConfig.exchangeButtonColor;
|
PointActivityInfo.info['exchangeTextColor'] = homeConfig.exchangeTextColor;
|
PointActivityInfo.info['arriveButtonColor'] = homeConfig.arriveButtonColor;
|
PointActivityInfo.info['notArrivedButtonColor'] = homeConfig.notArrivedButtonColor;
|
|
PointActivityInfo.task = JSON.parse($('#taskInfo').val());
|
|
PointActivityInfo.prize = JSON.parse($('#priseInfo').val());
|
|
}
|
|
|
// 初始化头像上传
|
var avatarUp = new $WebUpload("signBackgroundImg");
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
var avatarUp = new $WebUpload("successImg");
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
var avatarUp = new $WebUpload("setPointImg");
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
|
|
$('#addHomeSet').on('click', function () {
|
const str = '<div class="ibox float-e-margins">\n' +
|
' <div class="ibox-content">\n' +
|
' <div class="form-horizontal" id="userInfoForm">' +
|
'<div class="row">' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label head-scu-label">主页背景图</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <div id="homePageBackgroundImgPreId">\n' +
|
' <div><img width="100px" height="100px" src="/static/img/NoPIC.png"></div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="col-sm-2">\n' +
|
' <div class="head-scu-btn upload-btn" id="homePageBackgroundImgBtnId">\n' +
|
' <i class="fa fa-upload"></i> 上传\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <input type="hidden" id="homePageBackgroundImg" value=""/>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label head-scu-label"></label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <div style="color: red;">推荐尺寸:375px * 724px(宽*高)<br/>推荐大小:不超过300K</div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">规则说明</label>\n' +
|
' <div class="col-sm-8" id="editorhtml">\n' +
|
' <div id="editor" type="text/plain" style="height: 500px;"></div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">兑换按钮文案</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="text" class="form-control" id="exchangeButtonText">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">兑换按钮颜色</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="color" class="form-control" id="exchangeButtonColor">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">兑换文案颜色</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="color" class="form-control" id="exchangeTextColor">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">已达到按钮及进度条颜色</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="color" class="form-control" id="arriveButtonColor">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-3 control-label">未达到按钮及进度条颜色</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="color" class="form-control" id="notArrivedButtonColor">\n' +
|
' </div>\n' +
|
' </div>' +
|
'</div>' +
|
'</div></div></div>'
|
layer.open({
|
type: 1
|
, title: '活动参数设置'
|
, area: ['80%', '80%']
|
, 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 //不显示遮罩
|
, zIndex: -99100
|
, yes: function () {
|
const homePageBackgroundImg = $('#homePageBackgroundImg').val();
|
if(null == homePageBackgroundImg || '' == homePageBackgroundImg){
|
Feng.error("主页背景图不能为空");
|
return
|
}
|
const ruleDescription = editor.getContent();
|
if(null == ruleDescription || '' == ruleDescription){
|
Feng.error("规则说明不能为空");
|
return
|
}
|
const exchangeButtonText = $('#exchangeButtonText').val();
|
if(null == exchangeButtonText || '' == exchangeButtonText){
|
Feng.error("兑换/查看按钮文案不能为空");
|
return
|
}
|
PointActivityInfo.info['homePageBackgroundImg'] = homePageBackgroundImg;
|
PointActivityInfo.info['ruleDescription'] = ruleDescription;
|
PointActivityInfo.info['exchangeButtonText'] = exchangeButtonText;
|
PointActivityInfo.info['exchangeButtonColor'] = $('#exchangeButtonColor').val();
|
PointActivityInfo.info['exchangeTextColor'] = $('#exchangeTextColor').val();
|
PointActivityInfo.info['arriveButtonColor'] = $('#arriveButtonColor').val();
|
PointActivityInfo.info['notArrivedButtonColor'] = $('#notArrivedButtonColor').val();
|
layer.closeAll();
|
},
|
});
|
var avatarUp = new $WebUpload("homePageBackgroundImg");
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
|
UE.delEditor('editor');
|
if(null == editor){
|
editor = UE.getEditor('editor');
|
// 手动指定上传文件调用的接口(不同文件类型不同接口)
|
UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
|
UE.Editor.prototype.getActionUrl = function(action) {
|
// 这里很重要,很重要,很重要,要和配置中的imageActionName值一样
|
if(action == 'uploadimage'){
|
// 这里调用后端我们写的图片上传接口
|
return '/ueditor/uploadImageData';
|
}else if(action == 'uploadfile'){
|
return '/ueditor/uploadFileData';
|
}else{
|
return this._bkGetActionUrl.call(this, action);
|
}
|
}
|
editorhtml = $('#editorhtml').html();
|
}else{
|
// $('#editorhtml').html(editorhtml);
|
editor = UE.getEditor('editor');
|
}
|
|
|
$('#homePageBackgroundImg').val(PointActivityInfo.info['homePageBackgroundImg']);
|
$('#homePageBackgroundImgPreId img').attr('src', PointActivityInfo.info['homePageBackgroundImg']);
|
$('#exchangeButtonText').val(PointActivityInfo.info['exchangeButtonText']);
|
$('#exchangeButtonColor').val(PointActivityInfo.info['exchangeButtonColor']);
|
$('#exchangeTextColor').val(PointActivityInfo.info['exchangeTextColor']);
|
$('#arriveButtonColor').val(PointActivityInfo.info['arriveButtonColor']);
|
$('#notArrivedButtonColor').val(PointActivityInfo.info['notArrivedButtonColor']);
|
if(PointActivityInfo.info['ruleDescription'] != '' && typeof PointActivityInfo.info['ruleDescription'] != "undefined"){
|
editor.ready(function () {
|
editor.setContent(PointActivityInfo.info['ruleDescription']);
|
});
|
}
|
})
|
|
|
$('#addTask').on('click', function () {
|
const html = ' ' +
|
' <div class="layui-colla-item tasks">\n' +
|
' <h2 class="layui-colla-title"><span></span><i class="layui-icon layui-icon-close" style="color: red;position: absolute; right: 15px; top: 0; font-size: 20px; font-weight: 800;" onclick="PointActivityInfo.deleteTask(this)"></i></h2>\n' +
|
' <div class="layui-colla-content layui-show">\n' +
|
' <div class="row">' +
|
' <input type="hidden" id="taskConfig">' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">任务名称</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="text" class="form-control" id="name">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">可获得集点数</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="number" min="0" class="form-control" id="points">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">说明</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <textarea class="form-control" id="explain"></textarea>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">任务类型</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <select class="form-control" id="taskType">\n' +
|
' <option value="1">长期任务</option>\n' +
|
' <option value="2">不定时任务</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div id="cqrw">\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">类型</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <select class="form-control" id="type">\n' +
|
' <option value="1">关注公众号</option>\n' +
|
' <option value="2">油品订单</option>\n' +
|
' <option value="3">非油品订单</option>\n' +
|
' <option value="4">积分兑换</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' <div class="col-sm-3">\n' +
|
' <button hidden style="height: 35px;line-height: 25px;width: 100px;background-color: #0E6828;color: #ffffff;" id="config" onclick="PointActivityInfo.setConfig(this)">设置条件</button>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div id="gzhdz">\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">跳转链接</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input class="form-control" id="link">\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div id="bdsrw" hidden>\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">跳转类型</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <select class="form-control" id="type">\n' +
|
' <option value="5">浏览外部网页</option>\n' +
|
' <option value="9">浏览小程序</option>\n' +
|
' <option value="6">券包购买</option>\n' +
|
' <option value="7">参与活动</option>\n' +
|
' <option value="8">访问首页</option>\n' +
|
' </select>\n' +
|
' </div>\n' +
|
' <div class="col-sm-3">\n' +
|
' <button hidden style="height: 35px;line-height: 25px;width: 100px;background-color: #0E6828;color: #ffffff;" id="config" onclick="PointActivityInfo.setConfig(this)">设置条件</button>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' </div>' +
|
' </div>\n' +
|
' </div>' ;
|
const str = '' +
|
'<div class="ibox float-e-margins">\n' +
|
' <div class="ibox-content">\n' +
|
' <div class="form-horizontal" id="userInfoForm">' +
|
' <div class="layui-collapse" lay-filter="tasks" id="tasks">\n' +
|
PointActivityInfo.initTask() +
|
' </div>' +
|
' </div>' +
|
' </div>' +
|
'</div>'
|
layer.open({
|
type: 1
|
, title: '活动任务设置'
|
, area: ['80%', '80%']
|
, 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(){
|
$('#tasks').append(html);
|
element.init();
|
$('.tasks #taskType').on('change', function () {
|
const item = $(this).parents('.layui-colla-item');
|
const v = $(this).val();
|
if(v == 1){
|
$(item).find('#cqrw').show();
|
$(item).find('#bdsrw').hide();
|
}
|
if(v == 2){
|
$(item).find("#bdsrw #config").show();
|
$(item).find('#cqrw').hide();
|
$(item).find('#bdsrw').show();
|
}
|
$(this).parents('.tasks').find('#cqrw #link').val('');
|
$(this).parents('.tasks').find('#taskConfig').val('');
|
})
|
|
$('.tasks #cqrw #type').on('change', function () {
|
const item = $(this).parents('.layui-colla-item');
|
const v = $(this).val();
|
if(v == 1){
|
$(item).find('#gzhdz').show();
|
$(item).find("#cqrw #config").hide();
|
}else{
|
$(item).find('#gzhdz').hide();
|
$(item).find("#cqrw #config").show();
|
}
|
$(this).parents('.tasks').find('#gzhdz #link').val('');
|
$(this).parents('.tasks').find('#taskConfig').val('');
|
})
|
$('.tasks #bdsrw #type').on('change', function () {
|
$(this).parents('.tasks').find('#gzhdz #link').val('');
|
$(this).parents('.tasks').find('#taskConfig').val('');
|
})
|
|
$('.tasks #gzhdz #link').on('blur', function () {
|
const item = $(this).parents('.layui-colla-item');
|
$(item).find('#taskConfig').val(JSON.stringify([$(this).val()]));
|
})
|
|
$('.tasks #name').on('blur', function () {
|
const h2 = $(this).parents('.tasks').find('h2 span');
|
h2.text($(this).val());
|
})
|
|
}
|
,btn2: function(){
|
let string = '';
|
let arr = [];
|
$('#tasks .tasks').each(function () {
|
const name = $(this).find('#name').val();
|
const points = $(this).find('#points').val();
|
const explain = $(this).find('#explain').val();
|
const taskType = $(this).find('#taskType').val();
|
const type = taskType == 1 ? $(this).find('#cqrw #type').val() : $(this).find('#bdsrw #type').val();
|
const taskConfig = $(this).find('#taskConfig').val();
|
if(null == name || '' == name){
|
Feng.error("任务名称不能为空");
|
return
|
}
|
if(null == points || '' == points){
|
Feng.error("可获得集点数不能为空");
|
return
|
}
|
if(null == explain || '' == explain){
|
Feng.error("说明不能为空");
|
return
|
}
|
if(null == taskConfig || '' == taskConfig){
|
Feng.error("任务配置不能为空");
|
return
|
}
|
string += name + ';';
|
arr.push({
|
name: name,
|
pointsNum: points,
|
explain: explain,
|
taskType: taskType,
|
type: type,
|
taskConfig: taskConfig
|
});
|
});
|
PointActivityInfo.task = arr;
|
$('#activity_task').val(string.substring(0, string.length - 1));
|
if(PointActivityInfo.task.length > 0){
|
layer.closeAll();
|
}else{
|
return false
|
}
|
}
|
});
|
element.init();
|
$('.tasks #taskType').on('change', function () {
|
const v = $(this).val();
|
if(v == 1){
|
$(this).parents('.tasks').find('#cqrw').show();
|
$(this).parents('.tasks').find('#cqrw #type').change();
|
$(this).parents('.tasks').find('#bdsrw').hide();
|
}
|
if(v == 2){
|
$(this).parents('.tasks').find("#bdsrw #config").show();
|
$(this).parents('.tasks').find('#cqrw').hide();
|
$(this).parents('.tasks').find('#bdsrw').show();
|
$(this).parents('.tasks').find('#bdsrw #type').change();
|
}
|
$(this).parents('.tasks').find('#cqrw #link').val('');
|
$(this).parents('.tasks').find('#taskConfig').val('');
|
})
|
|
$('.tasks #cqrw #type').on('change', function () {
|
const v = $(this).val();
|
if(v == 1){
|
$(this).parents('.tasks').find('#gzhdz').show();
|
$(this).parents('.tasks').find("#config").hide();
|
}else{
|
$(this).parents('.tasks').find('#gzhdz').hide();
|
$(this).parents('.tasks').find("#config").show();
|
}
|
$(this).parents('.tasks').find('#gzhdz #link').val('');
|
$(this).parents('.tasks').find('#taskConfig').val('');
|
})
|
$('.tasks #bdsrw #type').on('change', function () {
|
$(this).parents('.tasks').find('#gzhdz #link').val('');
|
$(this).parents('.tasks').find('#taskConfig').val('');
|
})
|
|
|
$('.tasks #gzhdz #link').on('blur', function () {
|
$(this).parents('.tasks').find('#taskConfig').val(JSON.stringify([$(this).val()]));
|
})
|
|
$('.tasks #name').on('blur', function () {
|
const h2 = $(this).parents('.tasks').find('h2 span');
|
h2.text($(this).val());
|
})
|
})
|
|
|
|
$('#addPrize').on('click', function () {
|
const str = '' +
|
'<div class="ibox float-e-margins">\n' +
|
' <div class="ibox-content">\n' +
|
' <div class="form-horizontal" id="userInfoForm">' +
|
' <div class="layui-collapse" lay-filter="prizes" id="prizes">\n' +
|
PointActivityInfo.initPrise() +
|
' </div>' +
|
' </div>' +
|
' </div>' +
|
'</div>'
|
layer.open({
|
type: 1
|
, title: '活动奖品设置'
|
, area: ['80%', '80%']
|
, 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(){
|
num++;
|
var ajax = new $ax(Feng.ctxPath + "/coupon/queryThirdCount", function (data) {
|
if(data.code == 200){
|
const arr = data.data;
|
let str = '<option value="">请选择</option>';
|
for(const i in arr){
|
str += '<option value="' + arr[i].couponTemplateCode + '">' + arr[i].couponTemplateName + '</option>'
|
}
|
|
$('#prizes').append(' ' +
|
' <div class="layui-colla-item prizes">\n' +
|
' <h2 class="layui-colla-title"><span></span><i class="layui-icon layui-icon-close" style="color: red;position: absolute; right: 15px; top: 0; font-size: 20px; font-weight: 800;" onclick="PointActivityInfo.deleteTask(this)"></i></h2>\n' +
|
' <div class="layui-colla-content layui-show">\n' +
|
' <div class="row">' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">奖品名称</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="text" class="form-control" id="name">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">奖品类型</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <select class="form-control type' + num + '" id="type">' +
|
' <option value="1">优惠券</option>' +
|
' <option value="2">积分</option>' +
|
' </select>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">消耗集点数</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="number" min="0" class="form-control" id="pointsNum">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">总数</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="number" min="0" class="form-control" id="total">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">每人兑换次数限制</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="number" min="0" class="form-control" id="limitTimes" placeholder="一次只能兑换一个">\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group" id="codeDiv' + num + '">\n' +
|
' <label class="col-sm-2 control-label">券模板ID</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <select class="form-control" id="code">' +
|
str +
|
' </select>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="form-group" id="codeNumberDiv' + num + '">'+
|
' <label class="col-sm-2 control-label">发放数量</label>'+
|
' <div class="col-sm-8">'+
|
' <input class="form-control" id="number" value="1" placeholder="单次单人发放的数量" onBlur="inputInteger(this)">'+
|
' </div>'+
|
' </div>'+
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label head-scu-label">奖品图</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <div id="prizeImg' + num + 'PreId">\n' +
|
' <div><img width="100px" height="100px" src="/static/img/NoPIC.png"></div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="col-sm-2">\n' +
|
' <div class="head-scu-btn upload-btn" id="prizeImg' + num + 'BtnId">\n' +
|
' <i class="fa fa-upload"></i> 上传\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <input type="hidden" id="prizeImg'+ num + '" class="prizeImg" value=""/>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label head-scu-label"></label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <div style="color: red;" id="size">推荐尺寸:544px * 158px(宽*高)<br/>推荐大小:不超过300K</div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">奖品描述</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <textarea class="form-control" id="prizeDescribe"></textarea>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">剩余数量字体颜色</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="color" class="form-control" id="surplusColor">\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label head-scu-label">不可兑换icon</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <div id="inconvertibilityIcon' + num +'PreId">\n' +
|
' <div><img width="100px" height="100px" src="/static/img/NoPIC.png"></div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="col-sm-2">\n' +
|
' <div class="head-scu-btn upload-btn" id="inconvertibilityIcon' + num + 'BtnId">\n' +
|
' <i class="fa fa-upload"></i> 上传\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <input type="hidden" id="inconvertibilityIcon' + num + '" class="inconvertibilityIcon" value=""/>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label head-scu-label"></label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <div style="color: red;" id="size">推荐尺寸:30px * 30px(宽*高)<br/>推荐大小:不超过300K</div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label head-scu-label">可兑换icon</label>\n' +
|
' <div class="col-sm-4">\n' +
|
' <div id="convertibleIcon' + num + 'PreId">\n' +
|
' <div><img width="100px" height="100px" src="/static/img/NoPIC.png"></div>\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <div class="col-sm-2">\n' +
|
' <div class="head-scu-btn upload-btn" id="convertibleIcon' + num + 'BtnId">\n' +
|
' <i class="fa fa-upload"></i> 上传\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' <input type="hidden" id="convertibleIcon' + num + '" class="convertibleIcon" value=""/>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label head-scu-label"></label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <div style="color: red;" id="size">推荐尺寸:30px * 30px(宽*高)<br/>推荐大小:不超过300K</div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' <div class="form-group">\n' +
|
' <label class="col-sm-2 control-label">奖品排序</label>\n' +
|
' <div class="col-sm-8">\n' +
|
' <input type="number" min="0" class="form-control" id="sort">\n' +
|
' </div>\n' +
|
' </div>\n' +
|
' </div>' +
|
' </div>\n' +
|
' </div>');
|
element.init();
|
|
var avatarUp = new $WebUpload("prizeImg" + num);
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
var avatarUp = new $WebUpload("inconvertibilityIcon" + num);
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
var avatarUp = new $WebUpload("convertibleIcon" + num);
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
|
$('.prizes #name').on('blur', function () {
|
$(this).parents('.prizes').find('h2 span').text($(this).val());
|
})
|
$(".type"+ num).on('change',function (){
|
var type = $(".type"+num).val();
|
if(type == 1){
|
$("#codeDiv"+num).show();
|
$("#codeNumberDiv"+num).find('label').text("发放数量");
|
}else {
|
$("#codeDiv"+num).hide();
|
$("#codeNumberDiv"+num).find('label').text("发放积分");
|
}
|
})
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("获取失败!" + data.responseJSON.message + "!");
|
});
|
ajax.start();
|
}
|
,btn2: function(){
|
let string = '';
|
let arr = [];
|
$('#prizes .prizes').each(function () {
|
const name = $(this).find('#name').val();
|
const type = $(this).find('#type').val();
|
const number = $(this).find('#number').val();
|
const pointsNum = $(this).find('#pointsNum').val();
|
const total = $(this).find('#total').val();
|
const limitTimes = $(this).find('#limitTimes').val();
|
const code = $(this).find('#code').val();
|
const prizeImg = $(this).find('.prizeImg').val();
|
const prizeDescribe = $(this).find('#prizeDescribe').val();
|
const surplusColor = $(this).find('#surplusColor').val();
|
const inconvertibilityIcon = $(this).find('.inconvertibilityIcon').val();
|
const convertibleIcon = $(this).find('.convertibleIcon').val();
|
const sort = $(this).find('#sort').val();
|
if(null == name || '' == name){
|
Feng.error("奖品名称不能为空");
|
return
|
}
|
if(null == name || '' == name){
|
Feng.error("奖品类型不能为空");
|
return
|
}
|
if(null == pointsNum || '' == pointsNum){
|
Feng.error("消耗集点数不能为空");
|
return
|
}
|
if(null == total || '' == total){
|
Feng.error("奖品总数不能为空");
|
return
|
}
|
if(null == limitTimes || '' == limitTimes){
|
Feng.error("每人兑换次数限制不能为空");
|
return
|
}
|
if(null == number || '' == number){
|
Feng.error("发放数量不能为空");
|
return
|
}
|
if($("#type").val()==1){
|
if(null == code || '' == code){
|
Feng.error("券模板ID不能为空");
|
return
|
}
|
if(number > 5){
|
Feng.error("发放数量不能大于5张")
|
return
|
}
|
}
|
|
if(null == prizeImg || '' == prizeImg){
|
Feng.error("奖品图片不能为空");
|
return
|
}
|
if(null == prizeDescribe || '' == prizeDescribe){
|
Feng.error("奖品描述不能为空");
|
return
|
}
|
if(null == inconvertibilityIcon || '' == inconvertibilityIcon){
|
Feng.error("不可兑换icon不能为空");
|
return
|
}
|
if(null == convertibleIcon || '' == convertibleIcon){
|
Feng.error("可兑换icon不能为空");
|
return
|
}
|
if(null == sort || '' == sort){
|
Feng.error("奖品排序不能为空");
|
return
|
}
|
string += name + ';';
|
|
arr.push({
|
name: name,
|
type: type,
|
number: number,
|
pointsNum: pointsNum,
|
total: total,
|
limitTimes: limitTimes,
|
code: code,
|
prizeImg: prizeImg,
|
prizeDescribe: prizeDescribe,
|
surplusColor: surplusColor,
|
inconvertibilityIcon: inconvertibilityIcon,
|
convertibleIcon: convertibleIcon,
|
sort: sort
|
})
|
|
});
|
PointActivityInfo.prize = arr;
|
$('#activity_prize').val(string.substring(0, string.length - 1));
|
if(PointActivityInfo.prize.length > 0){
|
layer.closeAll();
|
}else{
|
return false;
|
}
|
}
|
});
|
element.init();
|
PointActivityInfo.prize.forEach(function (item, index) {
|
index++;
|
var avatarUp = new $WebUpload("prizeImg" + index);
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
var avatarUp = new $WebUpload("inconvertibilityIcon" + index);
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
var avatarUp = new $WebUpload("convertibleIcon" + index);
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
|
$(".type" + index).on('change', function () {
|
var type = $(".type" + index).val();
|
if (type == 1) {
|
$("#codeDiv" + index).show();
|
$("#codeNumberDiv" + index).find('label').text("发放数量");
|
} else {
|
$("#codeDiv" + index).hide();
|
$("#codeNumberDiv" + index).find('label').text("发放积分");
|
}
|
})
|
})
|
$('.prizes #name').on('blur', function () {
|
$(this).parents('.prizes').find('h2 span').text($(this).val());
|
})
|
|
for(var x = 1;x<= num;x++) {
|
var type = $(".type"+x).val();
|
if (type == 1) {
|
$("#codeDiv" + x).show();
|
$("#codeNumberDiv" + x).find('label').text("发放数量");
|
} else {
|
$("#codeDiv" + x).hide();
|
$("#codeNumberDiv" + x).find('label').text("发放积分");
|
}
|
}
|
})
|
});
|