Authored by 郭成尧

next-handle-fav

... ... @@ -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,
... ...
... ... @@ -221,6 +221,23 @@ const favCount = (shopId, uid, channel, udid) => {
return singleAPI.get('favorite', finalParams);
};
/**
* 获取非红人店铺的店铺装修数据
* @param {int} shopId 店铺id
* @return array
*/
const getShopDecorator = (shopId) => {
return api.get('', {
method: 'app.shopsdecorator.getList',
shop_id: shopId
}, {
cache: true,
code: 200
}).then((result) => {
return (result && result.data) || {};
});
};
module.exports = {
getShopBrands,
getShopInfo,
... ... @@ -230,5 +247,6 @@ module.exports = {
getBanner,
getShopsdecorator,
getShopCategory,
favCount
favCount,
getShopDecorator
};
... ...
<div class="good-list-page yoho-page">
{{#if brandInfo.banner}}
{{# brandInfo}}
<div id="brand-header" class="brand-header" data-id={{id}}>
<img src={{image2 banner q=60}}>
<a class="btn-intro" href="javascript:void(0);">
品牌介绍
</a>
<a class="btn-col" href="javascript:void(0);">
<span class="iconfont">&#xe622;</span>
<span class="txt"></span>
</a>
</div>
<div id="intro-box" class="brand-intro-box hide">
<div id="brand-intro" class="brand-intro">
<h2>品牌介绍</h2>
<div class="con">
{{{intro}}}
</div>
<p class="fo">
<span class="iconfont">&#xe629;</span> 100%品牌授权正品
</p>
<span class="iconfont close-intro">&#xe623;</span>
</div>
</div>
{{/ brandInfo}}
{{/if}}
<!-- 优惠卷 -->
<div class="coupon-group"></div>
<!-- /品牌页面 -->
{{!--筛选tab--}}
<div class="filter-box">
{{> product/filter-tab-new}}
... ...
<div class="good-list-page yoho-page">
<!-- 基础店铺页面 -->
{{# shopInfo}}
<div id="brand-header" class="brand-header" data-id={{shops_id}} data-isbaseshop="{{isBaseShop}}">
<img src={{image2 banner q=60}}>
<a class="btn-intro" href="javascript:void(0);">
店铺介绍
</a>
<a class="btn-col" href="javascript:void(0);">
<span class="iconfont">&#xe622;</span>
<span class="txt"></span>
</a>
</div>
<div id="intro-box" class="brand-intro-box hide">
<div id="brand-intro" class="brand-intro">
<h2>店铺介绍</h2>
<div class="con">
{{{shop_intro}}}
</div>
<p class="fo">
<span class="iconfont">&#xe629;</span>
100%品牌授权正品
</p>
<span class="iconfont close-intro">&#xe623;</span>
</div>
</div>
{{/ shopInfo}}
<!-- 优惠卷 -->
<div class="coupon-group"></div>
<!-- /基础店铺页面 -->
{{!--筛选tab--}}
<div class="filter-box">
{{> product/filter-tab-new}}
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-03-23 11:02:31
* @Last Modified by: Targaryen
* @Last Modified time: 2017-07-18 14:29:33
* @Last Modified time: 2017-08-02 11:11:07
*/
/* 红人店铺数据处理 */
... ... @@ -365,9 +365,32 @@ const pushGoodsInfo = (decorators, goodsList) => {
return decorators;
};
/**
* 获取非红人店铺的店铺 Banner
*/
const getShopBanner = (shopDecoratorList) => {
let banner = '';
_.forEach(shopDecoratorList, floorData => {
let resData = JSON.parse(floorData.resource_data);
if (floorData.resource_name) {
floorData[_.camelCase(floorData.resource_name)] = true;
}
// 店铺banner
if (floorData.shopTopBannerApp) {
banner = resData[0].shopSrc;
}
});
return banner;
};
module.exports = {
floor,
shopIntro,
category,
pushGoodsInfo
pushGoodsInfo,
getShopBanner
};
... ...