Authored by htoooth

fix

... ... @@ -28,7 +28,6 @@ const brandService = require('./brand-service');
const favoriteProductService = require('./favorite-product-service');
const shopService = require('./shop-service');
const searchAPI = require('./search-api');
const homeService = require('./home-service');
const HeaderModel = require('../../../doraemon/models/header');
... ... @@ -483,16 +482,17 @@ const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => {
/**
* 获取分类导航列表
*/
function _getSortNavAsync(smallSortId, gender) {
return co(function*() {
let data = yield searchAPI.getSortByConditionAsync({sort: smallSortId});
if (_.isEmpty(data)) {
return [];
}
function _getSortNavAsync(productInfo, gender) {
let data = [{
sort_id: _.get(productInfo, 'data.maxSortId', ''),
sort_name: _.get(productInfo, 'data.max_sort_name', '')
}, {
sort_id: _.get(productInfo, 'data.middleSortId', ''),
sort_name: _.get(productInfo, 'data.middle_sort_name', '')
}];
let navs = [];
let sort = _.get(data, 'data.sort[0]', {});
let sort = data[0];
// 一级分类
navs.push({
... ... @@ -501,19 +501,16 @@ function _getSortNavAsync(smallSortId, gender) {
pathTitle: sort.sort_name
});
if (sort.sub) {
// 二级分类
let subSort = _.head(sort.sub) || {};
let subSort = data[1];
navs.push({
href: helpers.urlFormat('', {msort: sort.sort_id, misort: subSort.sort_id, gender: gender}, 'list'),
name: subSort.sort_name,
pathTitle: subSort.sort_name
});
}
return navs;
})();
}
// 保存在 gids 和 skns ,最近流览功能
... ... @@ -1532,30 +1529,29 @@ const showMainAsync = (req, data) => {
});
}
let smallSortId = _.get(productData, 'data.smallSortId');
let maxSortId = _.get(productData, 'data.maxSortId');
let productId = _.get(productData, 'data.product_id');
let productSkn = _.get(productData, 'data.product_skn');
let curUserProduct = _.partial(_detailDataPkg, _, data.uid, data.vipLevel, data.gid, data.saveInCookies);
let requestData = yield Promise.all([
_getSortNavAsync(smallSortId, data.gender), // 面包屑导航
HeaderModel.requestHeaderData(data.channel), // 通用头部数据
_getProductIntroAsync(productId, productSkn), // 商品详细介绍
curUserProduct(productData), // 商品详细价格
tdk('skn', data.skn, req) // seo
]);
let smallSortNavigator = requestData[0];
let navigatorHeader = requestData[1];
let productDescription = requestData[2];
let productInfo = requestData[3];
let navigatorHeader = requestData[0];
let productDescription = requestData[1];
let productInfo = requestData[2];
let tdkData = requestData[3];
let sortNavigator = _getSortNavAsync(productData, data.gender);
if (requestData[4][0]) {
if (tdkData[0]) {
req.tdk = {
title: requestData[4][1],
keywords: requestData[4][2],
description: requestData[4][3]
title: tdkData[1],
keywords: tdkData[2],
description: tdkData[3]
};
}
... ... @@ -1572,24 +1568,24 @@ const showMainAsync = (req, data) => {
result.deatil = Object.assign(result.detail, intro);
// seo
result.seo = _getSeoByGoodsInfo(productInfo.goodsInfo, smallSortNavigator);
result.seo = _getSeoByGoodsInfo(productInfo.goodsInfo, sortNavigator);
// 商品页面统计
result.statGoodsInfo = Object.assign({fullSortName: smallSortNavigator.map(x => x.name).join('-')},
result.statGoodsInfo = Object.assign({fullSortName: sortNavigator.map(x => x.name).join('-')},
productInfo.statGoodsInfo
);
// 面包屑导航
result.detail.pathNav = _.concat(
homeService.getHomeChannelNav(data.channel),
smallSortNavigator,
sortNavigator,
[{name: _.get(productInfo, 'goodsInfo.name')}]
);
// 统计代码中需要新的path
result.statGoodsInfo.category = _.concat(
homeService.getHomeChannelNav(data.channel),
smallSortNavigator
sortNavigator
).map(n => n.name).join('>');
// 头部数据
... ... @@ -1602,7 +1598,7 @@ const showMainAsync = (req, data) => {
// 最近浏览,最多5条记录
result.detail.latestWalk = 5;
return result;
})();
})().catch(console.log);
};
/**
... ...
... ... @@ -14,12 +14,6 @@ const helpers = global.yoho.helpers;
const cache = global.yoho.cache;
const logger = global.yoho.logger;
const getSortByConditionAsync = (condition) => {
return api.get('', Object.assign({
method: 'web.regular.groupsort'
}, condition), config.apiCache);
};
// 判断用户是否收藏品牌
const isFavoriteBrandUrl = '/shops/service/v1/favorite/getUidBrandFav';
... ... @@ -482,7 +476,6 @@ const lessRecommend = (channelNum, uid, udid, recPos, limit) => {
};
module.exports = {
getSortByConditionAsync,
getKeyActivityAsync,
getProductList,
getSortList,
... ...