router.js 1.21 KB
/**
 * router of sub app brands
 * @author: ghw<hongwei.gao@yoho.cn>
 * @date: 2016/09/29
 */

'use strict';

const express = require('express');
const cRoot = './controllers';

const router = express.Router(); // eslint-disable-line
const brandsController = require(`${cRoot}/brands`);

// 品牌一览
router.get('/brands', brandsController.index); // 暂时保留

router.get(/\/(boys|girls|kids|lifestyle)-brands(\/)?$/,
    function(req, res, next) {
        req.query.channel = req.params[0];
        if (req.query.channel === 'kids') {
            req.query.msort = 365;
        }
        next();
    }, brandsController.index);

// 悬浮出现品牌信息
router.get('/brands/brandinfo', brandsController.brandInfo);

// 品牌没有加载完全,继续加载
router.post('/brands/brandList', brandsController.brandList);

// brands/plusstar 暂时保留
router.get('/brands/plusstar', brandsController.plusstarList);

// seo plusstar
router.get(/\/(boys|girls|kids|lifestyle)-brands\/plusstar\/id(\d*)-p(\d*)\/?/, function(req, res, next) {
    req.query.channel = req.params[0];
    req.query.id = req.params[1];
    req.query.page = req.params[2];
    next();
}, brandsController.plusstarList);

module.exports = router;