plusstar.js 1.57 KB
/**
 * 潮流优选
 * @author: xiaoxiao<xiaoxiao.hao@yoho.cn>
 * @date: 2016/08/04
 */
'use strict';

const mRoot = '../models';
const plusstarModel = require(`${mRoot}/plusstar`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
let channels = {
    boys: 1,
    girl: 2,
    kids: 3,
    lifestyle: 4
};

/**
 * 潮流优选首页
 */
exports.index = (req, res, next) => {
    let isApp = req.query.app_version || req.query.appVersion || false;
    let parameter = {};
    let title = '潮流优选';
    let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;

    if (isApp === false) {
        parameter = {
            pageHeader: headerModel.setNav({
                navTitle: title
            }),
            pageFooter: true
        };
    }

    plusstarModel.getAllChannels({gender: gender, app_type: 0}).then(result => {
        res.render('plusstar/index', Object.assign({
            page: 'plusstar-index',
            result: result,
            isApp: isApp,
            title: title
        }, parameter));
    }).catch(next);
};

/**
 * 潮流优选首页-资源位
 */
exports.resourcesTemplate = (req, res, next) => {
    let code = req.query.code || '';
    let isApp = req.query.app_version || req.query.appVersion || false;

    plusstarModel.getResources({
        content_code: code
    }, {
        isApp: isApp
    }).then(result => {
        res.render('plusstar/resources-template', {
            layout: false,
            result: result,
            title: '潮流优选'
        });
    }).catch(next);
};