outlet.js 1.93 KB
/**
 * 奥莱页面
 * @author: 赵彪<bill.zhao@yoho.cn>
 * @date: 2016/05/09
 */
'use strict';

const outletModel = require('../models/outlet');
const headerModel = require('../../../doraemon/models/header');

const renderData = {
    module: 'product'
};


// 奥莱首页控制器
exports.index = (req, res) => {
    let headerData = headerModel.setNav({
        navTitle: 'OUTLET',
        navBtn: false
    });

    let categoryId = req.query.category_id;
    let yhChannel = req.query.yh_channel || 1;
    let contentcode = req.query.content_code;

    outletModel.getContent(categoryId, yhChannel, contentcode).then(result => {
        res.render('outlet', Object.assign({
            page: 'outlet',
            pageHeader: headerData
        }, renderData, result));
    });
};

// 奥莱活动详情页
exports.activityDetail = (req, res) => {
    let headerData = headerModel.setNav({
        navTitle: 'OUTLET',
        navBtn: false
    });

    outletModel.getActivity(req.query.id).then(result => {
        res.render('outlet/activity', Object.assign({
            page: 'outlet-detail',
            pageHeader: headerData,
            pageFooter: true
        }, renderData, result));
    });
};

// 奥莱活动频道列表页
exports.activityList = (req, res) => {
    let headerData = headerModel.setNav({
        navTitle: 'OUTLET',
        navBtn: false
    });
    let categoryId = req.query.category_id;
    let type = req.query.type || 2;
    let template = parseInt(type, 10) === 2 ? 'outlet/will-end' : 'outlet/will-start';
    let page = parseInt(type, 10) === 2 ? 'outlet-will-end' : 'outlet-will-start';

    if (!categoryId) {
        throw new Error('No parent_id for OUTLET channel page!');
    }

    outletModel.getRecentActivity(type, categoryId).then(result => {
        res.render(template, Object.assign({
            page: page,
            pageHeader: headerData,
            pageFooter: true
        }, renderData, result));
    });
};