fix 什么值得买 (#1771)

在商品比较少的时候,一些列表是空,不应该加进去,否则会出现一些item是undefined
![image](https://user-images.githubusercontent.com/20673460/54503780-b8119880-496b-11e9-82c1-3e69a4ce01ac.png)
This commit is contained in:
Chenyang Shi 2019-03-18 15:14:50 +08:00 committed by DIYgod
parent f80f1a8feb
commit 6b0eba41f4
1 changed files with 6 additions and 2 deletions

View File

@ -15,8 +15,12 @@ module.exports = async (ctx) => {
const list1 = [];
const list2 = [];
for (let i = 0; i < Math.min(6, data.length); i++) {
list1.push(data[i][0]);
list2.push(data[i][1]);
if (data[i][0].length !== 0) {
list1.push(data[i][0]);
}
if (data[i][1].length !== 0) {
list2.push(data[i][1]);
}
}
const list = [...list1, ...list2];