Blame view

apps/home/controllers/family.js 3 KB
zhangxiaoru authored
1 2
'use strict';
李靖 authored
3
const headerModel = require('../../../doraemon/models/header'); // 头部model
李靖 authored
4
const family = require('../models/family');
zhangxiaoru authored
5
6 7
exports.familyIndex = (req, res, next) => {
    let uid = req.user.uid;
8 9
    let contentCodeOne = '486e6adc7c83001b2e9e83996438fab8';
    let contentCodeTwo = 'eebbcc60607ac443922d8fabe44eb222';
zhangxiaoru authored
10
11
    req.ctx(family).familyIndex(uid, contentCodeOne, contentCodeTwo).then(result => {
12 13 14 15 16 17 18 19
        res.render('family/index', {
            page: 'family',
            title: 'family',
            width750: true,
            localCss: true,
            familyIndexData: result
        });
    }).catch(next);
zhangxiaoru authored
20
};
李靖 authored
21
zhangxiaoru authored
22 23 24 25 26 27 28 29
exports.familyVip = (req, res, next) => {
    // let uid = req.user.uid;

    req.ctx(family).familyVip().then(result => {
        res.json(result);
    }).catch(next);
};
李靖 authored
30
exports.coinDetail = (req, res) => {
李靖 authored
31 32
    let responseData = {
        module: 'home',
李靖 authored
33
        page: 'family-coin',
李靖 authored
34
        pageHeader: headerModel.setNav({
李靖 authored
35
            navTitle: '积分明细'
李靖 authored
36
        }),
李靖 authored
37
        title: 'YOHO!积分明细',
李靖 authored
38 39 40 41
        width750: true,
        localCss: true
    };
李靖 authored
42
    res.render('family/coin-detail', responseData);
李靖 authored
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
};

exports.getCoinData = (req, res, next) => {
    let params = {
        uid: req.user.uid,
        source: req.query.source,
        queryType: req.query.queryType,
        beginTime: req.query.beginTime,
        endTime: req.query.endTime,
        page: req.query.page,
        limit: req.query.limit
    };

    req.ctx(family).getCoinData(params).then(result => {
        res.json(result);
    }).catch(next);
李靖 authored
59
};
李靖 authored
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

exports.userInfo = (req, res, next) => {
    let responseData = {
        module: 'home',
        page: 'family-userInfo',
        pageHeader: headerModel.setNav({
            navTitle: '个人信息'
        }),
        title: 'YOHO!个人信息',
        width750: true,
        localCss: true
    };

    let params = {
        uid: req.user.uid
    };

    req.ctx(family).userInfo(params).then(result => {
        res.render('family/userInfo', Object.assign(responseData, result));
    }).catch(next);
};

exports.modify = (req, res, next) => {
    let params = {
        uid: req.user.uid,
        nickName: req.query.nickName,
        gender: req.query.gender,
李靖 authored
87 88 89
        birthday: req.query.birthday,
        height: req.query.height,
        weight: req.query.weight
李靖 authored
90 91 92 93 94 95
    };

    req.ctx(family).modify(params).then((result) => {
        res.json(result);
    }).catch(next);
};
李靖 authored
96
李靖 authored
97 98 99 100 101 102 103 104 105 106 107
exports.getCity = (req, res, next) => {
    let params = {
        uid: req.user.uid,
        id: req.query.id
    };

    req.ctx(family).getCity(params).then((result) => {
        res.json(result);
    }).catch(next);
};
李靖 authored
108 109 110 111 112 113 114 115 116 117 118 119 120 121
exports.coinMall = (req, res) => {
    let responseData = {
        module: 'home',
        page: 'family-coinMall',
        pageHeader: headerModel.setNav({
            navTitle: '积分商城'
        }),
        title: 'YOHO!积分商城',
        width750: true,
        localCss: true
    };

    res.render('family/coinMall', Object.assign(responseData, ''));
};