Authored by 郭成尧

next-handle-fav

@@ -11,7 +11,7 @@ const headerModel = require('../../../doraemon/models/header'); @@ -11,7 +11,7 @@ const headerModel = require('../../../doraemon/models/header');
11 const _ = require('lodash'); 11 const _ = require('lodash');
12 const helpers = global.yoho.helpers; 12 const helpers = global.yoho.helpers;
13 const productProcess = require(`${utils}/product-process`); 13 const productProcess = require(`${utils}/product-process`);
14 -const redShopPrcs = require(`${utils}/redshop-process`); 14 +const shopPrcs = require(`${utils}/shop-process`);
15 const co = require('bluebird').coroutine; 15 const co = require('bluebird').coroutine;
16 16
17 const shop = { 17 const shop = {
@@ -38,9 +38,17 @@ const shop = { @@ -38,9 +38,17 @@ const shop = {
38 let shopInfoApi = (yield shopModel.getShopInfo(shopId, uid)) || {}; 38 let shopInfoApi = (yield shopModel.getShopInfo(shopId, uid)) || {};
39 let shopInfo = _.get(shopInfoApi, 'data', {}); 39 let shopInfo = _.get(shopInfoApi, 'data', {});
40 40
  41 + // 红人店铺
41 if (shopInfo && shopInfo.is_red_shop === 1) { 42 if (shopInfo && shopInfo.is_red_shop === 1) {
42 - shopInfo.shopId = _.get(shopInfo, 'shops_id', ''); 43 + shopInfo.isRedShop = true;
43 } 44 }
  45 +
  46 + // 店铺,非红人店铺,跳转店铺列表
  47 + if (shopInfo && shopInfo.is_red_shop !== 1) {
  48 + shopInfo.isShop = true;
  49 + }
  50 +
  51 + // 可能没有店铺信息,跳转店铺列表
44 req.shopInfo = shopInfo; 52 req.shopInfo = shopInfo;
45 } else if (domain) { 53 } else if (domain) {
46 let domainInfo = (yield shopModel.getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息 54 let domainInfo = (yield shopModel.getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息
@@ -55,11 +63,11 @@ const shop = { @@ -55,11 +63,11 @@ const shop = {
55 } 63 }
56 } 64 }
57 65
58 - if (req.shopInfo.shopId) { // 店铺 66 + if (req.shopInfo.isRedShop) { // 店铺
59 return shop.redShop(req, res, next); 67 return shop.redShop(req, res, next);
60 } else if (req.shopInfo.id) { // 品牌,id 来自 domainInfo 68 } else if (req.shopInfo.id) { // 品牌,id 来自 domainInfo
61 return shop.brand(req, res, next); 69 return shop.brand(req, res, next);
62 - } else if (shopId) { // 没有查到店铺数据但是有 shopId 的请求 70 + } else if (shopId) { // 非红人店铺非品牌
63 return shop.list(req, res, next); 71 return shop.list(req, res, next);
64 } else { // 什么都没有,去首页 72 } else { // 什么都没有,去首页
65 return res.redirect(helpers.urlFormat('', {go: '-1'})); 73 return res.redirect(helpers.urlFormat('', {go: '-1'}));
@@ -122,8 +130,7 @@ const shop = { @@ -122,8 +130,7 @@ const shop = {
122 }; 130 };
123 131
124 co(function* () { 132 co(function* () {
125 - let [banner, brandInfo, goodsListApi] = yield Promise.all([  
126 - shopModel.getBrandBanner(brandId), 133 + let [brandInfo, goodsListApi] = yield Promise.all([
127 shopModel.getBrandIntro(brandId, uid), 134 shopModel.getBrandIntro(brandId, uid),
128 searchModel.getBrandGoods(searchParam) 135 searchModel.getBrandGoods(searchParam)
129 ]); 136 ]);
@@ -131,7 +138,6 @@ const shop = { @@ -131,7 +138,6 @@ const shop = {
131 let title = brandInfo.title; 138 let title = brandInfo.title;
132 let goodsList = productProcess.processProductList(_.get(goodsListApi, 'data.product_list', [])); 139 let goodsList = productProcess.processProductList(_.get(goodsListApi, 'data.product_list', []));
133 140
134 - brandInfo.banner = banner;  
135 141
136 res.render('newshop/shop-brand', { 142 res.render('newshop/shop-brand', {
137 module: 'product', 143 module: 'product',
@@ -145,7 +151,6 @@ const shop = { @@ -145,7 +151,6 @@ const shop = {
145 keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰', 151 keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰',
146 description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。', 152 description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
147 brandId: brandId, 153 brandId: brandId,
148 - brandInfo: brandInfo,  
149 goodsList: goodsList, 154 goodsList: goodsList,
150 shopPage: true, 155 shopPage: true,
151 _noLazy: true, 156 _noLazy: true,
@@ -158,7 +163,7 @@ const shop = { @@ -158,7 +163,7 @@ const shop = {
158 * 红人店铺 163 * 红人店铺
159 */ 164 */
160 redShop(req, res, next) { 165 redShop(req, res, next) {
161 - let shopId = req.shopInfo.shopId; 166 + let shopId = req.shopInfo.shops_id;
162 let channel = req.yoho.channel || 'boys'; 167 let channel = req.yoho.channel || 'boys';
163 let uid = req.user.uid || 0; 168 let uid = req.user.uid || 0;
164 let udid = req.sessionID || 'yoho'; 169 let udid = req.sessionID || 'yoho';
@@ -178,11 +183,11 @@ const shop = { @@ -178,11 +183,11 @@ const shop = {
178 let banner = _.get(bannerData, 'data.banner'); 183 let banner = _.get(bannerData, 'data.banner');
179 let shopInfo = req.shopInfo; 184 let shopInfo = req.shopInfo;
180 let favCount = _.get(favCountData, 'data[0].approximateCount', '2.1w'); 185 let favCount = _.get(favCountData, 'data[0].approximateCount', '2.1w');
181 - let decoratorsAll = redShopPrcs.floor(_.get(decoratorsData, 'data.modules', []));  
182 - let category = redShopPrcs.category(_.get(categoryData, 'data', []), shopId); 186 + let decoratorsAll = shopPrcs.floor(_.get(decoratorsData, 'data.modules', []));
  187 + let category = shopPrcs.category(_.get(categoryData, 'data', []), shopId);
183 188
184 let goodsListBySkn = yield searchModel.searchProductBySkn(decoratorsAll.skns); 189 let goodsListBySkn = yield searchModel.searchProductBySkn(decoratorsAll.skns);
185 - let decorators = redShopPrcs.pushGoodsInfo(decoratorsAll.decorators, goodsListBySkn); 190 + let decorators = shopPrcs.pushGoodsInfo(decoratorsAll.decorators, goodsListBySkn);
186 191
187 shopInfo.shop_intro_link = helpers.urlFormat('/product/index/intro', {shop_id: shopId}); 192 shopInfo.shop_intro_link = helpers.urlFormat('/product/index/intro', {shop_id: shopId});
188 193
@@ -224,8 +229,9 @@ const shop = { @@ -224,8 +229,9 @@ const shop = {
224 */ 229 */
225 list(req, res, next) { 230 list(req, res, next) {
226 co(function* () { 231 co(function* () {
227 - let title = '店铺商品列表';  
228 let shopId = req.query.shop_id; 232 let shopId = req.query.shop_id;
  233 + let shopInfo = req.shopInfo || {};
  234 + let title = shopInfo.shop_name || '店铺商品列表';
229 let searchParam = { 235 let searchParam = {
230 isApp: req.yoho.isApp, 236 isApp: req.yoho.isApp,
231 shop_id: shopId, 237 shop_id: shopId,
@@ -238,6 +244,15 @@ const shop = { @@ -238,6 +244,15 @@ const shop = {
238 let goodsListApi = yield searchModel.getShopGoods(searchParam); 244 let goodsListApi = yield searchModel.getShopGoods(searchParam);
239 let goodsList = productProcess.processProductList(_.get(goodsListApi, 'data.product_list', [])); 245 let goodsList = productProcess.processProductList(_.get(goodsListApi, 'data.product_list', []));
240 246
  247 + if (shopInfo.isShop) {
  248 + let shopDecorator = yield shopModel.getShopDecorator(shopId);
  249 + let shopDecoratorList = _.get(shopDecorator, 'list', []);
  250 +
  251 + if (shopDecoratorList) {
  252 + shopInfo.banner = shopPrcs.getShopBanner(shopDecoratorList);
  253 + }
  254 + }
  255 +
241 res.render('newshop/shop-list', { 256 res.render('newshop/shop-list', {
242 module: 'product', 257 module: 'product',
243 page: 'shop-list', 258 page: 'shop-list',
@@ -250,6 +265,7 @@ const shop = { @@ -250,6 +265,7 @@ const shop = {
250 keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰', 265 keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰',
251 description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。', 266 description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
252 shopId: shopId, 267 shopId: shopId,
  268 + shopInfo: shopInfo,
253 goodsList: goodsList, 269 goodsList: goodsList,
254 shopPage: true, 270 shopPage: true,
255 _noLazy: true, 271 _noLazy: true,
@@ -221,6 +221,23 @@ const favCount = (shopId, uid, channel, udid) => { @@ -221,6 +221,23 @@ const favCount = (shopId, uid, channel, udid) => {
221 return singleAPI.get('favorite', finalParams); 221 return singleAPI.get('favorite', finalParams);
222 }; 222 };
223 223
  224 +/**
  225 + * 获取非红人店铺的店铺装修数据
  226 + * @param {int} shopId 店铺id
  227 + * @return array
  228 + */
  229 +const getShopDecorator = (shopId) => {
  230 + return api.get('', {
  231 + method: 'app.shopsdecorator.getList',
  232 + shop_id: shopId
  233 + }, {
  234 + cache: true,
  235 + code: 200
  236 + }).then((result) => {
  237 + return (result && result.data) || {};
  238 + });
  239 +};
  240 +
224 module.exports = { 241 module.exports = {
225 getShopBrands, 242 getShopBrands,
226 getShopInfo, 243 getShopInfo,
@@ -230,5 +247,6 @@ module.exports = { @@ -230,5 +247,6 @@ module.exports = {
230 getBanner, 247 getBanner,
231 getShopsdecorator, 248 getShopsdecorator,
232 getShopCategory, 249 getShopCategory,
233 - favCount 250 + favCount,
  251 + getShopDecorator
234 }; 252 };
1 <div class="good-list-page yoho-page"> 1 <div class="good-list-page yoho-page">
2 - {{#if brandInfo.banner}}  
3 - {{# brandInfo}}  
4 - <div id="brand-header" class="brand-header" data-id={{id}}>  
5 - <img src={{image2 banner q=60}}>  
6 - <a class="btn-intro" href="javascript:void(0);">  
7 - 品牌介绍  
8 - </a>  
9 - <a class="btn-col" href="javascript:void(0);">  
10 - <span class="iconfont">&#xe622;</span>  
11 - <span class="txt"></span>  
12 - </a>  
13 - </div>  
14 - <div id="intro-box" class="brand-intro-box hide">  
15 - <div id="brand-intro" class="brand-intro">  
16 - <h2>品牌介绍</h2>  
17 - <div class="con">  
18 - {{{intro}}}  
19 - </div>  
20 - <p class="fo">  
21 - <span class="iconfont">&#xe629;</span> 100%品牌授权正品  
22 - </p>  
23 - <span class="iconfont close-intro">&#xe623;</span>  
24 - </div>  
25 - </div>  
26 - {{/ brandInfo}}  
27 - {{/if}}  
28 - <!-- 优惠卷 -->  
29 - <div class="coupon-group"></div>  
30 - <!-- /品牌页面 -->  
31 -  
32 {{!--筛选tab--}} 2 {{!--筛选tab--}}
33 <div class="filter-box"> 3 <div class="filter-box">
34 {{> product/filter-tab-new}} 4 {{> product/filter-tab-new}}
1 <div class="good-list-page yoho-page"> 1 <div class="good-list-page yoho-page">
  2 + <!-- 基础店铺页面 -->
  3 + {{# shopInfo}}
  4 + <div id="brand-header" class="brand-header" data-id={{shops_id}} data-isbaseshop="{{isBaseShop}}">
  5 + <img src={{image2 banner q=60}}>
  6 + <a class="btn-intro" href="javascript:void(0);">
  7 + 店铺介绍
  8 + </a>
  9 + <a class="btn-col" href="javascript:void(0);">
  10 + <span class="iconfont">&#xe622;</span>
  11 + <span class="txt"></span>
  12 + </a>
  13 + </div>
  14 + <div id="intro-box" class="brand-intro-box hide">
  15 + <div id="brand-intro" class="brand-intro">
  16 + <h2>店铺介绍</h2>
  17 + <div class="con">
  18 + {{{shop_intro}}}
  19 + </div>
  20 + <p class="fo">
  21 + <span class="iconfont">&#xe629;</span>
  22 + 100%品牌授权正品
  23 + </p>
  24 + <span class="iconfont close-intro">&#xe623;</span>
  25 + </div>
  26 + </div>
  27 + {{/ shopInfo}}
  28 +
  29 + <!-- 优惠卷 -->
  30 + <div class="coupon-group"></div>
  31 +
  32 + <!-- /基础店铺页面 -->
2 {{!--筛选tab--}} 33 {{!--筛选tab--}}
3 <div class="filter-box"> 34 <div class="filter-box">
4 {{> product/filter-tab-new}} 35 {{> product/filter-tab-new}}
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-03-23 11:02:31 3 * @Date: 2017-03-23 11:02:31
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-07-18 14:29:33 5 + * @Last Modified time: 2017-08-02 11:11:07
6 */ 6 */
7 /* 红人店铺数据处理 */ 7 /* 红人店铺数据处理 */
8 8
@@ -365,9 +365,32 @@ const pushGoodsInfo = (decorators, goodsList) => { @@ -365,9 +365,32 @@ const pushGoodsInfo = (decorators, goodsList) => {
365 return decorators; 365 return decorators;
366 }; 366 };
367 367
  368 +/**
  369 + * 获取非红人店铺的店铺 Banner
  370 + */
  371 +const getShopBanner = (shopDecoratorList) => {
  372 + let banner = '';
  373 +
  374 + _.forEach(shopDecoratorList, floorData => {
  375 + let resData = JSON.parse(floorData.resource_data);
  376 +
  377 + if (floorData.resource_name) {
  378 + floorData[_.camelCase(floorData.resource_name)] = true;
  379 + }
  380 +
  381 + // 店铺banner
  382 + if (floorData.shopTopBannerApp) {
  383 + banner = resData[0].shopSrc;
  384 + }
  385 + });
  386 +
  387 + return banner;
  388 +};
  389 +
368 module.exports = { 390 module.exports = {
369 floor, 391 floor,
370 shopIntro, 392 shopIntro,
371 category, 393 category,
372 - pushGoodsInfo 394 + pushGoodsInfo,
  395 + getShopBanner
373 }; 396 };