family.js 3.83 KB
'use strict';

const headerModel = require('../../../doraemon/models/header'); // 头部model
const family = require('../models/family');

exports.familyIndex = (req, res, next) => {
    let uid = req.user.uid;
    let contentCodeOne = '486e6adc7c83001b2e9e83996438fab8';
    let contentCodeTwo = 'eebbcc60607ac443922d8fabe44eb222';

    req.ctx(family).familyIndex(uid, contentCodeOne, contentCodeTwo).then(result => {
        res.render('family/index', {
            page: 'family',
            title: 'family',
            width750: true,
            localCss: true,
            familyIndexData: result
        });
    }).catch(next);
};

exports.integralCharts = (req, res, next) => {
    let uid = req.user.uid;

    req.ctx(family).integralCharts(uid).then(result => {
        res.josn(result);
    }).catch(next);
};

exports.familyVip = (req, res, next) => {
    let udid = req.sessionID || 'yoho';
    let uid = req.user.uid;
    let yohoApp = req.yoho.isApp && !req.yoho.isMarsApp;
    let marsApp = req.yoho.isMarsApp;

    req.ctx(family).familyVip(udid, uid, yohoApp, marsApp).then(result => {
        res.json(result);
    }).catch(next);
};

exports.downLoadData = (req, res, next) => {
    let params = {
        yohoCode: '940a47540078396366bcb8b64b1ed0e7',
        nowCode: 'ac12681cc68993fcfd20e40536a2aed2',
        marsCode: '9f48cba22034cda2df8493ec9187797e',
        coffeeCode: '357cae962a4e1a99d8f156850ad5dc78',
        littleCode: 'ab1cbfb5b33d4e174ddb7ec49f734968',
        greenCode: 'c2778fe64439251b67ffd1338fe982fb',
    };

    req.ctx(family).downLoadData(params).then(result => {
        res.json(result);
    }).catch(next);
};

exports.coinDetail = (req, res) => {
    let responseData = {
        module: 'home',
        page: 'family-coin',
        pageHeader: headerModel.setNav({
            navTitle: '积分明细'
        }),
        title: 'YOHO!积分明细',
        width750: true,
        localCss: true
    };

    res.render('family/coin-detail', responseData);
};

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);
};

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,
        birthday: req.query.birthday,
        height: req.query.height,
        weight: req.query.weight
    };

    req.ctx(family).modify(params).then((result) => {
        res.json(result);
    }).catch(next);
};

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);
};

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, ''));
};