router.js 7.67 KB
/**
 * router of sub app product
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2016/05/06
 */

'use strict';

const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
const auth = require(`${global.middleware}/auth`);
const gbk2utf = require(`${global.middleware}/gbk2utf`);
const paramParse = require(`${global.middleware}/param-parse`);

const sitemap = require('../3party/controllers/sitemap');

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

// 商品到货提醒
const notify = require(`${cRoot}/notify`);

// 收藏品牌,商品,店铺
const favorite = require(`${cRoot}/favorite`);

// 优惠券
const coupon = require(`${cRoot}/coupon`);

// 商品促销controller
const sale = require(`${cRoot}/sale`);

// 奥特莱斯controller
const outlets = require(`${cRoot}/outlets`);

// 商品促销controller
const outletsList = require(`${cRoot}/outletsList`);

// 商品分类列表
const list = require(`${cRoot}/list`);

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

// 学生优惠controller
const students = require(`${cRoot}/students`);

// 新品到着controller
const newArrive = require(`${cRoot}/newArrive`);

// 全球购controller
const globalCtrl = require(`${cRoot}/global`);

// 店铺controller
const shop = require(`${cRoot}/shop`);

// 商品促销routers
router.get('/sale', sale.index); // sale 首页
router.get('/sale/vip', sale.vip); // VIP 活动专区
router.get('/sale/vip/:pathQs', paramParse, sale.vip); // VIP 活动专区 带伪静态参数
router.get('/sale/discount', sale.discount); // 折扣专场详情页
router.get('/sale/discount/:pathQs', paramParse, sale.discount); // 折扣专场详情页 带伪静态参数
router.get('/sale/breakingYards', sale.breakingYards); // 断码区
router.get('/sale/breakingYards/:pathQs', paramParse, sale.breakingYards); // 断码区 带伪静态参数
router.get('/sale/newSale', sale.newSale); // 最新降价
router.get('/sale/newSale/:pathQs', paramParse, sale.newSale); // 最新降价 带伪静态参数
router.get('/sale/special', '/sale/special', sale.special); // sale活动页 原PHP sale.yohobuy.com
router.get('/sale/special/:pathQs', '/sale/special/:pathQs', paramParse, sale.special); // sale活动页 原PHP sale.yohobuy.com
router.get('/sale/goods', sale.getGoodsList); // ajax 获取商品列表

// 奥特莱斯routers
router.get('/outlets', outlets.index); // 奥莱首页
router.get('/outlets/index', outlets.index); // 奥莱首页
router.get('/outlets/special/detail', outlets.special); // 奥莱活动页
router.get('/outlets/list', outlets.list); // 奥莱品类页
router.get('/outlets/:channel', outlets.channel); // 奥莱频道页

// 商品详情
router.get('/outletslist', outletsList.index);


router.get(/^\/([\d]+)(.*)/, detail.showMain);                          // 新的商品详情routers
router.get(/\/p([\d]+)(.*)/, detail.showMainBack);                      // 老的商品详情routers

router.get('/detail/header', detail.productHeader);                     // 价格数据重新获取接口
router.get('/detail/comment', detail.indexComment);                     // 商品评论
router.get('/detail/consult', detail.indexConsult);                     // 商品咨询
router.post('/detail/consult', auth, detail.createConsult);             // 创建咨询
router.get('/detail/consult/like/:id', auth, detail.likeConsult);       // 咨询喜欢
router.get('/detail/consult/useful/:id', auth, detail.usefulConsult);   // 咨询有用
router.get('/detail/hotarea', detail.indexHotArea);                     // 商品热区
router.post('/index/favoriteBrand', favorite.changeFavoriteBrand);      // 收藏品牌
router.post('/item/togglecollect', favorite.collectProduct);            // 收藏商品
router.get('/detail/return', detail.detailReturn);                      // 特殊商品退换货
router.get('/detail/recommend', detail.recommend);                      // 推荐商品
router.get('/index/isfav', favorite.isFavoriteBrand);                   // 品牌收藏状态
router.get('/index/favnum', favorite.num);                              // 收藏数量(先店铺,后品牌)
router.get('/detail/coupon', auth, coupon.acquire);                     // 获得优惠券
router.get('/detail/getPacakge', detail.getPackage);                    // 获取套餐
router.get('/detail/notify/status', auth, notify.show);                 // 到货通知状态
router.post('/detail/notify/add', auth, notify.add);                    // 增加到货通知
router.post('/detail/notify/cancel', auth, notify.cancel);              // 删除到货通知

// 全球购routers
router.get('/list/global', '/list/global', globalCtrl.list); // 全球购列表页
router.get('/list/global/:pathQs','/list/global/:pathQs', paramParse, globalCtrl.list); // 全球购列表页
router.get('/global/list', globalCtrl.list); // 全球购列表页  【老路由,待删】
router.get('/global/detail', globalCtrl.detail);
router.get(/\/global\/([\d]+)(.*)/, globalCtrl.detail);

// router.get(/\/global\/([\d]+)(.*)/, globalCtrl.detail); // 全球购商品详情页

// 搜索
router.get('/search', '/search', gbk2utf, search.index);
router.get('/search/filter/brands', search.searchFilterBrands);
router.get('/search/suggest', search.suggest); // 搜索提示
router.get('/api/suggest', search.suggest4Old);
router.get('/search/history', search.searchHistory); // 搜索历史提示
router.get('/search/less/recommend', search.searchLessRecommend);// 搜索少或无 有可能喜欢
router.get('/search/keyword/:id', search.keyword);
router.get('/search/chanpin/:id', search.keyId);

// 新品到着
router.get('/list/new', list.newWithChannel);
router.get('/list/new/:pathQs', paramParse, list.newWithChannel);

// 商品分类列表页
router.get('/list', '/list', gbk2utf, list.index);
router.get('/list/index', gbk2utf, list.index);
router.get('/list/:pathQs', '/list/:pathQs', paramParse, gbk2utf, list.index);

// 品牌店铺
router.get('/index/about', list.brandAbout); // 品牌店铺介绍页
router.post('/index/isFavoriteBrand', list.isFavoriteBrand); // 判断用户是否收藏品牌
router.post('/index/getNodeContent', list.getNodeContent); // 品牌页水牌
router.post('/index/getAdnav', list.getAdnav); // 品牌页系列

router.get('/brand/couponsync', list.brandCouponSync);
router.get('/shop/couponsync', list.shopCouponSync);

router.get('/shop', shop.index); // 店铺首页
// router.get('/shop/:domain/:shopId.html', shop.index); // 店铺首页
router.get('/shop/:shopInfo.html', '/shop/:shopInfo.html', shop.index); // 店铺首页
router.get('/shop/:shopInfo', '/shop/:shopInfo', shop.list); // 店铺列表页
router.get('/shop/:shopInfo/:pathQs', '/shop/:shopInfo/:pathQs', paramParse, shop.list); // 店铺列表页
// router.get('/shoplist', shop.list); // 店铺列表页
router.post('/shop/article', shop.article); // 店铺推荐文章
router.post('/shop/togglecollect', favorite.collectShop); // 店铺收藏
router.post('/index/isFavoriteShop', favorite.isFavShop); // 判断用户是否收藏品牌


// 学生优惠routers
router.get('/students', students.index); // students 首页
router.get('/students/schoolArea', students.schoolArea); // 学校地区
router.get('/students/schoolList', students.schoolList); // 学校地区
router.get('/students/eduLevel', students.eduLevel); // 学校地区
router.get('/students/verify', students.verify); // 身份验证
router.get('/students/userAcquireStatus', students.userAcquireStatus); // 获取优惠券领取状态
router.get('/students/list', students.list); // 获取优惠券领取状态

// 新品到着改版
router.get('/newArrive', newArrive.index); // 获取优惠券领取状态

// list&item 站点地图
router.get('/sitemap.xml', sitemap.siteMap);

module.exports = router;