Authored by 郭成尧

Merge branch 'hotfix/shopdomain' into 'gray'

Hotfix/shopdomain



See merge request !1227
... ... @@ -26,7 +26,8 @@
"type": "node",
"request": "launch",
"name": "Node",
"program": "${workspaceFolder}/app.js"
"program": "${workspaceFolder}/app.js",
"console":"integratedTerminal"
}
]
}
... ...
... ... @@ -78,6 +78,18 @@ const shop = {
},
/**
* 解析店铺的参数
*/
resolveShopParams(req, res, next) {
if (req.params.shopParams) {
req.query.shop_id = _.last(_.split(req.params.shopParams, '-'));
req.query.domain = req.params.shopParams.replace(`-${req.query.shop_id}`, '');
}
return next();
},
/**
* 店铺统一入口
*/
entry(req, res, next) {
... ...
... ... @@ -258,12 +258,29 @@ exports.filter = (req, res, next) => {
let params = {};
let currentUrlParams = {}; // 页面链接伪静态固定参数
if (req.query.currentUrl) {
if (req.query.isShopList === 'Y') {
let shopId;
let pathSplitArr = _.compact(_.split(req.query.currentUrl, '/'));
let pathParams = _.last(pathSplitArr);
if (pathSplitArr.length === 2) {
shopId = _.last(_.split(pathParams, '-'));
} else {
currentUrlParams = listParamsProcess.getParams(pathParams);
let shopInfoPath = _.replace(req.query.currentUrl, `/${pathParams}`, '');
shopId = _.last(_.split(shopInfoPath, '-'));
}
_.assign(req.query, currentUrlParams, {shop_id: shopId});
} else {
currentUrlParams = listParamsProcess.getParams(req.query.currentUrl);
delete req.query.currentUrl;
delete req.query.page;
}
delete req.query.currentUrl;
delete req.query.page;
_.assign(params, currentUrlParams, req.query);
let uid = req.user.uid || 0;
... ...
... ... @@ -167,13 +167,22 @@ router.get('/index/shopFav', list.shopFav);
router.get('/index/category', list.shopCategory);
router.get('/index/getBrandCouponsList', list.getBrandCouponsList);
router.get('/shop', newShop.redirect); // 老路由重定向前置处理
router.get('/shop/:domain-:shop_id.html', newShop.entry); // 新入口
router.get('/shop/:domain-(:shop_id)(/:pathParams)?', rewrite.resolvePathParams, newShop.goodsList); // 店铺商品列表
router.get('/shop/goodslist',
cors,
rewrite.resolveShopPathParamsAjax,
newShop.goodsListAjax); // 店铺商品列表异步查询
router.get('/shop/:shopParams.html',
newShop.resolveShopParams,
newShop.entry); // 新入口
router.get('/shop/:shopParams',
rewrite.resolvePathParams,
newShop.resolveShopParams,
newShop.goodsList); // 店铺商品列表
router.get('/shop/:shopParams/:pathParams',
rewrite.resolvePathParams,
newShop.resolveShopParams,
newShop.goodsList); // 店铺商品列表
router.get('/shop', newShop.redirect); // 老路由重定向前置处理
router.get('/index/brand', newShop.entry); // 旧的路由,走到新的 controller
router.get('/index/brandFav', newShop.brandFav);
... ...
... ... @@ -162,10 +162,20 @@ const resolvePathParamsAjax = (req, res, next) => {
* 解析 Path 类型店铺商品列表异步请求中 URL 的参数
*/
const resolveShopPathParamsAjax = (req, res, next) => {
let pathParams = _.last(_.split(req.query.currentUrl, '/'));
let currentUrlParams = listParamsProcess.getParams(pathParams);
let shopInfoPath = _.replace(req.query.currentUrl, `/${pathParams}`, '');
let shopId = _.last(_.split(shopInfoPath, '-'));
let shopId;
let currentUrlParams;
let pathSplitArr = _.compact(_.split(req.query.currentUrl, '/'));
let pathParams = _.last(pathSplitArr);
if (pathSplitArr.length === 2) {
shopId = _.last(_.split(pathParams, '-'));
} else {
currentUrlParams = listParamsProcess.getParams(pathParams);
let shopInfoPath = _.replace(req.query.currentUrl, `/${pathParams}`, '');
shopId = _.last(_.split(shopInfoPath, '-'));
}
delete req.query.currentUrl;
... ...
... ... @@ -3,15 +3,21 @@
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/7/21
*/
require('product/search/list.page.css');
const qs = require('yoho-qs');
const ProductListWithFilter = require('./list/product-list-with-filter');
require('product/search/list.page.css');
let initParams = {
page: 2,
currentUrl: location.pathname
};
if (qs) {
$.extend(initParams, qs);
}
new ProductListWithFilter(initParams, 'product/search/category');
require('common/footer');
require('./shop/coupon');
new ProductListWithFilter({
page: 2,
currentUrl: location.pathname,
isNewList: 'Y'
}, 'product/search/category');
... ...
... ... @@ -10,5 +10,5 @@ require('common/footer');
new ProductListWithFilter({
page: 2,
currentUrl: location.pathname,
isNewList: 'Y'
isShopList: 'Y'
}, 'product/shop/goodslist');
... ...