记得上下班打卡 | git大法好,push需谨慎

创建积分活动+优惠券选择

parent 40c5beec
...@@ -114,11 +114,11 @@ ...@@ -114,11 +114,11 @@
</div> </div>
</div> </div>
</form> </form>
<div id="detailsFormList" class="details-form-list"> <div id="detailsFormList" class="details-form-list" style="display: none">
<!--奖品详情--> <!--奖品详情-->
<div class="details-pop-inner"> <div class="details-pop-inner">
<button type="button" class="btn btn-primary" onclick="addCouponShow()">添加</button> <button type="button" class="btn btn-primary" onclick="addCouponShow()">添加</button>
<button type="button" class="btn btn-primary" onclick="closeCoupon()">关闭窗口</button> <button type="button" class="btn btn-primary" onclick="closeCouponShow()">关闭窗口</button>
<hr> <hr>
<div class="coupon-select" style="display: none"> <div class="coupon-select" style="display: none">
<!--选择优惠券--> <!--选择优惠券-->
...@@ -364,12 +364,10 @@ ...@@ -364,12 +364,10 @@
] ]
}; };
var nowList = []; // 当前编辑的奖品详情列表 var nowList = []; // 当前编辑的奖品详情列表
var nowPrizeId = ''; // 当前编辑的奖品ID var nowShowData = {}; // 当前编辑的奖品信息
var integralActivityId = ''; // 当前编辑的活动ID
let searchVal = ''; // 优惠券输入框内数据 let searchVal = ''; // 优惠券输入框内数据
let searchData = []; // 优惠券搜索总数据 let searchData = []; // 优惠券搜索总数据
let nowCouponSelectId = ''; // 当前选择的优惠券ID var nowCouponSelect = {}; // 当前选择的优惠券
let nowCouponSelectTitle = ''; // 当前选择的优惠券title
var detailsOptions = { var detailsOptions = {
id: "details-table", id: "details-table",
data: nowList, data: nowList,
...@@ -393,7 +391,7 @@ ...@@ -393,7 +391,7 @@
align: 'center', align: 'center',
title: "优惠券ID", title: "优惠券ID",
formatter: function (value, row, index) { formatter: function (value, row, index) {
return data[index].couponId; return nowList[index].couponId;
} }
}, },
{ {
...@@ -401,7 +399,7 @@ ...@@ -401,7 +399,7 @@
align: 'center', align: 'center',
title: "优惠券名称", title: "优惠券名称",
formatter: function (value, row, index) { formatter: function (value, row, index) {
return data[index].couponTitle; return nowList[index].couponTitle;
} }
}, },
{ {
...@@ -487,7 +485,6 @@ ...@@ -487,7 +485,6 @@
data.push(obj) data.push(obj)
} }
$.table.init(options); $.table.init(options);
console.log($.table);
} }
}); });
...@@ -681,8 +678,6 @@ ...@@ -681,8 +678,6 @@
estimatedNum: $("#estimatedNum").val(), estimatedNum: $("#estimatedNum").val(),
probabilityPublicity: $("#probabilityPublicity").val() probabilityPublicity: $("#probabilityPublicity").val()
} }
console.log('========', data);
console.log('========', datas);
let url = '/sweet/integralActivity/create'; let url = '/sweet/integralActivity/create';
let type = 'post'; let type = 'post';
if (itemId) { if (itemId) {
...@@ -706,36 +701,40 @@ ...@@ -706,36 +701,40 @@
} }
}) })
} }
// 展示已配置的优惠券列表
function showList (index) { function showList (index) {
console.log('showList===', data[index]); nowShowData = data[index];
nowPrizeId = data[index].prizeId; nowShowData.index = index;
integralActivityId = data[index].integralActivityId; nowList = [];
detailsOptions.data = [];
// 拿列表数据 $.table.destroy("details-table");
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: '/sweet/integralActivityPrizeRelation/list', url: '/sweet/integralActivityPrizeRelation/list',
data: {prizeId: nowPrizeId}, data: { prizeId: nowShowData['prizeId'] },
success: function (e) { success: function (res) {
if (e.code == 0) { nowList = res;
let res = e.data; detailsOptions.data = res;
} setTimeout(()=>{
$.table.init(detailsOptions);
}, 500)
$("#detailsFormList").show();
} }
}); });
$.table.init(detailsOptions);
$("#detailsFormList").show();
} }
function addCouponShow () { function addCouponShow () {
$(".coupon-select").show(); $(".coupon-select").show();
} }
function closeCouponShow () {
$("#detailsFormList").hide();
}
// 添加优惠券
function addCouponFun () { function addCouponFun () {
console.log('添加优惠券===');
let postData = { let postData = {
"couponId": nowCouponSelectId, "couponId": nowCouponSelect.couponId,
"couponTitle": nowCouponSelectTitle, "couponTitle": nowCouponSelect.title,
"integralActivityId": integralActivityId, "integralActivityId": nowShowData['integralActivityId'],
"prizeId": nowPrizeId "prizeId": nowShowData['prizeId']
}; };
$.ajax({ $.ajax({
type: 'post', type: 'post',
...@@ -744,16 +743,29 @@ ...@@ -744,16 +743,29 @@
contentType: 'application/json', contentType: 'application/json',
success: function (e) { success: function (e) {
if (e.code == 0) { if (e.code == 0) {
showList(nowShowData.index);
alert('添加成功!'); alert('添加成功!');
} }
} }
}); });
} }
// 删除优惠券
function deleteCoupon(index) { function deleteCoupon(index) {
console.log('删除优惠券==='); let postData = {
} "integralActivityId": nowShowData['integralActivityId'],
function closeCoupon () { "prizeRelationId": nowList[index]['prizeRelationId']
$("#detailsFormList").hide(); };
$.ajax({
type: 'put',
url: '/sweet/integralActivityPrizeRelation/delete',
data: postData,
success: function (e) {
if (e.code == 0) {
showList(nowShowData.index);
alert('删除成功!');
}
}
});
} }
// 远程搜索券 // 远程搜索券
function getMallList() { function getMallList() {
...@@ -790,15 +802,14 @@ ...@@ -790,15 +802,14 @@
}) })
}) })
} }
// 选择优惠券
function selectOne(id, name) { function selectOne(id, name) {
searchData.some( item => { searchData.some( (item, index) => {
if (item[name] == id) { if (item[name] == id) {
nowCouponSelectTitle = item.title; nowCouponSelect = item;
return $("#searchIpt").val(item.title); return $("#searchIpt").val(item.title);
} }
} ) } )
nowCouponSelectId = id;
console.log('选择===', id, nowCouponSelectTitle);
} }
$("#searchIpt").focus(function(){ $("#searchIpt").focus(function(){
getMallList() getMallList()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment