/**
|
* 用户详情对话框(可用于添加和修改对话框)
|
*/
|
var CouponInfo = {
|
userInfoData: {},
|
layerIndex: -1,
|
exposureCrowd: $('#exposureCrowd').val()
|
};
|
|
var editor = null;
|
|
/**
|
* 关闭此对话框
|
*/
|
CouponInfo.close = function () {
|
parent.layer.close(window.parent.Coupon.layerIndex);
|
};
|
|
|
/**
|
* 提交添加coupon
|
*/
|
CouponInfo.addSubmit = function () {
|
const img = $('#img').val();
|
const name = $('#name').val();
|
const code = $('#code').val();
|
const listDescribe = $('#listDescribe').val();
|
const infoDescribe = $('#infoDescribe').val();
|
const price = $('#price').val();
|
const unitPrice = $('#unitPrice').val();
|
const total = $('#total').val();
|
const startNumber = $('#startNumber').val();
|
const restrictedQuantity = $('#restrictedQuantity').val();
|
const seckillState = $('#seckillState').val();
|
const activityPrice = $('#activityPrice').val();
|
const dateTime = $('#dateTime').val();
|
const forwardShareState = $('#forwardShareState').val();
|
const backgroundImg = $('#backgroundImg').val();
|
const purchaseInstructions = editor.getContent();
|
|
const number = $("#number").val();
|
const frequency = $('#frequency').val();
|
const zhouSelectpicker = $('#zhouSelectpicker').find("select").val();
|
const yueSelectpicker = $('#yueSelectpicker').find("select").val();
|
var frequencyTime="";
|
if(frequency==1){//周
|
frequencyTime=zhouSelectpicker==null?[]:zhouSelectpicker;
|
}else {
|
frequencyTime=yueSelectpicker==null?[]:yueSelectpicker;
|
}
|
var pointTime = [];
|
$(".pointTime").each(function(){
|
pointTime.push($(this).val());
|
});
|
|
if(null == img || '' == img){
|
Feng.error("图片不能为空");
|
return
|
}
|
if(null == name || '' == name){
|
Feng.error("券包名称不能为空");
|
return
|
}
|
if(null == code || '' == code){
|
Feng.error("券包模板ID不能为空");
|
return
|
}
|
if(null == listDescribe || '' == listDescribe){
|
Feng.error("列表描述不能为空");
|
return
|
}
|
if(null == infoDescribe || '' == infoDescribe){
|
Feng.error("详情描述不能为空");
|
return
|
}
|
if(null == price || '' == price){
|
Feng.error("券包价值不能为空");
|
return
|
}
|
if(null == number || '' == number){
|
Feng.error("发放数量不能为空");
|
return
|
}
|
if(number > 5){
|
Feng.error("发放数量不能大于5张")
|
return
|
}
|
if(null == unitPrice || '' == unitPrice){
|
Feng.error("券包价格不能为空");
|
return
|
}
|
if(null == total || '' == total){
|
Feng.error("数量上限不能为空");
|
return
|
}
|
if(null == startNumber || '' == startNumber){
|
Feng.error("已购买起始人数不能为空");
|
return
|
}
|
if(null == restrictedQuantity || '' == restrictedQuantity){
|
Feng.error("单人限购不能为空");
|
return
|
}
|
if(1 == seckillState && (null == activityPrice || '' == activityPrice)){
|
Feng.error("活动价格不能为空");
|
return
|
}
|
if(1 == seckillState && (null == dateTime || '' == dateTime)){
|
Feng.error("活动时间周期不能为空");
|
return
|
}
|
if(1 == forwardShareState && (null == backgroundImg || '' == backgroundImg)){
|
Feng.error("分享页主页背景不能为空");
|
return
|
}
|
if(null == purchaseInstructions || '' == purchaseInstructions){
|
Feng.error("购买须知不能为空");
|
return
|
}
|
let obj = {
|
img: img,
|
name: name,
|
code: code,
|
listDescribe: listDescribe,
|
infoDescribe: infoDescribe,
|
price: price,
|
unitPrice: unitPrice,
|
total: total,
|
startNumber: startNumber,
|
restrictedQuantity: restrictedQuantity,
|
seckillState: seckillState,
|
activityPrice: activityPrice,
|
forwardShareState: forwardShareState,
|
backgroundImg: backgroundImg,
|
purchaseInstructions: purchaseInstructions,
|
frequency: frequency,
|
frequencyTime: JSON.stringify(frequencyTime),
|
pointTime: JSON.stringify(pointTime),
|
number: number,
|
exposureCrowd: CouponInfo.exposureCrowd
|
}
|
if(null != dateTime && '' != dateTime){
|
obj.activityStartTime = dateTime.split(' - ')[0];
|
obj.activityEndTime = dateTime.split(' - ')[1];
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/coupon/addCoupon", function (data) {
|
if(data.code == 200){
|
Feng.success("添加成功!");
|
window.parent.Coupon.table.refresh();
|
CouponInfo.close();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(obj);
|
ajax.start();
|
};
|
|
/**
|
* 提交修改
|
*/
|
CouponInfo.editSubmit = function () {
|
const img = $('#img').val();
|
const name = $('#name').val();
|
const code = $('#code').val();
|
const listDescribe = $('#listDescribe').val();
|
const infoDescribe = $('#infoDescribe').val();
|
const price = $('#price').val();
|
const unitPrice = $('#unitPrice').val();
|
const total = $('#total').val();
|
const startNumber = $('#startNumber').val();
|
const restrictedQuantity = $('#restrictedQuantity').val();
|
const seckillState = $('#seckillState').val();
|
const activityPrice = $('#activityPrice').val();
|
const dateTime = $('#dateTime').val();
|
const forwardShareState = $('#forwardShareState').val();
|
const backgroundImg = $('#backgroundImg').val();
|
const purchaseInstructions = editor.getContent();
|
|
const number = $("#number").val();
|
const frequency = $('#frequency').val();
|
const zhouSelectpicker = $('#zhouSelectpicker').find("select").val();
|
const yueSelectpicker = $('#yueSelectpicker').find("select").val();
|
var frequencyTime="";
|
if(frequency==1){//周
|
frequencyTime=zhouSelectpicker==null?[]:zhouSelectpicker;
|
}else {
|
frequencyTime=yueSelectpicker==null?[]:yueSelectpicker;
|
}
|
var pointTime = [];
|
$(".pointTime").each(function(){
|
pointTime.push($(this).val());
|
});
|
|
if(null == img || '' == img){
|
Feng.error("图片不能为空");
|
return
|
}
|
if(null == name || '' == name){
|
Feng.error("券包名称不能为空");
|
return
|
}
|
if(null == code || '' == code){
|
Feng.error("券包模板ID不能为空");
|
return
|
}
|
if(null == listDescribe || '' == listDescribe){
|
Feng.error("列表描述不能为空");
|
return
|
}
|
if(null == infoDescribe || '' == infoDescribe){
|
Feng.error("详情描述不能为空");
|
return
|
}
|
if(null == price || '' == price){
|
Feng.error("券包价值不能为空");
|
return
|
}
|
if(null == number || '' == number){
|
Feng.error("发放数量不能为空");
|
return
|
}
|
if(number > 5){
|
Feng.error("发放数量不能大于5张")
|
return
|
}
|
|
if(null == unitPrice || '' == unitPrice){
|
Feng.error("券包价格不能为空");
|
return
|
}
|
if(null == total || '' == total){
|
Feng.error("数量上限不能为空");
|
return
|
}
|
if(null == startNumber || '' == startNumber){
|
Feng.error("已购买起始人数不能为空");
|
return
|
}
|
if(null == restrictedQuantity || '' == restrictedQuantity){
|
Feng.error("单人限购不能为空");
|
return
|
}
|
if(1 == seckillState && (null == activityPrice || '' == activityPrice)){
|
Feng.error("活动价格不能为空");
|
return
|
}
|
if(1 == seckillState && (null == dateTime || '' == dateTime)){
|
Feng.error("活动时间周期不能为空");
|
return
|
}
|
if(1 == forwardShareState && (null == backgroundImg || '' == backgroundImg)){
|
Feng.error("分享页主页背景不能为空");
|
return
|
}
|
if(null == purchaseInstructions || '' == purchaseInstructions){
|
Feng.error("购买须知不能为空");
|
return
|
}
|
let obj = {
|
id: $('#id').val(),
|
img: img,
|
name: name,
|
code: code,
|
listDescribe: listDescribe,
|
infoDescribe: infoDescribe,
|
price: price,
|
unitPrice: unitPrice,
|
total: total,
|
startNumber: startNumber,
|
restrictedQuantity: restrictedQuantity,
|
seckillState: seckillState,
|
activityPrice: activityPrice,
|
forwardShareState: forwardShareState,
|
backgroundImg: backgroundImg,
|
purchaseInstructions: purchaseInstructions,
|
frequency: frequency,
|
frequencyTime: JSON.stringify(frequencyTime),
|
pointTime: JSON.stringify(pointTime),
|
number: number,
|
exposureCrowd: CouponInfo.exposureCrowd
|
}
|
if(null != dateTime && '' != dateTime){
|
obj.activityStartTime = dateTime.split(' - ')[0];
|
obj.activityEndTime = dateTime.split(' - ')[1];
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/coupon/editCoupon", function (data) {
|
if(data.code == 200){
|
Feng.success("编辑成功!");
|
window.parent.Coupon.table.refresh();
|
CouponInfo.close();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("编辑失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(obj);
|
ajax.start();
|
};
|
|
|
CouponInfo.showExposureCrowd = function(){
|
var index = layer.open({
|
type: 2,
|
title: '用户标签设置',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/exposureCrowd/showExposureCrowd?objectType=2&id=' + $('#id').val() + "&page=CouponInfo"
|
});
|
this.layerIndex = index;
|
}
|
|
|
//投放时间点添加
|
CouponInfo.addPointTime = function(){
|
var pointTimeDiv='<div class="form-group">\n' +
|
' <label class="col-sm-3 control-label"></label>\n' +
|
' <div class="col-sm-2">\n' +
|
' <input class="form-control pointTime">\n' +
|
' </div>\n' +
|
' <div class="col-sm-1">\n' +
|
' <i class="fa fa-minus-square" onclick="CouponInfo.subtractPointTime(this)" style="font-size:24px"></i>\n' +
|
' </div>\n' +
|
' </div>';
|
$(".pointTime").last().parent().parent().after(pointTimeDiv);
|
//初始化时间选择器
|
$('.pointTime').each(function (e, i) {
|
layui.use('laydate', function() {
|
var laydate = layui.laydate;
|
laydate.render({
|
// 绑定元素
|
elem: i,
|
// 类型:时间
|
type: 'time',
|
range:true,
|
// 格式:时分秒
|
format: 'HH:mm:ss',
|
|
});
|
});
|
});
|
}
|
|
//投放时间点删除
|
CouponInfo.subtractPointTime = function(e){
|
$(e).parent().parent().remove();
|
}
|
|
$(function () {
|
// 初始化头像上传
|
var avatarUp = new $WebUpload("img");
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
var avatarUp = new $WebUpload("backgroundImg");
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
|
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);
|
}
|
}
|
|
|
$('#seckillState').on('change', function () {
|
const v = $(this).val();
|
if(v == 0){
|
$('#seckill').hide();
|
$('#activityPrice').val('');
|
$('#dateTime').val('');
|
}
|
if(v == 1){
|
$('#seckill').show();
|
}
|
})
|
$('#forwardShareState').on('change', function () {
|
const v = $(this).val();
|
if(v == 0){
|
$('#forwardShare').hide();
|
}
|
if(v == 1){
|
$('#forwardShare').show();
|
var avatarUp = new $WebUpload("backgroundImg");
|
avatarUp.setUploadBarId("progressBar");
|
avatarUp.init();
|
}
|
})
|
|
if($('#id').val() != ''){
|
editor.ready(function() {
|
editor.setContent($('#purchaseInstructions').val())
|
});
|
}
|
|
//投放频率切换
|
$('#frequency').on('change', function () {
|
var frequencyVal = $(this).val();
|
$(".selectpicker").selectpicker('val',"");
|
if(frequencyVal==2){
|
$("#zhouSelectpicker").hide();
|
$("#yueSelectpicker").show();
|
$("#nullSelectpicker").hide();
|
}else if(frequencyVal==1){
|
$("#zhouSelectpicker").show();
|
$("#yueSelectpicker").hide();
|
$("#nullSelectpicker").hide();
|
}else{
|
$("#zhouSelectpicker").hide();
|
$("#yueSelectpicker").hide();
|
$("#nullSelectpicker").show();
|
}
|
})
|
//编辑回显投放频率类型
|
var frequencyInput = $('#frequencyInput').val();
|
if(frequencyInput==2){
|
$("#zhouSelectpicker").hide();
|
$("#yueSelectpicker").show();
|
$("#nullSelectpicker").hide();
|
}else if(frequencyInput==1){
|
$("#zhouSelectpicker").show();
|
$("#yueSelectpicker").hide();
|
$("#nullSelectpicker").hide();
|
}else{
|
$("#zhouSelectpicker").hide();
|
$("#yueSelectpicker").hide();
|
$("#nullSelectpicker").show();
|
}
|
//编辑回显投放频率时间
|
var obj = eval('(' + $("#frequencyTimeInput").val() + ')');
|
$(".selectpicker").selectpicker('val',obj );
|
});
|