brands.js 1.45 KB
/**
 * 品牌一览 controller
 * @author: ghw<hongwei.gao@yoho.cn>
 * @date: 2016/9/29
 */

'use strict';
const mRoot = '../models';

const brandsService = require(`${mRoot}/brands-service`); // students  model

/**
 * brands 首页
 * @param  {[type]} req [description]
 * @param  {[type]} res [description]
 * @return {[type]}     [description]
 */

exports.index = (req, res, next) => {
    let channel = req.query.channel || req.cookies._Channel || 'boys';

    brandsService.getBrandViewList(channel, req).then(result => {

        res.render('brands', result);

    }).catch(next);
};

/**
 * brandList-Ajax调用
 */
exports.brandList = (req, res, next) => {
    let channel = req.query.channel || req.cookies._Channel || 'boys';

    brandsService.getBrandList(channel, req.body.start).then(result => {

        res.render('brand-list', Object.assign({layout: false}, result));

    }).catch(next);
};

/**
 * 品牌接口数据
 *
 * @param string brandId 获取品牌ID
 * @return json
 */
exports.brandInfo = (req, res, next) => {

    let brandId = req.query.brandId || 0;

    brandsService.brandInfo(brandId, req.user.uid).then(result => {
        res.json(result);
    }).catch(next);
};

/**
 * 品牌plusstar列表
 */
exports.plusstarList = (req, res, next) => {
    let channel = req.query.channel || req.cookies._Channel || 'boys';

    brandsService.plusstarList(channel, req).then(result => {
        res.render('plusstar', result);
    }).catch(next);
};