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

创建积分活动+奖品库存

parent 66dc9e26
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
str += `<option value="${i}">${item}</option>` str += `<option value="${i}">${item}</option>`
} }
}) })
let dom = `<select id='prizeType${index}' class='form-control' name=''> let dom = `<select id='prizeType${index}' class='form-control' name='' onchange="changePrizeType(this, ${index})">
${str} ${str}
</select>` </select>`
return dom; return dom;
...@@ -270,12 +270,7 @@ ...@@ -270,12 +270,7 @@
title: '奖励积分数量', title: '奖励积分数量',
formatter: function(value, row, index) { formatter: function(value, row, index) {
let str = ''; let str = '';
if (data[index].prizeType === 1) { str = `<input id='prizeTypeNum${index}' class='form-control' type='text' name='' value='${data[index].prizeTypeNum}'>`
str = `<input id='prizeTypeNum${index}' class='form-control' type='text' name='' value='${data[index].prizeTypeNum}'>`
} else {
str = '';
// str = `<input id='prizeTypeNum${index}' class='form-control' type='text' name='' value=''>`
}
var html = $.common.sprintf(str, index, value); var html = $.common.sprintf(str, index, value);
return html; return html;
} }
...@@ -295,6 +290,24 @@ ...@@ -295,6 +290,24 @@
return html; return html;
} }
}, },
{
field: 'isInfinite',
align: 'center',
title: '奖品库存',
formatter: function(value, row, index) {
let str = '';
if (data[index].isInfinite !== '') {
str = `<div class="radio-box"><input type="radio" name="isInfinite${index}" value="1" checked="${data[index].isInfinite} === 1" onclick="changeInfinite(this, ${index})"/>有限库存</div>
<div class="radio-box"><input type="radio" name="isInfinite${index}" value="2" checked="${data[index].isInfinite} === 2" onclick="changeInfinite(this, ${index})"/>无限库存</div>`
} else {
str = `<div class="radio-box"><input type="radio" name="isInfinite${index}" value="1" checked="${data[index].isInfinite} === 1" onclick="changeInfinite(this, ${index})"/>有限库存</div>
<div class="radio-box"><input type="radio" name="isInfinite${index}" value="2" checked="${data[index].isInfinite} === 2" onclick="changeInfinite(this, ${index})"/>无限库存</div>`
}
var html = $.common.sprintf(str, index, value);
return html;
}
},
{ {
field: 'prizeNum', field: 'prizeNum',
align: 'center', align: 'center',
...@@ -486,13 +499,14 @@ ...@@ -486,13 +499,14 @@
prizeImgSelect: "", prizeImgSelect: "",
winPrizeNum: "", winPrizeNum: "",
prizeType: 1, prizeType: 1,
prizeTypeNum: "", prizeTypeNum: 0,
isInfinite: 1,
prizeNum: 0,
winningProbability: "", winningProbability: "",
prizeDescribe: "", prizeDescribe: "",
residue: "", residue: ""
prizeNum: ""
}; };
for( var i = 0; i < 20; i++) { for( var i = 0; i < 2; i++) {
data.push(obj) data.push(obj)
} }
$.table.init(options); $.table.init(options);
...@@ -639,6 +653,7 @@ ...@@ -639,6 +653,7 @@
|| !$("#showPicSelect"+index).attr('src') || !$("#showPicSelect"+index).attr('src')
|| !$("#prizeType"+index).val() || !$("#prizeType"+index).val()
|| !$("#winningProbability"+index).val() || !$("#winningProbability"+index).val()
|| !$("input[name=isInfinite"+index+"]:checked").val()
|| !$("#prizeNum"+index).val() || !$("#prizeNum"+index).val()
|| !$("#prizeDescribe"+index).val() || !$("#prizeDescribe"+index).val()
) { ) {
...@@ -650,7 +665,12 @@ ...@@ -650,7 +665,12 @@
temp.prizeImgSelect = $("#showPicSelect"+index).attr('src'); temp.prizeImgSelect = $("#showPicSelect"+index).attr('src');
temp.prizeType = $("#prizeType"+index).val(); temp.prizeType = $("#prizeType"+index).val();
temp.prizeTypeNum = temp.prizeType == '1' ? $("#prizeTypeNum"+index).val() : 0; temp.prizeTypeNum = temp.prizeType == '1' ? $("#prizeTypeNum"+index).val() : 0;
temp.prizeNum = $("#prizeNum"+index).val(); temp.isInfinite = $("input[name=isInfinite"+index+"]:checked").val();
if (temp.isInfinite === '1') {
temp.prizeNum = $("#prizeNum"+index).val();
} else {
temp.prizeNum = 0;
}
temp.winningProbability = $("#winningProbability"+index).val(); temp.winningProbability = $("#winningProbability"+index).val();
temp.prizeDescribe = $("#prizeDescribe"+index).val(); temp.prizeDescribe = $("#prizeDescribe"+index).val();
} }
...@@ -699,6 +719,22 @@ ...@@ -699,6 +719,22 @@
} }
}) })
} }
// 奖品类型切换
function changePrizeType (item, index) {
if (item.value === '1') {
$('#prizeTypeNum' + index).show(); // 填积分数量
} else {
$('#prizeTypeNum' + index).hide(); // 不填数量
}
}
// 库存切换
function changeInfinite(item, index) {
if (item.value === '1') {
$('#prizeNum' + index).show(); // 填数量
} else if (item.value === '2') {
$('#prizeNum' + index).hide(); // 无限库存,不填数量
}
}
// 展示已配置的优惠券列表 // 展示已配置的优惠券列表
function showList (index) { function showList (index) {
nowShowData = data[index]; nowShowData = data[index];
...@@ -981,6 +1017,10 @@ ...@@ -981,6 +1017,10 @@
.search_ipt .layui-input { .search_ipt .layui-input {
width: 200px; width: 200px;
} }
.radio-box input[type=radio]{
vertical-align: middle;
}
</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