Authored by 郭成尧

'shop-use-api-modified'

@@ -14,9 +14,9 @@ const helpers = global.yoho.helpers; @@ -14,9 +14,9 @@ const helpers = global.yoho.helpers;
14 /** 14 /**
15 * 店铺基础模板 15 * 店铺基础模板
16 */ 16 */
17 -const _baseShop = (req, res, data) => { 17 +const _baseShop = (req, res, shopInfo) => {
18 18
19 - listModel.getBaseShopData(Object.assign(req.query, data)).then(result => { 19 + listModel.getBaseShopData(req.query, shopInfo).then(result => {
20 20
21 res.render('search/goods-list', { 21 res.render('search/goods-list', {
22 module: 'product', 22 module: 'product',
@@ -65,7 +65,7 @@ const _shop = (req, res, shopId) => { @@ -65,7 +65,7 @@ const _shop = (req, res, shopId) => {
65 }); 65 });
66 } 66 }
67 67
68 - listModel.getShopData(req, shopId, uid, isApp).then((result) => { 68 + listModel.getShopData(req, shopId, uid, isApp).then(result => {
69 if (result.goBrand) { 69 if (result.goBrand) {
70 70
71 // 跳转基础模板 71 // 跳转基础模板
@@ -310,6 +310,7 @@ const _formShopData = (data, shopId, isApp) => { @@ -310,6 +310,7 @@ const _formShopData = (data, shopId, isApp) => {
310 }; 310 };
311 311
312 formatData = _.assign({ 312 formatData = _.assign({
  313 + shopIntro: data.shopInfo.shopIntro,
313 logoImg: data.shopInfo.shopLogo, 314 logoImg: data.shopInfo.shopLogo,
314 storeName: (data.shopInfo.isShowShopName === 'Y') ? data.shopInfo.shopName : '', 315 storeName: (data.shopInfo.isShowShopName === 'Y') ? data.shopInfo.shopName : '',
315 collect: data.shopInfo.isFavorite === 'Y', 316 collect: data.shopInfo.isFavorite === 'Y',
@@ -387,9 +388,11 @@ const _formShopData = (data, shopId, isApp) => { @@ -387,9 +388,11 @@ const _formShopData = (data, shopId, isApp) => {
387 /** 388 /**
388 * 使用基础模板的店铺首页 389 * 使用基础模板的店铺首页
389 * @param params 390 * @param params
  391 + * @param shopInfo
390 * @returns {*|Promise.<TResult>} 392 * @returns {*|Promise.<TResult>}
391 */ 393 */
392 -const getBaseShopData = (params) => { 394 +const getBaseShopData = (params, shopInfo) => {
  395 +
393 let finalResult = { 396 let finalResult = {
394 cartUrl: helpers.urlFormat('/cart/index/index') 397 cartUrl: helpers.urlFormat('/cart/index/index')
395 }; 398 };
@@ -406,7 +409,11 @@ const getBaseShopData = (params) => { @@ -406,7 +409,11 @@ const getBaseShopData = (params) => {
406 409
407 finalResult = _.assign(finalResult, { 410 finalResult = _.assign(finalResult, {
408 baseShopHome: { 411 baseShopHome: {
409 - banner: _.get(banner, 'banner[0].shopSrc', '') 412 + appVersion: _.get(params, 'app_version', ''),
  413 + id: params.shop_id,
  414 + intro: shopInfo.shopIntro,
  415 + isBaseShop: true,
  416 + banner: _.get(banner[0], 'shopSrc', '')
410 } 417 }
411 }); 418 });
412 } 419 }
@@ -434,44 +441,47 @@ const getShopData = (req, shopId, uid, isApp) => { @@ -434,44 +441,47 @@ const getShopData = (req, shopId, uid, isApp) => {
434 let shopData = {}; 441 let shopData = {};
435 let channel = req.yoho.channel; 442 let channel = req.yoho.channel;
436 443
437 - return Promise.all([  
438 - _getShopDecorator(shopId),  
439 - _getShopInfo(shopId, uid),  
440 - searchModel.getFilterData({  
441 - shop_id: shopId,  
442 - gender: '1,3', // TODO TAR 获取性别  
443 - channel: channel,  
444 - brand: '' // TODO TAR 获取品牌  
445 - }),  
446 - searchModel.getSearchData({  
447 - shop_id: shopId,  
448 - gender: '1,3', // TODO TAR 获取性别  
449 - channel: channel,  
450 - brand: '' // TODO TAR 获取品牌  
451 - })  
452 - ]).then((result) => {  
453 - shopData = {  
454 - decorator: result[0], // 店铺装修资源数据  
455 - shopInfo: result[1] // 店铺信息  
456 - }; 444 + return _getShopInfo(shopId, uid).then(shopInfoResult => {
457 445
458 - // 店铺使用基础模板,返回品牌页面  
459 - if (shopData.shopInfo.shopTemplateType && parseInt(shopData.shopInfo.shopTemplateType, 10) === 1) { 446 + /* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
  447 + if (shopInfoResult.shopTemplateType && parseInt(shopInfoResult.shopTemplateType, 10) === 1) {
460 return { 448 return {
461 - goBrand: shopData.shopInfo 449 + goBrand: shopInfoResult
462 }; 450 };
463 } 451 }
464 452
465 - // 店铺分类  
466 - return _getShopCategory(shopId, channel).then((shopCategory) => {  
467 - shopData = _.assign({  
468 - shopCategory: shopCategory  
469 - }, shopData); 453 + return Promise.all([
  454 + _getShopDecorator(shopId),
  455 + searchModel.getFilterData({
  456 + shop_id: shopId,
  457 + gender: '1,3', // TODO TAR 获取性别
  458 + channel: channel,
  459 + brand: '' // TODO TAR 获取品牌
  460 + }),
  461 + searchModel.getSearchData({
  462 + shop_id: shopId,
  463 + gender: '1,3', // TODO TAR 获取性别
  464 + channel: channel,
  465 + brand: '' // TODO TAR 获取品牌
  466 + })
  467 + ]).then((result) => {
  468 + shopData = {
  469 + decorator: result[0], // 店铺装修资源数据
  470 + shopInfo: shopInfoResult // 店铺信息
  471 + };
  472 +
  473 + // 店铺分类
  474 + return _getShopCategory(shopId, channel).then((shopCategory) => {
  475 + shopData = _.assign({
  476 + shopCategory: shopCategory
  477 + }, shopData);
470 478
471 - // noinspection JSCheckFunctionSignatures  
472 - return Object.assign(_formShopData(shopData, shopId, isApp),  
473 - {filter: result[2]}, {goods: result[3]}); // TODO TAR 获取筛选数据和商品数据数据校验 479 + // noinspection JSCheckFunctionSignatures
  480 + return Object.assign(_formShopData(shopData, shopId, isApp),
  481 + {filter: result[2]}, {goods: result[3]}); // TODO TAR 获取筛选数据和商品数据数据校验
  482 + });
474 }); 483 });
  484 +
475 }); 485 });
476 }; 486 };
477 487