增加:有品-每日上新 (#861)
* 增加:有品-每日上新 * 修复 summary 字段错误 * 将 youpin 模块转移至 mi 目录下,并更新文档
This commit is contained in:
parent
45d425416b
commit
8c464e807c
|
|
@ -1515,6 +1515,8 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
|
|||
|
||||
<route name="众筹" author="DIYgod" example="/mi/crowdfunding" path="/mi/crowdfunding"/>
|
||||
|
||||
<route name="有品-每日上新" author="xyqfer" example="/mi/youpin/new" path="/mi/youpin/new"/>
|
||||
|
||||
## 网络小说
|
||||
|
||||
### 笔趣阁
|
||||
|
|
|
|||
|
|
@ -373,6 +373,7 @@ router.get('/hexo/next/:url', require('./routes/hexo/next'));
|
|||
|
||||
// 小米
|
||||
router.get('/mi/crowdfunding', require('./routes/mi/crowdfunding'));
|
||||
router.get('/mi/youpin/new', require('./routes/mi/youpin/new'));
|
||||
|
||||
// Keep
|
||||
router.get('/keep/user/:id', require('./routes/keep/user'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
const axios = require('../../../utils/axios');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: 'https://home.mi.com/lasagne/page/4',
|
||||
});
|
||||
|
||||
const data = response.data.floors;
|
||||
|
||||
ctx.state.data = {
|
||||
title: '有品-每日上新',
|
||||
link: 'https://home.mi.com/newproduct?pageid=4',
|
||||
description: '有品-每日上新',
|
||||
item: data.reduce((acc, item) => {
|
||||
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: `<img referrerpolicy="no-referrer" src="${img}"><br>${goods.summary}<br>价格:${goods.market_price / 100}元`,
|
||||
link: goods.jump_url,
|
||||
pubDate: new Date(goods.first_release_time * 1000).toUTCString(),
|
||||
});
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, []),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue