...
|
...
|
@@ -202,12 +202,14 @@ |
|
|
},
|
|
|
created() {
|
|
|
const newsId = $('#app').data('newsId');
|
|
|
let loadDeferred = null;
|
|
|
|
|
|
$.get(`/news/news_${newsId}.json`).then(result => {
|
|
|
const article = result[0],
|
|
|
content = result[1],
|
|
|
brands = result[2],
|
|
|
other = result[3];
|
|
|
let goods, prodMap = {};
|
|
|
|
|
|
if (article && article.code === 200 && article.data) {
|
|
|
this.article = article.data;
|
...
|
...
|
@@ -222,18 +224,26 @@ |
|
|
|
|
|
|
|
|
const list = [];
|
|
|
const goods = products[0] ? products[0].goods.data : null;
|
|
|
|
|
|
goods = products[0] ? products[0].goods.data : null;
|
|
|
|
|
|
// 封装产品数据适应产品列表组件
|
|
|
if (goods) {
|
|
|
goods.forEach((item)=> {
|
|
|
list.push({
|
|
|
const obj = {
|
|
|
productId: item.id,
|
|
|
goodsList: [
|
|
|
{
|
|
|
imagesUrl: item.src
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
],
|
|
|
marketPrice: 0,
|
|
|
salesPrice: 0,
|
|
|
productName: ''
|
|
|
};
|
|
|
|
|
|
list.push(obj);
|
|
|
prodMap[item.id] = obj;
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -247,6 +257,33 @@ |
|
|
if (other && other.code === 200 && content.data) {
|
|
|
this.other = other.data;
|
|
|
}
|
|
|
|
|
|
|
|
|
// 延时读取商品价格、名称等信息
|
|
|
loadDeferred = () => {
|
|
|
$.get('/product/search_product.json', {
|
|
|
ids: goods.map((item)=> {
|
|
|
return item.id;
|
|
|
}).join(',')
|
|
|
}).then((data)=> {
|
|
|
data.forEach((item)=> {
|
|
|
const g = prodMap[item.productSkn];
|
|
|
|
|
|
g.marketPrice = item.marketPrice;
|
|
|
g.salesPrice = item.salesPrice;
|
|
|
g.productName = item.productName;
|
|
|
});
|
|
|
|
|
|
this.$set('recommendProducts', this.recommendProducts);
|
|
|
});
|
|
|
};
|
|
|
});
|
|
|
|
|
|
$(window).on('scroll', ()=> {
|
|
|
if ($(window).scrollTop() > 200 && loadDeferred) {
|
|
|
loadDeferred();
|
|
|
loadDeferred = null;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
};
|
...
|
...
|
|