Showing
4 changed files
with
33 additions
and
7 deletions
@@ -39,15 +39,18 @@ const shop = { | @@ -39,15 +39,18 @@ const shop = { | ||
39 | if (shopId) { | 39 | if (shopId) { |
40 | let shopInfo = (yield listModel.getShopInfo(shopId, uid)) || {}; | 40 | let shopInfo = (yield listModel.getShopInfo(shopId, uid)) || {}; |
41 | 41 | ||
42 | - req.shopInfo = _.assign(shopInfo, {shopId: shopId}); // 通过店铺 ID 查询店铺类型 | 42 | + if (shopInfo) { |
43 | + shopInfo.shopId = _.get(shopInfo, 'shops_id', ''); | ||
44 | + } | ||
45 | + req.shopInfo = shopInfo; | ||
43 | } else if (domain) { | 46 | } else if (domain) { |
44 | let domainInfo = (yield listModel.getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息 | 47 | let domainInfo = (yield listModel.getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息 |
45 | 48 | ||
46 | - if (domainInfo.shopId && domainInfo.type === '2') { | 49 | + if (domainInfo.shopId && domainInfo.type === '2') { // 红人店铺 |
47 | let shopInfo = yield listModel.getShopInfo(domainInfo.shopId, uid); | 50 | let shopInfo = yield listModel.getShopInfo(domainInfo.shopId, uid); |
48 | 51 | ||
49 | _.assign(req.shopInfo, domainInfo, shopInfo); | 52 | _.assign(req.shopInfo, domainInfo, shopInfo); |
50 | - } else { | 53 | + } else { // 品牌 |
51 | req.shopInfo = domainInfo; | 54 | req.shopInfo = domainInfo; |
52 | } | 55 | } |
53 | } | 56 | } |
@@ -217,7 +220,7 @@ const shop = { | @@ -217,7 +220,7 @@ const shop = { | ||
217 | list(req, res, next) { | 220 | list(req, res, next) { |
218 | co(function* () { | 221 | co(function* () { |
219 | let title = '商品列表'; | 222 | let title = '商品列表'; |
220 | - let shopId = req.shopInfo.shopId; | 223 | + let shopId = req.query.shop_id; |
221 | let searchParam = { | 224 | let searchParam = { |
222 | isApp: req.yoho.isApp, | 225 | isApp: req.yoho.isApp, |
223 | shop_id: shopId, | 226 | shop_id: shopId, |
@@ -363,6 +363,28 @@ const searchBrandGoods = (req, res, next) => { | @@ -363,6 +363,28 @@ const searchBrandGoods = (req, res, next) => { | ||
363 | })().catch(next); | 363 | })().catch(next); |
364 | }; | 364 | }; |
365 | 365 | ||
366 | +/** | ||
367 | + * 搜索店铺下的商品 | ||
368 | + */ | ||
369 | +const searchShopGoods = (req, res, next) => { | ||
370 | + co(function* () { | ||
371 | + let goodListApi = yield searchModel.getShopGoods(req.query); | ||
372 | + | ||
373 | + let goodsData = _.get(goodListApi, 'data', []); | ||
374 | + let goodsList = productProcess.processProductList(_.get(goodListApi, 'data.product_list', [])); | ||
375 | + | ||
376 | + if (goodsList) { | ||
377 | + res.render('search/goods-list-ajax', { | ||
378 | + layout: false, | ||
379 | + goodsList: goodsList, | ||
380 | + _noLazy: req.query.noLazy || false | ||
381 | + }); | ||
382 | + } else { | ||
383 | + res.json(goodsData); | ||
384 | + } | ||
385 | + })().catch(next); | ||
386 | +}; | ||
387 | + | ||
366 | module.exports = { | 388 | module.exports = { |
367 | list, | 389 | list, |
368 | filter, | 390 | filter, |
@@ -371,5 +393,6 @@ module.exports = { | @@ -371,5 +393,6 @@ module.exports = { | ||
371 | fuzzyDatas, | 393 | fuzzyDatas, |
372 | keyword, | 394 | keyword, |
373 | keyId, | 395 | keyId, |
374 | - searchBrandGoods | 396 | + searchBrandGoods, |
397 | + searchShopGoods | ||
375 | }; | 398 | }; |
@@ -149,7 +149,7 @@ router.get('/search/fuzzyDatas', search.fuzzyDatas); | @@ -149,7 +149,7 @@ router.get('/search/fuzzyDatas', search.fuzzyDatas); | ||
149 | 149 | ||
150 | router.get('/search/search', search.search); // ajax 请求商品数据 | 150 | router.get('/search/search', search.search); // ajax 请求商品数据 |
151 | router.get('/search/brand/goods', search.searchBrandGoods); // 搜索品牌下的商品 | 151 | router.get('/search/brand/goods', search.searchBrandGoods); // 搜索品牌下的商品 |
152 | - | 152 | +router.get('/search/shop/goods', search.searchShopGoods); // 搜索店铺下的商品 |
153 | // 品类 | 153 | // 品类 |
154 | router.get('/index/index', rewrite.sortParams, list.category); | 154 | router.get('/index/index', rewrite.sortParams, list.category); |
155 | router.get('/list/index', rewrite.sortParams, list.category); // 兼容 PC 的链接 | 155 | router.get('/list/index', rewrite.sortParams, list.category); // 兼容 PC 的链接 |
@@ -8,6 +8,6 @@ let productListWithFilterModel = | @@ -8,6 +8,6 @@ let productListWithFilterModel = | ||
8 | shop_id: shopId, | 8 | shop_id: shopId, |
9 | page: 2, // 首页服务端已经渲染 | 9 | page: 2, // 首页服务端已经渲染 |
10 | isShopList: 'Y' // 传给 filter,表明调用哪个接口获取筛选面板的数据 | 10 | isShopList: 'Y' // 传给 filter,表明调用哪个接口获取筛选面板的数据 |
11 | - }, 'product/search/brand/goods'); | 11 | + }, 'product/search/shop/goods'); |
12 | 12 | ||
13 | productListWithFilterModel.getFilter(); | 13 | productListWithFilterModel.getFilter(); |
-
Please register or login to post a comment