star.js 17.4 KB
/**
 * 新潮教室
 * @author: wsl<shuiling.wang@yoho.cn>
 * @date: 2016/05/30
 */
'use strict';

const mRoot = '../models';
const _ = require('lodash');
const headerModel = require('../../../doraemon/models/header');
const starModel = require(`${mRoot}/star`);

const headTab = [
    {
        cur: false,
        url: '/guang/star',
        name: '全部'
    },
    {
        cur: false,
        url: '/guang/star/special',
        name: '星专题'
    },
    {
        cur: false,
        url: '/guang/star/collocation',
        name: '星搭配'
    }
];

const headerData = headerModel.setNavHeader('新潮教室');

const renderData = {
    module: 'guang',
    title: '新潮教室',
    pageHeader: headerData
};

const curHeadTab = (num) => {
    let i = 0;

    for (i; i <= 2; i++) {
        if (i === num) {
            headTab[i].cur = true;
        } else {
            headTab[i].cur = false;
        }
    }
};

/**
 * 星潮教室首页
 * @param  {[object]} req
 * @param  {[object]} res
 * @return {[type]}
 */
exports.index = (req, res) => {
    renderData.page = 'star';
    starModel.getIndexData().then((result) => {
        curHeadTab(0);
        res.render('star/index', _.assign(renderData, {
            content: result,
            headTab: headTab,
            starAvatar: [
                {
                    url: '',
                    src: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/07/16/0142677eb1abf7bf7b233524f604d71fd6.png?imageView/2/w/{width}/h/{height}'
                },
                {
                    url: '',
                    src: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/07/16/01c4d65c836f3c210e192630109bb32e43.png?imageView/2/w/{width}/h/{height}'
                },
                {
                    url: '',
                    src: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/07/16/0142677eb1abf7bf7b233524f604d71fd6.png?imageView/2/w/{width}/h/{height}'
                },
                {
                    url: '',
                    src: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/07/16/01c4d65c836f3c210e192630109bb32e43.png?imageView/2/w/{width}/h/{height}'
                },
                {
                    url: '',
                    src: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/07/16/0142677eb1abf7bf7b233524f604d71fd6.png?imageView/2/w/{width}/h/{height}'
                },
                {
                    url: '',
                    src: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/07/16/01c4d65c836f3c210e192630109bb32e43.png?imageView/2/w/{width}/h/{height}'
                },
                {
                    url: '',
                    src: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/07/16/0142677eb1abf7bf7b233524f604d71fd6.png?imageView/2/w/{width}/h/{height}'
                },
                {
                    url: '',
                    src: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/07/16/01c4d65c836f3c210e192630109bb32e43.png?imageView/2/w/{width}/h/{height}'
                },
                {
                    url: '',
                    src: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/07/16/0142677eb1abf7bf7b233524f604d71fd6.png?imageView/2/w/{width}/h/{height}'
                },
                {
                    url: '',
                    src: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/07/16/01c4d65c836f3c210e192630109bb32e43.png?imageView/2/w/{width}/h/{height}'
                },
                {
                    url: '',
                    src: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/07/16/0142677eb1abf7bf7b233524f604d71fd6.png?imageView/2/w/{width}/h/{height}'
                },
                {
                    url: '',
                    src: 'http://img10.static.yhbimg.com/yhb-img01/2016/05/07/16/01c4d65c836f3c210e192630109bb32e43.png?imageView/2/w/{width}/h/{height}'
                }
            ],
            articles: [
                {
                    articleId: '48187',
                    isSwiper: true,
                    starAvatar: [
                        {
                            src: 'http://img11.static.yhbimg.com/yhb-img02/2016/04/28/02/01c3e9be0e46915b124962b97d752557cd.jpg?imageView/0/w/{width}/h/{height}',
                            name: 'DREAMER',
                            avatarUrl: ''
                        },
                        {
                            src: '//img12.static.yhbimg.com/yhb-img02/2016/01/05/07/022e56ed48c7d0b5745683e' +
                            '87518d6141b.jpg?imageView/0/w/{width}/h/{height}',
                            name: 'DREAMER',
                            avatarUrl: ''
                        },
                        {
                            src: '//img12.static.yhbimg.com/yhb-img02/2016/02/22/06/02f992b88afc92359113fc1355' +
                            '90ea9ce8.jpg?imageView/0/w/{width}/h/{height}',
                            name: 'DREAMER',
                            avatarUrl: ''
                        }
                    ],
                    title: 'dangerous people 跟着薛之谦维护世界和平T恤',
                    url: 'http://guang.m.yohobuy.com/info/index?id=48187',
                    articeTxt: '薛之谦以Dangerous People为主题,以暗黑街头的风格为主线,透过纸袋人的形象,' +
                                '从反面讽刺了社会的种种丑陋与黑暗现象, 从而反映出那些“边缘人物” 想让大家看到' +
                                '真实自我的渴望与期待世界和平的美好憧憬。 作为新一代潮流的引领人,薛之谦也有着自' +
                                '身对潮流文化的理解, Dangerous People的产品系列主要以黑白为主,在产品质量上也力求做到最好。',
                    articeImg: [
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/02b9522beb59efd9863d67e246a7793de8.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img11.static.yhbimg.com/goodsimg/2016/06/01/03/015720dbe0dfd866a0cdf8701b19f4eebf.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/024f7d9704e5a545e90125432db69cae5c.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/02b246a819d5de16a0a22316fe8f668926.jpg?imageView/2/w/{width}/h/{height}'
                    ],
                    publishTime: '6月1日 11:30',
                    viewsNum: '7694'
                },
                {
                    articleId: '48187',
                    starAvatar: [
                        {
                            src: 'http://img11.static.yhbimg.com/yhb-img02/2016/04/28/02/01c3e9be0e46915b124962b97d752557cd.jpg?imageView/0/w/{width}/h/{height}',
                            name: 'DREAMER',
                            avatarUrl: ''
                        }
                    ],
                    title: 'dangerous people 跟着薛之谦维护世界和平T恤',
                    url: 'http://guang.m.yohobuy.com/info/index?id=48187',
                    articeTxt: '薛之谦以Dangerous People为主题,以暗黑街头的风格为主线,透过纸袋人的形象,' +
                                '从反面讽刺了社会的种种丑陋与黑暗现象, 从而反映出那些“边缘人物” 想让大家看到' +
                                '真实自我的渴望与期待世界和平的美好憧憬。 作为新一代潮流的引领人,薛之谦也有着自' +
                                '身对潮流文化的理解, Dangerous People的产品系列主要以黑白为主,在产品质量上也力求做到最好。',
                    articeImg: [
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/02b9522beb59efd9863d67e246a7793de8.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img11.static.yhbimg.com/goodsimg/2016/06/01/03/015720dbe0dfd866a0cdf8701b19f4eebf.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/024f7d9704e5a545e90125432db69cae5c.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/02b246a819d5de16a0a22316fe8f668926.jpg?imageView/2/w/{width}/h/{height}'
                    ],
                    publishTime: '6月1日 11:30',
                    viewsNum: '7694'
                },
                {
                    articleId: '48187',
                    starAvatar: [
                        {
                            src: 'http://img11.static.yhbimg.com/yhb-img02/2016/04/28/02/01c3e9be0e46915b124962b97d752557cd.jpg?imageView/0/w/{width}/h/{height}',
                            name: 'DREAMER',
                            avatarUrl: ''
                        }
                    ],
                    title: 'dangerous people 跟着薛之谦维护世界和平T恤',
                    url: 'http://guang.m.yohobuy.com/info/index?id=48187',
                    articeTxt: '薛之谦以Dangerous People为主题,以暗黑街头的风格为主线,透过纸袋人的形象,' +
                                '从反面讽刺了社会的种种丑陋与黑暗现象, 从而反映出那些“边缘人物” 想让大家看到' +
                                '真实自我的渴望与期待世界和平的美好憧憬。 作为新一代潮流的引领人,薛之谦也有着自' +
                                '身对潮流文化的理解, Dangerous People的产品系列主要以黑白为主,在产品质量上也力求做到最好。',
                    articeImg: [
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/02b9522beb59efd9863d67e246a7793de8.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img11.static.yhbimg.com/goodsimg/2016/06/01/03/015720dbe0dfd866a0cdf8701b19f4eebf.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/024f7d9704e5a545e90125432db69cae5c.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/02b246a819d5de16a0a22316fe8f668926.jpg?imageView/2/w/{width}/h/{height}'
                    ],
                    publishTime: '6月1日 11:30',
                    viewsNum: '7694'
                },
                {
                    articleId: '48187',
                    starAvatar: [
                        {
                            src: 'http://img11.static.yhbimg.com/yhb-img02/2016/04/28/02/01c3e9be0e46915b124962b97d752557cd.jpg?imageView/0/w/{width}/h/{height}',
                            name: 'DREAMER',
                            avatarUrl: ''
                        }
                    ],
                    title: 'dangerous people 跟着薛之谦维护世界和平T恤',
                    url: 'http://guang.m.yohobuy.com/info/index?id=48187',
                    articeTxt: '薛之谦以Dangerous People为主题,以暗黑街头的风格为主线,透过纸袋人的形象,' +
                                '从反面讽刺了社会的种种丑陋与黑暗现象, 从而反映出那些“边缘人物” 想让大家看到' +
                                '真实自我的渴望与期待世界和平的美好憧憬。 作为新一代潮流的引领人,薛之谦也有着自' +
                                '身对潮流文化的理解, Dangerous People的产品系列主要以黑白为主,在产品质量上也力求做到最好。',
                    articeImg: [
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/02b9522beb59efd9863d67e246a7793de8.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img11.static.yhbimg.com/goodsimg/2016/06/01/03/015720dbe0dfd866a0cdf8701b19f4eebf.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/024f7d9704e5a545e90125432db69cae5c.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/02b246a819d5de16a0a22316fe8f668926.jpg?imageView/2/w/{width}/h/{height}'
                    ],
                    publishTime: '6月1日 11:30',
                    viewsNum: '7694'
                },
                {
                    articleId: '48187',
                    starAvatar: [
                        {
                            src: 'http://img11.static.yhbimg.com/yhb-img02/2016/04/28/02/01c3e9be0e46915b124962b97d752557cd.jpg?imageView/0/w/{width}/h/{height}',
                            name: 'DREAMER',
                            avatarUrl: ''
                        }
                    ],
                    title: 'dangerous people 跟着薛之谦维护世界和平T恤',
                    url: 'http://guang.m.yohobuy.com/info/index?id=48187',
                    articeTxt: '薛之谦以Dangerous People为主题,以暗黑街头的风格为主线,透过纸袋人的形象,' +
                                '从反面讽刺了社会的种种丑陋与黑暗现象, 从而反映出那些“边缘人物” 想让大家看到' +
                                '真实自我的渴望与期待世界和平的美好憧憬。 作为新一代潮流的引领人,薛之谦也有着自' +
                                '身对潮流文化的理解, Dangerous People的产品系列主要以黑白为主,在产品质量上也力求做到最好。',
                    articeImg: [
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/02b9522beb59efd9863d67e246a7793de8.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img11.static.yhbimg.com/goodsimg/2016/06/01/03/015720dbe0dfd866a0cdf8701b19f4eebf.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/024f7d9704e5a545e90125432db69cae5c.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/02b246a819d5de16a0a22316fe8f668926.jpg?imageView/2/w/{width}/h/{height}'
                    ],
                    publishTime: '6月1日 11:30',
                    viewsNum: '7694'
                },
                {
                    articleId: '48187',
                    starAvatar: [
                        {
                            src: 'http://img11.static.yhbimg.com/yhb-img02/2016/04/28/02/01c3e9be0e46915b124962b97d752557cd.jpg?imageView/0/w/{width}/h/{height}',
                            name: 'DREAMER',
                            avatarUrl: ''
                        }
                    ],
                    title: 'dangerous people 跟着薛之谦维护世界和平T恤',
                    url: 'http://guang.m.yohobuy.com/info/index?id=48187',
                    articeTxt: '薛之谦以Dangerous People为主题,以暗黑街头的风格为主线,透过纸袋人的形象,' +
                                '从反面讽刺了社会的种种丑陋与黑暗现象, 从而反映出那些“边缘人物” 想让大家看到' +
                                '真实自我的渴望与期待世界和平的美好憧憬。 作为新一代潮流的引领人,薛之谦也有着自' +
                                '身对潮流文化的理解, Dangerous People的产品系列主要以黑白为主,在产品质量上也力求做到最好。',
                    articeImg: [
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/02b9522beb59efd9863d67e246a7793de8.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img11.static.yhbimg.com/goodsimg/2016/06/01/03/015720dbe0dfd866a0cdf8701b19f4eebf.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/024f7d9704e5a545e90125432db69cae5c.jpg?imageView/2/w/{width}/h/{height}',
                        'http://img12.static.yhbimg.com/goodsimg/2016/06/01/03/02b246a819d5de16a0a22316fe8f668926.jpg?imageView/2/w/{width}/h/{height}'
                    ],
                    publishTime: '6月1日 11:30',
                    viewsNum: '7694'
                }
            ]
        }));
    });
};

/**
 * 星专题
 * @param  {[object]} req
 * @param  {[object]} res
 * @return {[type]}
 */
exports.special = (req, res) => {
    renderData.page = 'star';
    starModel.getSpecialData().then((result) => {
        curHeadTab(1);
        res.render('star/special', _.assign(renderData, {
            resources: result,
            headTab: headTab
        }));
    });
};


/**
 * 星搭配
 * @param  {[object]} req
 * @param  {[object]} res
 * @return {[type]}
 */
exports.collocation = (req, res) => {
    renderData.page = 'collocation';
    curHeadTab(2);
    res.render('star/collocation', _.assign(renderData, {
        headTab: headTab
    }));
};

/**
 * 星搭配文章请求
 * @param  {[object]} req
 * @param  {[object]} res
 * @return {[type]}
 */
exports.collocationList = (req, res) => {
    let params = req.query;
    let uid = 9239279 || req.user.uid || 0;

    starModel.getCollocationListData(params, uid).then((result) => {
        res.render('star/collocation-list', _.assign({
            layout: false,
            params: params,
            list: result,
            isApp: req.query.app_version || false
        }));
    });
};

/**
 * 明星文章专区
 * @param  {[object]} req
 * @param  {[object]} res
 * @return {[type]}
 */
exports.detail = (req, res) => {
    res.render('star/detail');
};