Commit 1fd82056 authored by 陈家荣's avatar 陈家荣

2222

parent 66894048
...@@ -28,18 +28,22 @@ var checkLimitAction = function(req) { ...@@ -28,18 +28,22 @@ var checkLimitAction = function(req) {
res.json('success'); res.json('success');
} else { } else {
// 获取到用户行为限制记录 // 获取到用户行为限制记录
var limit_actions = forumLimitActionRef.limit_actions; if(forumLimitActionRef){
for (var i = 0; i < limit_actions.length; i += 1) { var limit_actions = forumLimitActionRef.limit_actions;
var limit_action = limit_actions[i]; for (var i = 0; i < limit_actions.length; i += 1) {
var flag = compareTime(new Date(), limit_action.begin_time, limit_action.end_time); var limit_action = limit_actions[i];
//把flag和limit_action_type 放进session var flag = compareTime(new Date(), limit_action.begin_time, limit_action.end_time);
var obj = { //把flag和limit_action_type 放进session
result : flag, var obj = {
code : limit_action.limit_action_type result : flag,
} code : limit_action.limit_action_type
req.session.mobileForumUser.limit_actions.push(obj); }
res.json('success'); req.session.mobileForumUser.limit_actions.push(obj);
} res.json('success');
}
}else{
res.json('success');
}
} }
}); });
}else{ }else{
......
...@@ -14,21 +14,21 @@ module.exports = function(app) { ...@@ -14,21 +14,21 @@ module.exports = function(app) {
}; };
//格式化日期 (格式:年-月-日) //格式化日期 (格式:年-月-日)
function date_format(date) { // function date_format(date) {
return moment(date).format('YYYY/MM/DD'); // return moment(date).format('YYYY-MM-DD');
} // }
//判断时间是否在指定范围 //判断时间是否在指定范围
function compareTime(now, begin_time, end_time) { // function compareTime(now, begin_time, end_time) {
now = date_format(now); // now = date_format(now);
begin_time = date_format(begin_time); // begin_time = date_format(begin_time);
end_time = date_format(end_time); // end_time = date_format(end_time);
if (moment(now).isSame(begin_time) || moment(now).isSame(end_time)) { //如果等于开始时间或者结束时间 // if (moment(now).isSame(begin_time) || moment(now).isSame(end_time)) { //如果等于开始时间或者结束时间
return true; // return true;
} else { // } else {
return moment(now).isBetween(begin_time, end_time); // return moment(now).isBetween(begin_time, end_time);
} // }
} // }
//新增或更新论坛行为限制 //新增或更新论坛行为限制
router.post('/limitActionRef/createOrUpdate', function(req, res, next) { router.post('/limitActionRef/createOrUpdate', function(req, res, next) {
...@@ -50,8 +50,8 @@ router.post('/limitActionRef/createOrUpdate', function(req, res, next) { ...@@ -50,8 +50,8 @@ router.post('/limitActionRef/createOrUpdate', function(req, res, next) {
for (var i in selects) { for (var i in selects) {
for (var j in results) { for (var j in results) {
if (selects[i] === results[j]._id.toString()) { if (selects[i] === results[j]._id.toString()) {
var begin_time = moment().format('YYYY-MM-DD'); var begin_time = moment(new Date()).format('YYYY-MM-DD');
var end_time = moment().add(results[j].limit_time, 'days').format('YYYY-MM-DD'); var end_time = moment(new Date()).add(results[j].limit_time, 'days').format('YYYY-MM-DD');
var obj = { var obj = {
limit_action: selects[i], limit_action: selects[i],
limit_action_type: results[j].limit_action_type, limit_action_type: results[j].limit_action_type,
......
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