activate.js 938 Bytes
/**
 * 激活点击统计 controller
 * @author: wsl<shuiling.wang@yoho.cn>
 * @date: 2017/03/21
 */

'use strict';

const Model = require('../models/activate');

const index = (req, res, next) => {
    let uid = req.user.uid;

    Model.canLogin(uid).then(canLogin => {
        if (canLogin === 'N') {
            return next();
        } else {
            res.render('activate', {
                module: '3party',
                page: 'activate',
                layout: false
            });
        }
    }).catch(next);
};

const getList = (req, res, next) => {
    let uid = req.user.uid;

    Model.getList({
        uid: uid,
        activateTimeBegin: req.query.startTime ? req.query.startTime + ' 00:00:00' : '',
        activateTimeEnd: req.query.endTime ? req.query.endTime + ' 23:59:59' : ''
    }).then(result => {
        res.json(result.data.list);
    }).catch(next);
};


module.exports = {
    index,
    getList
};