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

创建积分活动

parent 65a713fd
...@@ -117,8 +117,22 @@ ...@@ -117,8 +117,22 @@
<div id="detailsFormList" class="details-form-list"> <div id="detailsFormList" class="details-form-list">
<!--奖品详情--> <!--奖品详情-->
<div class="details-pop-inner"> <div class="details-pop-inner">
<button type="button" class="btn btn-primary" onclick="addCoupon()">添加</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="closeCoupon()">关闭窗口</button>
<hr>
<div class="coupon-select" style="display: none">
<!--选择优惠券-->
<div class="scope_application" id="scope_application">
<span class="labelName"><i class="required">*</i>选择优惠券:</span>
<div class="search_ipt" style="position: relative;display: inline;">
<input type="text" id="searchIpt" autocomplete="off" class="layui-input" placeholder="全部">
<ul id="dataList" style="position: absolute;"></ul>
</div>
<button type="button" class="btn btn-primary" onclick="addCouponFun()">确认添加当前优惠券</button>
</div>
</div>
<hr>
<div class="scoreTable"> <div class="scoreTable">
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
...@@ -140,6 +154,8 @@ ...@@ -140,6 +154,8 @@
<script type="text/javascript"> <script type="text/javascript">
var platformUrl = `[[${platformUrl}]]` var platformUrl = `[[${platformUrl}]]`
var prefix = ctx + "sweet/sweetIntegralActivity"; var prefix = ctx + "sweet/sweetIntegralActivity";
var candyfix = ctx + "candy/coupon";
let showIndex = null; let showIndex = null;
// 初始化数据, 可以由后台传过来 // 初始化数据, 可以由后台传过来
var data = []; // 表格内数据集合 var data = []; // 表格内数据集合
...@@ -348,6 +364,12 @@ ...@@ -348,6 +364,12 @@
] ]
}; };
var nowList = []; // 当前编辑的奖品详情列表 var nowList = []; // 当前编辑的奖品详情列表
var nowPrizeId = ''; // 当前编辑的奖品ID
var integralActivityId = ''; // 当前编辑的活动ID
let searchVal = ''; // 优惠券输入框内数据
let searchData = []; // 优惠券搜索总数据
let nowCouponSelectId = ''; // 当前选择的优惠券ID
let nowCouponSelectTitle = ''; // 当前选择的优惠券title
var detailsOptions = { var detailsOptions = {
id: "details-table", id: "details-table",
data: nowList, data: nowList,
...@@ -365,27 +387,21 @@ ...@@ -365,27 +387,21 @@
formatter: function (value, row, index) { formatter: function (value, row, index) {
return index+1; return index+1;
} }
},{ },
field: 'index', {
field: 'couponId',
align: 'center', align: 'center',
title: "序号", title: "优惠券ID",
formatter: function (value, row, index) { formatter: function (value, row, index) {
return index+1; return data[index].couponId;
} }
}, },
{ {
field: 'prizeTitle', field: 'couponTitle',
align: 'center', align: 'center',
title: '奖品名称', title: "优惠券名称",
formatter: function(value, row, index) { formatter: function (value, row, index) {
let str = ''; return data[index].couponTitle;
if (data[index].prizeTitle) {
str = "<input id='prizeTitle"+index+"' class='form-control' type='text' name='' value='"+data[index].prizeTitle+"'>"
} else {
str = "<input id='prizeTitle"+index+"' class='form-control' type='text' name='' value=''>"
}
var html = $.common.sprintf(str, index, value);
return html;
} }
}, },
{ {
...@@ -622,6 +638,7 @@ ...@@ -622,6 +638,7 @@
) { ) {
flag = true flag = true
} else { } else {
temp.prizeId = data[index].prizeId ? data[index].prizeId : '';
temp.prizeTitle = $("#prizeTitle"+index).val(); temp.prizeTitle = $("#prizeTitle"+index).val();
temp.prizeImgInit = $("#showPic"+index).attr('src'); temp.prizeImgInit = $("#showPic"+index).attr('src');
temp.prizeImgSelect = $("#showPicSelect"+index).attr('src'); temp.prizeImgSelect = $("#showPicSelect"+index).attr('src');
...@@ -632,6 +649,7 @@ ...@@ -632,6 +649,7 @@
temp.prizeDescribe = $("#prizeDescribe"+index).val(); temp.prizeDescribe = $("#prizeDescribe"+index).val();
} }
// TODO // TODO
temp.prizeId = data[index].prizeId ? data[index].prizeId : '';
temp.prizeTitle = '名称'; temp.prizeTitle = '名称';
temp.prizeImgInit = "https://img.zhengzai.tv/other/2021/12/03/9b70f3c310f0452bb4544f9d7d5f482e.png"; temp.prizeImgInit = "https://img.zhengzai.tv/other/2021/12/03/9b70f3c310f0452bb4544f9d7d5f482e.png";
temp.prizeImgSelect = "https://img.zhengzai.tv/other/2021/12/03/9b70f3c310f0452bb4544f9d7d5f482e.png"; temp.prizeImgSelect = "https://img.zhengzai.tv/other/2021/12/03/9b70f3c310f0452bb4544f9d7d5f482e.png";
...@@ -689,19 +707,47 @@ ...@@ -689,19 +707,47 @@
}) })
} }
function showList (index) { function showList (index) {
console.log(index); console.log('showList===', data[index]);
data[index].prizeId; nowPrizeId = data[index].prizeId;
$("#detailsFormList").show(); integralActivityId = data[index].integralActivityId;
// 拿列表数据 // 拿列表数据
$.ajax({
type: 'get',
url: '/sweet/integralActivityPrizeRelation/list',
data: {prizeId: nowPrizeId},
success: function (e) {
if (e.code == 0) {
let res = e.data;
}
}
});
$.table.init(detailsOptions); $.table.init(detailsOptions);
$("#detailsFormList").show();
}
function addCouponShow () {
$(".coupon-select").show();
} }
function addCoupon () { function addCouponFun () {
console.log('添加优惠券==='); console.log('添加优惠券===');
nowList.push({
id: 1, let postData = {
name: 'hello' "couponId": nowCouponSelectId,
"couponTitle": nowCouponSelectTitle,
"integralActivityId": integralActivityId,
"prizeId": nowPrizeId
};
$.ajax({
type: 'post',
url: '/sweet/integralActivityPrizeRelation/create',
data: JSON.stringify(postData),
contentType: 'application/json',
success: function (e) {
if (e.code == 0) {
alert('添加成功!');
}
}
}); });
// 添加数据
} }
function deleteCoupon(index) { function deleteCoupon(index) {
console.log('删除优惠券==='); console.log('删除优惠券===');
...@@ -709,6 +755,64 @@ ...@@ -709,6 +755,64 @@
function closeCoupon () { function closeCoupon () {
$("#detailsFormList").hide(); $("#detailsFormList").hide();
} }
// 远程搜索券
function getMallList() {
let data = {
keyword: searchVal,
busiType: 0,
pageSize: 20,
pageNum: 1,
bindType: 2
}
let str = '';
promiseMethods(candyfix + "/list",'post',data,'application/x-www-form-urlencoded').then(res=>{
if (res.rows.length>0) {
searchData = res.rows;
searchData.forEach((item,index)=>{
str+= `<li class="selectData" onclick="selectOne('${item.couponId}', 'couponId')">${item.title}</li>`
})
$('#dataList').html(str);
} else {
$('#dataList').html('<li style="width:100%;text-align:center;color:#ccc;">--- 暂无数据 ---</li>');
}
})
}
function promiseMethods(url,type,data,contentType) {
return new Promise((resolve,reject)=>{
$.ajax({
url,
type,
data,
contentType,
success:function(res) {
resolve(res);
}
})
})
}
function selectOne(id, name) {
searchData.some( item => {
if (item[name] == id) {
nowCouponSelectTitle = item.title;
return $("#searchIpt").val(item.title);
}
} )
nowCouponSelectId = id;
console.log('选择===', id, nowCouponSelectTitle);
}
$("#searchIpt").focus(function(){
getMallList()
$('#dataList').show()
});
$("#searchIpt").blur(function(){
setTimeout(() => {
$('#dataList').hide()
}, 500);
});
$("#searchIpt").keyup(function(){
searchVal = $("#searchIpt").val()
getMallList()
});
</script> </script>
<style> <style>
...@@ -822,6 +926,45 @@ ...@@ -822,6 +926,45 @@
padding: 10px; padding: 10px;
background: #fff; background: #fff;
} }
.search_ipt ul,.search_ipt li{
padding: 0;
margin: 0;
font-style: normal;
list-style: none;
}
.search_ipt ul {
display: none;
position: absolute;
left: 0;
top: 26px;
padding: 5px 0;
z-index: 899;
min-width: 200px;
border: 1px solid #eee;
max-height: 300px;
overflow-y: auto;
background-color: #fff;
border-radius: 2px;
box-sizing: border-box;
box-shadow: 1px 1px 4px rgb(0 0 0 / 8%);
}
.search_ipt li {
background-color: #fff;
cursor: pointer;
padding-left: 10px!important;
color: #999;
padding: 0 10px;
line-height: 36px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.search_ipt li:hover {
background: #F6F6F6;
}
.search_ipt .layui-input {
width: 200px;
}
</style> </style>
</html> </html>
\ No newline at end of file
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