Authored by Aiden Xu

资讯详情

... ... @@ -9,6 +9,7 @@ Name | Path | Note
品牌店铺分享页面 | /product/brand-share?domain=colormad |
商品详情 | /product/{productId} |
资讯列表 | /news |
资讯详情 | /news/{newsId} |
----
### order 常亮
... ... @@ -20,4 +21,4 @@ s_p_desc | 价格降序
p_d_asc | 折扣升序
p_d_desc | 折扣降序
s_n_asc | 销量升序
s_n_desc | 销量降序
\ No newline at end of file
s_n_desc | 销量降序
... ...
... ... @@ -126,6 +126,24 @@ const component = {
api.get('', params).then(result => {
res.json(result);
}).catch(next);
},
/**
* 搜索产品
*
* @param req
* @param res
* @param next
*/
search: (req, res, next) => {
let params = {
query: req.query.ids,
limit: 4
};
model.search(params).then(result => {
res.json(result);
}).catch(next);
}
};
... ...
... ... @@ -9,6 +9,7 @@
// const helpers = global.yoho.helpers;
const api = global.yoho.API;
const camelCase = global.yoho.camelCase;
/**
* 商品详情
... ... @@ -65,6 +66,24 @@ const model = {
return api.get('', Object.assign({
method: 'app.Shopping.count'
}, params));
},
/**
* 搜索
*
* @param params
* @returns {*}
*/
search: (params) => {
return api.get('', Object.assign({
method: 'app.search.li'
}, params)).then((result)=> {
if (result.code === 200) {
return Promise.resolve(camelCase(result.data).productList);
} else {
Promise.reject(result);
}
});
}
};
... ...
... ... @@ -46,4 +46,5 @@ router.get(/\/intro_([\d]+)\.json/, detail.intro);
router.post(/cart.json/, detail.addToCart);
router.post(/favorite.json/, detail.favorite);
router.get(/cart-count.json/, detail.getCartCount);
router.get(/search_product\.json/, detail.search);
module.exports = router;
... ...
... ... @@ -15,8 +15,10 @@ module.exports = {
port: 6004,
siteUrl: '//m.yohoblk.com',
domains: {
api: 'http://192.168.102.202:8080/gateway/',
service: 'http://192.168.102.202:8080/gateway/'
// api: 'http://192.168.102.202:8080/gateway/',
// service: 'http://192.168.102.202:8080/gateway/',
api: 'http://devapi.yoho.cn:58078/',
service: 'http://devservice.yoho.cn:58077/'
},
subDomains: {
host: '.m.yohoblk.com',
... ...
... ... @@ -135,9 +135,9 @@ Vue.filter('formatUnixTime', (value) => {
// let Y = date.getFullYear() + '-';
let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
let D = (date.getDate() + 1 < 10 ? '0' + (date.getDate() + 1) : date.getDate() + 1);
let h = date.getHours();
let m = date.getMinutes();
let D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
let h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
let m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
// let s = date.getSeconds();
... ...
... ... @@ -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;
}
});
}
};
... ...