fix: 部份 app 内购空值的问题 (#3544)

close #3490
This commit is contained in:
Henry Wang 2019-12-07 18:39:44 +00:00 committed by DIYgod
parent e7f3e25e32
commit d1a3fc7c26
1 changed files with 11 additions and 13 deletions

View File

@ -35,22 +35,20 @@ module.exports = async (ctx) => {
let title;
let item = [];
const iap = apiResponse.relationships['merchandised-in-apps'].data;
const iap = apiResponse.relationships['top-in-apps'].data;
if (iap) {
title = `${country === 'cn' ? '内购限免提醒' : 'IAP price watcher'}: ${titleTemp} for ${platform}`;
item = iap
.filter((e) => e.attributes.isMerchandisedEnabled)
.map((e) => {
const title = `${e.attributes.name} is now ${e.attributes.offers[0].priceFormatted}`;
return {
link,
guid: e.attributes.url,
description: e.attributes.description.standard,
title,
pubDate: new Date().toUTCString(),
};
});
item = iap.map((e) => {
const title = `${e.attributes.name} is now ${e.attributes.offers[0].priceFormatted}`;
return {
link,
guid: e.attributes.url,
description: e.attributes.description.standard + `<br><img src=${e.attributes.artwork.url.replace('{w}x{h}{c}.{f}', '320x0w.jpg')}>`,
title,
pubDate: new Date().toUTCString(),
};
});
}
ctx.state.data = {