router.js
809 Bytes
/**
* router of sub app product
* @author: Aiden Xu<aiden.xu@yoho.cn>
* @author: chen xuan<xuan.chen@yoho.cn>
* @date: 2016/07/19
*/
'use strict';
const expressRouter = require('express').Router;
const cRoot = './controllers';
const productList = require(`${cRoot}/list`);
const router = expressRouter();
// 商品列表
router.use('/list', (req, res, next) => {
req.module = 'product';
req.page = 'list';
next();
});
router.get('/list', productList.index);
router.post('/list', productList.getProducts);
// 商品详情controller
const detail = require(`${cRoot}/detail`);
router.get(/\/pro_([\d]+)_([\d]+)\/(.*)/, detail.index); // 商品详情routers
router.get(/\/product_([\d]+)_([\d]+)\.json/, detail.product);
router.get(/\/intro\.json/, detail.intro);
module.exports = router;