guang-new.js 1.02 KB

'use strict';

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

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

exports.index = (req, res, next) => {
    let responseData = {
        pageHeader: headerModel.setNav({
            navTitle: '有货逛不停'
        }),
        title: '有货逛不停',
        module: 'guang',
        page: 'guang-new',
        width750: true,
        localCss: true,
        pageStyle: 'guang-new-bg'
    };

    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);
};