Authored by 郭成尧

resolveShopParams

@@ -78,6 +78,18 @@ const shop = { @@ -78,6 +78,18 @@ const shop = {
78 }, 78 },
79 79
80 /** 80 /**
  81 + * 解析店铺的参数
  82 + */
  83 + resolveShopParams(req, res, next) {
  84 + if (req.params.shopParams) {
  85 + req.query.shop_id = _.last(_.split(req.params.shopParams, '-'));
  86 + req.query.domain = req.params.shopParams.replace(`-${req.query.shop_id}`, '');
  87 + }
  88 +
  89 + return next();
  90 + },
  91 +
  92 + /**
81 * 店铺统一入口 93 * 店铺统一入口
82 */ 94 */
83 entry(req, res, next) { 95 entry(req, res, next) {
@@ -162,10 +162,20 @@ const resolvePathParamsAjax = (req, res, next) => { @@ -162,10 +162,20 @@ const resolvePathParamsAjax = (req, res, next) => {
162 * 解析 Path 类型店铺商品列表异步请求中 URL 的参数 162 * 解析 Path 类型店铺商品列表异步请求中 URL 的参数
163 */ 163 */
164 const resolveShopPathParamsAjax = (req, res, next) => { 164 const resolveShopPathParamsAjax = (req, res, next) => {
165 - let pathParams = _.last(_.split(req.query.currentUrl, '/'));  
166 - let currentUrlParams = listParamsProcess.getParams(pathParams);  
167 - let shopInfoPath = _.replace(req.query.currentUrl, `/${pathParams}`, '');  
168 - let shopId = _.last(_.split(shopInfoPath, '-')); 165 + let shopId;
  166 + let currentUrlParams;
  167 + let pathSplitArr = _.compact(_.split(req.query.currentUrl, '/'));
  168 + let pathParams = _.last(pathSplitArr);
  169 +
  170 + if (pathSplitArr.length === 2) {
  171 + shopId = _.last(_.split(pathParams, '-'));
  172 + } else {
  173 + currentUrlParams = listParamsProcess.getParams(pathParams);
  174 +
  175 + let shopInfoPath = _.replace(req.query.currentUrl, `/${pathParams}`, '');
  176 +
  177 + shopId = _.last(_.split(shopInfoPath, '-'));
  178 + }
169 179
170 delete req.query.currentUrl; 180 delete req.query.currentUrl;
171 181