router.js
2.84 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* 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 auth = require(`${global.doraemon}/middleware/auth`);
// 产品 搜索 页面
const search = require(`${cRoot}/search`);
router.get('/product/search', search.index);
router.get('/product/search.json', search.fetchProducts); // ajax
// 新品页
const newProduct = require(`${cRoot}/new`);
router.get('/product/new', newProduct.index);
router.get('/product/new.json', newProduct.fetchProducts);
// 产品 列表页
const productList = require(`${cRoot}/product-list`);
router.get('/product/list', productList.index);
router.get('/product/list.json', productList.fetchProducts);
// 品牌店铺页面
const shop = require(`${cRoot}/shop`);
// router.get('/brand', shop.index); // 品牌 集合页
router.get('/product/shop/info.json', shop.getShopInfo); // 店铺介绍
router.get('/product/shop/goods.json', shop.getBrandShopGoods); // 店铺商品列表
router.post('/product/shop/collect.json', auth, shop.collectShop); // 收藏品牌店铺
router.get('/product/shop/:domain', shop.index); // 品牌店铺页
router.get('/product/shop/:domain/share', shop.shopShare); // 品牌店铺页分享
// 商品详情controller
const detail = require(`${cRoot}/detail`);
router.get(/\/product\/pro_([\d]+)_([\d]+)\/(.*).html/, detail.index); // 商品详情routers
router.get(/\/product\/pro_([\d]+).html/, detail.sknIndex); // skn商品详情
router.get(/\/product\/product_([\d]+)\.json/, detail.product);
router.get(/\/product\/intro_([\d]+)\.json/, detail.intro);
router.get('/product/refundExchange/:skn', detail.supportRefundExchange); // 是否支持7天无理由退换货
router.get('/product/mightLike', detail.mightLike); // 猜你喜欢
router.get('/product/isFavorite/:id', detail.isFavorite); // 判断是否收藏
router.post(/\product\/cart.json/, detail.addToCart);
router.post(/\product\/favorite.json/, auth, detail.favorite);
router.get(/\/product\/cart-count.json/, detail.getCartCount);
router.get(/\/product\/search_product\.json/, detail.search);
router.get(/\/product\/search_skn\.json/, detail.searchSkn);
// alias: TODO: 测试完成 删除一下router,并更新资源位
// router.get(/\/brand\/share\/(.*)/, shop.shopShare); // 品牌店铺分享页面
router.get(/\/item\/([\d]+)(.*)\.html/, detail.index); // 商品详情routers
// router.get(/\/brand\/(.*)/, shop.index); // 店铺首页
router.get('/new', newProduct.index);
router.get('/new.json', newProduct.fetchProducts);
router.get('/list', productList.index);
router.get('/list.json', productList.fetchProducts);
router.get('/search', search.index);
router.get('/search.json', search.fetchProducts); // ajax
module.exports = router;