|
|
var $ = require('jquery'),
|
|
|
common=require('../common/common');
|
|
|
common = require('../../common/common');
|
|
|
var e = new common.edit("#activityForm", {
|
|
|
"bucket" : "activity"
|
|
|
"bucket": "activity"
|
|
|
});
|
|
|
|
|
|
e.on("render", function() {
|
|
|
e.on("render", function () {
|
|
|
|
|
|
});
|
|
|
|
|
|
var bgStyle = $("#backgroundStyle").val();
|
|
|
var prizeList = $("#prizeList").val();
|
|
|
if (bgStyle) {
|
|
|
var arr = bgStyle.split(",");
|
|
|
$(arr).each(function(index, item) {
|
|
|
$("#backgroundStyle"+ (index + 1)).attr("value", item);
|
|
|
});
|
|
|
var arr = bgStyle.split(",");
|
|
|
$(arr).each(function (index, item) {
|
|
|
$("#backgroundStyle" + (index + 1)).attr("value", item);
|
|
|
});
|
|
|
}
|
|
|
if (prizeList) {
|
|
|
var prizeObj = JSON.parse(prizeList)[0];
|
|
|
$("#prizeId").val(prizeObj.prizeId);
|
|
|
$("#prize").val(prizeObj.prize);
|
|
|
$("#whiteList").val(prizeObj.whiteList);
|
|
|
$("#realUserNum").val(prizeObj.realUserNum);
|
|
|
$("#sockUserNum").val(prizeObj.sockUserNum);
|
|
|
$("#prizeType").val(prizeObj.prizeType);
|
|
|
var prizeObj = JSON.parse(prizeList)[0];
|
|
|
$("#prizeId").val(prizeObj.prizeId);
|
|
|
$("#prize").val(prizeObj.prize);
|
|
|
$("#whiteList").val(prizeObj.whiteList);
|
|
|
$("#realUserNum").val(prizeObj.realUserNum);
|
|
|
$("#sockUserNum").val(prizeObj.sockUserNum);
|
|
|
$("#prizeType").val(prizeObj.prizeType);
|
|
|
}
|
|
|
|
|
|
function dealTotalHours() {
|
|
|
var beginTimeStr = $("#beginTimeStr").val();
|
|
|
var endTimeStr = $("#endTimeStr").val();
|
|
|
if (beginTimeStr != "" && endTimeStr != "") {
|
|
|
var bDate = new Date(beginTimeStr);
|
|
|
var eDate = new Date(endTimeStr);
|
|
|
var hours = eDate.getTime() - bDate.getTime();
|
|
|
$("#totalHours").html("总计时间:" + parseInt(hours / (1000 * 60 * 60)) + " 小时");
|
|
|
} else {
|
|
|
$("#totalHours").html("");
|
|
|
}
|
|
|
var beginTimeStr = $("#beginTimeStr").val();
|
|
|
var endTimeStr = $("#endTimeStr").val();
|
|
|
if (beginTimeStr != "" && endTimeStr != "") {
|
|
|
var bDate = new Date(beginTimeStr);
|
|
|
var eDate = new Date(endTimeStr);
|
|
|
var hours = eDate.getTime() - bDate.getTime();
|
|
|
$("#totalHours").html("总计时间:" + parseInt(hours / (1000 * 60 * 60)) + " 小时");
|
|
|
} else {
|
|
|
$("#totalHours").html("");
|
|
|
}
|
|
|
}
|
|
|
dealTotalHours();
|
|
|
$("#beginTimeStr,#endTimeStr").change(function() {
|
|
|
dealTotalHours();
|
|
|
$("#beginTimeStr,#endTimeStr").change(function () {
|
|
|
dealTotalHours();
|
|
|
});
|
|
|
|
|
|
e.init();
|
|
|
e.on("validate", function() {
|
|
|
if(new Date($("#beginTimeStr").val()).getTime() >= new Date($("#endTimeStr").val()).getTime()) {
|
|
|
return "开始时间必须小于结束时间";
|
|
|
}
|
|
|
e.on("validate", function () {
|
|
|
if (new Date($("#beginTimeStr").val()).getTime() >= new Date($("#endTimeStr").val()).getTime()) {
|
|
|
return "开始时间必须小于结束时间";
|
|
|
}
|
|
|
});
|
|
|
|
|
|
e.on("validate",function() {
|
|
|
var bkStyle = [];
|
|
|
bkStyle.push(!($("#backgroundStyle1").attr("value")) ? "" : $("#backgroundStyle1").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle2").attr("value")) ? "" : $("#backgroundStyle2").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle3").attr("value")) ? "" : $("#backgroundStyle3").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle4").attr("value")) ? "" : $("#backgroundStyle4").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle5").attr("value")) ? "" : $("#backgroundStyle5").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle6").attr("value")) ? "" : $("#backgroundStyle6").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle7").attr("value")) ? "" : $("#backgroundStyle7").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle8").attr("value")) ? "" : $("#backgroundStyle8").attr("value"));
|
|
|
$("#backgroundStyle").val(bkStyle.join(","));
|
|
|
var prizeObj = [{
|
|
|
prizeId : $("#prizeId").val(),
|
|
|
prizeType : $("#prizeType").val(),
|
|
|
prize : $("#prize").val(),
|
|
|
whiteList : $("#whiteList").val(),
|
|
|
realUserNum : $("#realUserNum").val(),
|
|
|
sockUserNum : $("#sockUserNum").val()
|
|
|
}];
|
|
|
$("#prizeList").val(JSON.stringify(prizeObj));
|
|
|
return true;
|
|
|
e.on("validate", function () {
|
|
|
var bkStyle = [];
|
|
|
bkStyle.push(!($("#backgroundStyle1").attr("value")) ? "" : $("#backgroundStyle1").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle2").attr("value")) ? "" : $("#backgroundStyle2").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle3").attr("value")) ? "" : $("#backgroundStyle3").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle4").attr("value")) ? "" : $("#backgroundStyle4").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle5").attr("value")) ? "" : $("#backgroundStyle5").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle6").attr("value")) ? "" : $("#backgroundStyle6").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle7").attr("value")) ? "" : $("#backgroundStyle7").attr("value"));
|
|
|
bkStyle.push(!($("#backgroundStyle8").attr("value")) ? "" : $("#backgroundStyle8").attr("value"));
|
|
|
$("#backgroundStyle").val(bkStyle.join(","));
|
|
|
var prizeObj = [{
|
|
|
prizeId: $("#prizeId").val(),
|
|
|
prizeType: $("#prizeType").val(),
|
|
|
prize: $("#prize").val(),
|
|
|
whiteList: $("#whiteList").val(),
|
|
|
realUserNum: $("#realUserNum").val(),
|
|
|
sockUserNum: $("#sockUserNum").val()
|
|
|
}];
|
|
|
$("#prizeList").val(JSON.stringify(prizeObj));
|
|
|
return true;
|
|
|
});
|
|
|
$("#btnReview").click(function(){
|
|
|
e.submit($("#activityForm").attr("action"),function(option){
|
|
|
option.success=function(res){
|
|
|
res = res.data;
|
|
|
if(res.code == "200") {
|
|
|
e.$tip("提交成功", function() {
|
|
|
location.href="/activity/drawline/index"
|
|
|
}, 'growl-success');
|
|
|
}else{
|
|
|
e.$tip(res.message);
|
|
|
}
|
|
|
},
|
|
|
option.error=function(res){
|
|
|
e.$tip(res.message);
|
|
|
}
|
|
|
});
|
|
|
$("#btnReview").click(function () {
|
|
|
e.submit($("#activityForm").attr("action"), function (option) {
|
|
|
option.success = function (res) {
|
|
|
if (res.code == "200") {
|
|
|
e.$tip("提交成功", function () {
|
|
|
location.href = "/activity/drawline/index"
|
|
|
}, 'growl-success');
|
|
|
} else {
|
|
|
e.$tip(res.message);
|
|
|
}
|
|
|
};
|
|
|
option.error = function (res) {
|
|
|
e.$tip(res.message);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
//输入限制
|
|
|
$(".number").on("keyup", function() {
|
|
|
$(this).val($(this).val().replace(/\D/g, ''));
|
|
|
$(".number").on("keyup", function () {
|
|
|
$(this).val($(this).val().replace(/\D/g, ''));
|
|
|
}); |
...
|
...
|
|