Authored by ping

抽签活动


'use strict';
var $ = require('jquery'),
common=require('../common/common');
var e = new common.edit("#activityForm");
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);
});
}
if (prizeList) {
var prizeObj = JSON.parse(prizeList)[0];
$("#prize").val(prizeObj.prize);
$("#whiteList").val(prizeObj.whiteList);
$("#realUserNum").val(prizeObj.realUserNum);
$("#sockUserNum").val(prizeObj.sockUserNum);
}
});
e.init();
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 = [{
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);
}
});
});
... ...
//商家管理
'use strict';
var $ = require('jquery'),
common=require('../common/common');
var ENUM={
status:{1:'开启',0:'关闭',2:'未过期'}
}
new common.dropDown({el:"#status"});
$('#filter-btn').on('click',function(){
g.reload(1);
});
var g=new common.grid({
el:'#basicTable',
parms:function(){
return {
"status":common.util.__input("status"),
"activityName":common.util.__input("activityName")
};
},
columns:[
{display:"活动ID",name:"id"},
{display:"活动名称",name:"activityName"},
{display:"状态",name:"status",render:function(item){
var str = ENUM.status[item.status];
var now = parseInt(new Date().getTime() / 1000);
if (item.endTime < now) {
str += "&nbsp;&nbsp;已过期";
}
return str;
}},
{display:"活动时间",name:"createTime",render:function(item) {
return item.beginTimeStr + "&nbsp;-&nbsp;" + item.endTimeStr;
}},
{display:"中奖信息",name:"winInfo",render:function(item) {
var str = [];
str.push("参与人数:");
str.push(item.winInfo.totalAttend);
str.push("(");
str.push(item.winInfo.virtualNum);
str.push(")&nbsp;&nbsp;&nbsp;中奖人数:");
str.push(item.winInfo.totalWin);
str.push("(");
str.push(item.winInfo.virtualWinNum);
str.push(")&nbsp;&nbsp;&nbsp;<font color='red'>奖池剩余:");
str.push(item.winInfo.totalSurplus);
str.push("(");
str.push(item.winInfo.virtualSurplus);
str.push(")</font>");
return str.join("");
}},
{display:"操作",name:"",render:function(item){
var HtmArr=[];
HtmArr.push('<a href="/activity/drawline/update/'+item.activityId+'" href="javascript:void(0);" class="btn btn-info btn-xs">编辑</a>');
if (item.status == 0) {
HtmArr.push('<a data-index="'+item.__index+'" href="javascript:void(0);" class="openshops btn btn-success btn-xs">开启</a>');
} else if (item.status == 1) {
HtmArr.push('<a data-index="'+item.__index+'" href="javascript:void(0);" class="closeshops btn btn-danger btn-xs">关闭</a>');
}
return HtmArr.join('');
}}
]
})
g.init("/activity/drawline/indexPage");
var Bll={
toast:function(content,url,id){
common.dialog.confirm("温馨提示",content,function(){
common.util.__ajax({
url:url,
data:{activityId:id}
},function(){
g.reload();
});
});
}
}
//关闭活动
$('#basicTable').on('click', '.closeshops', function() {
var item=g.rows[$(this).data("index")];
Bll.toast("确定要关闭此活动吗?","/activity/drawline/close",item.id);
});
//开启活动
$('#basicTable').on('click', '.openshops', function() {
var item=g.rows[$(this).data("index")];
Bll.toast("确定要开启此活动吗?","/activity/drawline/open",item.id);
});
//shopsstatus
\ No newline at end of file
... ...
/**
* Created by ping.huang 2016-03-02
*/
//接口主域
exports.domain = require('../config/common.js').domain;
exports.domain ="http://172.16.6.246:8081/platform/";
//路由配置
exports.res = [
{
//排队抽签活动
route: '/activity/drawline/index',
method: 'GET',
view: 'pages/activity/index',
src: '/activity/index',
data: {
gridurl:'/supplier/store/indexPage',
pagetitle:{
level1title:"活动管理",
level2title:"抽奖活动管理",
level3title:"抽奖活动列表"
}
}
}, {
//获取列表数据
route: '/activity/drawline/indexPage',
method: 'POST',
url:"/DrawlineActivityRest/getDrawlineActivityList",
params:[
{name: 'activityName', type: 'String'},
{name: 'status', type: 'Number'},
{name: 'size', type: 'Number'},
{name: 'page', type: 'Number'}
]
}, {
// 关闭活动
route: '/activity/drawline/close',
method: 'POST',
url : "/DrawlineActivityRest/closeActivity",
params:[
{name:"activityId",type:"Number"}
]
}, {
// 开启活动
route: '/activity/drawline/open',
method: 'POST',
url : "/DrawlineActivityRest/openActivity",
params:[
{name:"activityId",type:"Number"}
]
}, {
// 新增抽签活动页面渲染
route: '/activity/drawline/add',
method: 'GET',
view: 'pages/activity/edit',
src:'/activity/edit',
data:{
pageTitel:"添加抽奖活动",
action:'/activity/drawline/addsave',
data:{
activityId:0,
backgroundStyle:"",
prizeList: ""
}
}
}, {
// 保存新增抽签活动
route: '/activity/drawline/addsave',
method: 'POST',
url: '/DrawlineActivityRest/addDrawlineActivity',
params:[
{name: 'activityName',type: 'string'},
{name: 'beginTimeStr',type: 'string'},
{name: 'endTimeStr',type: 'string'},
{name: 'topBanner',type: 'string'},
{name: 'backgroundStyle',type: 'string'},
{name: 'activityDesc',type: 'string'},
{name: 'prizeList',type: 'string'}
]
}, {
// 修改活动页面渲染
route: '/activity/drawline/update/:activityId',
method: 'GET',
view: 'pages/activity/edit',
url : "/DrawlineActivityRest/getDrawlineActivityDetail",
params:[{
name:'activityId',
type:'Number'
}],
data:{
pageTitel : "修改抽奖活动",
action : '/activity/drawline/updatesave'
},
src:'/activity/edit'
}, {
// 保存修改抽签活动
route: '/activity/drawline/updatesave',
method: 'POST',
url: '/DrawlineActivityRest/updateDrawlineActivity',
params:[
{name: 'activityId',type: 'Number'},
{name: 'activityName',type: 'string'},
{name: 'beginTimeStr',type: 'string'},
{name: 'endTimeStr',type: 'string'},
{name: 'topBanner',type: 'string'},
{name: 'backgroundStyle',type: 'string'},
{name: 'activityDesc',type: 'string'},
{name: 'prizeList',type: 'string'}
]
}
];
... ...
<div class="pageheader">
<div class="media">
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
<div class="media-body">
<ul class="breadcrumb">
<li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="">抽奖活动管理</a></li>
<li>抽奖活动列表</li>
</ul>
<div>
<div style="width: 30%;float: left;">
<h4>{{pageTitel}}</h4>
</div>
</div>
</div>
</div>
</div>
<div class="contentpanel">
<div class="row">
<div class="col-md-12">
<div id="activityForm" role="form" class="form-horizontal form-bordered" method="post" action="{{action}}">
<input type="hidden" id="activityId" value="{{data.activityId}}" />
<input type="hidden" id="backgroundStyle" value="{{data.backgroundStyle}}" />
<input type="hidden" id="prizeList" value="{{data.prizeList}}" />
<div class="panel panel-default">
{{# data}}
<div class="panel-heading">
<h4 class="panel-title">{{pageTitel}}</h4>
</div><!-- panel-heading -->
<div class="panel-body">
<div class="row">
<div class="form-group">
<label class="col-sm-2 control-label">活动名称<span class="red">*</span></label>
<div class="col-sm-8">
<input type="text" id="activityName" placeholder="活动名称" class="form-control" required value="{{activityName}}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">活动时间<span class="red">*</span></label>
<div class="col-sm-3">
<input type="text" class="form-control" jsaction="time:end:endTimeStr" id="beginTimeStr" required placeholder="活动开始时间" value="{{beginTimeStr}}" readonly>
</div>
<div class="col-sm-3">
<input type="text" class="form-control" jsaction="time:start:beginTimeStr" id="endTimeStr" required placeholder="活动结束时间" value="{{endTimeStr}}" readonly >
</div>
<!-- readonly require-->
</div>
<div class="form-group">
<label class="col-sm-2 control-label">奖品类型<span class="red">*</span></label>
<div class="col-sm-3">
<select name="prizeType" id="prizeType" value='{{prizeType}}' required class="form-control">
<option value="3">限购码</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">奖品设置<span class="red">*</span></label>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon">限购码ID:<span class="red">*</span></span>
<input type="text" form="activityForm" name="prize" id="prize" class="form-control" value="{{ prize}}" placeholder="限购码ID" required>
</div>
<div class="input-group">
<span class="input-group-addon">白名单:<span class="red">*</span></span>
<input type="text" form="activityForm" name="whiteList" id="whiteList" class="form-control" value="{{ whiteList}}" placeholder="请输入UID,用逗号隔开" required>
</div>
<div class="input-group">
<span class="input-group-addon">真实用户中奖数:<span class="red">*</span></span>
<input type="number" form="activityForm" name="realUserNum" id="realUserNum" class="form-control" value="{{ realUserNum}}" placeholder="请输入数量" required>
</div>
<div class="input-group">
<span class="input-group-addon">马甲用户中奖数:<span class="red">*</span></span>
<input type="number" form="activityForm" name="sockUserNum" id="sockUserNum" class="form-control" value="{{ sockUserNum}}" placeholder="请输入数量" required>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">内容管理<span class="red">*</span></label>
<div class="col-sm-10">
<div class="input-group col-sm-4">
<div class="col-sm-3">
<label class="">顶部banner:<span class="red">*</span></label>
</div>
<div class="col-sm-7">
<input type="file" id="topBanner" name="topBanner" value="{{topBanner}}" placeholder="顶部banner" />
</div>
</div>
<div class="input-group col-sm-10">
<div class="col-sm-2">
<label class="">背景样式:<span class="red">*</span></label>
</div>
<div class="col-sm-1">
<input type="file" id="backgroundStyle1" name="backgroundStyle1" placeholder="背景样式" />
</div>
<div class="col-sm-1">
<input type="file" id="backgroundStyle2" name="backgroundStyle2" placeholder="背景样式" />
</div>
<div class="col-sm-1">
<input type="file" id="backgroundStyle3" name="backgroundStyle3" placeholder="背景样式" />
</div>
<div class="col-sm-1">
<input type="file" id="backgroundStyle4" name="backgroundStyle4" placeholder="背景样式" />
</div>
<div class="col-sm-1">
<input type="file" id="backgroundStyle5" name="backgroundStyle5" placeholder="背景样式" />
</div>
<div class="col-sm-1">
<input type="file" id="backgroundStyle6" name="backgroundStyle6" placeholder="背景样式" />
</div>
<div class="col-sm-1">
<input type="file" id="backgroundStyle7" name="backgroundStyle7" placeholder="背景样式" />
</div>
<div class="col-sm-1">
<input type="file" id="backgroundStyle8" name="backgroundStyle8" placeholder="背景样式" />
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">活动说明:</label>
<div class="col-sm-8">
<input type="text" id="activityDesc" placeholder="活动说明" class="form-control" value="{{activityDesc}}">
</div>
</div>
</div>
</div>
{{/ data}}
<div class="panel-footer">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<a href="javascript:;" class="btn btn-default" onclick="javascript:history.go(-1);">取消</a>
<button type="submit" class="btn btn-success mr5" data-loading-text="保存中..." id="btnReview">保存</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
... ...
<div class="pageheader">
<div class="media">
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
{{#pagetitle}}
<div class="media-body">
<ul class="breadcrumb">
<li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="">{{level1title}}</a></li>
<li>{{level2title}}</li>
</ul>
<div>
<div style="width: 30%;float: left;">
<h4>{{level3title}}</h4>
</div>
</div>
</div>
{{/pagetitle}}
</div>
</div>
<div class="contentpanel">
<div class="panel panel-default" style="margin-bottom:10px;">
<div class="panel-heading">
<a href="/activity/drawline/add" class="btn btn-success"><i class="fa fa-plus"></i> 添加抽奖活动</a>
</div>
<div class="panel-body">
<div class="row">
<select name="status" id="status" tabindex="-1" title="" class="select2-offscreen brandBtn-group">
<option value="-1" selected="">活动状态</option>
<option value="1">开启</option>
<option value="0">关闭</option>
<option value="2">未过期</option>
</select>
<div class="form-group col-md-2">
<input name="activityName" id="activityName" type="text" value="" class="form-control" placeholder="请输入活动名称" />
</div>
<a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
<a id="all-btn" href="" class="btn btn-info">全部</a>
</div>
</div>
<input type="hidden" id="url" value="/supplier/store/indexPage">
<div class="panel panel-primary-head">
<div id="basicTable" class="dataTables_wrapper no-footer">
<div class="dataTables_length" id="storeadmin_Tabel"></div>
</div>
</div>
</div>
</div>
... ...