...
|
...
|
@@ -11,7 +11,7 @@ const headerModel = require('../../../doraemon/models/header'); |
|
|
const _ = require('lodash');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const productProcess = require(`${utils}/product-process`);
|
|
|
const redShopPrcs = require(`${utils}/redshop-process`);
|
|
|
const shopPrcs = require(`${utils}/shop-process`);
|
|
|
const co = require('bluebird').coroutine;
|
|
|
|
|
|
const shop = {
|
...
|
...
|
@@ -38,9 +38,17 @@ const shop = { |
|
|
let shopInfoApi = (yield shopModel.getShopInfo(shopId, uid)) || {};
|
|
|
let shopInfo = _.get(shopInfoApi, 'data', {});
|
|
|
|
|
|
// 红人店铺
|
|
|
if (shopInfo && shopInfo.is_red_shop === 1) {
|
|
|
shopInfo.shopId = _.get(shopInfo, 'shops_id', '');
|
|
|
shopInfo.isRedShop = true;
|
|
|
}
|
|
|
|
|
|
// 店铺,非红人店铺,跳转店铺列表
|
|
|
if (shopInfo && shopInfo.is_red_shop !== 1) {
|
|
|
shopInfo.isShop = true;
|
|
|
}
|
|
|
|
|
|
// 可能没有店铺信息,跳转店铺列表
|
|
|
req.shopInfo = shopInfo;
|
|
|
} else if (domain) {
|
|
|
let domainInfo = (yield shopModel.getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息
|
...
|
...
|
@@ -55,11 +63,11 @@ const shop = { |
|
|
}
|
|
|
}
|
|
|
|
|
|
if (req.shopInfo.shopId) { // 店铺
|
|
|
if (req.shopInfo.isRedShop) { // 店铺
|
|
|
return shop.redShop(req, res, next);
|
|
|
} else if (req.shopInfo.id) { // 品牌,id 来自 domainInfo
|
|
|
return shop.brand(req, res, next);
|
|
|
} else if (shopId) { // 没有查到店铺数据但是有 shopId 的请求
|
|
|
} else if (shopId) { // 非红人店铺非品牌
|
|
|
return shop.list(req, res, next);
|
|
|
} else { // 什么都没有,去首页
|
|
|
return res.redirect(helpers.urlFormat('', {go: '-1'}));
|
...
|
...
|
@@ -122,8 +130,7 @@ const shop = { |
|
|
};
|
|
|
|
|
|
co(function* () {
|
|
|
let [banner, brandInfo, goodsListApi] = yield Promise.all([
|
|
|
shopModel.getBrandBanner(brandId),
|
|
|
let [brandInfo, goodsListApi] = yield Promise.all([
|
|
|
shopModel.getBrandIntro(brandId, uid),
|
|
|
searchModel.getBrandGoods(searchParam)
|
|
|
]);
|
...
|
...
|
@@ -131,7 +138,6 @@ const shop = { |
|
|
let title = brandInfo.title;
|
|
|
let goodsList = productProcess.processProductList(_.get(goodsListApi, 'data.product_list', []));
|
|
|
|
|
|
brandInfo.banner = banner;
|
|
|
|
|
|
res.render('newshop/shop-brand', {
|
|
|
module: 'product',
|
...
|
...
|
@@ -145,7 +151,6 @@ const shop = { |
|
|
keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰',
|
|
|
description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
|
|
|
brandId: brandId,
|
|
|
brandInfo: brandInfo,
|
|
|
goodsList: goodsList,
|
|
|
shopPage: true,
|
|
|
_noLazy: true,
|
...
|
...
|
@@ -158,7 +163,7 @@ const shop = { |
|
|
* 红人店铺
|
|
|
*/
|
|
|
redShop(req, res, next) {
|
|
|
let shopId = req.shopInfo.shopId;
|
|
|
let shopId = req.shopInfo.shops_id;
|
|
|
let channel = req.yoho.channel || 'boys';
|
|
|
let uid = req.user.uid || 0;
|
|
|
let udid = req.sessionID || 'yoho';
|
...
|
...
|
@@ -178,11 +183,11 @@ const shop = { |
|
|
let banner = _.get(bannerData, 'data.banner');
|
|
|
let shopInfo = req.shopInfo;
|
|
|
let favCount = _.get(favCountData, 'data[0].approximateCount', '2.1w');
|
|
|
let decoratorsAll = redShopPrcs.floor(_.get(decoratorsData, 'data.modules', []));
|
|
|
let category = redShopPrcs.category(_.get(categoryData, 'data', []), shopId);
|
|
|
let decoratorsAll = shopPrcs.floor(_.get(decoratorsData, 'data.modules', []));
|
|
|
let category = shopPrcs.category(_.get(categoryData, 'data', []), shopId);
|
|
|
|
|
|
let goodsListBySkn = yield searchModel.searchProductBySkn(decoratorsAll.skns);
|
|
|
let decorators = redShopPrcs.pushGoodsInfo(decoratorsAll.decorators, goodsListBySkn);
|
|
|
let decorators = shopPrcs.pushGoodsInfo(decoratorsAll.decorators, goodsListBySkn);
|
|
|
|
|
|
shopInfo.shop_intro_link = helpers.urlFormat('/product/index/intro', {shop_id: shopId});
|
|
|
|
...
|
...
|
@@ -224,8 +229,9 @@ const shop = { |
|
|
*/
|
|
|
list(req, res, next) {
|
|
|
co(function* () {
|
|
|
let title = '店铺商品列表';
|
|
|
let shopId = req.query.shop_id;
|
|
|
let shopInfo = req.shopInfo || {};
|
|
|
let title = shopInfo.shop_name || '店铺商品列表';
|
|
|
let searchParam = {
|
|
|
isApp: req.yoho.isApp,
|
|
|
shop_id: shopId,
|
...
|
...
|
@@ -238,6 +244,15 @@ const shop = { |
|
|
let goodsListApi = yield searchModel.getShopGoods(searchParam);
|
|
|
let goodsList = productProcess.processProductList(_.get(goodsListApi, 'data.product_list', []));
|
|
|
|
|
|
if (shopInfo.isShop) {
|
|
|
let shopDecorator = yield shopModel.getShopDecorator(shopId);
|
|
|
let shopDecoratorList = _.get(shopDecorator, 'list', []);
|
|
|
|
|
|
if (shopDecoratorList) {
|
|
|
shopInfo.banner = shopPrcs.getShopBanner(shopDecoratorList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
res.render('newshop/shop-list', {
|
|
|
module: 'product',
|
|
|
page: 'shop-list',
|
...
|
...
|
@@ -250,6 +265,7 @@ const shop = { |
|
|
keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰',
|
|
|
description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
|
|
|
shopId: shopId,
|
|
|
shopInfo: shopInfo,
|
|
|
goodsList: goodsList,
|
|
|
shopPage: true,
|
|
|
_noLazy: true,
|
...
|
...
|
|