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

创建积分活动

parent 33341010
;(function ($) {
//这里放入插件代码
var RemoteSearchPerformance = function (element, options) {
this.$element = $(element);
this.options = $.extend(true, {}, $.fn.remoteSearchPerformance.defaults, options);
this.id = $(element).attr('id');
this.ulID = '#' + this.id + '_ul';
this.ulFoucus = false;
// Method overrides
this.render = this.options.render || this.render;
this.select = this.options.select || this.select;
this.ajax = $.extend({}, $.fn.remoteSearchPerformance.defaults.ajax, this.options.ajax);
this.listen();
}
RemoteSearchPerformance.prototype = {
listen: function () {
this.$element.on('blur', $.proxy(this.blur, this))
.on('keyup', $.proxy(this.keyup, this));
this.$element.parent('div.remote_wrapper').on('click',this.ulID, $.proxy(this.click, this));
},
blur: function (e) {
var that = this;
e.stopPropagation();
e.preventDefault();
setTimeout(function () {
if (!that.ulFoucus) {
that.$element.val(that.$element.attr('data-name'));
that.hide();
}
}, 150)
},
keyup: function (e) {
e.stopPropagation();
e.preventDefault();
switch (e.keyCode) {
case 40:
// down arrow
case 38:
// up arrow
break;
case 9:
// tab
case 13:
// enter
this.ajaxer();
case 27:
// escape
break;
default:
this.ajaxer();
}
},
hide: function () {
$(this.ulID).remove();
return this;
},
ajaxer: function () {
var that = this,
keyword = that.$element.val();
busiType = window.typeRadio;
couType = window.typeCoupe;
// Query changed
that.keyword = keyword;
// Cancel last timer if set
if (that.ajax.timerId) {
clearTimeout(that.ajax.timerId);
that.ajax.timerId = null;
}
// Query is good to send, set a timer
that.ajax.timerId = setTimeout(function() {
var params = {
keyword : keyword,
busiType: busiType,
couType: couType,
bindType: '1,4'
};
var jAjax = $.post;
jAjax(that.ajax.url, params, function(data){
return that.render(data.rows);
});
that.ajax.timerId = null;
}, that.ajax.timeout);
return that;
},
render: function (data) {
this.ulFoucus = false;
var liList = data || [];
var num = this._getNum();
//添加 ul
if($(this.ulID).length == 0) {
this.$element.after("<ul id='" + this.id + "_ul' class='remote_search remote_search_top'></ul>");
};
//添加li
var str = "";
if(num) {
if(liList.length) {
for(var i = 0; i < liList.length; i++) {
str += "<li data-id='"+liList[i].couponId+"' data-name='"+liList[i].title+"' title='"+liList[i].title+"' value='"+liList[i].couponId+"'>" + liList[i].title + "</li>";
}
} else {
str = "<li data-id='' data-name=''>搜索无数据</li>"
}
} else {
this.$element.attr('data-name',"");
this.$element.attr('data-id',"");
}
$(this.ulID).html(str);
var bodyHeight = $(document.body).height();
var offsetTop = this.$element.offset().top;
var height = $(this.ulID).outerHeight(true);
if(offsetTop + height > bodyHeight){
$(this.ulID).addClass('remote_search_bottom').removeClass('remote_search_top');
}else{
$(this.ulID).addClass('remote_search_top').removeClass('remote_search_bottom');
}
return this;
},
click: function (e) {
e.stopPropagation();
e.preventDefault();
var dataName = $(e.target).attr('data-name');
var dataID = $(e.target).attr('data-id');
this.$element.val(dataName);
this.$element.attr('data-name',dataName);
this.$element.attr('data-id',dataID);
this.options.chose(dataName,dataID);
this.ulFoucus = true;
return this.hide();
},
_getNum: function(){
return this.$element.val().length;
}
}
$.fn.remoteSearchPerformance = function (option) {
return this.each(function () {
var $this = $(this),
data = $this.data('remoteSearchPerformance'),
options = typeof option === 'object' && option;
if (!data) {
$this.data('remoteSearchPerformance', (data = new RemoteSearchPerformance(this, options)));
}
if (typeof option === 'string') {
data[option]();
}
});
}
$.fn.remoteSearchPerformance.defaults = {
hiddenVal: '',
chose: function () { },
ajax: {
url: null,
timeout: 300,
method: 'get',
timerId: null
},
success: function(res){
}
}
$.fn.remoteSearchPerformance.Constructor = RemoteSearchPerformance;
})(jQuery);
\ No newline at end of file
......@@ -43,6 +43,8 @@
<script th:src="@{/ruoyi/js/ry-ui.js?v=4.6.1}"></script>
<!--远程搜索下拉框-->
<script th:src="@{/js/remote-search-performance.js}"></script>
<!--远程搜索下拉框:积分抽奖配置使用-->
<script th:src="@{/js/remote-search-coupon-list.js}"></script>
</div>
<!-- ztree树插件 -->
......
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<head>
<th:block th:include="include :: header('添加活动')"/>
<th:block th:include="include :: bootstrap-fileinput-css" />
<style>
.layui-form {
padding: 20px;
}
.main_type, .money, .scope_application, .sendType,.phoneNumber,.playMethod {
margin-bottom: 20px;
}
</head>
.phoneNumber,.playMethod {
display: none;
}
.labelName {
display: inline-block;
width: 100px;
text-align: right;
}
input {
border: 1px solid #ddd;
border-radius: 4px;
background: transparent;
outline: none;
padding-left: 5px;
height: 30px;
}
.main_type .form-control.kv-fileinput-caption {
height: 42px !important;
}
.prompt {
margin-left: 100px !important;
}
.main_type input, .sendType input,.playMethod input {
margin-top: -2px;
margin-right: 5px;
}
.main_type span, .sendType span, .playMethod span {
margin-right: 12px;
line-height: 28px;
}
.layui-form .money input {
width: 60px;
}
.main_bottom .describe, .main_bottom .sendTime {
margin-bottom: 20px;
}
.describe,.main_type {
display: flex;
}
.sendTime {
display: flex;
}
.sendTime input {
margin-top: -6px;
margin-right: 5px;
}
.bottom_btn {
width: 25%;
text-align: center;
}
select {
border: 1px solid #ddd;
border-radius: 4px;
background: transparent;
outline: none;
height: 30px;
width: 200px;
}
.required {
font-style: normal;
color: red;
}
.ibox-content {
border-style: none;
border-width: 0px;
}
.main_type .file-footer-buttons .kv-file-remove {
display: none !important;
}
.selectScore {
display: flex;
align-items: center;
}
.selectScore p {
margin: 0;
}
.selectScore button {
margin: 0 12px;
}
.selectScore span {
color: #ccc;
}
.scoreTable {
margin-bottom: 12px;
}
</style>
</head>
<body class="white-bg">
<form id="form-user-add" class="layui-form">
<body class="white-bg">
<!--奖品项配置表单-->
<form id="form-user-add" class="layui-form">
<div>
基础信息
</div>
......@@ -167,12 +74,24 @@
</div>
</div>
<div class="main_bottom">
<div class="main_type">
<span class="labelName"><i class="required">*</i>预估玩此活动的总人数:</span>
<div class="layui-input-block" style="display: flex">
<input type="text" id="estimatedNum" autocomplete="off" class="layui-input" placeholder="预估玩此活动的总人数">
</div>
</div>
<div class="describe">
<span class="labelName">
<i class="required">*</i>活动规则:
</span>
<textarea id="activityRule" class="form-control" style="min-height: 160px;"></textarea>
</div>
<div class="describe">
<span class="labelName">
<i class="required">*</i>概率公示:
</span>
<textarea id="probabilityPublicity" class="form-control" style="min-height: 160px;"></textarea>
</div>
<div class="sendTime">
<span class="labelName"><i class="required">*</i>是否上线:</span>
<div class="layui-input-block" style="display: flex">
......@@ -194,12 +113,31 @@
<button type="button" class="btn btn-primary" onclick="create()">确 定</button>
</div>
</div>
</form>
<div id="detailsFormList" class="details-form-list">
<!--奖品详情-->
<div class="details-pop-inner">
<button type="button" class="btn btn-primary" onclick="addCoupon()">添加</button>
<button type="button" class="btn btn-primary" onclick="closeCoupon()">关闭窗口</button>
<div class="scoreTable">
<div class="row">
<div class="col-sm-12">
<div class="col-sm-12 select-table table-striped">
<table id="details-table"></table>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</form>
<th:block th:include="include :: footer"/>
<script th:src="@{/js/jquery.tmpl.js}"></script>
<th:block th:include="include :: bootstrap-fileinput-js" />
<script type="text/javascript">
<th:block th:include="include :: footer"/>
<script th:src="@{/js/jquery.tmpl.js}"></script>
<th:block th:include="include :: bootstrap-fileinput-js" />
<script type="text/javascript">
var platformUrl = `[[${platformUrl}]]`
var prefix = ctx + "sweet/sweetIntegralActivity";
let showIndex = null;
......@@ -218,6 +156,7 @@
let itemId = '';
let activitySize = false;
var options = {
id: "bootstrap-table",
data: data,
pagination: false,
showSearch: false,
......@@ -284,7 +223,7 @@
align: 'center',
title: '奖品类型',
formatter: function(value, row, index) {
let arr = ['谢谢惠顾', '积分', '代金券', '满减券', '优先购买', '实物'];
let arr = ['积分', '优惠券', '实物', '登登登VIP'];
let str = '';
arr.forEach((item,i)=> {
i++
......@@ -300,6 +239,21 @@
return dom;
}
},
{
field: 'prizeTypeNum',
align: 'center',
title: '奖励积分数量',
formatter: function(value, row, index) {
let str = '';
if (data[index].prizeTypeNum && (data[index].prizeType === 1)) {
str = `<input id='prizeTypeNum${index}' class='form-control' type='text' name='' value='${data[index].prizeTypeNum}'>`
} else {
str = `<input id='prizeTypeNum${index}' class='form-control' type='text' name='' value=''>`
}
var html = $.common.sprintf(str, index, value);
return html;
}
},
{
field: 'winningProbability',
align: 'center',
......@@ -331,20 +285,35 @@
}
},
{
field: 'winnersNum',
field: 'prizeDescribe',
align: 'center',
title: '中奖人数',
title: '奖品描述',
formatter: function(value, row, index) {
let str = '';
if (data[index].winnersNum) {
str = `<input id='winnersNum${index}' class='form-control' type='text' name='' value='${data[index].winnersNum}'>`
if (data[index].prizeNum) {
str = `<input id='prizeDescribe${index}' class='form-control' type='text' name='' value='${data[index].prizeDescribe}'>`
} else {
str = `<input id='winnersNum${index}' class='form-control' type='text' name='' value=''>`
str = `<input id='prizeDescribe${index}' class='form-control' type='text' name='' value=''>`
}
var html = $.common.sprintf(str, index, value);
return html;
}
},
// {
// field: 'winnersNum',
// align: 'center',
// title: '中奖人数',
// formatter: function(value, row, index) {
// let str = '';
// if (data[index].winnersNum) {
// str = `<input id='winnersNum${index}' class='form-control' type='text' name='' value='${data[index].winnersNum}'>`
// } else {
// str = `<input id='winnersNum${index}' class='form-control' type='text' name='' value=''>`
// }
// var html = $.common.sprintf(str, index, value);
// return html;
// }
// },
{
field: 'winPrizeNum',
align: 'center',
......@@ -361,30 +330,78 @@
return '0'
}
}
},
{
field: '',
align: 'center',
title: '操作',
formatter: function(value, row, index) {
let str = '';
if (data[index].prizeTitle) {
str = `<button type="button" class="btn btn-primary" onclick="showList(` + index + `)">查看列表</button>`
}
var html = $.common.sprintf(str, index, value);
return html;
}
}
]
};
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
var nowList = []; // 当前编辑的奖品详情列表
var detailsOptions = {
id: "details-table",
data: nowList,
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
sidePagination: "client",
columns: [
{
field: 'index',
align: 'center',
title: "序号",
formatter: function (value, row, index) {
return index+1;
}
},{
field: 'index',
align: 'center',
title: "序号",
formatter: function (value, row, index) {
return index+1;
}
},
{
field: 'prizeTitle',
align: 'center',
title: '奖品名称',
formatter: function(value, row, index) {
let str = '';
if (data[index].prizeTitle) {
str = "<input id='prizeTitle"+index+"' class='form-control' type='text' name='' value='"+data[index].prizeTitle+"'>"
} else {
activitySize = false;
str = "<input id='prizeTitle"+index+"' class='form-control' type='text' name='' value=''>"
}
})
var html = $.common.sprintf(str, index, value);
return html;
}
},
{
field: '',
align: 'center',
title: '操作',
formatter: function(value, row, index) {
let str = '';
str = `<button type="button" class="btn btn-primary" onclick="deleteCoupon(` + index + `)">删除</button>`
var html = $.common.sprintf(str, index, value);
return html;
}
}
]
};
$(function() {
itemId = getUrlParms('id')
function getUrlParms(name){
......@@ -407,6 +424,8 @@
$("#integral").val(res.activityNum);
$("#activityRule").val(res.activityRules);
$("#ActivityName").val(res.activityTitle);
$("#estimatedNum").val(res.estimatedNum);
$("#probabilityPublicity").val(res.probabilityPublicity);
// activityType: 1,
courierType = res.expressFeeType;
if (courierType == 2) {
......@@ -417,7 +436,6 @@
if (online == 2) {
$("input[name='online'][value='2']").attr('checked', true).siblings().removeAttr('checked');
}
// prizeList: data,
timeType = res.timeType;
if (timeType == 2) {
......@@ -441,10 +459,11 @@
prizeTitle: "",
prizeImgInit: "",
prizeImgSelect: "",
winnersNum: "",
winPrizeNum: "",
prizeType: "",
prizeTypeNum: "",
winningProbability: "",
prizeDescribe: "",
residue: "",
prizeNum: ""
};
......@@ -452,10 +471,32 @@
data.push(obj)
}
$.table.init(options);
console.log($.table);
}
});
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;
}
})
$("input[name=sendType]").change((e)=>{
timeType = e.target.value;
if (timeType == 1) {
......@@ -544,7 +585,15 @@
$("#viewImg").attr('src', showPicture)
})
function create() {
if (!$("#ActivityName").val() || !$("#ActivityType").val() || !showPicture || !$("#integral").val() || !$("#activityRule").val() || !$("#viewImg").attr('src')) {
if (!$("#ActivityName").val()
|| !$("#ActivityType").val()
|| !showPicture
|| !$("#integral").val()
|| !$("#activityRule").val()
|| !$("#viewImg").attr('src')
|| !$("#estimatedNum").val()
|| !$("#probabilityPublicity").val()
) {
return layer.msg('请将必填信息填写完整!')
}
if (timeType == 2) {
......@@ -560,23 +609,44 @@
return
}
let flag = false;
let prizeListArr = []
data = data.map((item,index)=>{
if (!$("#prizeTitle"+index).val()||!$("#showPic"+index).attr('src')||!$("#showPicSelect"+index).attr('src')||!$("#winnersNum"+index).val()||!$("#prizeType"+index).val()||!$("#winningProbability"+index).val()||!$("#prizeNum"+index).val()) {
let temp = {};
if (!$("#prizeTitle"+index).val()
|| !$("#showPic"+index).attr('src')
|| !$("#showPicSelect"+index).attr('src')
|| !$("#prizeType"+index).val()
|| !$("#winningProbability"+index).val()
|| !$("#prizeNum"+index).val()
|| !$("#prizeDescribe"+index).val()
) {
flag = true
} else {
item.prizeTitle = $("#prizeTitle"+index).val();
item.prizeImgInit = $("#showPic"+index).attr('src');
item.prizeImgSelect = $("#showPicSelect"+index).attr('src');
item.winnersNum = $("#winnersNum"+index).val();
item.prizeType = $("#prizeType"+index).val();
item.winningProbability = $("#winningProbability"+index).val();
item.prizeNum = $("#prizeNum"+index).val();
}
return {...item};
temp.prizeTitle = $("#prizeTitle"+index).val();
temp.prizeImgInit = $("#showPic"+index).attr('src');
temp.prizeImgSelect = $("#showPicSelect"+index).attr('src');
temp.prizeType = $("#prizeType"+index).val();
temp.prizeTypeNum = temp.prizeType == '1' ? $("#prizeTypeNum"+index).val() : 0;
temp.prizeNum = $("#prizeNum"+index).val();
temp.winningProbability = $("#winningProbability"+index).val();
temp.prizeDescribe = $("#prizeDescribe"+index).val();
}
// TODO
temp.prizeTitle = '名称';
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.prizeType = $("#prizeType"+index).val();
temp.winningProbability = 1;
temp.prizeNum = 1;
temp.prizeTypeNum = temp.prizeType == '1' ? 1: 0;
temp.prizeDescribe = "描述";
prizeListArr.push(temp);
// return {...item};
})
if (flag) {
return layer.msg('请将表格内容填写完整!')
}
// if (flag) {
// return layer.msg('请将表格内容填写完整!')
// }
let datas = {
activityImg: showPicture,
activityNum: $("#integral").val(),
......@@ -587,10 +657,14 @@
integralActivityId: itemId || '',
endTime: $.common.dateFormat($("#endTime").val(), 'yyyy-MM-dd HH:mm:ss') , //
isOnline: online,
prizeList: data,
prizeList: prizeListArr,
startTime: $.common.dateFormat($("#startTime").val(), 'yyyy-MM-dd HH:mm:ss'),
timeType: timeType
timeType: timeType,
estimatedNum: $("#estimatedNum").val(),
probabilityPublicity: $("#probabilityPublicity").val()
}
console.log('========', data);
console.log('========', datas);
let url = '/sweet/integralActivity/create';
let type = 'post';
if (itemId) {
......@@ -614,7 +688,140 @@
}
})
}
function showList (index) {
console.log(index);
data[index].prizeId;
$("#detailsFormList").show();
// 拿列表数据
$.table.init(detailsOptions);
}
function addCoupon () {
console.log('添加优惠券===');
nowList.push({
id: 1,
name: 'hello'
});
// 添加数据
}
function deleteCoupon(index) {
console.log('删除优惠券===');
}
function closeCoupon () {
$("#detailsFormList").hide();
}
</script>
<style>
.layui-form {
padding: 20px;
}
.main_type, .money, .scope_application, .sendType,.phoneNumber,.playMethod {
margin-bottom: 20px;
}
.phoneNumber,.playMethod {
display: none;
}
.labelName {
display: inline-block;
width: 100px;
text-align: right;
}
input {
border: 1px solid #ddd;
border-radius: 4px;
background: transparent;
outline: none;
padding-left: 5px;
height: 30px;
}
.main_type .form-control.kv-fileinput-caption {
height: 42px !important;
}
.prompt {
margin-left: 100px !important;
}
.main_type input, .sendType input,.playMethod input {
margin-top: -2px;
margin-right: 5px;
}
.main_type span, .sendType span, .playMethod span {
margin-right: 12px;
line-height: 28px;
}
.layui-form .money input {
width: 60px;
}
.main_bottom .describe, .main_bottom .sendTime {
margin-bottom: 20px;
}
.describe,.main_type {
display: flex;
}
.sendTime {
display: flex;
}
.sendTime input {
margin-top: -6px;
margin-right: 5px;
}
.bottom_btn {
width: 25%;
text-align: center;
}
select {
border: 1px solid #ddd;
border-radius: 4px;
background: transparent;
outline: none;
height: 30px;
width: 200px;
}
.required {
font-style: normal;
color: red;
}
.ibox-content {
border-style: none;
border-width: 0px;
}
.main_type .file-footer-buttons .kv-file-remove {
display: none !important;
}
.selectScore {
display: flex;
align-items: center;
}
.selectScore p {
margin: 0;
}
.selectScore button {
margin: 0 12px;
}
.selectScore span {
color: #ccc;
}
.scoreTable {
margin-bottom: 12px;
}
.details-form-list {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, .5);
display: flex;
justify-content: center;
align-items: center;
}
.details-pop-inner {
width: 800px;
height: 800px;
padding: 10px;
background: #fff;
}
</style>
</script>
</body>
</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