me-gift.js 1.19 KB
/**
 * 个人中心---我的礼品卡
 * @author xiaoxiao <xiaoxiao.hao@yoho.cn>
 * @date: 2017/9/1
 */
'use strict';

const meGiftService = require('../models/me-gift-service');

/**
 * 礼品卡列表
 */
exports.index = (req, res, next) => {
    let uid = req.user.uid;
    let responseData = {
        module: 'home',
        page: 'me-gift'
    };

    req.ctx(meGiftService).getList(req.query, uid).then(result => {
        responseData.meGiftPage = true;
        Object.assign(responseData, result);
        res.render('home/gift/me-gift', responseData);
    }).catch(next);
};

/**
 * 消费明细
 */
exports.detail = (req, res, next) => {
    let uid = req.user.uid;
    let responseData = {
        module: 'home',
        page: 'me-gift'
    };

    req.ctx(meGiftService).detailList(req.query, uid).then(result => {
        responseData.meGiftPage = true;
        Object.assign(responseData, result);
        res.render('home/gift/me-detail', responseData);
    }).catch(next);
};

/**
 * 激活礼品卡
 */
exports.activateGift = (req, res, next) => {
    let uid = req.user.uid;

    req.ctx(meGiftService).activateGift(req.body, uid).then(result => {
        res.json(result);
    }).catch(next);
};