index.js 1.34 KB
/**
 * 频道页面
 * @author: Bi Kai<kai.bi@yoho.cn>
 * @date: 2016/05/09
 */
'use strict';
const _ = require('lodash');
const channelModel = require('../models/channel');
const helpers = require('../../../library/helpers');

const mod = 'channel';
let footerTab = {
    indexUrl: helpers.url('/?go=1'), // 首页
    categoryUrl: helpers.url('/cate'), // 分类
    guangUrl: helpers.url('', null, 'guang'), // 逛首页
    shoppingCartUrl: helpers.url('/cart/index/index'), // 购物车
    mineUrl: helpers.url('/home') // 个人中心
};

exports.switchChannel = (req, res, next) => {
    let channel = req.cookies._Channel;

    if (req.query.go && channel) {
        res.redirect('/' + channel);
    } else {
        // 设置浏览器缓存5分钟 300000ms
        res.set('Expires', (new Date(_.now() + 300000)).toGMTString());
        return next();
    }
};

/**
 * 男生首页
 */
exports.boys = (req, res) => {
    channelModel.getChannelDate({
        gender: '1,3'
    }).then(result => {

        res.render('channel', Object.assign({
            module: mod,
            page: 'home',
            title: '男生首页',
            homeHeader: {
                searchUrl: helpers.url('/search', null, 'search')
            },
            maybeLike: true,
            showFooterTab: footerTab,
            pageFooter: true
        }, result));
    });
};