Authored by 郭成尧

shop-list-ok

... ... @@ -39,15 +39,18 @@ const shop = {
if (shopId) {
let shopInfo = (yield listModel.getShopInfo(shopId, uid)) || {};
req.shopInfo = _.assign(shopInfo, {shopId: shopId}); // 通过店铺 ID 查询店铺类型
if (shopInfo) {
shopInfo.shopId = _.get(shopInfo, 'shops_id', '');
}
req.shopInfo = shopInfo;
} else if (domain) {
let domainInfo = (yield listModel.getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息
if (domainInfo.shopId && domainInfo.type === '2') {
if (domainInfo.shopId && domainInfo.type === '2') { // 红人店铺
let shopInfo = yield listModel.getShopInfo(domainInfo.shopId, uid);
_.assign(req.shopInfo, domainInfo, shopInfo);
} else {
} else { // 品牌
req.shopInfo = domainInfo;
}
}
... ... @@ -217,7 +220,7 @@ const shop = {
list(req, res, next) {
co(function* () {
let title = '商品列表';
let shopId = req.shopInfo.shopId;
let shopId = req.query.shop_id;
let searchParam = {
isApp: req.yoho.isApp,
shop_id: shopId,
... ...
... ... @@ -363,6 +363,28 @@ const searchBrandGoods = (req, res, next) => {
})().catch(next);
};
/**
* 搜索店铺下的商品
*/
const searchShopGoods = (req, res, next) => {
co(function* () {
let goodListApi = yield searchModel.getShopGoods(req.query);
let goodsData = _.get(goodListApi, 'data', []);
let goodsList = productProcess.processProductList(_.get(goodListApi, 'data.product_list', []));
if (goodsList) {
res.render('search/goods-list-ajax', {
layout: false,
goodsList: goodsList,
_noLazy: req.query.noLazy || false
});
} else {
res.json(goodsData);
}
})().catch(next);
};
module.exports = {
list,
filter,
... ... @@ -371,5 +393,6 @@ module.exports = {
fuzzyDatas,
keyword,
keyId,
searchBrandGoods
searchBrandGoods,
searchShopGoods
};
... ...
... ... @@ -149,7 +149,7 @@ router.get('/search/fuzzyDatas', search.fuzzyDatas);
router.get('/search/search', search.search); // ajax 请求商品数据
router.get('/search/brand/goods', search.searchBrandGoods); // 搜索品牌下的商品
router.get('/search/shop/goods', search.searchShopGoods); // 搜索店铺下的商品
// 品类
router.get('/index/index', rewrite.sortParams, list.category);
router.get('/list/index', rewrite.sortParams, list.category); // 兼容 PC 的链接
... ...
... ... @@ -8,6 +8,6 @@ let productListWithFilterModel =
shop_id: shopId,
page: 2, // 首页服务端已经渲染
isShopList: 'Y' // 传给 filter,表明调用哪个接口获取筛选面板的数据
}, 'product/search/brand/goods');
}, 'product/search/shop/goods');
productListWithFilterModel.getFilter();
... ...