/**
|
* 用户详情对话框(可用于添加和修改对话框)
|
*/
|
var CouponActivityInfo = {
|
userInfoData: {},
|
layerIndex: -1,
|
exposureCrowd: $('#exposureCrowd').val(),
|
paymentMethod: []
|
};
|
|
var editor = null;
|
|
/**
|
* 关闭此对话框
|
*/
|
CouponActivityInfo.close = function () {
|
parent.layer.close(window.parent.CouponActivity.layerIndex);
|
};
|
|
|
|
|
|
/**
|
* 提交添加coupon
|
*/
|
CouponActivityInfo.addSubmit = function () {
|
let name = $('#name').val();
|
let code = $('#code').val();
|
let description = $('#description').val();
|
let startAndEndTime = $('#startAndEndTime').val();
|
let deliveryFrequency = $('#deliveryFrequency').val();
|
let deliveryFrequencyWeek = $('#deliveryFrequencyWeek').val();
|
if(null == deliveryFrequencyWeek){
|
deliveryFrequencyWeek = [];
|
}
|
let deliveryFrequencyMonth = $('#deliveryFrequencyMonth').val();
|
if(null == deliveryFrequencyMonth){
|
deliveryFrequencyMonth = [];
|
}
|
let deliveryTime = [];
|
$('#deliveryTime .form-group .form-control').each(function (i, e) {
|
let v = $(e).val();
|
if(null != v && '' != v){
|
deliveryTime.push(v);
|
}
|
});
|
let type = null;
|
$("input[name='type']").each(function (i, e) {
|
if($(e).is(":checked")){
|
type = $(e).val();
|
}
|
})
|
let couponCode = $('#couponCode').val();
|
let number = $('#number').val();
|
let startingNumber = $('#startingNumber').val();
|
let activityRule = editor.getContent();
|
let activityRuleDisplay = null;
|
$("input[name='activityRuleDisplay']").each(function (i, e) {
|
if($(e).is(":checked")){
|
activityRuleDisplay = $(e).val();
|
}
|
})
|
let claimCycleType = $('#claimCycleType').val();
|
let claimsNumber = $('#claimsNumber').val();
|
let totalClaimsNumber = $('#totalClaimsNumber').val();
|
let overallMaximumEntitlement = $('#overallMaximumEntitlement').val();
|
let forwardAndShare = $('#forwardAndShare').val();
|
let shareBackgroundImage = $('#shareBackgroundImage').val();
|
let shareTitleName = $('#shareTitleName').val();
|
let coverPicture = $('#coverPicture').val();
|
let baseMap = $('#baseMap').val();
|
let successChart = $('#successChart').val();
|
let ineligiblePromptDiagram = $('#ineligiblePromptDiagram').val();
|
let overclaimReminderChart = $('#overclaimReminderChart').val();
|
let getTheFailureDiagram = $('#getTheFailureDiagram').val();
|
let noteOfCouponFailure = $('#noteOfCouponFailure').val();
|
let buttonColor = $('#buttonColor').val();
|
let freeButtonCopy = $('#freeButtonCopy').val();
|
let paidButtonCopy = $('#paidButtonCopy').val();
|
let buttonCopyColor = $('#buttonCopyColor').val();
|
|
if(null == name || '' == name){
|
Feng.error("活动名称不能为空");
|
return
|
}
|
if(null == description || '' == description){
|
Feng.error("活动说明不能为空");
|
return
|
}
|
if(description.length > 15){
|
Feng.error("活动说明不能大于15个文字");
|
return
|
}
|
if(null == startAndEndTime || '' == startAndEndTime){
|
Feng.error("活动时间周期不能为空");
|
return
|
}
|
// if(null == deliveryFrequency || '' == deliveryFrequency){
|
// Feng.error("投放频率不能为空");
|
// return
|
// }
|
// if(1 == deliveryFrequency && (null == deliveryFrequencyWeek || '' == deliveryFrequencyWeek)){
|
// Feng.error("投放频率不能为空");
|
// return
|
// }
|
// if(2 == deliveryFrequency && (null == deliveryFrequencyMonth || '' == deliveryFrequencyMonth)){
|
// Feng.error("投放频率不能为空");
|
// return
|
// }
|
// if(null == deliveryTime || deliveryTime.length == 0){
|
// Feng.error("投放时间点不能为空");
|
// return
|
// }
|
if(type == 1){
|
number = 0;
|
startingNumber = 0;
|
couponCode = [];
|
}else if(type == 2){
|
CouponActivityInfo.paymentMethod = [];
|
$('.vipLevelId').each(function (i, e) {
|
let id = $(e).attr('id');
|
CouponActivityInfo.paymentMethod.push({
|
id: id,
|
value:{
|
price: 0,
|
integral: 0,
|
payType: 1
|
}
|
})
|
})
|
if(null == couponCode || couponCode.length == 0){
|
Feng.error("商品ID不能为空");
|
return
|
}
|
if(null == number || '' == number){
|
Feng.error("发放数量不能为空");
|
return
|
}
|
if(5 < number){
|
Feng.error("发放数量不能大于5张");
|
return
|
}
|
if(null == startingNumber || '' == startingNumber){
|
Feng.error("已购买起始人数不能为空");
|
return
|
}
|
}else{
|
if(null == couponCode || couponCode.length == 0){
|
Feng.error("商品ID不能为空");
|
return
|
}
|
if(null == number || '' == number){
|
Feng.error("发放数量不能为空");
|
return
|
}
|
if(5 < number){
|
Feng.error("发放数量不能大于5张");
|
return
|
}
|
if(CouponActivityInfo.paymentMethod.length == 0){
|
Feng.error("请配置有效的支付方式");
|
return
|
}
|
for(let i in CouponActivityInfo.paymentMethod){
|
let id = CouponActivityInfo.paymentMethod[i].id;
|
let v = CouponActivityInfo.paymentMethod[i].value;
|
if(id == 0 && v.payType == 2 && (null == v.integral || '' == v.integral || 0 == v.integral)){
|
Feng.error("请配置有效的支付方式");
|
return
|
}
|
if(id == 0 && v.payType == 3 && (null == v.price || '' == v.price|| 0 == v.price)){
|
Feng.error("请配置有效的支付方式");
|
return
|
}
|
if(id == 0 && id == 0 && v.payType == 4 && (null == v.price || '' == v.price || 0 == v.price || null == v.integral || '' == v.integral || 0 == v.integral)){
|
Feng.error("请配置有效的支付方式");
|
return
|
}
|
}
|
if(null == startingNumber || '' == startingNumber){
|
Feng.error("已购买起始人数不能为空");
|
return
|
}
|
}
|
|
if(null == activityRule || '' == activityRule){
|
Feng.error("活动规则不能为空");
|
return
|
}
|
if(type == 1){
|
claimsNumber = 0;
|
totalClaimsNumber = 0;
|
overallMaximumEntitlement = 0;
|
}
|
if(type != 1){
|
if(null == claimsNumber || '' == claimsNumber || null == totalClaimsNumber || '' == totalClaimsNumber){
|
Feng.error("请填写有效的每人参与限制");
|
return
|
}
|
if(null == overallMaximumEntitlement || '' == overallMaximumEntitlement){
|
Feng.error("活动总参与上限不能为空");
|
return
|
}
|
}
|
|
if(1 == forwardAndShare && (null == shareBackgroundImage || '' == shareBackgroundImage)){
|
Feng.error("分享页主页背景不能为空");
|
return
|
}
|
if(1 == forwardAndShare && (null == shareTitleName || '' == shareTitleName)){
|
Feng.error("分享标题不能为空");
|
return
|
}
|
if(1 == forwardAndShare && shareTitleName.length > 25){
|
Feng.error("分享标题不超过25个文字");
|
return
|
}
|
if(null == coverPicture || '' == coverPicture){
|
Feng.error("活动封面图不能为空");
|
return
|
}
|
if(null == baseMap || '' == baseMap){
|
Feng.error("活动底图不能为空");
|
return
|
}
|
if(type == 1){
|
successChart = "";
|
ineligiblePromptDiagram = "";
|
overclaimReminderChart = "";
|
getTheFailureDiagram = "";
|
noteOfCouponFailure = "";
|
}
|
if(type != 1){
|
if(null == successChart || '' == successChart){
|
Feng.error("成功提示图不能为空");
|
return
|
}
|
if(null == ineligiblePromptDiagram || '' == ineligiblePromptDiagram){
|
Feng.error("不符合条件提示图不能为空");
|
return
|
}
|
if(null == overclaimReminderChart || '' == overclaimReminderChart){
|
Feng.error("超出领取数量上限提示图不能为空");
|
return
|
}
|
if(null == getTheFailureDiagram || '' == getTheFailureDiagram){
|
Feng.error("失败提示图不能为空");
|
return
|
}
|
if(null == noteOfCouponFailure || '' == noteOfCouponFailure){
|
Feng.error("发券未成功提示图不能为空");
|
return
|
}
|
}
|
if(type == 1 || type == 2){
|
freeButtonCopy = "";
|
paidButtonCopy = "";
|
}
|
if(type == 3){
|
if(null == freeButtonCopy || '' == freeButtonCopy){
|
Feng.error("按钮文案(免费)不能为空");
|
return
|
}
|
if(null == paidButtonCopy || '' == paidButtonCopy){
|
Feng.error("按钮文案(付费)不能为空");
|
return
|
}
|
}
|
let obj = {
|
code: code,
|
name: name,
|
description: description,
|
deliveryFrequencyType: deliveryFrequency,
|
type: type,
|
couponCode: couponCode,
|
number: number,
|
startingNumber: startingNumber,
|
activityRule: activityRule,
|
activityRuleDisplay: activityRuleDisplay,
|
claimCycleType: claimCycleType,
|
claimsNumber: claimsNumber,
|
totalClaimsNumber: totalClaimsNumber,
|
overallMaximumEntitlement: overallMaximumEntitlement,
|
forwardAndShare: forwardAndShare,
|
shareBackgroundImage: shareBackgroundImage,
|
shareTitleName: shareTitleName,
|
coverPicture: coverPicture,
|
baseMap: baseMap,
|
successChart: successChart,
|
ineligiblePromptDiagram: ineligiblePromptDiagram,
|
overclaimReminderChart: overclaimReminderChart,
|
getTheFailureDiagram: getTheFailureDiagram,
|
noteOfCouponFailure: noteOfCouponFailure,
|
buttonColor: buttonColor,
|
freeButtonCopy: freeButtonCopy,
|
paidButtonCopy: paidButtonCopy,
|
buttonCopyColor: buttonCopyColor,
|
exposureCrowd: CouponActivityInfo.exposureCrowd,
|
frequency: JSON.stringify(1 == deliveryFrequency ? deliveryFrequencyWeek : deliveryFrequencyMonth),
|
deliveryTime: deliveryTime.length == 0 ? "" : JSON.stringify(deliveryTime),
|
paymentMethod: JSON.stringify(CouponActivityInfo.paymentMethod)
|
}
|
if(null != startAndEndTime && '' != startAndEndTime){
|
obj.startTime = startAndEndTime.split(' - ')[0] + " 00:00:00";
|
obj.endTime = startAndEndTime.split(' - ')[1] + " 23:59:59";
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/couponActivity/addCouponActivity", function (data) {
|
if(data.code == 200){
|
Feng.success("添加成功!");
|
window.parent.CouponActivity.table.refresh();
|
CouponActivityInfo.close();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(obj);
|
ajax.start();
|
};
|
|
/**
|
* 提交修改
|
*/
|
CouponActivityInfo.editSubmit = function () {
|
let name = $('#name').val();
|
let code = $('#code').val();
|
let description = $('#description').val();
|
let startAndEndTime = $('#startAndEndTime').val();
|
let deliveryFrequency = $('#deliveryFrequency').val();
|
let deliveryFrequencyWeek = $('#deliveryFrequencyWeek').val();
|
if(null == deliveryFrequencyWeek){
|
deliveryFrequencyWeek = [];
|
}
|
let deliveryFrequencyMonth = $('#deliveryFrequencyMonth').val();
|
if(null == deliveryFrequencyMonth){
|
deliveryFrequencyMonth = [];
|
}
|
let deliveryTime = [];
|
$('#deliveryTime .form-group .form-control').each(function (i, e) {
|
let v = $(e).val();
|
if(null != v && '' != v){
|
deliveryTime.push(v);
|
}
|
});
|
let type = null;
|
$("input[name='type']").each(function (i, e) {
|
if($(e).is(":checked")){
|
type = $(e).val();
|
}
|
})
|
let couponCode = $('#couponCode').val();
|
let number = $('#number').val();
|
let startingNumber = $('#startingNumber').val();
|
let activityRule = editor.getContent();
|
let activityRuleDisplay = null;
|
$("input[name='activityRuleDisplay']").each(function (i, e) {
|
if($(e).is(":checked")){
|
activityRuleDisplay = $(e).val();
|
}
|
})
|
let claimCycleType = $('#claimCycleType').val();
|
let claimsNumber = $('#claimsNumber').val();
|
let totalClaimsNumber = $('#totalClaimsNumber').val();
|
let overallMaximumEntitlement = $('#overallMaximumEntitlement').val();
|
let forwardAndShare = $('#forwardAndShare').val();
|
let shareBackgroundImage = $('#shareBackgroundImage').val();
|
let coverPicture = $('#coverPicture').val();
|
let baseMap = $('#baseMap').val();
|
let successChart = $('#successChart').val();
|
let ineligiblePromptDiagram = $('#ineligiblePromptDiagram').val();
|
let overclaimReminderChart = $('#overclaimReminderChart').val();
|
let getTheFailureDiagram = $('#getTheFailureDiagram').val();
|
let noteOfCouponFailure = $('#noteOfCouponFailure').val();
|
let buttonColor = $('#buttonColor').val();
|
let freeButtonCopy = $('#freeButtonCopy').val();
|
let paidButtonCopy = $('#paidButtonCopy').val();
|
let buttonCopyColor = $('#buttonCopyColor').val();
|
let shareTitleName = $('#shareTitleName').val();
|
|
if(null == name || '' == name){
|
Feng.error("活动名称不能为空");
|
return
|
}
|
if(null == description || '' == description){
|
Feng.error("活动说明不能为空");
|
return
|
}
|
if(description.length > 15){
|
Feng.error("活动说明不能大于15个文字");
|
return
|
}
|
if(null == startAndEndTime || '' == startAndEndTime){
|
Feng.error("活动时间周期不能为空");
|
return
|
}
|
// if(null == deliveryFrequency || '' == deliveryFrequency){
|
// Feng.error("投放频率不能为空");
|
// return
|
// }
|
// if(1 == deliveryFrequency && (null == deliveryFrequencyWeek || '' == deliveryFrequencyWeek)){
|
// Feng.error("投放频率不能为空");
|
// return
|
// }
|
// if(2 == deliveryFrequency && (null == deliveryFrequencyMonth || '' == deliveryFrequencyMonth)){
|
// Feng.error("投放频率不能为空");
|
// return
|
// }
|
// if(null == deliveryTime || deliveryTime.length == 0){
|
// Feng.error("投放时间点不能为空");
|
// return
|
// }
|
if(type == 1){
|
number = 0;
|
startingNumber = 0;
|
couponCode = [];
|
}else if(type == 2){
|
CouponActivityInfo.paymentMethod = [];
|
$('.vipLevelId').each(function (i, e) {
|
let id = $(e).attr('id');
|
CouponActivityInfo.paymentMethod.push({
|
id: id,
|
value:{
|
price: 0,
|
integral: 0,
|
payType: 1
|
}
|
})
|
})
|
if(null == couponCode || couponCode.length == 0){
|
Feng.error("商品ID不能为空");
|
return
|
}
|
if(null == number || '' == number){
|
Feng.error("发放数量不能为空");
|
return
|
}
|
if(5 < number){
|
Feng.error("发放数量不能大于5张");
|
return
|
}
|
if(null == startingNumber || '' == startingNumber){
|
Feng.error("已购买起始人数不能为空");
|
return
|
}
|
}else{
|
if(null == couponCode || couponCode.length == 0){
|
Feng.error("商品ID不能为空");
|
return
|
}
|
if(null == number || '' == number){
|
Feng.error("发放数量不能为空");
|
return
|
}
|
if(5 < number){
|
Feng.error("发放数量不能大于5张");
|
return
|
}
|
if(CouponActivityInfo.paymentMethod.length == 0){
|
Feng.error("请配置有效的支付方式");
|
return
|
}
|
for(let i in CouponActivityInfo.paymentMethod){
|
let id = CouponActivityInfo.paymentMethod[i].id;
|
let v = CouponActivityInfo.paymentMethod[i].value;
|
if(id == 0 && v.payType == 2 && (null == v.integral || '' == v.integral || 0 == v.integral)){
|
Feng.error("请配置有效的支付方式");
|
return
|
}
|
if(id == 0 && v.payType == 3 && (null == v.price || '' == v.price|| 0 == v.price)){
|
Feng.error("请配置有效的支付方式");
|
return
|
}
|
if(id == 0 && id == 0 && v.payType == 4 && (null == v.price || '' == v.price || 0 == v.price || null == v.integral || '' == v.integral || 0 == v.integral)){
|
Feng.error("请配置有效的支付方式");
|
return
|
}
|
}
|
if(null == startingNumber || '' == startingNumber){
|
Feng.error("已购买起始人数不能为空");
|
return
|
}
|
}
|
|
if(null == activityRule || '' == activityRule){
|
Feng.error("活动规则不能为空");
|
return
|
}
|
if(type == 1){
|
claimsNumber = 0;
|
totalClaimsNumber = 0;
|
overallMaximumEntitlement = 0;
|
}
|
if(type != 1){
|
if(null == claimsNumber || '' == claimsNumber || null == totalClaimsNumber || '' == totalClaimsNumber){
|
Feng.error("请填写有效的每人参与限制");
|
return
|
}
|
if(null == overallMaximumEntitlement || '' == overallMaximumEntitlement){
|
Feng.error("活动总参与上限不能为空");
|
return
|
}
|
}
|
|
if(1 == forwardAndShare && (null == shareBackgroundImage || '' == shareBackgroundImage)){
|
Feng.error("分享页主页背景不能为空");
|
return
|
}
|
if(1 == forwardAndShare && (null == shareTitleName || '' == shareTitleName)){
|
Feng.error("分享标题不能为空");
|
return
|
}
|
if(1 == forwardAndShare && shareTitleName.length > 25){
|
Feng.error("分享标题不超过25个文字");
|
return
|
}
|
if(null == coverPicture || '' == coverPicture){
|
Feng.error("活动封面图不能为空");
|
return
|
}
|
if(null == baseMap || '' == baseMap){
|
Feng.error("活动底图不能为空");
|
return
|
}
|
if(type == 1){
|
successChart = "";
|
ineligiblePromptDiagram = "";
|
overclaimReminderChart = "";
|
getTheFailureDiagram = "";
|
noteOfCouponFailure = "";
|
}
|
if(type != 1){
|
if(null == successChart || '' == successChart){
|
Feng.error("成功提示图不能为空");
|
return
|
}
|
if(null == ineligiblePromptDiagram || '' == ineligiblePromptDiagram){
|
Feng.error("不符合条件提示图不能为空");
|
return
|
}
|
if(null == overclaimReminderChart || '' == overclaimReminderChart){
|
Feng.error("超出领取数量上限提示图不能为空");
|
return
|
}
|
if(null == getTheFailureDiagram || '' == getTheFailureDiagram){
|
Feng.error("失败提示图不能为空");
|
return
|
}
|
if(null == noteOfCouponFailure || '' == noteOfCouponFailure){
|
Feng.error("发券未成功提示图不能为空");
|
return
|
}
|
}
|
if(type == 1 || type == 2){
|
freeButtonCopy = "";
|
paidButtonCopy = "";
|
}
|
if(type == 3){
|
if(null == freeButtonCopy || '' == freeButtonCopy){
|
Feng.error("按钮文案(免费)不能为空");
|
return
|
}
|
if(null == paidButtonCopy || '' == paidButtonCopy){
|
Feng.error("按钮文案(付费)不能为空");
|
return
|
}
|
}
|
let obj = {
|
id: $('#id').val(),
|
code: code,
|
name: name,
|
description: description,
|
deliveryFrequencyType: deliveryFrequency,
|
type: type,
|
couponCode: couponCode,
|
number: number,
|
startingNumber: startingNumber,
|
activityRule: activityRule,
|
activityRuleDisplay: activityRuleDisplay,
|
claimCycleType: claimCycleType,
|
claimsNumber: claimsNumber,
|
totalClaimsNumber: totalClaimsNumber,
|
overallMaximumEntitlement: overallMaximumEntitlement,
|
forwardAndShare: forwardAndShare,
|
shareBackgroundImage: shareBackgroundImage,
|
shareTitleName: shareTitleName,
|
coverPicture: coverPicture,
|
baseMap: baseMap,
|
successChart: successChart,
|
ineligiblePromptDiagram: ineligiblePromptDiagram,
|
overclaimReminderChart: overclaimReminderChart,
|
getTheFailureDiagram: getTheFailureDiagram,
|
noteOfCouponFailure: noteOfCouponFailure,
|
buttonColor: buttonColor,
|
freeButtonCopy: freeButtonCopy,
|
paidButtonCopy: paidButtonCopy,
|
buttonCopyColor: buttonCopyColor,
|
exposureCrowd: CouponActivityInfo.exposureCrowd,
|
frequency: JSON.stringify(1 == deliveryFrequency ? deliveryFrequencyWeek : deliveryFrequencyMonth),
|
deliveryTime: deliveryTime.length == 0 ? "" : JSON.stringify(deliveryTime),
|
paymentMethod: JSON.stringify(CouponActivityInfo.paymentMethod)
|
}
|
if(null != startAndEndTime && '' != startAndEndTime){
|
obj.startTime = startAndEndTime.split(' - ')[0] + " 00:00:00";
|
obj.endTime = startAndEndTime.split(' - ')[1] + " 23:59:59";
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/couponActivity/updateCouponActivity", function (data) {
|
if(data.code == 200){
|
Feng.success("编辑成功!");
|
window.parent.CouponActivity.table.refresh();
|
CouponActivityInfo.close();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("编辑失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(obj);
|
ajax.start();
|
};
|
|
|
CouponActivityInfo.showExposureCrowd = function(){
|
var index = layer.open({
|
type: 2,
|
title: '曝光人群',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/exposureCrowd/showExposureCrowd?objectType=6&id=' + $('#id').val() + "&page=CouponActivityInfo"
|
});
|
this.layerIndex = index;
|
}
|
|
|
|
|
CouponActivityInfo.choosePay = function(e){
|
$(e).siblings('div').css({
|
'background-color': '#fff',
|
'color': '#3399ff'
|
});
|
$(e).siblings('div').attr('tag', 'false');
|
$(e).css({
|
'background-color': '#3399ff',
|
'color': '#fff'
|
});
|
$(e).attr('tag', 'true');
|
let id = $(e).attr('id');
|
let b = true;
|
for(var i in CouponActivityInfo.paymentMethod){
|
let o = CouponActivityInfo.paymentMethod[i];
|
if(o.id == id){
|
let v = o.value;
|
$('#payType').val(v.payType);
|
$('#price').val(v.price);
|
$('#integral').val(v.integral);
|
$('#payType').change();
|
b = false;
|
break
|
}
|
}
|
if(b){
|
$('#payType').val(1);
|
$('#price').val('');
|
$('#integral').val('');
|
$('#payType').change();
|
}
|
}
|
|
|
CouponActivityInfo.addPaymentMethod = function(e, l){
|
if(typeof l != "undefined" && l == 0){
|
let v = $(e).val();
|
if(!regInt.test(v)){
|
$(e).val('');
|
Feng.error("请输入正整数");
|
return
|
}
|
}
|
if(typeof l != "undefined" && l == 2){
|
let v = $(e).val();
|
if(!regDouble.test(v)){
|
$(e).val('');
|
Feng.error("请输入两位小数的数值");
|
return
|
}
|
}
|
|
let vipLevelId = null;
|
$('.vipLevelId').each(function (i, e) {
|
let tag = $(e).attr('tag');
|
if(tag == 'true'){
|
vipLevelId = $(e).attr('id');
|
}
|
})
|
|
let b = true;
|
for(var i in CouponActivityInfo.paymentMethod){
|
let o = CouponActivityInfo.paymentMethod[i]
|
if(o.id == vipLevelId){
|
o.value = {
|
price: $('#price').val(),
|
integral: $('#integral').val(),
|
payType: $('#payType').val()
|
}
|
b = false;
|
break
|
}
|
}
|
if(b){
|
CouponActivityInfo.paymentMethod.push({
|
id: vipLevelId,
|
value: {
|
price: $('#price').val(),
|
integral: $('#integral').val(),
|
payType: $('#payType').val()
|
}
|
})
|
}
|
}
|
|
|
|
CouponActivityInfo.nextPage = function(page){
|
if(1 == page){
|
let name = $('#name').val();
|
let description = $('#description').val();
|
let startAndEndTime = $('#startAndEndTime').val();
|
let deliveryTime = [];
|
$('#deliveryTime .form-group .form-control').each(function (i, e) {
|
let v = $(e).val();
|
if(null != v && '' != v){
|
deliveryTime.push(v);
|
}
|
});
|
let type = null;
|
$("input[name='type']").each(function (i, e) {
|
if($(e).is(":checked")){
|
type = $(e).val();
|
}
|
})
|
let couponCode = $('#couponCode').val();
|
let number = $('#number').val();
|
let startingNumber = $('#startingNumber').val();
|
let activityRule = editor.getContent();
|
let activityRuleDisplay = null;
|
$("input[name='activityRuleDisplay']").each(function (i, e) {
|
if($(e).is(":checked")){
|
activityRuleDisplay = $(e).val();
|
}
|
})
|
|
if(null == name || '' == name){
|
Feng.error("活动名称不能为空");
|
return
|
}
|
if(null == description || '' == description){
|
Feng.error("活动说明不能为空");
|
return
|
}
|
if(description.length > 15){
|
Feng.error("活动说明不能大于15个文字");
|
return
|
}
|
if(null == startAndEndTime || '' == startAndEndTime){
|
Feng.error("活动时间周期不能为空");
|
return
|
}
|
|
if(type == 2){
|
if(null == couponCode || couponCode.length == 0){
|
Feng.error("商品ID不能为空");
|
return
|
}
|
if(null == number || '' == number){
|
Feng.error("发放数量不能为空");
|
return
|
}
|
if(5 < number){
|
Feng.error("发放数量不能大于5张");
|
return
|
}
|
if(null == startingNumber || '' == startingNumber){
|
Feng.error("已购买起始人数不能为空");
|
return
|
}
|
}else if(type == 3){
|
if(null == couponCode || couponCode.length == 0){
|
Feng.error("商品ID不能为空");
|
return
|
}
|
if(null == number || '' == number){
|
Feng.error("发放数量不能为空");
|
return
|
}
|
if(5 < number){
|
Feng.error("发放数量不能大于5张");
|
return
|
}
|
if(CouponActivityInfo.paymentMethod.length == 0){
|
Feng.error("请配置有效的支付方式");
|
return
|
}
|
for(let i in CouponActivityInfo.paymentMethod){
|
let id = CouponActivityInfo.paymentMethod[i].id;
|
let v = CouponActivityInfo.paymentMethod[i].value;
|
if(id == 0 && v.payType == 2 && (null == v.integral || '' == v.integral || 0 == v.integral)){
|
Feng.error("请配置有效的支付方式");
|
return
|
}
|
if(id == 0 && v.payType == 3 && (null == v.price || '' == v.price|| 0 == v.price)){
|
Feng.error("请配置有效的支付方式");
|
return
|
}
|
if(id == 0 && id == 0 && v.payType == 4 && (null == v.price || '' == v.price || 0 == v.price || null == v.integral || '' == v.integral || 0 == v.integral)){
|
Feng.error("请配置有效的支付方式");
|
return
|
}
|
}
|
if(null == startingNumber || '' == startingNumber){
|
Feng.error("已购买起始人数不能为空");
|
return
|
}
|
}
|
|
if(null == activityRule || '' == activityRule){
|
Feng.error("活动规则不能为空");
|
return
|
}
|
|
$('#basicData').hide();
|
$('#rule').show();
|
$('#activityImg').hide();
|
|
// $('#forwardShare').show();
|
var shareBackgroundImage = new $WebUpload("shareBackgroundImage");
|
shareBackgroundImage.setUploadBarId("progressBar1");
|
shareBackgroundImage.init();
|
}
|
if(2 == page){
|
let type = null;
|
$("input[name='type']").each(function (i, e) {
|
if($(e).is(":checked")){
|
type = $(e).val();
|
}
|
})
|
let claimsNumber = $('#claimsNumber').val();
|
let totalClaimsNumber = $('#totalClaimsNumber').val();
|
let overallMaximumEntitlement = $('#overallMaximumEntitlement').val();
|
let forwardAndShare = $('#forwardAndShare').val();
|
let shareBackgroundImage = $('#shareBackgroundImage').val();
|
let shareTitleName = $('#shareTitleName').val();
|
|
if(type != 1){
|
if(null == claimsNumber || '' == claimsNumber || null == totalClaimsNumber || '' == totalClaimsNumber){
|
Feng.error("请填写有效的每人参与限制");
|
return
|
}
|
if(null == overallMaximumEntitlement || '' == overallMaximumEntitlement){
|
Feng.error("活动总参与上限不能为空");
|
return
|
}
|
}
|
|
if(1 == forwardAndShare && (null == shareBackgroundImage || '' == shareBackgroundImage)){
|
Feng.error("分享页主页背景不能为空");
|
return
|
}
|
if(1 == forwardAndShare && (null == shareTitleName || '' == shareTitleName)){
|
Feng.error("分享标题不能为空");
|
return
|
}
|
if(1 == forwardAndShare && shareTitleName.length > 25){
|
Feng.error("分享标题不超过25个文字");
|
return
|
}
|
|
$('#basicData').hide();
|
$('#rule').hide();
|
$('#activityImg').show();
|
if(type == 2){
|
$('.automaticPickup').hide();
|
}
|
|
var coverPicture = new $WebUpload("coverPicture");
|
coverPicture.setUploadBarId("progressBar2");
|
coverPicture.init();
|
var baseMap = new $WebUpload("baseMap");
|
baseMap.setUploadBarId("progressBar3");
|
baseMap.init();
|
var successChart = new $WebUpload("successChart");
|
successChart.setUploadBarId("progressBar4");
|
successChart.init();
|
var ineligiblePromptDiagram = new $WebUpload("ineligiblePromptDiagram");
|
ineligiblePromptDiagram.setUploadBarId("progressBar5");
|
ineligiblePromptDiagram.init();
|
var overclaimReminderChart = new $WebUpload("overclaimReminderChart");
|
overclaimReminderChart.setUploadBarId("progressBar6");
|
overclaimReminderChart.init();
|
var getTheFailureDiagram = new $WebUpload("getTheFailureDiagram");
|
getTheFailureDiagram.setUploadBarId("progressBar7");
|
getTheFailureDiagram.init();
|
var noteOfCouponFailure = new $WebUpload("noteOfCouponFailure");
|
noteOfCouponFailure.setUploadBarId("progressBar8");
|
noteOfCouponFailure.init();
|
}
|
}
|
|
CouponActivityInfo.previousPage = function(page){
|
if(2 == page){
|
$('#basicData').show();
|
$('#rule').hide();
|
$('#activityImg').hide();
|
}
|
if(3 == page){
|
$('#basicData').hide();
|
$('#rule').show();
|
$('#activityImg').hide();
|
}
|
}
|
|
|
CouponActivityInfo.addDeliveryTime = function(v){
|
let n = $('#deliveryTime .form-group').length + 1;
|
$('#deliveryTime').append('<div class="form-group">\n' +
|
' <label class="col-sm-2 control-label"></label>\n' +
|
' <div class="col-sm-2">\n' +
|
' <input class="form-control" id="deliveryTime' + n + '" value="' + (typeof v == "undefined" ? '' : v) + '">\n' +
|
' </div>\n' +
|
' <div class="col-sm-1">\n' +
|
' <i class="fa fa-minus-square" onclick="CouponActivityInfo.delDeliveryTime(this)" style="font-size:24px"></i>\n' +
|
' </div>\n' +
|
' </div>');
|
|
layui.use('laydate', function() {
|
var laydate = layui.laydate;
|
laydate.render({
|
elem: '#deliveryTime' + n
|
, type: 'time'
|
, range: true
|
});
|
});
|
}
|
|
CouponActivityInfo.delDeliveryTime = function(e){
|
$(e).parent().parent().remove();
|
}
|
|
|
|
$(function () {
|
$('#deliveryFrequencyWeek').selectpicker();
|
$('#couponCode').selectpicker();
|
|
editor = UE.getEditor('activityRule');
|
// 手动指定上传文件调用的接口(不同文件类型不同接口)
|
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);
|
}
|
}
|
$('#deliveryFrequency').on('change', function () {
|
let v = $(this).val();
|
if(v == 0){
|
$('#deliveryFrequencyDiv').html('' +
|
'<select id="deliveryFrequencyWeek" class="selectpicker show-tick form-control" multiple data-live-search="true" data-style="btn-info" title="全部">\n' +
|
'</select>'
|
);
|
$('#deliveryFrequencyWeek').selectpicker();
|
}
|
if(v == 1){
|
$('#deliveryFrequencyDiv').html('' +
|
'<select id="deliveryFrequencyWeek" class="selectpicker show-tick form-control" multiple data-live-search="true" data-style="btn-info" title="全部">\n' +
|
' <option value="1">周一</option>\n' +
|
' <option value="2">周二</option>\n' +
|
' <option value="3">周三</option>\n' +
|
' <option value="4">周四</option>\n' +
|
' <option value="5">周五</option>\n' +
|
' <option value="6">周六</option>\n' +
|
' <option value="7">周日</option>\n' +
|
'</select>'
|
);
|
$('#deliveryFrequencyWeek').selectpicker();
|
}
|
if(v == 2){
|
$('#deliveryFrequencyDiv').html('' +
|
'<select id="deliveryFrequencyMonth" class="selectpicker show-tick form-control" multiple data-live-search="true" data-style="btn-info" title="全部">\n' +
|
' <option value="1">1日</option>\n' +
|
' <option value="2">2日</option>\n' +
|
' <option value="3">3日</option>\n' +
|
' <option value="4">4日</option>\n' +
|
' <option value="5">5日</option>\n' +
|
' <option value="6">6日</option>\n' +
|
' <option value="7">7日</option>\n' +
|
' <option value="8">8日</option>\n' +
|
' <option value="9">9日</option>\n' +
|
' <option value="10">10日</option>\n' +
|
' <option value="11">11日</option>\n' +
|
' <option value="12">12日</option>\n' +
|
' <option value="13">13日</option>\n' +
|
' <option value="14">14日</option>\n' +
|
' <option value="15">15日</option>\n' +
|
' <option value="16">16日</option>\n' +
|
' <option value="17">17日</option>\n' +
|
' <option value="18">18日</option>\n' +
|
' <option value="19">19日</option>\n' +
|
' <option value="20">20日</option>\n' +
|
' <option value="21">21日</option>\n' +
|
' <option value="22">22日</option>\n' +
|
' <option value="23">23日</option>\n' +
|
' <option value="24">24日</option>\n' +
|
' <option value="25">25日</option>\n' +
|
' <option value="26">26日</option>\n' +
|
' <option value="27">27日</option>\n' +
|
' <option value="28">28日</option>\n' +
|
' <option value="29">29日</option>\n' +
|
' <option value="30">30日</option>\n' +
|
' <option value="31">31日</option>\n' +
|
'</select>'
|
);
|
$('#deliveryFrequencyMonth').selectpicker();
|
}
|
})
|
$('#payType').on('change', function () {
|
let v = $(this).val();
|
if(v == 1){
|
$('.price').hide();
|
$('#price').val('');
|
$('.integral').hide();
|
$('#integral').val('');
|
}
|
if(v == 2){
|
$('.price').hide();
|
$('#price').val('');
|
$('.integral').show();
|
}
|
if(v == 3){
|
$('.price').show();
|
$('.integral').hide();
|
$('#integral').val('');
|
}
|
if(v == 4){
|
$('.price').show();
|
$('.integral').show();
|
}
|
CouponActivityInfo.addPaymentMethod();
|
})
|
|
$('#forwardAndShare').on('change', function () {
|
let v = $(this).val();
|
if(v == 0){
|
$('#forwardShare').hide();
|
}
|
if(v == 1){
|
$('#forwardShare').show();
|
var shareBackgroundImage = new $WebUpload("shareBackgroundImage");
|
shareBackgroundImage.setUploadBarId("progressBar1");
|
shareBackgroundImage.init();
|
}
|
})
|
$("input[name='type']").on('change', function () {
|
let v = $(this).val();
|
if(v == 1){
|
$('.pureImages').hide();
|
}
|
if(v == 2){
|
$('.pureImages').show();
|
$('.automaticPickup').hide();
|
}
|
if(v == 3){
|
$('.pureImages').show();
|
$('.automaticPickup').show();
|
}
|
})
|
|
|
$('.vipLevelId').each(function (i, e) {
|
let id = $(e).attr('id');
|
CouponActivityInfo.paymentMethod.push({
|
id: id,
|
value:{
|
price: 0,
|
integral: 0,
|
payType: 1
|
}
|
})
|
})
|
|
if($('#id').val() != ''){
|
editor.ready(function() {
|
editor.setContent($('#activityRule1').val())
|
});
|
CouponActivityInfo.paymentMethod = JSON.parse($('#paymentMethod').val());
|
$('#0').click();
|
let deliveryFrequency1 = JSON.parse($('#deliveryFrequency1').val());
|
let frequency = deliveryFrequency1.frequency;
|
let deliveryTime = deliveryFrequency1.deliveryTime;
|
$('#deliveryFrequency').change();
|
let deliveryFrequency = $('#deliveryFrequency').val();
|
if(deliveryFrequency == 1){
|
$('#deliveryFrequencyWeek').selectpicker('val', frequency);
|
$('#deliveryFrequencyWeek').selectpicker('refresh');
|
}else{
|
$('#deliveryFrequencyMonth').selectpicker('val', frequency);
|
$('#deliveryFrequencyMonth').selectpicker('refresh');
|
}
|
for(let i in deliveryTime){
|
if(i == 0){
|
$('#deliveryTime1').val(deliveryTime[i]);
|
}else{
|
CouponActivityInfo.addDeliveryTime(deliveryTime[i]);
|
}
|
}
|
CouponActivityInfo.exposureCrowd = $('#exposureCrowd').val();
|
}
|
});
|