|
|
'use strict';
|
|
|
const api = global.yoho.API;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
/**
|
|
|
* 处理用户收藏的商品数据
|
...
|
...
|
@@ -16,7 +17,47 @@ exports.getFavProductData = (uid, page, limit) => { |
|
|
page: page,
|
|
|
limit: limit
|
|
|
}).then(result => {
|
|
|
return result.data;
|
|
|
var isend = true,
|
|
|
list = [],
|
|
|
data = result.data;
|
|
|
|
|
|
if (data && page <= data.page_total) {
|
|
|
data.product_list.forEach(function(d) {
|
|
|
if (!d.product_skn) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let link = '';
|
|
|
let discountPrice = false;
|
|
|
|
|
|
if (d.goodsId && d.cnAlphabet) {
|
|
|
link = helpers.urlFormat(`/product/pro_${d.product_id}_${d.goodsId}/${d.cnAlphabet}.html`);
|
|
|
}
|
|
|
|
|
|
if (Number(d.market_price) - Number(d.sales_price) > 0) {
|
|
|
discountPrice = '¥' + Number(Math.max(d.sales_price, 0)).toFixed(2);
|
|
|
}
|
|
|
|
|
|
list.push({
|
|
|
fav_id: d.product_id,
|
|
|
link: link,
|
|
|
imgUrl: d.image ? helpers.image(d.image) : '',
|
|
|
title: d.product_name,
|
|
|
price: '¥' + Number(Math.max(d.market_price, 0)).toFixed(2),
|
|
|
discountPrice: discountPrice,
|
|
|
sellOut: d.storage < 0,
|
|
|
invalidGoods: d.status === 0
|
|
|
});
|
|
|
});
|
|
|
|
|
|
if (page < data.page_total) {
|
|
|
isend = false;
|
|
|
}
|
|
|
}
|
|
|
return {
|
|
|
isend: isend,
|
|
|
list: list
|
|
|
};
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
@@ -37,7 +78,30 @@ exports.getFavBrandData = (uid, gender, page, limit) => { |
|
|
page: page,
|
|
|
limit: limit
|
|
|
}).then(result => {
|
|
|
return result.data;
|
|
|
var isend = true,
|
|
|
list = [],
|
|
|
data = result.data;
|
|
|
|
|
|
if (data && page <= data.page_total) {
|
|
|
data.brand_list.forEach(function(d) {
|
|
|
list.push({
|
|
|
fav_id: d.brand_id,
|
|
|
link: '', // todo
|
|
|
imgUrl: d.brand_ico ? helpers.image(d.brand_ico, 160, 125) : '',
|
|
|
brandName: d.brand_name,
|
|
|
down: d.status === 0
|
|
|
});
|
|
|
});
|
|
|
|
|
|
if (page < data.page_total) {
|
|
|
isend = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
isend: isend,
|
|
|
list: list
|
|
|
};
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
|