resources-process.js
2.03 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const _ = require('lodash');
const processTime = require('./time-process');
/**
* 处理楼层数据
* @param {[array]} list
* @return {[array]}
*/
module.exports = (list) => {
const formatData = [];
list = list || [];
_.forEach(list, (floor) => {
floor[_.camelCase(floor.template_name)] = true;
// 特殊资源位处理
// PLUS
if (floor.singleNameImage && floor.data) {
floor.data.title = {
title: floor.data.title
};
}
// 潮流时装/经典裤裙/时尚靴履/潮人配饰/潮流上装
if (floor.recommendContentOne && floor.data) {
if (floor.data.big_image && floor.data.big_image.length > 1) {
floor.data.big_image = {
bigList: floor.data.big_image
};
}
}
// OUTLETS
if (floor.titleImage && floor.data) {
if (floor.data.image) {
floor.data.big_image = {
bigList: [floor.data.image]
};
}
floor.data.title = {
moreName: floor.data.moreName,
moreUrl: floor.data.moreUrl,
title: floor.data.title
};
}
// 折扣专场
if (floor.discountActivity && floor.data && floor.data.list.length) {
_.map(floor.data.list, (item) => {
Object.assign(item, processTime(item.left_time));
});
}
// 断码区 , 此资源位数据结构比较坑
if (floor.offCodeArea && floor.data && floor.data.list.length) {
floor.data = {
title: floor.data.title,
data: [floor.data.list[0]],
left: [floor.data.list[1]],
right: floor.data.list.slice(2)
};
}
// 会员专享
if (floor.vipFloor && floor.data) {
floor.data.data = floor.data.image;
}
formatData.push(floor);
});
return formatData;
};