Blame view

apps/home/controllers/gift.js 901 Bytes
hongweigao authored
1 2 3 4 5 6 7 8
/**
 * 个人中心---兑换礼品卡
 * @author gaohongwei <hongwei.gao@yoho.cn>
 * @date: 2016/9/7
 */
'use strict';

const mRoot = '../models';
OF1706 authored
9
const giftModel = require(`${mRoot}/gift-service`); // user  model
hongweigao authored
10 11 12 13 14 15 16 17 18 19 20 21 22

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

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

    // 真实数据输出
OF1706 authored
23
    req.ctx(giftModel).index(req.query, uid).then(result => {
hongweigao authored
24 25 26 27 28 29 30 31 32 33 34 35 36
        responseData.meGiftPage = true;
        Object.assign(responseData, result);
        res.render('gift', responseData);
    }).catch(next);
};

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

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