router.js
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* 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
router.get('/new', search.index);
router.get('/new.json', search.fetchProducts);
// 产品 列表页
const productList = require(`${cRoot}/list`);
router.get('/list', productList.index);
router.get('/list.json', productList.fetchProducts);
router.get('/filter', productList.subFilter);
router.get('/filters.json', productList.fetchFilters);
// 品牌店铺页面
const shop = require(`${cRoot}/shop`);
router.get('/shop', shop.index); // 店铺首页
router.get('/get-shop-info', shop.getShopInfo); // 店铺介绍
router.post('/get-brand-shop-goods', shop.getBrandShopGoods); // 店铺商品列表
router.post('/collect-shop', shop.collectShop); // 收藏品牌店铺
router.get('/shop-share', shop.shopShare); // 品牌店铺分享页面
// 商品详情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;