提交 240bbe1e 编写于 作者: AndroidLeaves's avatar AndroidLeaves

update

上级 f240f5f7
......@@ -3,7 +3,7 @@
// icon-color: red; icon-glyph: user-astronaut;
/**
* Author:LSP
* Date:2022-12-11
* Date:2022-12-13
*/
// -------------------------------------------------------
// 是否是开发环境,配合手机端调试使用,正式发布设置为false
......@@ -318,53 +318,46 @@ class Widget extends BaseWidget {
const URL = 'https://api5-normal-lq.toutiaoapi.com/vertical/sport/go/world_cup/match_info';
const RES = await this.httpGet(URL);
const match_infos = JSON.parse(RES.data).match_infos;
const fullDate = this.getDateStr(new Date(), 'yyyyMMdd');
const matchInfoKeys = Object.keys(match_infos);
let preDateIndex = -1;
let currDateIndex = 0;
for (let index = 0; index < matchInfoKeys.length; index++) {
const info = matchInfoKeys[index];
if (info >= fullDate) {
currDateIndex = index;
let key = matchInfoKeys[currDateIndex];
let tmpArr = match_infos[key];
let hasMatch = tmpArr.find(item => item.match_type == 1);
if (hasMatch) {
break
}
}
// -------------------------------------------------
const currDateKey = this.getDateStr(new Date(), 'yyyyMMdd');
let currDateIndex = matchInfoKeys.indexOf(currDateKey);
// -------------------------------------------------
let preDateIndex = currDateIndex - 1;
let preDateKey = matchInfoKeys[preDateIndex];
// -------------------------------------------------
let afterDateIndex = currDateIndex + 1;
let afterDateKey = '';
if (currDateIndex == matchInfoKeys.length - 1) {
afterDateIndex = -1;
} else {
afterDateKey = matchInfoKeys[afterDateIndex];
}
if (currDateIndex != 0) {
preDateIndex = currDateIndex - 1;
console.log(`preDateKey->${preDateKey}, afterDateKey:${afterDateKey}, currDateKey=${currDateKey}`);
// -------------------------------------------------
// match_status:1未开始,2:进行中,3:已结束,其他非比赛
let currMatch = match_infos[currDateKey];
let preMatch = match_infos[preDateKey];
let afterMatch;
if (afterDateKey.length > 0) {
afterMatch = match_infos[afterDateKey];
}
const currDateInfo = match_infos[fullDate] || [];
//
let showInfoArr = [];
const infoArr = [];
if (preDateIndex != -1) {
let preInfoKey = matchInfoKeys[preDateIndex];
let preInfoArr = match_infos[preInfoKey] || [];
preInfoArr = preInfoArr.filter(item => item.match_status == 2);
showInfoArr = showInfoArr.concat(preInfoArr);
}
showInfoArr = showInfoArr.concat(currDateInfo);
let hasGroup = true;
if (showInfoArr.length > 0) {
hasGroup = showInfoArr[0].group_name != undefined
if (preMatch.match_status == 2) {
showInfoArr = showInfoArr.concat(preMatch);
}
if (hasGroup) {
showInfoArr = showInfoArr.filter(item => item.group_name);
if ([1, 2, 3].indexOf(currMatch.match_status) != -1) {
showInfoArr = showInfoArr.concat(currMatch);
}
showInfoArr = showInfoArr.filter(item => item.host_team.team_id > 0);
if (filterFinished) {
showInfoArr = showInfoArr.filter(item => item.match_status != 3);
if (showInfoArr.length == 0 && currDateIndex != match_infos.length) {
let key = matchInfoKeys[currDateIndex + 1];
showInfoArr = showInfoArr.concat(match_infos[key]);
if (showInfoArr.length == 0 && afterDateKey.length > 0) {
showInfoArr = showInfoArr.concat(afterMatch);
}
}
const infoArr = [];
for (const info of showInfoArr) {
const {
round_name = '',
......
......@@ -131,7 +131,8 @@ class Widget extends BaseWidget {
textSpan.lineLimit = 1;
// ------------
leftStack.addSpacer(4);
textSpan = leftStack.addText(`完成率:${totalCount > 0 ? Math.floor((finishedCount / totalCount) * 100) : 0}%`);
const percent = totalCount > 0 ? Math.floor((finishedCount / totalCount) * 100) : 0;
textSpan = leftStack.addText(`完成率:${percent}%`);
textSpan.textColor = leftTextColor;
textSpan.font = leftTextFont;
textSpan.lineLimit = 1;
......@@ -143,12 +144,24 @@ class Widget extends BaseWidget {
const perHeight = height / 6;
const list = unfinishedList.slice(0, unfinishedList.length > 4 ? 4 : unfinishedList.length);
rightStack.addSpacer(10);
if (list.length === 0) {
rightStack.url = 'x-apple-reminderkit://';
const completeIcoStack = rightStack.addStack();
completeIcoStack.addSpacer();
img = await this.getImageByUrl('https://s3.uuu.ovh/imgs/2022/12/11/13440f7a07d814d3.png');
// ---------------------------------------
rightStack.url = 'x-apple-reminderkit://';
let percentIndex = 0;
if (percent > 0 && percent <= 25) {
percentIndex = 25;
} else if (percent > 25 && percent <= 50) {
percentIndex = 50;
} else if (percent > 50 && percent <= 75) {
percentIndex = 75;
} else if (percent > 75) {
percentIndex = 100;
}
if (percentIndex > 0) {
img = await this.getImageByUrl(`https://gitcode.net/enoyee/scriptable/-/raw/master/img/bg_celebrate_${percentIndex}.png`);
rightStack.backgroundImage = img;
}
// ---------------------------------------
if (list.length === 0) {
['', '', '', ''].forEach(_ => {
let rdStack = rightStack.addStack();
rdStack.url = 'x-apple-reminderkit://';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册