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

Commit 4d0165ef authored by dongchun's avatar dongchun

转盘页面相关功能

parent 01cbbb25
...@@ -150,12 +150,12 @@ ...@@ -150,12 +150,12 @@
<div style="display: flex;align-items: center;"> <div style="display: flex;align-items: center;">
<span class="labelName"><i class="required">*</i>活动时间:</span> <span class="labelName"><i class="required">*</i>活动时间:</span>
<div class="layui-input-block" style="display: flex"> <div class="layui-input-block" style="display: flex">
<input type="radio" value="0" name="sendType" checked><span>长期</span> <input type="radio" value="1" name="sendType" checked><span>长期</span>
<input type="radio" value="1" name="sendType"><span>选择开始结束时间</span> <input type="radio" value="2" name="sendType"><span>选择开始结束时间</span>
<div class="selectTime"> <div class="selectTime">
<input type="text" class="layui-input" id="startTime" placeholder="请选择起始时间"> <input type="text" class="layui-input" id="startTime" autocomplete="off" placeholder="请选择起始时间">
<span>~</span> <span>~</span>
<input type="text" class="layui-input" id="endTime" placeholder="请选择结束时间"> <input type="text" class="layui-input" id="endTime" autocomplete="off" placeholder="请选择结束时间">
</div> </div>
</div> </div>
</div> </div>
...@@ -186,17 +186,17 @@ ...@@ -186,17 +186,17 @@
<span class="labelName"><i class="required">*</i>是否上线:</span> <span class="labelName"><i class="required">*</i>是否上线:</span>
<div class="layui-input-block" style="display: flex"> <div class="layui-input-block" style="display: flex">
<input type="radio" name="online" value="1" checked><span>未上线</span> <input type="radio" name="online" value="1" checked><span>未上线</span>
<input type="radio" name="online" value="2" ><span>已上线</span> <input type="radio" name="online" value="2" style="margin-left: 12px;"><span>已上线</span>
</div> </div>
</div> </div>
<div class="sendTime"> <div class="sendTime">
<span class="labelName"><i class="required">*</i>快递费用:</span> <span class="labelName"><i class="required">*</i>快递费用:</span>
<div class="layui-input-block" style="display: flex"> <div class="layui-input-block" style="display: flex">
<input type="radio" name="sex" value="1" checked><span>包邮</span> <input type="radio" name="sex" value="1" checked><span>包邮</span>
<input type="radio" name="sex" value="2" ><span>到付</span> <input type="radio" name="sex" value="2" style="margin-left: 12px;"><span>到付</span>
<span style="margin-right:12px;"><p>输入金额</p></span>
</div> </div>
<input type="text" id="courierMoney" autocomplete="off" class="layui-input" placeholder="请输入金额"> <!-- <span style="margin-right:12px;"><p>输入金额</p></span>
<input type="text" id="courierMoney" autocomplete="off" class="layui-input" placeholder="请输入金额"> -->
</div> </div>
<div class="bottom_btn"> <div class="bottom_btn">
<!-- <button type="button" class="layui-btn btn btn-primary" lay-filter="formDemo" onclick="create()">创建代金券</button> --> <!-- <button type="button" class="layui-btn btn btn-primary" lay-filter="formDemo" onclick="create()">创建代金券</button> -->
...@@ -223,6 +223,8 @@ ...@@ -223,6 +223,8 @@
let courierMoney = ''; // 快递费用 let courierMoney = ''; // 快递费用
let showPicture = ''; // banner let showPicture = ''; // banner
let online = '1'; // 是否上线 let online = '1'; // 是否上线
let itemId = '';
let activitySize = false;
var options = { var options = {
data: data, data: data,
pagination: false, pagination: false,
...@@ -247,7 +249,7 @@ ...@@ -247,7 +249,7 @@
formatter: function(value, row, index) { formatter: function(value, row, index) {
let str = ''; let str = '';
if (data[index].prizeTitle) { if (data[index].prizeTitle) {
str = "<input id='prizeTitle"+index+"' class='form-control' type='text' name='' value='"+data[index].name+"'>" str = "<input id='prizeTitle"+index+"' class='form-control' type='text' name='' value='"+data[index].prizeTitle+"'>"
} else { } else {
str = "<input id='prizeTitle"+index+"' class='form-control' type='text' name='' value=''>" str = "<input id='prizeTitle"+index+"' class='form-control' type='text' name='' value=''>"
} }
...@@ -336,7 +338,7 @@ ...@@ -336,7 +338,7 @@
} }
}, },
{ {
field: 'send', field: 'WinPrizeNum',
align: 'center', align: 'center',
title: '已发出', title: '已发出',
formatter: function(value, row, index) { formatter: function(value, row, index) {
...@@ -352,8 +354,8 @@ ...@@ -352,8 +354,8 @@
align: 'center', align: 'center',
title: '奖品剩余', title: '奖品剩余',
formatter: function(value, row, index) { formatter: function(value, row, index) {
if (value) { if (itemId) {
return value return row.prizeNum - row.WinPrizeNum
} else { } else {
return '-' return '-'
} }
...@@ -361,12 +363,80 @@ ...@@ -361,12 +363,80 @@
} }
] ]
}; };
layui.use('laydate', function(){
var laydate = layui.laydate;
//执行一个laydate实例
laydate.render({
elem: '#startTime', //指定元素
type: 'datetime'
});
laydate.render({
elem: '#endTime', //指定元素
type: 'datetime'
});
});
$("#ActivityName").blur(function(e) {
if (e.target.value.length > 20) {
activitySize = true;
layer.msg('活动名称限制在20个字符以内!')
return
} else {
activitySize = false;
}
})
$(function() { $(function() {
itemId = getUrlParms('id')
function getUrlParms(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)
return unescape(r[2]);
return null;
}
if (itemId) {
$.ajax({
type: 'get',
url: '/sweet/integralActivity/details',
data: {integralActivityId: itemId},
success:function(e) {
if (e.code == 0) {
let res = e.data;
showPicture = res.activityImg;
$("#viewImg").attr('src', showPicture);
$("#integral").val(res.activityNum);
$("#activityRule").val(res.activityRules);
$("#ActivityName").val(res.activityTitle);
// activityType: 1,
courierType = res.expressFeeType;
if (courierType == 2) {
$("input[name='sex'][value='2']").attr('checked', true).siblings().removeAttr('checked');
}
integralActivityId = res.integralActivityId;
$("#endTime").val($.common.dateFormat(res.endTime, 'yyyy-MM-dd HH:mm:ss'));
online = res.isOnline;
if (online == 2) {
$("input[name='online'][value='2']").attr('checked', true).siblings().removeAttr('checked');
}
// prizeList: data,
$("#startTime").val($.common.dateFormat(res.startTime, 'yyyy-MM-dd HH:mm:ss'));
timeType = timeType;
if (timeType == 2) {
$("input[name='sendType'][value='2']").attr('checked', true).siblings().removeAttr('checked');
}
data = [...res.prizeList]
options.data = data;
setTimeout(()=>{
$.table.init(options);
}, 500)
}
}
})
} else {
let obj = { let obj = {
prizeTitle: "", prizeTitle: "",
prizeImg: "", prizeImg: "",
winnersNum: "", winnersNum: "",
send: "", WinPrizeNum: "",
prizeType: "", prizeType: "",
winningProbability: "", winningProbability: "",
residue: "", residue: "",
...@@ -376,9 +446,16 @@ ...@@ -376,9 +446,16 @@
data.push(obj) data.push(obj)
} }
$.table.init(options); $.table.init(options);
}
}); });
$("input[name=sendType]").change((e)=>{ $("input[name=sendType]").change((e)=>{
timeType = e.target.value; timeType = e.target.value;
if (timeType == 1) {
$("#endTime").val("");
$("#startTime").val("");
}
}) })
$("input[name=sex]").change((e)=>{ $("input[name=sex]").change((e)=>{
courierType = e.target.value; courierType = e.target.value;
...@@ -386,47 +463,11 @@ ...@@ -386,47 +463,11 @@
$("input[name=online]").change((e)=>{ $("input[name=online]").change((e)=>{
online = e.target.value; online = e.target.value;
}) })
function addColumn() {
if (data.length >= 6) {
return layer.msg('最多可上传6个商品!')
}
if (data.length > 0) {
data = data.map((item,index) => {
item.name = $('#prizeTitle'+index).val()
item.winnersNum = $('#winnersNum'+index).val()
item.send = $('#send'+index).val()
item.type = $('#prizeType'+index).val()
item.winningProbability = $('#winningProbability'+index).val()
item.residue = $('#residue'+index).val()
item.prizeNum = $('#prizeNum'+index).val()
return item
})
}
console.log(data, 'data')
var row = {
prizeTitle: "",
prizeImg: "",
winnersNum: "",
send: "",
type: "",
winningProbability: "",
residue: "",
prizeNum: ""
}
data.push(row)
row.prizeImg = 'https://img.zhengzai.tv/other/2021/10/26/17bf7fdea070448aa28d6e86506e4f6d.png';
$("#" + table.options.id).bootstrapTable('insertRow', {
index: data.length, // 你想插入到哪,0表示第一行
row: row
})
console.log(data)
}
function upFile(e) { function upFile(e) {
showIndex = e; showIndex = e;
$("#ceshi").click(); $("#ceshi").click();
} }
$("#ceshi").change((e) => { $("#ceshi").change((e) => {
console.log(e)
if (!e.target.files[0]) { if (!e.target.files[0]) {
return return
} }
...@@ -441,9 +482,7 @@ ...@@ -441,9 +482,7 @@
type: 'POST', type: 'POST',
success: function (res) { success: function (res) {
$("#showPic"+showIndex).attr('src','https://img.zhengzai.tv/' + res.data.ossPath) $("#showPic"+showIndex).attr('src','https://img.zhengzai.tv/' + res.data.ossPath)
console.log(res, res.data.ossPath,showIndex, data[showIndex], '????1')
data[showIndex].prizeImg = 'https://img.zhengzai.tv/' + res.data.ossPath; data[showIndex].prizeImg = 'https://img.zhengzai.tv/' + res.data.ossPath;
console.log(res, res.data.ossPath, '????2')
// $summernote.summernote('insertImage', 'https://img.zhengzai.tv/' + data.data.ossPath) // $summernote.summernote('insertImage', 'https://img.zhengzai.tv/' + data.data.ossPath)
} }
}); });
...@@ -473,39 +512,22 @@ ...@@ -473,39 +512,22 @@
$("#viewImg").attr('src', showPicture) $("#viewImg").attr('src', showPicture)
}) })
function create() { function create() {
/** if (!$("#ActivityName").val() || !$("#ActivityType").val() || !showPicture || !$("#integral").val() || !$("#activityRule").val() || !$("#viewImg").attr('src')) {
* let activityType = ''; // 活动类型
let timeType = ''; // 活动时间类型
let startTime = ''; // 开始时间
let endTime = ''; // 结束时间
let activityRule = ''; // 活动规则
let courierType = ''; // 快递类型
let courierMoney = ''; // 快递费用
*
*
* {
prizeTitle: "",
prizeImg: "",
winnersNum: "",
send: "",
prizeType: "",
winningProbability: "",
residue: "",
prizeNum: ""
},
* **/
console.log(!$("#ActivityName").val(),!$("#ActivityType").val(),!$("#courierMoney").val(),!showPicture,!$("#integral").val(),!$("#activityRule").val(),$("#viewImg").attr('src'))
if (!$("#ActivityName").val() || !$("#ActivityType").val() || !$("#courierMoney").val() || !showPicture || !$("#integral").val() || !$("#activityRule").val() || !$("#viewImg").attr('src')) {
return layer.msg('请将必填信息填写完整!') return layer.msg('请将必填信息填写完整!')
} }
if (timeType == 2) { if (timeType == 2) {
console.log(timeType, '?????') if (!$("#startTime").val() || !$("#endTime").val()) {
if (!$("#startTime").val() || !$("#endTIme").val()) {
return layer.msg('请选择时间!') return layer.msg('请选择时间!')
} }
} else {
$("#startTime").val("")
$("#endTime").val("")
}
if (activitySize) {
layer.msg("活动名称限制在20个字符以内!")
return
} }
let flag = false; let flag = false;
console.log($("#prizeTitle"+1).val())
data = data.map((item,index)=>{ data = data.map((item,index)=>{
if (!$("#prizeTitle"+index).val()||!$("#showPic"+index).attr('src')||!$("#winnersNum"+index).val()||!$("#prizeType"+index).val()||!$("#winningProbability"+index).val()||!$("#prizeNum"+index).val()) { if (!$("#prizeTitle"+index).val()||!$("#showPic"+index).attr('src')||!$("#winnersNum"+index).val()||!$("#prizeType"+index).val()||!$("#winningProbability"+index).val()||!$("#prizeNum"+index).val()) {
flag = true flag = true
...@@ -517,7 +539,7 @@ ...@@ -517,7 +539,7 @@
item.winningProbability = $("#winningProbability"+index).val(); item.winningProbability = $("#winningProbability"+index).val();
item.prizeNum = $("#prizeNum"+index).val(); item.prizeNum = $("#prizeNum"+index).val();
} }
return item; return {...item};
}) })
if (flag) { if (flag) {
return layer.msg('请将表格内容填写完整!') return layer.msg('请将表格内容填写完整!')
...@@ -529,16 +551,22 @@ ...@@ -529,16 +551,22 @@
activityTitle: $("#ActivityName").val(), activityTitle: $("#ActivityName").val(),
activityType: 1, activityType: 1,
expressFeeType: courierType, expressFeeType: courierType,
integralActivityId: '', integralActivityId: itemId || '',
endTime: $("#endTime").val(), endTime: $.common.dateFormat($("#endTime").val(), 'yyyy-MM-dd HH:mm:ss') , //
isOnline: online, isOnline: online,
prizeList: data, prizeList: data,
startTime: $("#startTime").val(), startTime: $.common.dateFormat($("#startTime").val(), 'yyyy-MM-dd HH:mm:ss'),
timeType: timeType timeType: timeType
} }
let url = '/sweet/integralActivity/create';
let type = 'post';
if (itemId) {
url = '/sweet/integralActivity/update'
type = 'put'
}
$.ajax({ $.ajax({
type: 'post', type,
url: '/sweet/integralActivity/create', url,
contentType: "application/json;charset=UTF-8", contentType: "application/json;charset=UTF-8",
data: JSON.stringify(datas), data: JSON.stringify(datas),
success:function(res) { success:function(res) {
...@@ -552,7 +580,6 @@ ...@@ -552,7 +580,6 @@
} }
} }
}) })
console.log(data, $("#" + table.options.id).bootstrapTable('getData'),$("#type0").val(), '???')
} }
</script> </script>
......
...@@ -124,8 +124,8 @@ ...@@ -124,8 +124,8 @@
formatter: function (value, row, index) { formatter: function (value, row, index) {
var actions = []; var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + drawListFlag + '" href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.integralActivityId + '\')"><i class="fa fa-edit"></i>查看中奖名单</a> '); actions.push('<a class="btn btn-success btn-xs ' + drawListFlag + '" href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.integralActivityId + '\')"><i class="fa fa-edit"></i>查看中奖名单</a> ');
actions.push('<a class="btn btn-success btn-xs ' + updateFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.integralActivityId + '\')"></i>编辑</a> '); actions.push('<a class="btn btn-success btn-xs ' + updateFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.integralActivityId + '\')"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + isOnlineFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.integralActivityId + '\')"></i>上下线</a> '); actions.push(`<a class="btn btn-danger btn-xs ${isOnlineFlag}" href="javascript:void(0)" onclick="openModal('${row.integralActivityId}','${row.isOnline}')"></i>上下线</a>`);
actions.push('<a class="btn btn-warning btn-xs ' + exportExcelFlag + '" href="javascript:void(0)" onclick="exportExcel(\'' + row.integralActivityId + '\')"></i>导出中奖信息</a> '); actions.push('<a class="btn btn-warning btn-xs ' + exportExcelFlag + '" href="javascript:void(0)" onclick="exportExcel(\'' + row.integralActivityId + '\')"></i>导出中奖信息</a> ');
return actions.join(''); return actions.join('');
} }
...@@ -135,6 +135,29 @@ ...@@ -135,6 +135,29 @@
$.table.init(options); $.table.init(options);
}); });
function openModal(id, data) {
console.log(id, data, 'dhsa')
let title = '';
let lineId = null;
if (data == 1) {
title = '上线';
lineId = 2
} else {
title = '下线';
lineId = 1
}
$.modal.confirm(`确定要${title}此活动吗`, function() {
$.ajax({
type: 'put',
url: '/sweet/integralActivity/isOnline',
data: {integralActivityId: id, isOnline: lineId},
success:function(e) {
console.log(e)
$("button[name=refresh]").click();
}
})
});
}
</script> </script>
</body> </body>
</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