Authored by yyq

notice & join num

... ... @@ -106,6 +106,14 @@ const zeroBuy = {
req.ctx(ActivityModel).saveZerobuyContent(req.body)
.then(res.json).catch(next);
},
zeroBuyNoticeEdit(req, res, next) {
req.ctx(ActivityModel).editZerobuyNotice(req.body)
.then(res.json).catch(next);
},
zeroBuyUserJoinNum(req, res, next) {
req.ctx(ActivityModel).getUserJoinNum(req.body.id)
.then(res.json).catch(next);
}
};
const activity = {
... ...
... ... @@ -434,7 +434,9 @@ class AdminModel extends global.yoho.BaseModel {
{type: 'edit', color: 'info', name: '编辑'},
{type: 'switch', color: 'info', name: '开启/关闭'},
{type: 'export', color: 'info', name: '导出'},
{type: 'publish', color: 'danger', name: '开奖'}
{type: 'publish', color: 'danger', name: '开奖'},
{type: 'notice', color: 'info', name: '悬浮内容'},
{type: 'joinnum', color: 'info', name: '查看参与人数'}
];
resData.list = _.forEach(result[0], value => {
... ... @@ -732,6 +734,37 @@ class AdminModel extends global.yoho.BaseModel {
});
}
editZerobuyNotice(params) {
if (!params.id || !params.notice) {
return Promise.resolve({
code: 400,
message: '缺少参数'
});
}
return mysqlCli.update(`update ${TABLE_ACT_PRIZE_PRODUCT} set
notice = :notice where id = :id`, {
id: params.id,
notice: params.notice
}).then(() => {
return {
code: 200,
message: '操作成功'
};
});
}
getUserJoinNum(actPrizeId) {
return mysqlCli.query(`select count(distinct uid) as join_num from ${TABLE_ACT_PRIZE_PRODUCT_USER}
where act_prize_id = :actPrizeId;`, {
actPrizeId
}).then(result => {
return {
code: 200,
data: _.get(result, '[0].join_num', 0)
};
});
}
/**
* 向参加活动用户发送开奖消息
* @param id
... ...
... ... @@ -36,6 +36,8 @@ router.post('/activity/zerobuy/publish', activity.zeroBuyPublish);
router.get('/activity/zerobuy/export', activity.zeroBuyExport);
router.get('/activity/zerobuy/edit', activity.zeroBuyEdit);
router.post('/activity/zerobuy/save', activity.zeroBuySave);
router.post('/activity/zerobuy/notice', activity.zeroBuyNoticeEdit);
router.post('/activity/zerobuy/joinnum', activity.zeroBuyUserJoinNum);
// 用户管理[page]
router.get('/user/list', user.userListPage);
... ...
... ... @@ -150,4 +150,23 @@
</div>
</div>
</div>
<div id="notice-modal" class="modal fade in" style="display: none; ">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>编辑悬浮内容</h3>
</div>
<div class="modal-body">
<input type="text" class="form-control notice-input" placeholder="悬浮内容">
</div>
<div class="modal-footer">
<a class="btn btn-success" data-dismiss="modal">取消</a>
<a class="btn btn-success sure-notice-btn">确定</a>
</div>
</div>
</div>
</div>
<!-- /page content -->
... ...
... ... @@ -4,5 +4,8 @@
@date: 2018-12-24 11:43:47
*/
#注意:GO;分割执行块
ALTER TABLE act_prize_product ADD `lottery_info` VARCHAR(800) DEFAULT '' comment '开奖信息';
ALTER TABLE act_prize_product ADD (
`notice` VARCHAR(500) DEFAULT '' comment '公告',
`lottery_info` VARCHAR(800) DEFAULT '' comment '开奖信息'
);
GO;
... ...
... ... @@ -14,6 +14,8 @@ function bindListPageEvent() {
const $searchKey = $('#search-key');
const $statusSwitch = $('#status-switch');
const $publishForm = $('#publish-form');
const $noticeModal = $('#notice-modal');
const $noticeInput = $noticeModal.find('.notice-input');
const searchFn = function() {
let val = $searchKey.val();
... ... @@ -81,10 +83,11 @@ function bindListPageEvent() {
tips[this.name] = this.value;
});
if (error) {
alert('请填写完整各端提示信息后进行开奖');
return;
}
// 暂时不限制必填
// if (error) {
// alert('请填写完整各端提示信息后进行开奖');
// return;
// }
$.ajax({
method: 'post',
... ... @@ -104,6 +107,47 @@ function bindListPageEvent() {
});
};
const noticeFn = function() {
let noticeVal = $noticeInput.val();
if (!noticeVal) {
alert('请填写悬浮内容');
return;
}
$.ajax({
method: 'post',
url: '/admin/activity/zerobuy/notice',
data: {
id: $noticeModal.data('id'),
notice: noticeVal
}
}).then(res => {
if (res.code === 200) {
location.reload();
} else {
alert(res.message);
}
});
};
const joinnumFn = function() {
$.ajax({
method: 'post',
url: '/admin/activity/zerobuy/joinnum',
data: {
id: $(this).data('id')
}
}).then(res => {
if (res.code === 200) {
$alert.find('.modal-text').text(`该活动当前参与人数为 ${res.data} 人`);
$alert.modal('show');
} else {
alert(res.message);
}
});
};
$('#search-btn').on('click', searchFn);
$('.status-switch').on('click', statusFn);
... ... @@ -116,7 +160,15 @@ function bindListPageEvent() {
$confirm.data('channel', $(this).data('channel'));
$confirm.modal('show');
});
$('.btn-notice').on('click', function() {
$noticeInput.text('');
$noticeModal.data('id', $(this).data('id'));
$noticeModal.modal('show');
});
$('.btn-joinnum').on('click', joinnumFn);
$('.sure-publish-btn').on('click', publishFn);
$('.sure-notice-btn').on('click', noticeFn);
}
let uploadedFn;
... ...