router.js 1.08 KB
/**
 * 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 router = expressRouter();

// 产品 搜索 页面
const search = require(`${cRoot}/search`);

router.get('/search', search.index);
router.get('/search.json', search.fetchProducts); // ajax


// 产品 列表页
const productList = require(`${cRoot}/list`);

router.get('/list', productList.index);
router.post('/list', productList.fetchProducts);
router.get('/filter', productList.subFilter);
router.get('/filters.json', productList.fetchFilters);


// 商品详情controller
const detail = require(`${cRoot}/detail`);

router.get(/\/([\d]+)(.*)/, detail.index); // 商品详情routers
router.get(/\/product_([\d]+)\.json/, detail.product);
router.get(/\/intro_([\d]+)\.json/, detail.intro);
router.post(/cart.json/, detail.addToCart);
router.post(/favorite.json/, detail.favorite);
router.get(/cart-count.json/, detail.getCartCount);
module.exports = router;