gift.js 901 Bytes
/**
 * 个人中心---兑换礼品卡
 * @author gaohongwei <hongwei.gao@yoho.cn>
 * @date: 2016/9/7
 */
'use strict';

const mRoot = '../models';
const giftModel = require(`${mRoot}/gift-service`); // user  model

/**
 * 礼品卡页面
 */
exports.index = (req, res, next) => {
    let uid = req.user.uid;

    let responseData = {
        module: 'home',
        page: 'gift'
    };

    // 真实数据输出
    req.ctx(giftModel).index(req.query, uid).then(result => {
        responseData.meGiftPage = true;
        Object.assign(responseData, result);
        res.render('gift', responseData);
    }).catch(next);
};

/**
 * 个人中心-兑换礼品卡提交返回信息
 */
exports.exchange = (req, res, next) => {
    let uid = req.user.uid;

    // 真实数据输出
    req.ctx(giftModel).exchange(req, req.body, uid).then(result => {
        res.json(result);
    }).catch(next);
};