brand.js 1.85 KB
/**
 * 品牌页
 * <jing.li@yoho.cn>
 * 2016/09/19
 */

'use strict';

const headerModel = require('../../../doraemon/models/header'); // 头部model
const indexModel = require('../models/brand');

/**
 * 品牌一览
 *
 * @param string gender 老版本中使用的参数, 做兼容判断
 * @param int channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
 */
let index = (req, res, next) => {

    let headerData = headerModel.setNav({
        navTitle: '品牌一览'
    });

    let responseData = {
        pageHeader: headerData,
        module: 'channel',
        page: 'brand',
        title: '品牌一览 | Yoho!Buy有货 | 潮流购物逛不停',
        //pageFooter: true
    };

    let param = {

        channel: req.query.channel || '1',

        gender: req.query.gender || '1,3'

    };

    indexModel.getBrandByChannel(param.channel).then(result => {
        res.render('brand/index', Object.assign(responseData, result));
    }).catch(next);

};

/**
 * 品牌一览搜索页
 *
 * @param string gender 老版本中使用的参数, 做兼容判断
 * @param int channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道
 */
let search = (req, res, next) => {

    let headerData = headerModel.setNav({
        navTitle: '品牌一览'
    });

    let responseData = {
        pageHeader: headerData,
        module: 'channel',
        page: 'brand',
        title: '品牌一览 | Yoho!Buy有货 | 潮流购物逛不停',
        pageFooter: true
    };

    let param = {

        uid: req.user.uid || 6228593, // TODO

        channel: req.query.channel || '1'

    };

    indexModel.branchSearch(param).then(result => {
        res.render('brand/search', Object.assign(responseData, result));
    }).catch(next);

};

module.exports = {
    index,
    search,
    delBrandHistory
};