Authored by yyq

notice & join num

@@ -106,6 +106,14 @@ const zeroBuy = { @@ -106,6 +106,14 @@ const zeroBuy = {
106 req.ctx(ActivityModel).saveZerobuyContent(req.body) 106 req.ctx(ActivityModel).saveZerobuyContent(req.body)
107 .then(res.json).catch(next); 107 .then(res.json).catch(next);
108 }, 108 },
  109 + zeroBuyNoticeEdit(req, res, next) {
  110 + req.ctx(ActivityModel).editZerobuyNotice(req.body)
  111 + .then(res.json).catch(next);
  112 + },
  113 + zeroBuyUserJoinNum(req, res, next) {
  114 + req.ctx(ActivityModel).getUserJoinNum(req.body.id)
  115 + .then(res.json).catch(next);
  116 + }
109 }; 117 };
110 118
111 const activity = { 119 const activity = {
@@ -434,7 +434,9 @@ class AdminModel extends global.yoho.BaseModel { @@ -434,7 +434,9 @@ class AdminModel extends global.yoho.BaseModel {
434 {type: 'edit', color: 'info', name: '编辑'}, 434 {type: 'edit', color: 'info', name: '编辑'},
435 {type: 'switch', color: 'info', name: '开启/关闭'}, 435 {type: 'switch', color: 'info', name: '开启/关闭'},
436 {type: 'export', color: 'info', name: '导出'}, 436 {type: 'export', color: 'info', name: '导出'},
437 - {type: 'publish', color: 'danger', name: '开奖'} 437 + {type: 'publish', color: 'danger', name: '开奖'},
  438 + {type: 'notice', color: 'info', name: '悬浮内容'},
  439 + {type: 'joinnum', color: 'info', name: '查看参与人数'}
438 ]; 440 ];
439 441
440 resData.list = _.forEach(result[0], value => { 442 resData.list = _.forEach(result[0], value => {
@@ -732,6 +734,37 @@ class AdminModel extends global.yoho.BaseModel { @@ -732,6 +734,37 @@ class AdminModel extends global.yoho.BaseModel {
732 }); 734 });
733 } 735 }
734 736
  737 + editZerobuyNotice(params) {
  738 + if (!params.id || !params.notice) {
  739 + return Promise.resolve({
  740 + code: 400,
  741 + message: '缺少参数'
  742 + });
  743 + }
  744 + return mysqlCli.update(`update ${TABLE_ACT_PRIZE_PRODUCT} set
  745 + notice = :notice where id = :id`, {
  746 + id: params.id,
  747 + notice: params.notice
  748 + }).then(() => {
  749 + return {
  750 + code: 200,
  751 + message: '操作成功'
  752 + };
  753 + });
  754 + }
  755 +
  756 + getUserJoinNum(actPrizeId) {
  757 + return mysqlCli.query(`select count(distinct uid) as join_num from ${TABLE_ACT_PRIZE_PRODUCT_USER}
  758 + where act_prize_id = :actPrizeId;`, {
  759 + actPrizeId
  760 + }).then(result => {
  761 + return {
  762 + code: 200,
  763 + data: _.get(result, '[0].join_num', 0)
  764 + };
  765 + });
  766 + }
  767 +
735 /** 768 /**
736 * 向参加活动用户发送开奖消息 769 * 向参加活动用户发送开奖消息
737 * @param id 770 * @param id
@@ -36,6 +36,8 @@ router.post('/activity/zerobuy/publish', activity.zeroBuyPublish); @@ -36,6 +36,8 @@ router.post('/activity/zerobuy/publish', activity.zeroBuyPublish);
36 router.get('/activity/zerobuy/export', activity.zeroBuyExport); 36 router.get('/activity/zerobuy/export', activity.zeroBuyExport);
37 router.get('/activity/zerobuy/edit', activity.zeroBuyEdit); 37 router.get('/activity/zerobuy/edit', activity.zeroBuyEdit);
38 router.post('/activity/zerobuy/save', activity.zeroBuySave); 38 router.post('/activity/zerobuy/save', activity.zeroBuySave);
  39 +router.post('/activity/zerobuy/notice', activity.zeroBuyNoticeEdit);
  40 +router.post('/activity/zerobuy/joinnum', activity.zeroBuyUserJoinNum);
39 41
40 // 用户管理[page] 42 // 用户管理[page]
41 router.get('/user/list', user.userListPage); 43 router.get('/user/list', user.userListPage);
@@ -150,4 +150,23 @@ @@ -150,4 +150,23 @@
150 </div> 150 </div>
151 </div> 151 </div>
152 </div> 152 </div>
  153 +
  154 +<div id="notice-modal" class="modal fade in" style="display: none; ">
  155 + <div class="modal-dialog">
  156 + <div class="modal-content">
  157 + <div class="modal-header">
  158 + <a class="close" data-dismiss="modal">×</a>
  159 + <h3>编辑悬浮内容</h3>
  160 + </div>
  161 + <div class="modal-body">
  162 + <input type="text" class="form-control notice-input" placeholder="悬浮内容">
  163 + </div>
  164 + <div class="modal-footer">
  165 + <a class="btn btn-success" data-dismiss="modal">取消</a>
  166 + <a class="btn btn-success sure-notice-btn">确定</a>
  167 + </div>
  168 + </div>
  169 + </div>
  170 +</div>
  171 +
153 <!-- /page content --> 172 <!-- /page content -->
@@ -4,5 +4,8 @@ @@ -4,5 +4,8 @@
4 @date: 2018-12-24 11:43:47 4 @date: 2018-12-24 11:43:47
5 */ 5 */
6 #注意:GO;分割执行块 6 #注意:GO;分割执行块
7 -ALTER TABLE act_prize_product ADD `lottery_info` VARCHAR(800) DEFAULT '' comment '开奖信息'; 7 +ALTER TABLE act_prize_product ADD (
  8 + `notice` VARCHAR(500) DEFAULT '' comment '公告',
  9 + `lottery_info` VARCHAR(800) DEFAULT '' comment '开奖信息'
  10 + );
8 GO; 11 GO;
@@ -14,6 +14,8 @@ function bindListPageEvent() { @@ -14,6 +14,8 @@ function bindListPageEvent() {
14 const $searchKey = $('#search-key'); 14 const $searchKey = $('#search-key');
15 const $statusSwitch = $('#status-switch'); 15 const $statusSwitch = $('#status-switch');
16 const $publishForm = $('#publish-form'); 16 const $publishForm = $('#publish-form');
  17 + const $noticeModal = $('#notice-modal');
  18 + const $noticeInput = $noticeModal.find('.notice-input');
17 19
18 const searchFn = function() { 20 const searchFn = function() {
19 let val = $searchKey.val(); 21 let val = $searchKey.val();
@@ -81,10 +83,11 @@ function bindListPageEvent() { @@ -81,10 +83,11 @@ function bindListPageEvent() {
81 tips[this.name] = this.value; 83 tips[this.name] = this.value;
82 }); 84 });
83 85
84 - if (error) {  
85 - alert('请填写完整各端提示信息后进行开奖');  
86 - return;  
87 - } 86 + // 暂时不限制必填
  87 + // if (error) {
  88 + // alert('请填写完整各端提示信息后进行开奖');
  89 + // return;
  90 + // }
88 91
89 $.ajax({ 92 $.ajax({
90 method: 'post', 93 method: 'post',
@@ -104,6 +107,47 @@ function bindListPageEvent() { @@ -104,6 +107,47 @@ function bindListPageEvent() {
104 }); 107 });
105 }; 108 };
106 109
  110 + const noticeFn = function() {
  111 + let noticeVal = $noticeInput.val();
  112 +
  113 + if (!noticeVal) {
  114 + alert('请填写悬浮内容');
  115 + return;
  116 + }
  117 +
  118 + $.ajax({
  119 + method: 'post',
  120 + url: '/admin/activity/zerobuy/notice',
  121 + data: {
  122 + id: $noticeModal.data('id'),
  123 + notice: noticeVal
  124 + }
  125 + }).then(res => {
  126 + if (res.code === 200) {
  127 + location.reload();
  128 + } else {
  129 + alert(res.message);
  130 + }
  131 + });
  132 + };
  133 +
  134 + const joinnumFn = function() {
  135 + $.ajax({
  136 + method: 'post',
  137 + url: '/admin/activity/zerobuy/joinnum',
  138 + data: {
  139 + id: $(this).data('id')
  140 + }
  141 + }).then(res => {
  142 + if (res.code === 200) {
  143 + $alert.find('.modal-text').text(`该活动当前参与人数为 ${res.data} 人`);
  144 + $alert.modal('show');
  145 + } else {
  146 + alert(res.message);
  147 + }
  148 + });
  149 + };
  150 +
107 $('#search-btn').on('click', searchFn); 151 $('#search-btn').on('click', searchFn);
108 $('.status-switch').on('click', statusFn); 152 $('.status-switch').on('click', statusFn);
109 153
@@ -116,7 +160,15 @@ function bindListPageEvent() { @@ -116,7 +160,15 @@ function bindListPageEvent() {
116 $confirm.data('channel', $(this).data('channel')); 160 $confirm.data('channel', $(this).data('channel'));
117 $confirm.modal('show'); 161 $confirm.modal('show');
118 }); 162 });
  163 + $('.btn-notice').on('click', function() {
  164 + $noticeInput.text('');
  165 + $noticeModal.data('id', $(this).data('id'));
  166 + $noticeModal.modal('show');
  167 + });
  168 + $('.btn-joinnum').on('click', joinnumFn);
  169 +
119 $('.sure-publish-btn').on('click', publishFn); 170 $('.sure-publish-btn').on('click', publishFn);
  171 + $('.sure-notice-btn').on('click', noticeFn);
120 } 172 }
121 173
122 let uploadedFn; 174 let uploadedFn;