Blame view

apps/home/controllers/myCurrency.js 1.99 KB
zhangxiaoru authored
1 2 3 4 5 6 7 8 9 10
/**
* 个人中心我的有货币
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/08/16
*/

'use strict';

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

const myCurrency = (req, res, next) => {
zhangxiaoru authored
14
    let uid = req.user.uid;
zhangxiaoru authored
15
    let contentCode = '05afedf76886d732573f10f7451a1703';
zhangxiaoru authored
16
zhangxiaoru authored
17
    myCurrencyModel.myCurrency(uid, contentCode).then(result => {
zhangxiaoru authored
18 19

        res.render('currency-new', {
20 21
            module: 'home',
            page: 'mycurrency',
zhangxiaoru authored
22
            pageHeader: _.assign(headerModel.setNav({
zhangxiaoru authored
23
                navTitle: '有货币'
zhangxiaoru authored
24 25 26
            }), {
                currencyPage: true,
                navBtn: false
zhangxiaoru authored
27 28 29
            }),
            title: '有货币',
            pageFooter: true,
zhangxiaoru authored
30
            yohoCoin: result.yohoCoin,
郝肖肖 authored
31 32
            banner: result.banner,
            localCss: true
zhangxiaoru authored
33 34 35 36 37
        });
    }).catch(next);
};

const currencyDetail = (req, res, next) => {
zhangxiaoru authored
38
    let uid = req.user.uid;
zhangxiaoru authored
39 40 41
    let page = 1;
    let limit = 10;
42
    myCurrencyModel.currencyDetailIndex(uid, page, limit).then(result => {
zhangxiaoru authored
43
        res.render('currency-detail', {
44 45
            module: 'home',
            page: 'currencyDetail',
zhangxiaoru authored
46
            pageHeader: _.assign(headerModel.setNav({
zhangxiaoru authored
47
                navTitle: '有货币明细'
zhangxiaoru authored
48 49 50
            }), {
                currencyDetailPage: true,
                navBtn: false
zhangxiaoru authored
51 52 53
            }),
            title: '有货币明细',
            pageFooter: true,
54 55 56
            result: result,
            money: (result.yohoCoin.yohocoin_num && result.yohoCoin.yohocoin_num > 0),
            localCss: true
zhangxiaoru authored
57 58 59 60 61
        });
    }).catch(next);
};

let ajaxCurrencyDetail = (req, res, next) => {
zhangxiaoru authored
62
    let uid = req.user.uid;
zhangxiaoru authored
63 64 65 66
    let page = req.body.page || 1;
    let limit = 10;

    myCurrencyModel.currencyDetail(uid, page, limit).then((result) => {
67
        res.json(result);
zhangxiaoru authored
68 69 70 71 72 73
    }).catch(next);
};

module.exports = {
    myCurrency,
    currencyDetail,
74
    ajaxCurrencyDetail
zhangxiaoru authored
75 76
};