guang-new.js 1.64 KB

'use strict';

const mRoot = '../models';
const newGuangModel = require(`${mRoot}/guang-new`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab

const channels = {
    boys: '1,3',
    girls: '2,3',
    kids: '1,2,3',
    lifestyle: '1,2,3'
};

exports.index = (req, res, next) => {
    // 兼容老链接
    if (req.query.type) {
        let queryParams = req.originalUrl.split('?')[1];

        return res.redirect(`//m.yohobuy.com/guang/type?${queryParams}`);
    }

    let responseData = {
        pageHeader: headerModel.setNav({
            navTitle: '有货逛不停'
        }),
        title: '潮流资讯,最新原创潮流时尚资讯-YOHO!BUY 有货',
        keywords: '潮流资讯,时尚潮流资讯',
        description: '来有货玩潮流,潮流资讯大分享!年轻人潮流购物中心,了解潮流趋势、掌握潮流文化知识信息,尽在有货逛潮流!',
        module: 'guang',
        page: 'guang-new',
        width750: true,
        localCss: true,
        pageStyle: 'guang-new-bg',
        isWechat: req.yoho.isWechat,
        showFooterTab: footerModel.getUrlData('guang')
    };

    let params = {
        gender: channels[req.cookies._Channel] || '1,3'
    };

    req.ctx(newGuangModel).index(params).then(result => {
        res.render('guang-new', Object.assign(responseData, result));
    }).catch(next);
};

exports.more = (req, res, next) => {
    let params = {
        page: req.query.page
    };

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