diff --git a/mini/pages/home/home.js b/mini/pages/home/home.js
index 5b9b68d..33ac586 100644
--- a/mini/pages/home/home.js
+++ b/mini/pages/home/home.js
@@ -82,6 +82,7 @@ Page({
const almanac = getAlmanacInfo(y, m, d);
this.setData({ dayInfo, almanac, currentYear: y, currentMonth: m });
this.refreshDerived();
+ this.loadUpcoming();
},
/** 计算派生数据(节假日/工作日/佛历/初一十五) */
@@ -92,12 +93,14 @@ Page({
const workday = isWorkday(y, m, d);
const termTime = dayInfo.solarTerm ? (SOLAR_TERM_TIMES[dayInfo.solarTerm] || '') : '';
const isFirstOrFifteen = highlightLunar && (dayInfo.lunarDay === 1 || dayInfo.lunarDay === 15);
- const nextBuddhist = showBuddhist ? getNextBuddhistFestival() : null;
+ const nextBuddhist = showBuddhist ? getNextBuddhistFestival(y, m, d) : null;
this.setData({ legalHoliday, workday, termTime, isFirstOrFifteen, nextBuddhist });
},
loadUpcoming() {
- this.setData({ upcoming: getUpcomingFestivals(5) });
+ const { dayInfo } = this.data;
+ const { solarYear: y, solarMonth: m, solarDay: d } = dayInfo;
+ this.setData({ upcoming: getUpcomingFestivals(5, y, m, d) });
},
prevDay() { this.shiftDay(-1); },
diff --git a/mini/pages/home/home.wxml b/mini/pages/home/home.wxml
index ee93e63..b7b22ac 100644
--- a/mini/pages/home/home.wxml
+++ b/mini/pages/home/home.wxml
@@ -27,10 +27,12 @@
-
+
‹
- {{dayInfo.solarDay}}
+
+ {{dayInfo.solarDay}}
+
›
@@ -40,17 +42,17 @@
{{dayInfo.lunarYearGanzhi}}年 {{dayInfo.lunarMonthGanzhi}}月 {{dayInfo.lunarDayGanzhi}}日 · 属{{dayInfo.zodiac}}
-
-
+
+
{{legalHoliday}}
{{dayInfo.lunarFestival}}
{{dayInfo.solarFestival}}
{{dayInfo.solarTerm}}{{termTime ? ' ' + termTime : ''}}
-
-
- 🪷 距 {{nextBuddhist.name}} 还有 {{nextBuddhist.daysLeft}} 天({{nextBuddhist.solarDate}})
+
+
+ 🪷 距 {{nextBuddhist.name}} 还有 {{nextBuddhist.daysLeft}} 天({{nextBuddhist.solarDate}})
diff --git a/mini/pages/home/home.wxss b/mini/pages/home/home.wxss
index 51e41dd..5958efe 100644
--- a/mini/pages/home/home.wxss
+++ b/mini/pages/home/home.wxss
@@ -128,13 +128,29 @@
}
.almanac-day-num {
- font-size: 240rpx;
+ font-size: 200rpx;
font-weight: 700;
line-height: 1.05;
- min-width: 400rpx;
text-align: center;
}
+/* 老黄历方框 */
+.day-frame {
+ min-width: 360rpx;
+ height: 300rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border: 6rpx solid;
+ border-radius: 16rpx;
+ background: #FFFDF8;
+ box-shadow: inset 0 0 0 4rpx #FFFDF8, inset 0 0 0 6rpx currentColor;
+}
+
+.frame-holiday { border-color: #C41E3A; color: #C41E3A; }
+.frame-workday { border-color: #2E7D32; color: #2E7D32; }
+.frame-weekend { border-color: #C41E3A; color: #C41E3A; }
+
.num-holiday { color: #C41E3A; }
.num-workday { color: #2E7D32; }
.num-weekend { color: #C41E3A; }
@@ -165,13 +181,15 @@
margin-top: 8rpx;
}
-/* 节日 */
+/* 节日(固定高度占位) */
.almanac-fest {
display: flex;
justify-content: center;
+ align-items: center;
flex-wrap: wrap;
gap: 12rpx;
margin-bottom: 12rpx;
+ min-height: 52rpx;
}
.badge-holiday {
@@ -191,11 +209,15 @@
color: #FFFFFF;
}
-/* 佛历提醒 */
+/* 佛历提醒(固定高度占位) */
.buddhist-tip {
text-align: center;
padding: 12rpx;
margin-bottom: 8rpx;
+ min-height: 50rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
}
.buddhist-text {
diff --git a/mini/utils/core/data.js b/mini/utils/core/data.js
index 545fe31..2c1ef75 100644
--- a/mini/utils/core/data.js
+++ b/mini/utils/core/data.js
@@ -75,6 +75,71 @@ const SOLAR_TERM_DATES = [
[7, 22] // 大雪, 冬至 (12月)
];
+/** 二十四节气精确日期表 2000-2060(天文算法生成,索引:小寒=0...冬至=23) */
+const SOLAR_TERM_TABLE = {
+ 2000: [6,21,4,19,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,21],
+ 2001: [5,20,4,18,5,20,5,20,5,21,5,21,7,23,7,23,7,23,8,23,7,22,7,22],
+ 2002: [5,20,4,19,6,21,5,20,6,21,6,21,7,23,8,23,8,23,8,23,7,22,7,22],
+ 2003: [6,20,4,19,6,21,5,20,6,21,6,22,7,23,8,23,8,23,9,24,8,23,7,22],
+ 2004: [6,21,4,19,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,21],
+ 2005: [5,20,4,18,5,20,5,20,5,21,5,21,7,23,7,23,7,23,8,23,7,22,7,22],
+ 2006: [5,20,4,19,6,21,5,20,5,21,6,21,7,23,7,23,8,23,8,23,7,22,7,22],
+ 2007: [6,20,4,19,6,21,5,20,6,21,6,22,7,23,8,23,8,23,9,24,8,23,7,22],
+ 2008: [6,21,4,19,5,20,4,20,5,21,5,21,7,22,7,23,7,22,8,23,7,22,7,21],
+ 2009: [5,20,4,18,5,20,4,20,5,21,5,21,7,23,7,23,7,23,8,23,7,22,7,22],
+ 2010: [5,20,4,19,6,21,5,20,5,21,6,21,7,23,7,23,8,23,8,23,7,22,7,22],
+ 2011: [6,20,4,19,6,21,5,20,6,21,6,22,7,23,8,23,8,23,8,24,8,23,7,22],
+ 2012: [6,21,4,19,5,20,4,20,5,20,5,21,7,22,7,23,7,22,8,23,7,22,7,21],
+ 2013: [5,20,4,18,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,22],
+ 2014: [5,20,4,19,6,21,5,20,5,21,6,21,7,23,7,23,8,23,8,23,7,22,7,22],
+ 2015: [6,20,4,19,6,21,5,20,6,21,6,22,7,23,8,23,8,23,8,24,8,22,7,22],
+ 2016: [6,20,4,19,5,20,4,19,5,20,5,21,7,22,7,23,7,22,8,23,7,22,7,21],
+ 2017: [5,20,3,18,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,22],
+ 2018: [5,20,4,19,5,21,5,20,5,21,6,21,7,23,7,23,8,23,8,23,7,22,7,22],
+ 2019: [5,20,4,19,6,21,5,20,6,21,6,21,7,23,8,23,8,23,8,24,8,22,7,22],
+ 2020: [6,20,4,19,5,20,4,19,5,20,5,21,6,22,7,22,7,22,8,23,7,22,7,21],
+ 2021: [5,20,3,18,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,21],
+ 2022: [5,20,4,19,5,20,5,20,5,21,6,21,7,23,7,23,7,23,8,23,7,22,7,22],
+ 2023: [5,20,4,19,6,21,5,20,6,21,6,21,7,23,8,23,8,23,8,24,8,22,7,22],
+ 2024: [6,20,4,19,5,20,4,19,5,20,5,21,6,22,7,22,7,22,8,23,7,22,6,21],
+ 2025: [5,20,3,18,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,21],
+ 2026: [5,20,4,18,5,20,5,20,5,21,5,21,7,23,7,23,7,23,8,23,7,22,7,22],
+ 2027: [5,20,4,19,6,21,5,20,6,21,6,21,7,23,8,23,8,23,8,23,7,22,7,22],
+ 2028: [6,20,4,19,5,20,4,19,5,20,5,21,6,22,7,22,7,22,8,23,7,22,6,21],
+ 2029: [5,20,3,18,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,21],
+ 2030: [5,20,4,18,5,20,5,20,5,21,5,21,7,23,7,23,7,23,8,23,7,22,7,22],
+ 2031: [5,20,4,19,6,21,5,20,6,21,6,21,7,23,8,23,8,23,8,23,7,22,7,22],
+ 2032: [6,20,4,19,5,20,4,19,5,20,5,21,6,22,7,22,7,22,8,23,7,22,6,21],
+ 2033: [5,20,3,18,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,21],
+ 2034: [5,20,4,18,5,20,5,20,5,21,5,21,7,23,7,23,7,23,8,23,7,22,7,22],
+ 2035: [5,20,4,19,6,21,5,20,5,21,6,21,7,23,7,23,8,23,8,23,7,22,7,22],
+ 2036: [6,20,4,19,5,20,4,19,5,20,5,21,6,22,7,22,7,22,8,23,7,22,6,21],
+ 2037: [5,20,3,18,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,21],
+ 2038: [5,20,4,18,5,20,5,20,5,21,5,21,7,23,7,23,7,23,8,23,7,22,7,22],
+ 2039: [5,20,4,19,6,21,5,20,5,21,6,21,7,23,7,23,8,23,8,23,7,22,7,22],
+ 2040: [6,20,4,19,5,20,4,19,5,20,5,21,6,22,7,22,7,22,8,23,7,22,6,21],
+ 2041: [5,20,3,18,5,20,4,20,5,20,5,21,7,22,7,23,7,22,8,23,7,22,7,21],
+ 2042: [5,20,4,18,5,20,4,20,5,21,5,21,7,23,7,23,7,23,8,23,7,22,7,22],
+ 2043: [5,20,4,19,6,21,5,20,5,21,6,21,7,23,7,23,8,23,8,23,7,22,7,22],
+ 2044: [6,20,4,19,5,20,4,19,5,20,5,21,6,22,7,22,7,22,7,23,7,22,6,21],
+ 2045: [5,20,3,18,5,20,4,19,5,20,5,21,7,22,7,23,7,22,8,23,7,22,7,21],
+ 2046: [5,20,4,18,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,22],
+ 2047: [5,20,4,19,6,21,5,20,5,21,6,21,7,23,7,23,8,23,8,23,7,22,7,22],
+ 2048: [6,20,4,19,5,20,4,19,5,20,5,20,6,22,7,22,7,22,7,23,7,21,6,21],
+ 2049: [5,19,3,18,5,20,4,19,5,20,5,21,6,22,7,22,7,22,8,23,7,22,7,21],
+ 2050: [5,20,3,18,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,22],
+ 2051: [5,20,4,19,5,20,5,20,5,21,6,21,7,23,7,23,7,23,8,23,7,22,7,22],
+ 2052: [5,20,4,19,5,20,4,19,5,20,5,20,6,22,7,22,7,22,7,23,7,21,6,21],
+ 2053: [5,19,3,18,5,20,4,19,5,20,5,21,6,22,7,22,7,22,8,23,7,22,7,21],
+ 2054: [5,20,3,18,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,22],
+ 2055: [5,20,4,19,5,20,5,20,5,21,5,21,7,23,7,23,7,23,8,23,7,22,7,22],
+ 2056: [5,20,4,19,5,20,4,19,5,20,5,20,6,22,7,22,7,22,7,23,7,21,6,21],
+ 2057: [5,19,3,18,5,20,4,19,5,20,5,21,6,22,7,22,7,22,8,23,7,22,6,21],
+ 2058: [5,20,3,18,5,20,4,20,5,21,5,21,7,22,7,23,7,23,8,23,7,22,7,21],
+ 2059: [5,20,4,19,5,20,5,20,5,21,5,21,7,23,7,23,7,23,8,23,7,22,7,22],
+ 2060: [5,20,4,19,5,20,4,19,5,20,5,20,6,22,7,22,7,22,7,22,6,21,6,21],
+};
+
/** 公历节日 */
const SOLAR_FESTIVALS = {
'1-1': '元旦', '2-14': '情人节', '3-8': '妇女节', '3-12': '植树节',
@@ -415,6 +480,7 @@ module.exports = {
CONSTELLATION_DATES,
SOLAR_TERMS,
SOLAR_TERM_DATES,
+ SOLAR_TERM_TABLE,
SOLAR_FESTIVALS,
LUNAR_FESTIVALS,
BUDDHIST_FESTIVALS,
diff --git a/mini/utils/core/index.js b/mini/utils/core/index.js
index c607dd7..df31dc0 100644
--- a/mini/utils/core/index.js
+++ b/mini/utils/core/index.js
@@ -10,6 +10,7 @@ const {
CONSTELLATION_DATES,
SOLAR_TERMS,
SOLAR_TERM_DATES,
+ SOLAR_TERM_TABLE,
SOLAR_FESTIVALS,
LUNAR_FESTIVALS,
BUDDHIST_FESTIVALS,
@@ -316,7 +317,7 @@ function getSolarTermDate(year, termIndex) {
return Math.floor(Y * 0.2422 + C) - Math.floor(Y / 4) + leapAdjust;
}
-/** 获取节气(准确算法)
+/** 获取节气(优先精确查表 2000-2060,范围外用 C 值法兜底)
* SOLAR_TERMS 数组从冬至开始:冬至=0, 小寒=1, 大寒=2, 立春=3, ..., 大雪=23
*/
function getSolarTerm(year, month, day) {
@@ -327,6 +328,16 @@ function getSolarTerm(year, month, day) {
// 转为天文顺序(小寒=0):SOLAR_TERMS 索引 - 1(冬至特殊为23)
const astroIdx1 = idx1 === 0 ? 23 : idx1 - 1;
const astroIdx2 = idx2 === 0 ? 23 : idx2 - 1;
+
+ // 优先用精确表
+ const table = SOLAR_TERM_TABLE[year];
+ if (table) {
+ if (day === table[astroIdx1]) return SOLAR_TERMS[idx1];
+ if (day === table[astroIdx2]) return SOLAR_TERMS[idx2];
+ return null;
+ }
+
+ // 兜底:C 值法
const d1 = getSolarTermDate(year, astroIdx1);
const d2 = getSolarTermDate(year, astroIdx2);
if (day === d1) return SOLAR_TERMS[idx1];
@@ -1209,12 +1220,14 @@ function daysBetween(fromY, fromM, fromD, toY, toM, toD) {
return Math.round((b - a) / (24 * 60 * 60 * 1000));
}
-/** 获取即将到来的 N 个节日(含今天之后的) */
-function getUpcomingFestivals(count = 6) {
+/** 获取即将到来的 N 个节日(含基准日之后的)
+ * baseYear/baseMonth/baseDay 可选,默认今天
+ */
+function getUpcomingFestivals(count = 6, baseYear, baseMonth, baseDay) {
const now = new Date();
- const y = now.getFullYear();
- const m = now.getMonth() + 1;
- const d = now.getDate();
+ const y = baseYear || now.getFullYear();
+ const m = baseMonth || (now.getMonth() + 1);
+ const d = baseDay || now.getDate();
const list = [];
for (const fest of FESTIVAL_QUICK_SEARCH) {
@@ -1241,12 +1254,12 @@ function getUpcomingFestivals(count = 6) {
return list.slice(0, count);
}
-/** 获取下一个佛教节日及倒计时 */
-function getNextBuddhistFestival() {
+/** 获取下一个佛教节日及倒计时(基准日可选,默认今天) */
+function getNextBuddhistFestival(baseYear, baseMonth, baseDay) {
const now = new Date();
- const y = now.getFullYear();
- const m = now.getMonth() + 1;
- const d = now.getDate();
+ const y = baseYear || now.getFullYear();
+ const m = baseMonth || (now.getMonth() + 1);
+ const d = baseDay || now.getDate();
const entries = Object.entries(BUDDHIST_FESTIVALS);
const list = [];