diff --git a/docs/shopping.md b/docs/shopping.md
index ef87cfac69..5f97dc90a9 100644
--- a/docs/shopping.md
+++ b/docs/shopping.md
@@ -211,7 +211,7 @@ For instance, in https://www.leboncoin.fr/recherche/?**category=10&locations=Par
### 小米有品每日上新
-
+
## 宜家 IKEA
diff --git a/lib/routes/mi/youpin/crowdfunding.js b/lib/routes/mi/youpin/crowdfunding.js
index 5be134c83b..2c211b140b 100644
--- a/lib/routes/mi/youpin/crowdfunding.js
+++ b/lib/routes/mi/youpin/crowdfunding.js
@@ -1,5 +1,4 @@
const got = require('@/utils/got');
-const utils = require('./utils');
module.exports = async (ctx) => {
const response = await got({
@@ -7,12 +6,34 @@ module.exports = async (ctx) => {
url: 'https://home.mi.com/lasagne/page/5',
});
- const data = response.data.floors;
+ const data = response.data.floors.filter((floor) => floor.floor_id === 99 || floor.floor_id === 100);
+ const item = data.reduce((acc, item) => {
+ if (!item.data) {
+ return acc;
+ }
+ let goodsList = [];
+
+ if (item.data.result) {
+ goodsList = item.data.result.goods_list;
+ }
+
+ goodsList.forEach((goods) => {
+ const img = goods.pic_url;
+ acc.push({
+ title: goods.name,
+ description: `
${goods.summary}
价格:${goods.market_price / 100}元`,
+ link: goods.jump_url,
+ pubDate: new Date(goods.first_release_time * 1000).toUTCString(),
+ });
+ });
+
+ return acc;
+ }, []);
ctx.state.data = {
title: '小米有品众筹',
- link: 'https://home.mi.com/crowdfunding?&pageid=5',
+ link: 'https://m.xiaomiyoupin.com/w/crowdfunding?pageid=5',
description: '小米有品众筹',
- item: utils.generateData(data),
+ item,
};
};
diff --git a/lib/routes/mi/youpin/new.js b/lib/routes/mi/youpin/new.js
index 712e97f1ca..f780b69559 100644
--- a/lib/routes/mi/youpin/new.js
+++ b/lib/routes/mi/youpin/new.js
@@ -1,18 +1,40 @@
const got = require('@/utils/got');
-const utils = require('./utils');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
- url: 'https://home.mi.com/lasagne/page/4',
+ url: 'https://home.mi.com/lasagne/page/1605',
});
- const data = response.data.floors;
+ const data = response.data.floors.filter((floor) => floor.floor_id === 25912);
+ const item = data.reduce((acc, item) => {
+ if (!item.data) {
+ return acc;
+ }
+ let goodsList = [];
+
+ if (item.data.result) {
+ goodsList = item.data.result.list;
+ }
+
+ goodsList.forEach((goods) => {
+ const item = goods.value.goods;
+ const img = item.pic_url;
+ acc.push({
+ title: item.name,
+ description: `
${item.summary}
价格:${item.market_price / 100}元`,
+ link: item.jump_url,
+ pubDate: new Date(item.first_release_time * 1000).toUTCString(),
+ });
+ });
+
+ return acc;
+ }, []);
ctx.state.data = {
title: '小米有品每日上新',
- link: 'https://home.mi.com/newproduct?pageid=4',
+ link: 'https://m.xiaomiyoupin.com/w/newproduct?pageid=1605',
description: '小米有品每日上新',
- item: utils.generateData(data),
+ item,
};
};
diff --git a/lib/routes/mi/youpin/utils.js b/lib/routes/mi/youpin/utils.js
deleted file mode 100644
index 4fd5f937a7..0000000000
--- a/lib/routes/mi/youpin/utils.js
+++ /dev/null
@@ -1,33 +0,0 @@
-module.exports = {
- generateData: (data) =>
- data.reduce((acc, item) => {
- if (!item.data) {
- return acc;
- }
- let goodsList = [];
-
- if (item.data.result) {
- goodsList = item.data.result.goods_list;
- } else if (item.data.tabs) {
- goodsList = item.data.tabs.reduce((acc, tab) => {
- if (tab.result) {
- tab.result.goods_list.forEach((goods) => goods);
- }
-
- return acc;
- }, []);
- }
-
- goodsList.forEach((goods) => {
- const img = goods.pic_url;
- acc.push({
- title: goods.name,
- description: `
${goods.summary}
价格:${goods.market_price / 100}元`,
- link: goods.jump_url,
- pubDate: new Date(goods.first_release_time * 1000).toUTCString(),
- });
- });
-
- return acc;
- }, []),
-};