router.js 1.68 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 newProduct = require(`${cRoot}/new`);

router.get('/new', newProduct.index);
router.get('/new.json', newProduct.fetchProducts);

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

router.get('/list', productList.index);
router.get('/list.json', productList.fetchProducts);

// 品牌店铺页面
const shop = require(`${cRoot}/shop`);

router.get(/\/brand\/share\/(.*)/, shop.shopShare); // 品牌店铺分享页面
router.get(/\/brand\/(.*)/, shop.index); // 店铺首页
router.get('/product/shop/info.json', shop.getShopInfo); // 店铺介绍
router.post('/product/shop/goods.json', shop.getBrandShopGoods); // 店铺商品列表
router.post('/product/shop/collect.json', shop.collectShop); // 收藏品牌店铺

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

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