Authored by htoooth

fix

@@ -28,7 +28,6 @@ const brandService = require('./brand-service'); @@ -28,7 +28,6 @@ const brandService = require('./brand-service');
28 const favoriteProductService = require('./favorite-product-service'); 28 const favoriteProductService = require('./favorite-product-service');
29 const shopService = require('./shop-service'); 29 const shopService = require('./shop-service');
30 30
31 -const searchAPI = require('./search-api');  
32 const homeService = require('./home-service'); 31 const homeService = require('./home-service');
33 const HeaderModel = require('../../../doraemon/models/header'); 32 const HeaderModel = require('../../../doraemon/models/header');
34 33
@@ -483,37 +482,35 @@ const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => { @@ -483,37 +482,35 @@ const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => {
483 /** 482 /**
484 * 获取分类导航列表 483 * 获取分类导航列表
485 */ 484 */
486 -function _getSortNavAsync(smallSortId, gender) {  
487 - return co(function*() {  
488 - let data = yield searchAPI.getSortByConditionAsync({sort: smallSortId});  
489 -  
490 - if (_.isEmpty(data)) {  
491 - return [];  
492 - } 485 +function _getSortNavAsync(productInfo, gender) {
  486 + let data = [{
  487 + sort_id: _.get(productInfo, 'data.maxSortId', ''),
  488 + sort_name: _.get(productInfo, 'data.max_sort_name', '')
  489 + }, {
  490 + sort_id: _.get(productInfo, 'data.middleSortId', ''),
  491 + sort_name: _.get(productInfo, 'data.middle_sort_name', '')
  492 + }];
493 493
494 - let navs = [];  
495 - let sort = _.get(data, 'data.sort[0]', {}); 494 + let navs = [];
  495 + let sort = data[0];
496 496
497 - // 一级分类  
498 - navs.push({  
499 - href: helpers.urlFormat('', {msort: sort.sort_id, gender: gender}, 'list'),  
500 - name: sort.sort_name,  
501 - pathTitle: sort.sort_name  
502 - }); 497 + // 一级分类
  498 + navs.push({
  499 + href: helpers.urlFormat('', {msort: sort.sort_id, gender: gender}, 'list'),
  500 + name: sort.sort_name,
  501 + pathTitle: sort.sort_name
  502 + });
503 503
504 - if (sort.sub) {  
505 - // 二级分类  
506 - let subSort = _.head(sort.sub) || {}; 504 + // 二级分类
  505 + let subSort = data[1];
507 506
508 - navs.push({  
509 - href: helpers.urlFormat('', {msort: sort.sort_id, misort: subSort.sort_id, gender: gender}, 'list'),  
510 - name: subSort.sort_name,  
511 - pathTitle: subSort.sort_name  
512 - });  
513 - } 507 + navs.push({
  508 + href: helpers.urlFormat('', {msort: sort.sort_id, misort: subSort.sort_id, gender: gender}, 'list'),
  509 + name: subSort.sort_name,
  510 + pathTitle: subSort.sort_name
  511 + });
514 512
515 - return navs;  
516 - })(); 513 + return navs;
517 } 514 }
518 515
519 // 保存在 gids 和 skns ,最近流览功能 516 // 保存在 gids 和 skns ,最近流览功能
@@ -1532,30 +1529,29 @@ const showMainAsync = (req, data) => { @@ -1532,30 +1529,29 @@ const showMainAsync = (req, data) => {
1532 }); 1529 });
1533 } 1530 }
1534 1531
1535 - let smallSortId = _.get(productData, 'data.smallSortId');  
1536 let maxSortId = _.get(productData, 'data.maxSortId'); 1532 let maxSortId = _.get(productData, 'data.maxSortId');
1537 let productId = _.get(productData, 'data.product_id'); 1533 let productId = _.get(productData, 'data.product_id');
1538 let productSkn = _.get(productData, 'data.product_skn'); 1534 let productSkn = _.get(productData, 'data.product_skn');
1539 let curUserProduct = _.partial(_detailDataPkg, _, data.uid, data.vipLevel, data.gid, data.saveInCookies); 1535 let curUserProduct = _.partial(_detailDataPkg, _, data.uid, data.vipLevel, data.gid, data.saveInCookies);
1540 1536
1541 let requestData = yield Promise.all([ 1537 let requestData = yield Promise.all([
1542 - _getSortNavAsync(smallSortId, data.gender), // 面包屑导航  
1543 HeaderModel.requestHeaderData(data.channel), // 通用头部数据 1538 HeaderModel.requestHeaderData(data.channel), // 通用头部数据
1544 _getProductIntroAsync(productId, productSkn), // 商品详细介绍 1539 _getProductIntroAsync(productId, productSkn), // 商品详细介绍
1545 curUserProduct(productData), // 商品详细价格 1540 curUserProduct(productData), // 商品详细价格
1546 tdk('skn', data.skn, req) // seo 1541 tdk('skn', data.skn, req) // seo
1547 ]); 1542 ]);
1548 1543
1549 - let smallSortNavigator = requestData[0];  
1550 - let navigatorHeader = requestData[1];  
1551 - let productDescription = requestData[2];  
1552 - let productInfo = requestData[3]; 1544 + let navigatorHeader = requestData[0];
  1545 + let productDescription = requestData[1];
  1546 + let productInfo = requestData[2];
  1547 + let tdkData = requestData[3];
  1548 + let sortNavigator = _getSortNavAsync(productData, data.gender);
1553 1549
1554 - if (requestData[4][0]) { 1550 + if (tdkData[0]) {
1555 req.tdk = { 1551 req.tdk = {
1556 - title: requestData[4][1],  
1557 - keywords: requestData[4][2],  
1558 - description: requestData[4][3] 1552 + title: tdkData[1],
  1553 + keywords: tdkData[2],
  1554 + description: tdkData[3]
1559 }; 1555 };
1560 } 1556 }
1561 1557
@@ -1572,24 +1568,24 @@ const showMainAsync = (req, data) => { @@ -1572,24 +1568,24 @@ const showMainAsync = (req, data) => {
1572 result.deatil = Object.assign(result.detail, intro); 1568 result.deatil = Object.assign(result.detail, intro);
1573 1569
1574 // seo 1570 // seo
1575 - result.seo = _getSeoByGoodsInfo(productInfo.goodsInfo, smallSortNavigator); 1571 + result.seo = _getSeoByGoodsInfo(productInfo.goodsInfo, sortNavigator);
1576 1572
1577 // 商品页面统计 1573 // 商品页面统计
1578 - result.statGoodsInfo = Object.assign({fullSortName: smallSortNavigator.map(x => x.name).join('-')}, 1574 + result.statGoodsInfo = Object.assign({fullSortName: sortNavigator.map(x => x.name).join('-')},
1579 productInfo.statGoodsInfo 1575 productInfo.statGoodsInfo
1580 ); 1576 );
1581 1577
1582 // 面包屑导航 1578 // 面包屑导航
1583 result.detail.pathNav = _.concat( 1579 result.detail.pathNav = _.concat(
1584 homeService.getHomeChannelNav(data.channel), 1580 homeService.getHomeChannelNav(data.channel),
1585 - smallSortNavigator, 1581 + sortNavigator,
1586 [{name: _.get(productInfo, 'goodsInfo.name')}] 1582 [{name: _.get(productInfo, 'goodsInfo.name')}]
1587 ); 1583 );
1588 1584
1589 // 统计代码中需要新的path 1585 // 统计代码中需要新的path
1590 result.statGoodsInfo.category = _.concat( 1586 result.statGoodsInfo.category = _.concat(
1591 homeService.getHomeChannelNav(data.channel), 1587 homeService.getHomeChannelNav(data.channel),
1592 - smallSortNavigator 1588 + sortNavigator
1593 ).map(n => n.name).join('>'); 1589 ).map(n => n.name).join('>');
1594 1590
1595 // 头部数据 1591 // 头部数据
@@ -1602,7 +1598,7 @@ const showMainAsync = (req, data) => { @@ -1602,7 +1598,7 @@ const showMainAsync = (req, data) => {
1602 // 最近浏览,最多5条记录 1598 // 最近浏览,最多5条记录
1603 result.detail.latestWalk = 5; 1599 result.detail.latestWalk = 5;
1604 return result; 1600 return result;
1605 - })(); 1601 + })().catch(console.log);
1606 }; 1602 };
1607 1603
1608 /** 1604 /**
@@ -14,12 +14,6 @@ const helpers = global.yoho.helpers; @@ -14,12 +14,6 @@ const helpers = global.yoho.helpers;
14 const cache = global.yoho.cache; 14 const cache = global.yoho.cache;
15 const logger = global.yoho.logger; 15 const logger = global.yoho.logger;
16 16
17 -const getSortByConditionAsync = (condition) => {  
18 - return api.get('', Object.assign({  
19 - method: 'web.regular.groupsort'  
20 - }, condition), config.apiCache);  
21 -};  
22 -  
23 // 判断用户是否收藏品牌 17 // 判断用户是否收藏品牌
24 const isFavoriteBrandUrl = '/shops/service/v1/favorite/getUidBrandFav'; 18 const isFavoriteBrandUrl = '/shops/service/v1/favorite/getUidBrandFav';
25 19
@@ -482,7 +476,6 @@ const lessRecommend = (channelNum, uid, udid, recPos, limit) => { @@ -482,7 +476,6 @@ const lessRecommend = (channelNum, uid, udid, recPos, limit) => {
482 }; 476 };
483 477
484 module.exports = { 478 module.exports = {
485 - getSortByConditionAsync,  
486 getKeyActivityAsync, 479 getKeyActivityAsync,
487 getProductList, 480 getProductList,
488 getSortList, 481 getSortList,