fix: 白鲸出海 (#6328)

This commit is contained in:
Ethan Shen
2020-12-04 15:56:45 +00:00
committed by GitHub
parent 982b1417d6
commit afe13f5343
+24 -33
View File
@@ -1,43 +1,34 @@
const got = require('@/utils/got');
const date = require('@/utils/date');
module.exports = async (ctx) => {
const response = await got({
method: 'post',
method: 'get',
url: 'http://www.baijingapp.com/api/get_more_articles/',
responseType: 'json',
form: {
deviceid: 'ios',
page: 1,
},
});
const resList = response.data;
const data = JSON.parse(response.data.substr(1, response.data.length - 1));
// json字符串转json对象
const resListObj = new Function('return ' + resList)();
if (resListObj.state === 1) {
const output = resListObj.data.list.map((item) => {
const title = item.title;
const link = 'https://www.baijingapp.com/article/' + item.id;
const time = item.time;
const author = item.user_name;
const image = item.image;
const single = {
title,
link,
time,
author,
image,
};
return single;
});
ctx.state.data = {
title: `白鲸出海`,
desription: '白鲸出海 - 泛互联网出海服务平台',
item: output,
const output = data.data.list.map((item) => {
const title = item.title;
const link = 'https://www.baijingapp.com/article/' + item.id;
const pubDate = date(item.time.replace(' ', ''));
const author = item.user_name;
const description = `<img src="${item.image}">`;
const single = {
title,
link,
pubDate,
author,
description,
};
}
return single;
});
ctx.state.data = {
title: `白鲸出海`,
desription: '白鲸出海 - 泛互联网出海服务平台',
item: output,
};
};