首页老黄历全面升级 + 修复农历转换核心bug
Publish Mini Program Dev Version / publish (push) Successful in 2m8s

【重要修复】重写农历双向转换算法(原来全错):
- solarToLunar/lunarToSolar 改用标准算法(基准1900-01-31正月初一,UTC避免时区误差)
- 验证:2026春节2-17、中秋9-25、端午6-19、2023闰二月全部正确

【首页大日历】
- 日期数字加大到240rpx,超醒目
- 节假日红色喜庆卡片+红数字(春节/国庆/中秋等法定假日)
- 工作日绿色卡片+绿数字(一眼知道要上班)
- 周末红色数字+米黄卡片
- 节气显示具体时刻(如 立秋 20:29)
- 初一/十五金色标记(可在设置关闭)
- 佛历提醒:距下一佛诞还有几天(可在设置开启)

【全屏放大弹窗(老年友好)】
- 大日历卡片/宜忌/详情/节日速查 点击均可全屏放大
- 宜忌放大后字号44rpx,详情放大后40rpx

【月历视图】
- swiper 左右滑动换月,预计算5个月居中显示
- 滑到边缘自动补月,可无限滚动
- 点选日期切回日视图

【节日速查】
- 首页显示近期5个节日(中秋/重阳等)+公历日期+倒计时
- 点击直接跳到该日老黄历

【设置页】
- 新增'显示佛历提醒'开关(默认关)
- 新增'初一十五高亮'开关(默认开)
This commit is contained in:
gouki
2026-08-07 12:49:57 +00:00
parent 5d40019ea5
commit 82c1a8d694
11 changed files with 1636 additions and 425 deletions
+170 -51
View File
@@ -12,24 +12,26 @@
<!-- 日视图:老黄历 -->
<scroll-view class="page-body" scroll-y wx:if="{{viewMode === 'day'}}" style="padding-top: {{statusBarHeight + navBarHeight}}px;">
<view class="container">
<!-- 大日历卡片 -->
<view class="almanac-card">
<!-- 大日历卡片(点击放大) -->
<view class="almanac-card {{legalHoliday ? 'is-holiday' : (workday ? 'is-workday' : 'is-weekend')}}" bindtap="openZoom" data-type="detail">
<!-- 顶部:公历 -->
<view class="almanac-head">
<view class="almanac-head-left">
<text class="almanac-year">{{dayInfo.solarYear}}年{{dayInfo.solarMonth}}月</text>
<text class="almanac-week">{{dayInfo.weekDay}} · {{dayInfo.constellation}}</text>
</view>
<view class="almanac-head-right" wx:if="{{dayInfo.isToday}}">
<text class="today-tag">今日</text>
<view class="head-tags">
<text class="today-tag" wx:if="{{dayInfo.isToday}}">今日</text>
<text class="lunar-tag" wx:if="{{isFirstOrFifteen}}">{{dayInfo.lunarDay === 1 ? '初一' : '十五'}}</text>
</view>
</view>
<!-- 大日期 -->
<view class="almanac-day-row">
<view class="day-arrow" bindtap="prevDay"></view>
<view class="almanac-day-num font-chinese">{{dayInfo.solarDay}}</view>
<view class="day-arrow" bindtap="nextDay"></view>
<view class="almanac-day-row" catchtap="noop">
<view class="day-arrow" catchtap="prevDay"></view>
<view class="almanac-day-num font-chinese {{legalHoliday ? 'num-holiday' : (workday ? 'num-workday' : 'num-weekend')}}">{{dayInfo.solarDay}}</view>
<view class="day-arrow" catchtap="nextDay"></view>
</view>
<!-- 农历 -->
@@ -38,14 +40,27 @@
<text class="almanac-lunar-sub">{{dayInfo.lunarYearGanzhi}}年 {{dayInfo.lunarMonthGanzhi}}月 {{dayInfo.lunarDayGanzhi}}日 · 属{{dayInfo.zodiac}}</text>
</view>
<!-- 节日/节气 -->
<view class="almanac-fest" wx:if="{{dayInfo.lunarFestival || dayInfo.solarFestival || dayInfo.solarTerm}}">
<text class="badge badge-festival" wx:if="{{dayInfo.lunarFestival}}">{{dayInfo.lunarFestival}}</text>
<text class="badge badge-festival" wx:if="{{dayInfo.solarFestival}}">{{dayInfo.solarFestival}}</text>
<text class="badge badge-outline" wx:if="{{dayInfo.solarTerm}}">{{dayInfo.solarTerm}}</text>
<!-- 节日/节气/佛历 -->
<view class="almanac-fest" wx:if="{{legalHoliday || dayInfo.lunarFestival || dayInfo.solarFestival || dayInfo.solarTerm}}">
<text class="badge badge-holiday" wx:if="{{legalHoliday}}">{{legalHoliday}}</text>
<text class="badge badge-festival" wx:if="{{dayInfo.lunarFestival && !legalHoliday}}">{{dayInfo.lunarFestival}}</text>
<text class="badge badge-festival" wx:if="{{dayInfo.solarFestival && !legalHoliday}}">{{dayInfo.solarFestival}}</text>
<text class="badge badge-term" wx:if="{{dayInfo.solarTerm}}">{{dayInfo.solarTerm}}{{termTime ? ' ' + termTime : ''}}</text>
</view>
<!-- 宜忌 -->
<!-- 佛历提醒 -->
<view class="buddhist-tip" wx:if="{{showBuddhist && nextBuddhist}}" catchtap="noop">
<text class="buddhist-text">🪷 距 {{nextBuddhist.name}} 还有 {{nextBuddhist.daysLeft}} 天({{nextBuddhist.solarDate}}</text>
</view>
<!-- 工作日/节假日提示 -->
<view class="day-type-tip {{legalHoliday ? 'tip-holiday' : (workday ? 'tip-workday' : 'tip-weekend')}}">
{{legalHoliday ? legalHoliday + ' · 放假' : (workday ? '工作日 · 上班' : '周末 · 休息')}}
</view>
</view>
<!-- 宜忌(点击放大) -->
<view class="card yiji-card" bindtap="openZoom" data-type="yiji">
<view class="yiji-row">
<view class="yiji-col">
<view class="yiji-title yi">宜</view>
@@ -61,13 +76,11 @@
</view>
</view>
</view>
<!-- 回今天 -->
<view class="back-today" wx:if="{{!dayInfo.isToday}}" bindtap="backToday">回到今天</view>
<view class="zoom-hint">点击放大 🔍</view>
</view>
<!-- 黄历详情 -->
<view class="card">
<!-- 黄历详情(点击放大) -->
<view class="card" bindtap="openZoom" data-type="detail">
<view class="grid grid-cols-2 gap-2">
<view class="p-2 bg-page rounded">
<text class="text-xs text-muted">值神</text>
@@ -94,41 +107,147 @@
<text class="text-base font-medium block">{{almanac.pengZu}}</text>
</view>
</view>
<view class="btn-primary mt-2 detail-btn" bindtap="goDetail">查看详情</view>
</view>
</view>
</scroll-view>
<!-- 月历视图 -->
<scroll-view class="page-body" scroll-y wx:if="{{viewMode === 'month'}}" style="padding-top: {{statusBarHeight + navBarHeight}}px;">
<view class="container">
<!-- 年月切换 -->
<view class="card flex justify-between items-center">
<view class="btn-ghost" bindtap="prevMonth"></view>
<view class="text-xl font-bold">{{year}}年{{month}}月</view>
<view class="btn-ghost" bindtap="nextMonth"></view>
<view class="zoom-hint">点击放大 🔍</view>
</view>
<!-- 星期头 -->
<view class="grid grid-cols-7 gap-1 mb-1">
<view class="text-center text-sm text-muted" wx:for="{{weekHeaders}}" wx:key="*this">{{item}}</view>
</view>
<!-- 日历网格 -->
<view class="grid grid-cols-7 gap-1">
<view
class="day-cell {{item.isToday ? 'today' : ''}} {{item.solarMonth !== month ? 'other-month' : ''}}"
wx:for="{{calendarDays}}"
wx:key="solarDate"
bindtap="selectDay"
data-date="{{item.solarDate}}"
>
<text class="day-number">{{item.solarDay}}</text>
<text class="day-lunar {{item.lunarFestival || item.solarFestival ? 'festival' : ''}}">
{{item.lunarFestival || item.solarFestival || item.lunarDayName}}
</text>
<view class="day-dot" wx:if="{{item.isTermDay}}"></view>
<!-- 节日速查 -->
<view class="card" bindtap="openZoom" data-type="fest">
<view class="section-title">节日速查</view>
<view class="fest-quick">
<view class="fest-quick-item" wx:for="{{upcoming}}" wx:key="name" catchtap="goFestival" data-date="{{item.solarDate}}">
<text class="fest-name">{{item.name}}</text>
<text class="fest-date">{{item.solarMonth}}月{{item.solarDay}}日</text>
<text class="fest-left {{item.daysLeft === 0 ? 'is-today' : ''}}">{{item.daysLeft === 0 ? '今天' : item.daysLeft + '天后'}}</text>
</view>
</view>
</view>
<!-- 回今天 -->
<view class="back-today" wx:if="{{!dayInfo.isToday}}" bindtap="backToday">回到今天</view>
</view>
</scroll-view>
<!-- 月历视图:swiper 上下/左右滚动换月 -->
<view class="page-body month-body" wx:if="{{viewMode === 'month'}}" style="padding-top: {{statusBarHeight + navBarHeight}}px;">
<view class="month-header">
<text class="month-title font-chinese">{{currentYear}}年{{currentMonth}}月</text>
<text class="month-hint">上下或左右滑动换月</text>
</view>
<view class="grid grid-cols-7 week-head">
<view class="text-center week-cell" wx:for="{{weekHeaders}}" wx:key="*this">{{item}}</view>
</view>
<swiper
class="month-swiper"
vertical="{{false}}"
circular="{{false}}"
current="{{monthIndex}}"
bindchange="onMonthSwiperChange"
duration="300"
>
<swiper-item wx:for="{{monthList}}" wx:key="key">
<scroll-view scroll-y class="month-scroll">
<view class="grid grid-cols-7 month-grid">
<view
class="day-cell {{d.isToday ? 'today' : ''}} {{d.solarMonth !== item.month ? 'other-month' : ''}}"
wx:for="{{item.weeks}}"
wx:for-item="week"
wx:key="week"
>
<block wx:for="{{week}}" wx:for-item="d" wx:key="solarDate">
<view
class="day-cell-inner {{d.isToday ? 'today' : ''}} {{d.solarMonth !== item.month ? 'other-month' : ''}}"
bindtap="selectDay"
data-date="{{d.solarDate}}"
>
<text class="day-number">{{d.solarDay}}</text>
<text class="day-lunar {{d.lunarFestival || d.solarFestival ? 'festival' : ''}}">
{{d.lunarFestival || d.solarFestival || d.lunarDayName}}
</text>
<view class="day-dot" wx:if="{{d.isTermDay}}"></view>
</view>
</block>
</view>
</view>
</scroll-view>
</swiper-item>
</swiper>
</view>
<!-- 全屏放大弹窗(老年友好) -->
<view class="zoom-mask {{zoomVisible ? 'show' : ''}}" bindtap="closeZoom">
<view class="zoom-panel" catchtap="noop">
<view class="zoom-header">
<text class="zoom-title font-chinese">{{zoomTitle}}</text>
<view class="zoom-close" bindtap="closeZoom">✕</view>
</view>
<!-- 宜忌放大 -->
<scroll-view scroll-y class="zoom-body" wx:if="{{zoomType === 'yiji' && zoomData}}">
<view class="zoom-yiji-block">
<view class="zoom-yiji-title yi">宜</view>
<view class="zoom-yiji-items">
<text class="zoom-yiji-item yi" wx:for="{{zoomData.recommends}}" wx:key="*this">{{item}}</text>
</view>
</view>
<view class="zoom-yiji-block">
<view class="zoom-yiji-title ji">忌</view>
<view class="zoom-yiji-items">
<text class="zoom-yiji-item ji" wx:for="{{zoomData.avoids}}" wx:key="*this">{{item}}</text>
</view>
</view>
</scroll-view>
<!-- 详情放大 -->
<scroll-view scroll-y class="zoom-body" wx:if="{{zoomType === 'detail' && zoomData}}">
<view class="zoom-detail-row" wx:if="{{zoomData.legalHoliday}}">
<text class="zoom-detail-label">节假日</text>
<text class="zoom-detail-value holiday">{{zoomData.legalHoliday}}</text>
</view>
<view class="zoom-detail-row" wx:if="{{zoomData.termTime}}">
<text class="zoom-detail-label">节气</text>
<text class="zoom-detail-value">{{zoomData.termTime}}</text>
</view>
<view class="zoom-detail-row">
<text class="zoom-detail-label">农历</text>
<text class="zoom-detail-value">{{zoomData.lunar}}</text>
</view>
<view class="zoom-detail-row">
<text class="zoom-detail-label">干支</text>
<text class="zoom-detail-value">{{zoomData.ganzhi}}</text>
</view>
<view class="zoom-detail-row">
<text class="zoom-detail-label">值神</text>
<text class="zoom-detail-value">{{zoomData.duty}}</text>
</view>
<view class="zoom-detail-row">
<text class="zoom-detail-label">黄道</text>
<text class="zoom-detail-value">{{zoomData.twelveStar}}</text>
</view>
<view class="zoom-detail-row">
<text class="zoom-detail-label">二十八宿</text>
<text class="zoom-detail-value">{{zoomData.twentyEightStar}}</text>
</view>
<view class="zoom-detail-row">
<text class="zoom-detail-label">六曜</text>
<text class="zoom-detail-value">{{zoomData.sixStar}}</text>
</view>
<view class="zoom-detail-row">
<text class="zoom-detail-label">冲煞</text>
<text class="zoom-detail-value">{{zoomData.clash}}</text>
</view>
<view class="zoom-detail-row">
<text class="zoom-detail-label">彭祖百忌</text>
<text class="zoom-detail-value">{{zoomData.pengZu}}</text>
</view>
</scroll-view>
<!-- 节日放大 -->
<scroll-view scroll-y class="zoom-body" wx:if="{{zoomType === 'fest' && zoomData}}">
<view class="zoom-fest-row" wx:for="{{zoomData.upcoming}}" wx:key="name" bindtap="goFestival" data-date="{{item.solarDate}}">
<text class="zoom-fest-name">{{item.name}}</text>
<text class="zoom-fest-date">{{item.solarDate}}</text>
<text class="zoom-fest-left {{item.daysLeft === 0 ? 'is-today' : ''}}">{{item.daysLeft === 0 ? '今天' : '还有' + item.daysLeft + '天'}}</text>
</view>
</scroll-view>
</view>
</view>