Authored by htoooth

fix error

... ... @@ -121,12 +121,12 @@ export default {
// 插入商品
const [goodsList, favsList] = await Promise.all([
this.$api.post('/api/guang/article/queryGoods', {
query: processContents.allgoods.join(','),
query: processContents.allgoods.skn.join(','),
order: 's_t_desc',
limit: processContents.allgoods.length || 1
limit: processContents.allgoods.skn.length || 1
}),
this.$api.post('/api/favorite/batchCheckIsFavorite', {
favIds: processContents.allgoods.join(','),
favIds: processContents.allgoods.id.join(','),
type: 'product'
})
]).then(([res1, res2]) => {
... ...
... ... @@ -81,7 +81,7 @@ function productGlobalUrl(skn) {
export function processArticleDetail(articleContent) {
let finalDetail = [];
let allgoods = [];
let allgoods = {id: [], skn: []};
let recommends = [];
for (let value of articleContent) {
... ... @@ -160,18 +160,21 @@ export function processArticleDetail(articleContent) {
// 普通商品
forEach(goodsData, (item) => {
allgoods.push(get(item, 'productId', 0));
allgoods.id.push(get(item, 'productId', 0));
allgoods.skn.push(get(item, 'id', 0));
});
// 全球购商品
forEach(goodsDataGlobal, (item) => {
allgoods.push(get(item, 'productId', 0));
allgoods.id.push(get(item, 'productId', 0));
allgoods.skn.push(get(item, 'id', 0));
goodsData.push(item);
});
// 限定商品
forEach(goodsDataLimit, (item) => {
allgoods.push(get(item, 'productId', 0));
allgoods.id.push(get(item, 'productId', 0));
allgoods.skn.push(get(item, 'id', 0));
goodsData.push(item);
});
... ... @@ -337,30 +340,34 @@ export function pushGoodsInfo(finalDetail, goodsList, favsList) {
forEach(finalDetail, (value, key) => {
if (value.relatedReco) {
let goodsIds = [];
let goodsSkn = [];
forEach(value.relatedReco.goods, relatedGoods => {
goodsIds.push(relatedGoods.id);
goodsSkn.push(relatedGoods.id);
});
goodsIds = uniq(goodsIds);
goodsSkn = uniq(goodsSkn);
finalDetail[key].relatedReco.goods = [];
forEach(goodsIds, (item, subKey) => {
forEach(goodsSkn, (item, subKey) => {
console.log(goodsObj, item)
if (goodsObj[item]) {
console.log(goodsObj[item])
finalDetail[key].relatedReco.goods[subKey] = goodsObj[item];
} else {
console.log('delete');
delete finalDetail[key].relatedReco.goods[subKey];
}
});
finalDetail[key].relatedReco.goods = remove(finalDetail[key].relatedReco.goods, (obj) => {
return obj;
});
let moreNum = get(finalDetail[key], 'relatedReco.goods.length', 0);
finalDetail[key].relatedReco.moreNum = moreNum - 4 > 0 ? moreNum - 4 : 0; // 改成第一屏幕最多展示4个
//
// finalDetail[key].relatedReco.goods = remove(finalDetail[key].relatedReco.goods, (obj) => {
// return obj;
// });
//
// let moreNum = get(finalDetail[key], 'relatedReco.goods.length', 0);
//
// finalDetail[key].relatedReco.moreNum = moreNum - 4 > 0 ? moreNum - 4 : 0; // 改成第一屏幕最多展示4个
}
if (value.collocation) {
... ...