index.js 1.61 KB
/**
 * guang controller
 * @author: lcy<chuanyang.liu@yoho.cn>
 * @date: 2016/08/31
 */

'use strict';

// const _ = require('lodash');

const channelModel = require('../models/index');

// const HeaderModel = require('../../../doraemon/models/header');

exports.index = (req, res, next) => {

    let channel = req.yoho.channel;
    let page = req.query.page || 1;
    let limit = req.query.limit || 20;
    let type = req.query.type || 0;

    let pathNav = channelModel.getIndexNav(channel);

    Promise.all([
        channelModel.getBanner(),
        channelModel.getCategory(),
        channelModel.getList(),

            // page
        channelModel.getHotTags(),
        channelModel.getAds(),
        channelModel.getExcellectRecos()
    ]).then(ret => {
        res.render('index', {
            guang: {
                slider: ret[0],
                msgTypes: ret[1],
                msgs: ret[2],
                hotTags: ret[6],
                ads: ret[3],
                exRecos: ret[5],
                msgPager: null,

                guangIndexPage: true,
                limit: limit,
                type: type,
                pathNav: pathNav,
                page: page
            }
        });
    }).catch(next);

    /* return res.render('index', {
        pageName: 'guang-index',
        world: {
            aaa: 'AAA'
        }
    });*/

};

exports.detail = (req, res) => {
    return res.render('detail', {
        detailId: req.params.id
    });
};

exports.tags = (req, res) => {
    return res.render('index', {

    });
};

exports.editor = (req, res) => {
    return res.render('index', {

    });
};