HelperHome.js
1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* @author: weiqingting<qingting.wei@yoho.cn>
*/
'use strict';
const helpers = global.yoho.helpers;
const Images = require('../../../utils/Images');
const formatFavBrand = (brandInfo, i)=>{
i = i || 10;
let hotBrands = [];
if (brandInfo.length > 0) {
for (let i = 0; i < brandInfo.length; i++) {
let value = brandInfo[i];
if (value.is_hot && value.is_hot == 'Y') {
hotBrands.push({
'href': helpers.urlFormat('', '', value['brand_domain']),
'logo': Images.getSourceUrl(value['brand_ico'], 'brandLogo'),
'name': value.brand_name
});
i--;
}
if (i <= 0) {
break;
}
}
}
return hotBrands;
};
const formatNew = (product)=>{
let result = [];
product.forEach(function(val, key) {
result[key] = {
href: helpers.getUrlBySkc(val['product_id'], val['goods_list'][0]['product_skc'], val['cn_alphabet']),
thumb: val['default_images'] ? Images.getImageUrl(val['default_images'], 400, 500) : '',
name: val['product_name'],
price: val['sales_price']
};
});
return result;
};
module.exports = {
formatFavBrand,
formatNew
};