myCurrency.js 1.96 KB
/**
* 个人中心我的有货币
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/08/16
*/

'use strict';

const myCurrencyModel = require('../models/myCurrency');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const _ = require('lodash');

const myCurrency = (req, res, next) => {
    let uid = req.user.uid;
    let contentCode = '05afedf76886d732573f10f7451a1703';

    myCurrencyModel.myCurrency(uid, contentCode).then(result => {

        res.render('currency-new', {
            module: 'home',
            page: 'currency-new',
            pageHeader: _.assign(headerModel.setNav({
                navTitle: '有货币'
            }), {
                currencyPage: true,
                navBtn: false
            }),
            title: '有货币',
            pageFooter: true,
            yohoCoin: result.yohoCoin,
            banner: result.banner
        });
    }).catch(next);
};

const currencyDetail = (req, res, next) => {
    let uid = req.user.uid;
    let page = 1;
    let limit = 10;

    myCurrencyModel.currencyDetail(uid, page, limit).then(result => {

        res.render('currency-detail', {
            module: 'home',
            page: 'currency-detail',
            pageHeader: _.assign(headerModel.setNav({
                navTitle: '有货币明细'
            }), {
                currencyDetailPage: true,
                navBtn: false
            }),
            title: '有货币明细',
            pageFooter: true,
            money: result.money
        });
    }).catch(next);
};

let ajaxCurrencyDetail = (req, res, next) => {
    let uid = req.user.uid;
    let page = req.body.page || 1;
    let limit = 10;

    myCurrencyModel.currencyDetail(uid, page, limit).then((result) => {

        res.render('ajax-currency-detail', {
            layout: false,
            coinlist: _.get(result, 'coinlist', [])
        });
    }).catch(next);
};

module.exports = {
    myCurrency,
    currencyDetail,
    ajaxCurrencyDetail
};