Blame view

apps/guang/controllers/guang-new.js 1.64 KB
李靖 authored
1 2 3

'use strict';
李靖 authored
4 5
const mRoot = '../models';
const newGuangModel = require(`${mRoot}/guang-new`);
李靖 authored
6
const headerModel = require('../../../doraemon/models/header'); // 头部model
李靖 authored
7
const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab
李靖 authored
8
李靖 authored
9
const channels = {
李靖 authored
10 11 12 13
    boys: '1,3',
    girls: '2,3',
    kids: '1,2,3',
    lifestyle: '1,2,3'
李靖 authored
14 15 16
};

exports.index = (req, res, next) => {
17 18
    // 兼容老链接
    if (req.query.type) {
李靖 authored
19 20
        let queryParams = req.originalUrl.split('?')[1];
李靖 authored
21
        return res.redirect(`//m.yohobuy.com/guang/type?${queryParams}`);
22 23
    }
李靖 authored
24 25
    let responseData = {
        pageHeader: headerModel.setNav({
李靖 authored
26
            navTitle: '有货逛不停'
李靖 authored
27
        }),
郭成尧 authored
28 29
        title: '潮流资讯,最新原创潮流时尚资讯-YOHO!BUY 有货',
        keywords: '潮流资讯,时尚潮流资讯',
30
        description: '来有货玩潮流,潮流资讯大分享!年轻人潮流购物中心,了解潮流趋势、掌握潮流文化知识信息,尽在有货逛潮流!',
李靖 authored
31 32 33
        module: 'guang',
        page: 'guang-new',
        width750: true,
李靖 authored
34
        localCss: true,
李靖 authored
35 36 37
        pageStyle: 'guang-new-bg',
        isWechat: req.yoho.isWechat,
        showFooterTab: footerModel.getUrlData('guang')
李靖 authored
38 39
    };
李靖 authored
40
    let params = {
李靖 authored
41
        gender: channels[req.cookies._Channel] || '1,3'
李靖 authored
42
    };
李靖 authored
43
李靖 authored
44 45 46
    req.ctx(newGuangModel).index(params).then(result => {
        res.render('guang-new', Object.assign(responseData, result));
    }).catch(next);
李靖 authored
47
};
李靖 authored
48 49 50 51 52 53 54 55 56 57

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

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