Authored by 郭成尧

router-adjust

@@ -9,9 +9,8 @@ @@ -9,9 +9,8 @@
9 const router = require('express').Router(); // eslint-disable-line 9 const router = require('express').Router(); // eslint-disable-line
10 10
11 const auth = require('../../doraemon/middleware/auth'); 11 const auth = require('../../doraemon/middleware/auth');
12 -  
13 const rewrite = require('../../doraemon/middleware/rewrite'); 12 const rewrite = require('../../doraemon/middleware/rewrite');
14 - 13 +const cors = require('../../doraemon/middleware/cors');
15 const cRoot = './controllers'; 14 const cRoot = './controllers';
16 15
17 // 商品详情controller 16 // 商品详情controller
@@ -117,107 +116,84 @@ router.get(/^\/(.*?)-sale\/vip/, rewrite.resolve, sale.vip); @@ -117,107 +116,84 @@ router.get(/^\/(.*?)-sale\/vip/, rewrite.resolve, sale.vip);
117 router.get(/^\/(.*?)-sale/, rewrite.resolve, sale.index); 116 router.get(/^\/(.*?)-sale/, rewrite.resolve, sale.index);
118 117
119 router.get('/sale/discount', sale.discount); 118 router.get('/sale/discount', sale.discount);
120 -  
121 router.get('/sale/discount/detail', sale.discountDetail); 119 router.get('/sale/discount/detail', sale.discountDetail);
122 router.get('/sale/breakingYards', sale.breakingYards); 120 router.get('/sale/breakingYards', sale.breakingYards);
123 -  
124 router.get('/sale/vip', sale.vip); 121 router.get('/sale/vip', sale.vip);
125 router.get('/sale/discount/getTime', sale.getTime); 122 router.get('/sale/discount/getTime', sale.getTime);
126 -  
127 router.get('/sale/search', rewrite.resolvePathParamsAjax, sale.search); 123 router.get('/sale/search', rewrite.resolvePathParamsAjax, sale.search);
128 router.get('/sale/filter', sale.filter); 124 router.get('/sale/filter', sale.filter);
129 125
130 router.get('/outlet', outlet.index); 126 router.get('/outlet', outlet.index);
131 router.get('/outlet/activity', outlet.activityDetail); 127 router.get('/outlet/activity', outlet.activityDetail);
132 router.get('/outlet/activityTime', outlet.activityTime); 128 router.get('/outlet/activityTime', outlet.activityTime);
133 -  
134 router.get('/outlet/activityinfo', outlet.activityList); 129 router.get('/outlet/activityinfo', outlet.activityList);
135 130
136 router.get('/recommend-for-you/userCenter', recommendForYou.userCenter); 131 router.get('/recommend-for-you/userCenter', recommendForYou.userCenter);
137 router.get('/recommend-for-you/cart', recommendForYou.cart); 132 router.get('/recommend-for-you/cart', recommendForYou.cart);
138 133
139 -  
140 router.get('/seckill', seckill.index); // 秒杀列表页 134 router.get('/seckill', seckill.index); // 秒杀列表页
141 router.get('/seckill/list', seckill.indexData); 135 router.get('/seckill/list', seckill.indexData);
142 -  
143 router.post('/seckill/remind', seckill.remind); // only app; 秒杀提醒 136 router.post('/seckill/remind', seckill.remind); // only app; 秒杀提醒
144 router.get('/seckill/get-product-list', seckill.getProductList); // 秒杀列表根据活动id获取商品列表 137 router.get('/seckill/get-product-list', seckill.getProductList); // 秒杀列表根据活动id获取商品列表
145 138
146 -// 搜索主页  
147 -router.get('/search/index', search.index);  
148 -  
149 -// 推广落地页  
150 -router.get('/search/so/:query.html', rewrite.sortParams, chanpin.keyword); 139 +router.get('/search/index', search.index); // 搜索主页
  140 +router.get('/search/so/:query.html', rewrite.sortParams, chanpin.keyword); // 推广落地页
151 router.get('/search/chanpin/:id.html', rewrite.sortParams, chanpin.keyId); 141 router.get('/search/chanpin/:id.html', rewrite.sortParams, chanpin.keyId);
152 router.get('/search/chanpin/goods', chanpin.searchGoods); // 搜索的商品 142 router.get('/search/chanpin/goods', chanpin.searchGoods); // 搜索的商品
153 -  
154 -// 搜索落地页  
155 -router.get('/search/list', rewrite.sortParams, search.list);  
156 -  
157 -// filter  
158 -router.get('/search/filter', search.filter);  
159 -  
160 -// fuzzyDatas  
161 -router.get('/search/fuzzyDatas', search.fuzzyDatas);  
162 - 143 +router.get('/search/list', rewrite.sortParams, search.list); // 搜索落地页
  144 +router.get('/search/filter', search.filter); // filter
  145 +router.get('/search/fuzzyDatas', search.fuzzyDatas); // fuzzyDatas
163 router.get('/search/search', search.search); // ajax 请求商品数据 146 router.get('/search/search', search.search); // ajax 请求商品数据
164 router.get('/search/brand/goods', search.searchBrandGoods); // 搜索品牌下的商品 147 router.get('/search/brand/goods', search.searchBrandGoods); // 搜索品牌下的商品
165 router.get('/search/shop/goods', search.searchShopGoods); // 搜索店铺下的商品 148 router.get('/search/shop/goods', search.searchShopGoods); // 搜索店铺下的商品
166 149
167 -// 全球购路由重写  
168 -router.get('/list/global(/*)?', rewrite.resolvePathParams, globalPro.list); // 全球购列表页  
169 -  
170 -// 品类  
171 -router.get('/index/index', rewrite.sortParams, list.category); 150 +router.get('/list/global(/*)?', rewrite.resolvePathParams, globalPro.list); // 全球购路由重写 全球购列表页
  151 +router.get('/index/index', rewrite.sortParams, list.category); // 旧品类首页
172 router.get('/list/index', rewrite.sortParams, list.category); // 兼容 PC 的链接 152 router.get('/list/index', rewrite.sortParams, list.category); // 兼容 PC 的链接
173 router.get('/list(/*)?', rewrite.resolvePathParams, list.listNew); // 列表新的 URL 153 router.get('/list(/*)?', rewrite.resolvePathParams, list.listNew); // 列表新的 URL
174 -router.get('/search/category', rewrite.resolvePathParamsAjax, list.getCategoryGoods); 154 +router.get('/search/category',
  155 + cors,
  156 + rewrite.resolvePathParamsAjax,
  157 + list.getCategoryGoods);
175 158
176 // 品牌 | 店铺 159 // 品牌 | 店铺
177 router.get('/index/shopAppCookie', list.shopAppCookie); 160 router.get('/index/shopAppCookie', list.shopAppCookie);
178 router.get('/index/shopFav', list.shopFav); 161 router.get('/index/shopFav', list.shopFav);
179 -  
180 router.get('/index/category', list.shopCategory); 162 router.get('/index/category', list.shopCategory);
181 router.get('/index/getBrandCouponsList', list.getBrandCouponsList); 163 router.get('/index/getBrandCouponsList', list.getBrandCouponsList);
182 164
183 -// 店铺重构  
184 router.get('/shop', newShop.redirect); // 老路由重定向前置处理 165 router.get('/shop', newShop.redirect); // 老路由重定向前置处理
185 router.get('/shop/:domain-:shop_id.html', newShop.resolveParams); // 新入口 166 router.get('/shop/:domain-:shop_id.html', newShop.resolveParams); // 新入口
186 -router.get('/shop/:domain-:shop_id/*', list.listNew); // 店铺列表路由 167 +router.get('/shop/:domain-:shop_id/*', rewrite.resolvePathParams, newShop.goodsList); // 店铺商品列表
  168 +router.get('/shop/goodslist',
  169 + cors,
  170 + rewrite.resolvePathParamsAjax,
  171 + newShop.goodsListAjax); // 店铺商品列表异步查询
187 172
188 router.get('/index/brand', newShop.entry); // 旧的路由,走到新的 controller 173 router.get('/index/brand', newShop.entry); // 旧的路由,走到新的 controller
189 router.get('/index/brandFav', newShop.brandFav); 174 router.get('/index/brandFav', newShop.brandFav);
190 router.get('/new/shop/hotlist', newShop.shopHotList); 175 router.get('/new/shop/hotlist', newShop.shopHotList);
191 router.get('/index/getShopCouponsList', newShop.getShopCouponsList); 176 router.get('/index/getShopCouponsList', newShop.getShopCouponsList);
192 router.post('/index/userCoupon', newShop.userCoupon); 177 router.post('/index/userCoupon', newShop.userCoupon);
193 -  
194 -router.get('/red-shop', newShop.redShop);  
195 -  
196 -// end- 店铺重构  
197 -  
198 -// 店铺介绍  
199 -router.get('/index/intro', list.shopIntro);  
200 -  
201 -// 品牌|店铺收藏|取消收藏  
202 -router.get('/opt/favoriteBrand', list.favoriteBrand); 178 +router.get('/red-shop', newShop.redShop); // 红人店铺
  179 +router.get('/index/intro', list.shopIntro); // 店铺介绍
  180 +router.get('/opt/favoriteBrand', list.favoriteBrand); // 品牌|店铺收藏|取消收藏
  181 +router.get('/index/allBrand', newShop.allBrand); // 店铺全部品牌
203 182
204 // 新品到着 183 // 新品到着
205 router.get('/new', rewrite.channel, news.newGoodsRedirect); 184 router.get('/new', rewrite.channel, news.newGoodsRedirect);
206 185
207 // 新品到着 SEO优化 186 // 新品到着 SEO优化
208 router.get(/^\/(.*?)-new/, rewrite.resolve, rewrite.resolvePathParams, news.newGoods); 187 router.get(/^\/(.*?)-new/, rewrite.resolve, rewrite.resolvePathParams, news.newGoods);
209 -  
210 router.get('/list/new', news.newGoods); // 兼容 PC 的链接 188 router.get('/list/new', news.newGoods); // 兼容 PC 的链接
211 router.get('/new/selectNewSale', rewrite.resolvePathParamsAjax, news.selectNewSale); 189 router.get('/new/selectNewSale', rewrite.resolvePathParamsAjax, news.selectNewSale);
212 router.get('/new/filter', rewrite.resolvePathParamsAjax, news.filter); 190 router.get('/new/filter', rewrite.resolvePathParamsAjax, news.filter);
213 -  
214 router.get('/newnew', news._newGoods); // TODO: repleace /new 191 router.get('/newnew', news._newGoods); // TODO: repleace /new
215 router.get('/new/recommend-shop.json', news.recommendShop); 192 router.get('/new/recommend-shop.json', news.recommendShop);
216 router.get('/new/goods.json', news.fetchNew); 193 router.get('/new/goods.json', news.fetchNew);
217 router.get('/new/goods-filter', news.goodsFilter); 194 router.get('/new/goods-filter', news.goodsFilter);
218 router.get('/new/shops', news.brands); 195 router.get('/new/shops', news.brands);
219 196
220 -  
221 // 新品到着(blk) 197 // 新品到着(blk)
222 router.get('/blknew', news.blkNewGoods); 198 router.get('/blknew', news.blkNewGoods);
223 199
@@ -230,8 +206,6 @@ router.post('/bundle/cart/add', bundle.addToCart); // 套装加入购物车 @@ -230,8 +206,6 @@ router.post('/bundle/cart/add', bundle.addToCart); // 套装加入购物车
230 router.post('/opt/favoriteProduct', newDetail.favoriteProduct); // 商品收藏、取消收藏 206 router.post('/opt/favoriteProduct', newDetail.favoriteProduct); // 商品收藏、取消收藏
231 router.get('/detail/limitHelp', newDetail.limitHelp); 207 router.get('/detail/limitHelp', newDetail.limitHelp);
232 208
233 -router.get('/index/allBrand', newShop.allBrand); // 店铺全部品牌  
234 -  
235 router.get('/global/list', globalPro.list); // 全球购列表页 209 router.get('/global/list', globalPro.list); // 全球购列表页
236 router.get('/global/search', rewrite.resolvePathParamsAjax, globalPro.search); // 全球购列表页搜索数据 210 router.get('/global/search', rewrite.resolvePathParamsAjax, globalPro.search); // 全球购列表页搜索数据
237 router.get(/^\/global\/(\d+)\.html/, globalPro.detail); // 全球购店铺详情页 211 router.get(/^\/global\/(\d+)\.html/, globalPro.detail); // 全球购店铺详情页