feat(home): 日视图swiper轮播+老黄历方框合并+引入lunar-javascript真实宜忌
Publish Mini Program Dev Version / publish (push) Has been cancelled
Publish Mini Program Dev Version / publish (push) Has been cancelled
1. 日视图改为swiper轮播,左右滑动切换日期,箭头固定在最左最右 2. 大日期方框扩大到包含农历和干支 3. 生肖(马年)移到导航栏右侧 4. 星期移到工作日提示左侧 5. 引入lunar-javascript(6tail库),用真实宜忌(最多20+项)替换手写4-5项 6. 值神/黄道详情样式调整:label大、value小、加间隔 7. 去掉点击放大提示
This commit is contained in:
+113
-58
@@ -8,33 +8,32 @@ function pad(n) { return String(n).padStart(2, '0'); }
|
||||
function fmt(y, m, d) { return `${y}-${pad(m)}-${pad(d)}`; }
|
||||
|
||||
const MONTH_SPAN = 2; // 当前月前后各2个月,共5个月
|
||||
const DAY_SPAN = 2; // 当前日前后各2天,共5天
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 20,
|
||||
navBarHeight: 44,
|
||||
viewMode: 'day',
|
||||
dayInfo: {},
|
||||
almanac: {},
|
||||
legalHoliday: null,
|
||||
workday: true,
|
||||
termTime: '',
|
||||
isFirstOrFifteen: false,
|
||||
nextBuddhist: null,
|
||||
showBuddhist: false,
|
||||
highlightLunar: true,
|
||||
upcoming: [],
|
||||
// 日视图 swiper
|
||||
dayList: [], // [{key, dayInfo, almanac, legalHoliday, workday, termTime, isFirstOrFifteen, nextBuddhist, showBuddhist, upcoming}]
|
||||
dayIndex: 2, // 当前居中
|
||||
// 月历 swiper
|
||||
monthList: [], // [{key, year, month, weeks}]
|
||||
monthIndex: 2, // 当前居中
|
||||
monthList: [],
|
||||
monthIndex: 2,
|
||||
currentYear: 0,
|
||||
currentMonth: 0,
|
||||
weekHeaders: ['日', '一', '二', '三', '四', '五', '六'],
|
||||
// 当前选中日期(用于月历联动)
|
||||
dayInfo: {},
|
||||
// 全屏弹窗
|
||||
zoomVisible: false,
|
||||
zoomTitle: '',
|
||||
zoomType: '', // yiji | detail | fest
|
||||
zoomData: null
|
||||
zoomType: '',
|
||||
zoomData: null,
|
||||
// 设置
|
||||
showBuddhist: false,
|
||||
highlightLunar: true
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -45,14 +44,12 @@ Page({
|
||||
if (menu && menu.top) navBarHeight = (menu.top - statusBarHeight) * 2 + menu.height;
|
||||
this.setData({ statusBarHeight, navBarHeight });
|
||||
this.loadSettings();
|
||||
this.loadDay(new Date());
|
||||
this.loadUpcoming();
|
||||
this.buildDayList(new Date());
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadSettings();
|
||||
// 设置可能变化,刷新
|
||||
if (this.data.dayInfo.solarYear) this.refreshDerived();
|
||||
if (this.data.dayList.length > 0) this.refreshDayListSettings();
|
||||
},
|
||||
|
||||
loadSettings() {
|
||||
@@ -65,55 +62,116 @@ Page({
|
||||
|
||||
onPullDownRefresh() {
|
||||
if (this.data.viewMode === 'day') {
|
||||
this.loadDay(new Date());
|
||||
this.loadUpcoming();
|
||||
this.buildDayList(new Date());
|
||||
} else {
|
||||
this.buildMonthList(this.data.currentYear, this.data.currentMonth);
|
||||
}
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
|
||||
/** 加载某日的老黄历 */
|
||||
loadDay(date) {
|
||||
/** 构建某日的完整数据 */
|
||||
buildDayData(date) {
|
||||
const y = date.getFullYear();
|
||||
const m = date.getMonth() + 1;
|
||||
const d = date.getDate();
|
||||
const dayInfo = getDayInfo(y, m, d);
|
||||
const almanac = getAlmanacInfo(y, m, d);
|
||||
this.setData({ dayInfo, almanac, currentYear: y, currentMonth: m });
|
||||
this.refreshDerived();
|
||||
this.loadUpcoming();
|
||||
},
|
||||
|
||||
/** 计算派生数据(节假日/工作日/佛历/初一十五) */
|
||||
refreshDerived() {
|
||||
const { dayInfo, showBuddhist, highlightLunar } = this.data;
|
||||
const { solarYear: y, solarMonth: m, solarDay: d } = dayInfo;
|
||||
const legalHoliday = getLegalHoliday(y, m, d);
|
||||
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(y, m, d) : null;
|
||||
this.setData({ legalHoliday, workday, termTime, isFirstOrFifteen, nextBuddhist });
|
||||
const isFirstOrFifteen = this.data.highlightLunar && (dayInfo.lunarDay === 1 || dayInfo.lunarDay === 15);
|
||||
const nextBuddhist = this.data.showBuddhist ? getNextBuddhistFestival(y, m, d) : null;
|
||||
const upcoming = getUpcomingFestivals(5, y, m, d);
|
||||
return {
|
||||
key: fmt(y, m, d),
|
||||
dayInfo, almanac, legalHoliday, workday, termTime,
|
||||
isFirstOrFifteen, nextBuddhist, upcoming,
|
||||
showBuddhist: this.data.showBuddhist
|
||||
};
|
||||
},
|
||||
|
||||
loadUpcoming() {
|
||||
const { dayInfo } = this.data;
|
||||
const { solarYear: y, solarMonth: m, solarDay: d } = dayInfo;
|
||||
this.setData({ upcoming: getUpcomingFestivals(5, y, m, d) });
|
||||
/** 构建5天的数据,居中显示 */
|
||||
buildDayList(centerDate) {
|
||||
const dayList = [];
|
||||
for (let i = -DAY_SPAN; i <= DAY_SPAN; i++) {
|
||||
const date = new Date(centerDate.getFullYear(), centerDate.getMonth(), centerDate.getDate() + i);
|
||||
dayList.push(this.buildDayData(date));
|
||||
}
|
||||
const center = dayList[DAY_SPAN];
|
||||
this.setData({
|
||||
dayList,
|
||||
dayIndex: DAY_SPAN,
|
||||
dayInfo: center.dayInfo,
|
||||
currentYear: center.dayInfo.solarYear,
|
||||
currentMonth: center.dayInfo.solarMonth
|
||||
});
|
||||
},
|
||||
|
||||
prevDay() { this.shiftDay(-1); },
|
||||
nextDay() { this.shiftDay(1); },
|
||||
shiftDay(delta) {
|
||||
const { dayInfo } = this.data;
|
||||
const date = new Date(dayInfo.solarYear, dayInfo.solarMonth - 1, dayInfo.solarDay + delta);
|
||||
this.loadDay(date);
|
||||
/** 设置变化后刷新 dayList */
|
||||
refreshDayListSettings() {
|
||||
const dayList = this.data.dayList.map(item => ({
|
||||
...item,
|
||||
showBuddhist: this.data.showBuddhist,
|
||||
isFirstOrFifteen: this.data.highlightLunar && (item.dayInfo.lunarDay === 1 || item.dayInfo.lunarDay === 15),
|
||||
nextBuddhist: this.data.showBuddhist ? getNextBuddhistFestival(item.dayInfo.solarYear, item.dayInfo.solarMonth, item.dayInfo.solarDay) : null
|
||||
}));
|
||||
this.setData({ dayList });
|
||||
},
|
||||
|
||||
/** 日视图 swiper 切换 */
|
||||
onDaySwiperChange(e) {
|
||||
const index = e.detail.current;
|
||||
const { dayList } = this.data;
|
||||
const cur = dayList[index];
|
||||
this.setData({
|
||||
dayIndex: index,
|
||||
dayInfo: cur.dayInfo,
|
||||
currentYear: cur.dayInfo.solarYear,
|
||||
currentMonth: cur.dayInfo.solarMonth
|
||||
});
|
||||
|
||||
// 边缘时向对应方向补一天,保持可无限滑动
|
||||
if (index === 0) {
|
||||
this.prependDay();
|
||||
} else if (index === dayList.length - 1) {
|
||||
this.appendDay();
|
||||
}
|
||||
},
|
||||
|
||||
prependDay() {
|
||||
const { dayList } = this.data;
|
||||
const first = dayList[0];
|
||||
const date = new Date(first.dayInfo.solarYear, first.dayInfo.solarMonth - 1, first.dayInfo.solarDay - 1);
|
||||
dayList.unshift(this.buildDayData(date));
|
||||
if (dayList.length > 7) dayList.pop();
|
||||
this.setData({ dayList, dayIndex: this.data.dayIndex + 1 });
|
||||
},
|
||||
|
||||
appendDay() {
|
||||
const { dayList } = this.data;
|
||||
const last = dayList[dayList.length - 1];
|
||||
const date = new Date(last.dayInfo.solarYear, last.dayInfo.solarMonth - 1, last.dayInfo.solarDay + 1);
|
||||
dayList.push(this.buildDayData(date));
|
||||
if (dayList.length > 7) dayList.shift();
|
||||
this.setData({ dayList, dayIndex: this.data.dayIndex - 1 });
|
||||
},
|
||||
|
||||
prevDay() {
|
||||
if (this.data.dayIndex > 0) {
|
||||
this.setData({ dayIndex: this.data.dayIndex - 1 });
|
||||
this.onDaySwiperChange({ detail: { current: this.data.dayIndex - 1 } });
|
||||
}
|
||||
},
|
||||
|
||||
nextDay() {
|
||||
if (this.data.dayIndex < this.data.dayList.length - 1) {
|
||||
this.setData({ dayIndex: this.data.dayIndex + 1 });
|
||||
this.onDaySwiperChange({ detail: { current: this.data.dayIndex + 1 } });
|
||||
}
|
||||
},
|
||||
|
||||
backToday() {
|
||||
this.loadDay(new Date());
|
||||
this.loadUpcoming();
|
||||
this.buildDayList(new Date());
|
||||
},
|
||||
|
||||
/** 切换 日/月 视图 */
|
||||
@@ -139,14 +197,13 @@ Page({
|
||||
this.setData({ monthList, monthIndex: MONTH_SPAN, currentYear: year, currentMonth: month });
|
||||
},
|
||||
|
||||
/** swiper 切换 */
|
||||
/** 月历 swiper 切换 */
|
||||
onMonthSwiperChange(e) {
|
||||
const index = e.detail.current;
|
||||
const { monthList } = this.data;
|
||||
const cur = monthList[index];
|
||||
this.setData({ monthIndex: index, currentYear: cur.year, currentMonth: cur.month });
|
||||
|
||||
// 边缘时向对应方向补一个月,保持可无限滚动
|
||||
if (index === 0) {
|
||||
this.prependMonth();
|
||||
} else if (index === monthList.length - 1) {
|
||||
@@ -180,28 +237,26 @@ Page({
|
||||
selectDay(e) {
|
||||
const date = e.currentTarget.dataset.date;
|
||||
const [y, m, d] = date.split('-').map(Number);
|
||||
this.loadDay(new Date(y, m - 1, d));
|
||||
this.buildDayList(new Date(y, m - 1, d));
|
||||
this.setData({ viewMode: 'day' });
|
||||
},
|
||||
|
||||
goDetail() {
|
||||
const { dayInfo } = this.data;
|
||||
wx.navigateTo({ url: `/pages/day-detail/day-detail?date=${fmt(dayInfo.solarYear, dayInfo.solarMonth, dayInfo.solarDay)}` });
|
||||
},
|
||||
|
||||
/** 跳转到某节日的老黄历 */
|
||||
goFestival(e) {
|
||||
const date = e.currentTarget.dataset.date;
|
||||
const [y, m, d] = date.split('-').map(Number);
|
||||
this.loadDay(new Date(y, m - 1, d));
|
||||
this.buildDayList(new Date(y, m - 1, d));
|
||||
this.setData({ viewMode: 'day' });
|
||||
wx.pageScrollTo && wx.pageScrollTo({ scrollTop: 0, duration: 0 });
|
||||
},
|
||||
|
||||
/** ===== 全屏放大弹窗 ===== */
|
||||
openZoom(e) {
|
||||
const type = e.currentTarget.dataset.type;
|
||||
const { dayInfo, almanac, legalHoliday, termTime } = this.data;
|
||||
const date = e.currentTarget.dataset.date;
|
||||
const dayItem = this.data.dayList.find(item => item.key === date);
|
||||
if (!dayItem) return;
|
||||
|
||||
const { dayInfo, almanac, legalHoliday, termTime } = dayItem;
|
||||
let zoomTitle = '';
|
||||
let zoomData = null;
|
||||
if (type === 'yiji') {
|
||||
@@ -223,7 +278,7 @@ Page({
|
||||
};
|
||||
} else if (type === 'fest') {
|
||||
zoomTitle = '近期节日';
|
||||
zoomData = { upcoming: this.data.upcoming };
|
||||
zoomData = { upcoming: dayItem.upcoming };
|
||||
}
|
||||
this.setData({ zoomVisible: true, zoomTitle, zoomType: type, zoomData });
|
||||
},
|
||||
|
||||
+123
-110
@@ -5,129 +5,142 @@
|
||||
<text class="nav-toggle-text">{{viewMode === 'day' ? '月历' : '日历'}}</text>
|
||||
</view>
|
||||
<text class="nav-title font-chinese">老黄历</text>
|
||||
<view class="nav-right"></view>
|
||||
<view class="nav-right">
|
||||
<text class="nav-zodiac">{{dayInfo.zodiac}}年</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 日视图:老黄历 -->
|
||||
<scroll-view class="page-body" scroll-y wx:if="{{viewMode === 'day'}}" style="padding-top: {{statusBarHeight + navBarHeight}}px;">
|
||||
<view class="container">
|
||||
<!-- 日视图:老黄历(swiper 轮播) -->
|
||||
<view class="page-body" wx:if="{{viewMode === 'day'}}" style="padding-top: {{statusBarHeight + navBarHeight}}px;">
|
||||
<swiper
|
||||
class="day-swiper"
|
||||
current="{{dayIndex}}"
|
||||
bindchange="onDaySwiperChange"
|
||||
duration="300"
|
||||
circular="{{false}}"
|
||||
>
|
||||
<swiper-item wx:for="{{dayList}}" wx:key="key" wx:for-item="dayItem">
|
||||
<scroll-view class="day-scroll" scroll-y>
|
||||
<view class="container">
|
||||
|
||||
<!-- 大日历卡片(点击放大) -->
|
||||
<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="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-card {{dayItem.legalHoliday ? 'is-holiday' : (dayItem.workday ? 'is-workday' : 'is-weekend')}}" bindtap="openZoom" data-type="detail" data-date="{{dayItem.key}}">
|
||||
<!-- 顶部:公历 -->
|
||||
<view class="almanac-head">
|
||||
<view class="almanac-head-left">
|
||||
<text class="almanac-year">{{dayItem.dayInfo.solarYear}}年{{dayItem.dayInfo.solarMonth}}月</text>
|
||||
</view>
|
||||
<view class="head-tags">
|
||||
<text class="today-tag" wx:if="{{dayItem.dayInfo.isToday}}">今日</text>
|
||||
<text class="lunar-tag" wx:if="{{dayItem.isFirstOrFifteen}}">{{dayItem.dayInfo.lunarDay === 1 ? '初一' : '十五'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 大日期(老黄历方框) -->
|
||||
<view class="almanac-day-row" catchtap="noop">
|
||||
<view class="day-arrow" catchtap="prevDay">‹</view>
|
||||
<view class="day-frame {{legalHoliday ? 'frame-holiday' : (workday ? 'frame-workday' : 'frame-weekend')}}">
|
||||
<view class="almanac-day-num font-chinese {{legalHoliday ? 'num-holiday' : (workday ? 'num-workday' : 'num-weekend')}}">{{dayInfo.solarDay}}</view>
|
||||
</view>
|
||||
<view class="day-arrow" catchtap="nextDay">›</view>
|
||||
</view>
|
||||
<!-- 大日期(老黄历方框,包含农历和干支) -->
|
||||
<view class="almanac-day-row" catchtap="noop">
|
||||
<view class="day-frame {{dayItem.legalHoliday ? 'frame-holiday' : (dayItem.workday ? 'frame-workday' : 'frame-weekend')}}">
|
||||
<view class="day-frame-inner">
|
||||
<view class="almanac-day-num font-chinese {{dayItem.legalHoliday ? 'num-holiday' : (dayItem.workday ? 'num-workday' : 'num-weekend')}}">{{dayItem.dayInfo.solarDay}}</view>
|
||||
<view class="day-frame-lunar">
|
||||
<text class="day-frame-lunar-main font-chinese">{{dayItem.dayInfo.lunarMonthName}}{{dayItem.dayInfo.lunarDayName}}</text>
|
||||
<text class="day-frame-lunar-sub">{{dayItem.dayInfo.lunarYearGanzhi}}年 {{dayItem.dayInfo.lunarMonthGanzhi}}月 {{dayItem.dayInfo.lunarDayGanzhi}}日</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 农历 -->
|
||||
<view class="almanac-lunar">
|
||||
<text class="almanac-lunar-main font-chinese">{{dayInfo.lunarMonthName}}{{dayInfo.lunarDayName}}</text>
|
||||
<text class="almanac-lunar-sub">{{dayInfo.lunarYearGanzhi}}年 {{dayInfo.lunarMonthGanzhi}}月 {{dayInfo.lunarDayGanzhi}}日 · 属{{dayInfo.zodiac}}</text>
|
||||
</view>
|
||||
<!-- 节日/节气(固定高度,空着也占位) -->
|
||||
<view class="almanac-fest">
|
||||
<text class="badge badge-holiday" wx:if="{{dayItem.legalHoliday}}">{{dayItem.legalHoliday}}</text>
|
||||
<text class="badge badge-festival" wx:if="{{dayItem.dayInfo.lunarFestival && !dayItem.legalHoliday}}">{{dayItem.dayInfo.lunarFestival}}</text>
|
||||
<text class="badge badge-festival" wx:if="{{dayItem.dayInfo.solarFestival && !dayItem.legalHoliday}}">{{dayItem.dayInfo.solarFestival}}</text>
|
||||
<text class="badge badge-term" wx:if="{{dayItem.dayInfo.solarTerm}}">{{dayItem.dayInfo.solarTerm}}{{dayItem.termTime ? ' ' + dayItem.termTime : ''}}</text>
|
||||
</view>
|
||||
|
||||
<!-- 节日/节气(固定高度,空着也占位) -->
|
||||
<view class="almanac-fest">
|
||||
<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">
|
||||
<text class="buddhist-text" wx:if="{{dayItem.showBuddhist && dayItem.nextBuddhist}}" catchtap="noop">🪷 距 {{dayItem.nextBuddhist.name}} 还有 {{dayItem.nextBuddhist.daysLeft}} 天({{dayItem.nextBuddhist.solarDate}})</text>
|
||||
</view>
|
||||
|
||||
<!-- 佛历提醒(固定高度,空着也占位) -->
|
||||
<view class="buddhist-tip">
|
||||
<text class="buddhist-text" wx:if="{{showBuddhist && nextBuddhist}}" catchtap="noop">🪷 距 {{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>
|
||||
<view class="yiji-items">
|
||||
<text class="yiji-item yi" wx:for="{{almanac.recommends}}" wx:key="*this">{{item}}</text>
|
||||
<!-- 星期 + 工作日/节假日提示 -->
|
||||
<view class="day-type-tip {{dayItem.legalHoliday ? 'tip-holiday' : (dayItem.workday ? 'tip-workday' : 'tip-weekend')}}">
|
||||
星期{{dayItem.dayInfo.weekDay}} · {{dayItem.legalHoliday ? dayItem.legalHoliday + ' · 放假' : (dayItem.workday ? '工作日 · 上班' : '周末 · 休息')}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="yiji-divider"></view>
|
||||
<view class="yiji-col">
|
||||
<view class="yiji-title ji">忌</view>
|
||||
<view class="yiji-items">
|
||||
<text class="yiji-item ji" wx:for="{{almanac.avoids}}" wx:key="*this">{{item}}</text>
|
||||
|
||||
<!-- 宜忌(点击放大) -->
|
||||
<view class="card yiji-card" bindtap="openZoom" data-type="yiji" data-date="{{dayItem.key}}">
|
||||
<view class="yiji-row">
|
||||
<view class="yiji-col">
|
||||
<view class="yiji-title yi">宜</view>
|
||||
<view class="yiji-items">
|
||||
<text class="yiji-item yi" wx:for="{{dayItem.almanac.recommends}}" wx:key="*this">{{item}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="yiji-divider"></view>
|
||||
<view class="yiji-col">
|
||||
<view class="yiji-title ji">忌</view>
|
||||
<view class="yiji-items">
|
||||
<text class="yiji-item ji" wx:for="{{dayItem.almanac.avoids}}" wx:key="*this">{{item}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="zoom-hint">点击放大 🔍</view>
|
||||
</view>
|
||||
|
||||
<!-- 黄历详情(点击放大) -->
|
||||
<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>
|
||||
<text class="text-base font-medium block">{{almanac.duty}}</text>
|
||||
</view>
|
||||
<view class="p-2 bg-page rounded">
|
||||
<text class="text-xs text-muted">黄道</text>
|
||||
<text class="text-base font-medium block">{{almanac.twelveStar.name}}({{almanac.twelveStar.ecliptic}})</text>
|
||||
</view>
|
||||
<view class="p-2 bg-page rounded">
|
||||
<text class="text-xs text-muted">二十八宿</text>
|
||||
<text class="text-base font-medium block">{{almanac.twentyEightStar.name}}</text>
|
||||
</view>
|
||||
<view class="p-2 bg-page rounded">
|
||||
<text class="text-xs text-muted">六曜</text>
|
||||
<text class="text-base font-medium block">{{almanac.sixStar}}</text>
|
||||
</view>
|
||||
<view class="p-2 bg-page rounded">
|
||||
<text class="text-xs text-muted">冲煞</text>
|
||||
<text class="text-base font-medium block">冲{{almanac.clash}} 煞{{almanac.evilDirection}}</text>
|
||||
</view>
|
||||
<view class="p-2 bg-page rounded">
|
||||
<text class="text-xs text-muted">彭祖百忌</text>
|
||||
<text class="text-base font-medium block">{{almanac.pengZu}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="zoom-hint">点击放大 🔍</view>
|
||||
</view>
|
||||
<!-- 黄历详情(点击放大) -->
|
||||
<view class="card" bindtap="openZoom" data-type="detail" data-date="{{dayItem.key}}">
|
||||
<view class="detail-grid">
|
||||
<view class="detail-item">
|
||||
<text class="detail-label">值神</text>
|
||||
<text class="detail-value">{{dayItem.almanac.duty}}</text>
|
||||
</view>
|
||||
<view class="detail-item">
|
||||
<text class="detail-label">黄道</text>
|
||||
<text class="detail-value">{{dayItem.almanac.twelveStar.name}}({{dayItem.almanac.twelveStar.ecliptic}})</text>
|
||||
</view>
|
||||
<view class="detail-item">
|
||||
<text class="detail-label">二十八宿</text>
|
||||
<text class="detail-value">{{dayItem.almanac.twentyEightStar.name}}</text>
|
||||
</view>
|
||||
<view class="detail-item">
|
||||
<text class="detail-label">六曜</text>
|
||||
<text class="detail-value">{{dayItem.almanac.sixStar}}</text>
|
||||
</view>
|
||||
<view class="detail-item">
|
||||
<text class="detail-label">冲煞</text>
|
||||
<text class="detail-value">冲{{dayItem.almanac.clash}} 煞{{dayItem.almanac.evilDirection}}</text>
|
||||
</view>
|
||||
<view class="detail-item">
|
||||
<text class="detail-label">彭祖百忌</text>
|
||||
<text class="detail-value">{{dayItem.almanac.pengZu}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</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="card" bindtap="openZoom" data-type="fest" data-date="{{dayItem.key}}">
|
||||
<view class="section-title">节日速查</view>
|
||||
<view class="fest-quick">
|
||||
<view class="fest-quick-item" wx:for="{{dayItem.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>
|
||||
<!-- 回今天 -->
|
||||
<view class="back-today" wx:if="{{!dayItem.dayInfo.isToday}}" bindtap="backToday">回到今天</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
|
||||
<!-- 左右箭头(固定在 swiper 最左最右) -->
|
||||
<view class="day-arrow-fixed left" bindtap="prevDay">‹</view>
|
||||
<view class="day-arrow-fixed right" bindtap="nextDay">›</view>
|
||||
</view>
|
||||
|
||||
<!-- 月历视图:swiper 上下/左右滚动换月 -->
|
||||
<view class="page-body month-body" wx:if="{{viewMode === 'month'}}" style="padding-top: {{statusBarHeight + navBarHeight}}px;">
|
||||
|
||||
+114
-55
@@ -40,11 +40,29 @@
|
||||
|
||||
.nav-right {
|
||||
min-width: 96rpx;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.nav-zodiac {
|
||||
color: #FFFFFF;
|
||||
font-size: 24rpx;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.page-body {
|
||||
box-sizing: border-box;
|
||||
min-height: 100vh;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* 日视图 swiper */
|
||||
.day-swiper {
|
||||
height: calc(100vh - 88px);
|
||||
}
|
||||
|
||||
.day-scroll {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
@@ -52,7 +70,33 @@
|
||||
padding-bottom: 40rpx;
|
||||
}
|
||||
|
||||
/* ===== 老黄历大日历卡片(节气精确查表版) ===== */
|
||||
/* 固定左右箭头 */
|
||||
.day-arrow-fixed {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
font-size: 72rpx;
|
||||
color: #C9B8A6;
|
||||
z-index: 50;
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.day-arrow-fixed.left {
|
||||
left: 10rpx;
|
||||
}
|
||||
|
||||
.day-arrow-fixed.right {
|
||||
right: 10rpx;
|
||||
}
|
||||
|
||||
/* ===== 老黄历大日历卡片 ===== */
|
||||
.almanac-card {
|
||||
border-radius: 24rpx;
|
||||
padding: 32rpx 24rpx 24rpx;
|
||||
@@ -92,12 +136,6 @@
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.almanac-week {
|
||||
font-size: 24rpx;
|
||||
color: #9E8E7E;
|
||||
margin-left: 16rpx;
|
||||
}
|
||||
|
||||
.head-tags {
|
||||
display: flex;
|
||||
gap: 12rpx;
|
||||
@@ -124,20 +162,13 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 8rpx 0;
|
||||
margin: 16rpx 0;
|
||||
}
|
||||
|
||||
.almanac-day-num {
|
||||
font-size: 200rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1.05;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 老黄历方框 */
|
||||
/* 老黄历方框(包含农历和干支) */
|
||||
.day-frame {
|
||||
min-width: 360rpx;
|
||||
height: 300rpx;
|
||||
min-width: 480rpx;
|
||||
padding: 32rpx 40rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -147,6 +178,40 @@
|
||||
box-shadow: inset 0 0 0 4rpx #FFFDF8, inset 0 0 0 6rpx currentColor;
|
||||
}
|
||||
|
||||
.day-frame-inner {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.almanac-day-num {
|
||||
font-size: 180rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.day-frame-lunar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
padding-top: 16rpx;
|
||||
border-top: 2rpx solid currentColor;
|
||||
}
|
||||
|
||||
.day-frame-lunar-main {
|
||||
font-size: 40rpx;
|
||||
font-weight: 600;
|
||||
color: #1A1A1A;
|
||||
}
|
||||
|
||||
.day-frame-lunar-sub {
|
||||
font-size: 22rpx;
|
||||
color: #9E8E7E;
|
||||
}
|
||||
|
||||
.frame-holiday { border-color: #C41E3A; color: #C41E3A; }
|
||||
.frame-workday { border-color: #2E7D32; color: #2E7D32; }
|
||||
.frame-weekend { border-color: #C41E3A; color: #C41E3A; }
|
||||
@@ -155,32 +220,6 @@
|
||||
.num-workday { color: #2E7D32; }
|
||||
.num-weekend { color: #C41E3A; }
|
||||
|
||||
.day-arrow {
|
||||
font-size: 72rpx;
|
||||
color: #C9B8A6;
|
||||
padding: 0 28rpx;
|
||||
}
|
||||
|
||||
/* 农历 */
|
||||
.almanac-lunar {
|
||||
text-align: center;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.almanac-lunar-main {
|
||||
font-size: 48rpx;
|
||||
font-weight: 600;
|
||||
color: #1A1A1A;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.almanac-lunar-sub {
|
||||
font-size: 24rpx;
|
||||
color: #9E8E7E;
|
||||
display: block;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
/* 节日(固定高度占位) */
|
||||
.almanac-fest {
|
||||
display: flex;
|
||||
@@ -225,7 +264,7 @@
|
||||
color: #B8860B;
|
||||
}
|
||||
|
||||
/* 工作日/节假日提示 */
|
||||
/* 星期 + 工作日/节假日提示 */
|
||||
.day-type-tip {
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
@@ -302,13 +341,6 @@
|
||||
.yiji-item.yi { background: #FEF2F2; color: #C41E3A; }
|
||||
.yiji-item.ji { background: #F1F5F9; color: #546E7A; }
|
||||
|
||||
.zoom-hint {
|
||||
text-align: center;
|
||||
font-size: 20rpx;
|
||||
color: #C9B8A6;
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
@@ -316,6 +348,36 @@
|
||||
color: #C41E3A;
|
||||
}
|
||||
|
||||
/* 黄历详情(label 大、value 小、加间隔) */
|
||||
.detail-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.detail-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24rpx;
|
||||
padding: 16rpx;
|
||||
background: #FFFBF5;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
font-size: 28rpx;
|
||||
color: #9E8E7E;
|
||||
min-width: 140rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.detail-value {
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
color: #1A1A1A;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* 节日速查 */
|
||||
.fest-quick {
|
||||
display: flex;
|
||||
@@ -619,6 +681,3 @@
|
||||
padding: 4rpx 24rpx;
|
||||
border-radius: 999rpx;
|
||||
}
|
||||
|
||||
|
||||
/* CI trigger: 节气修复部署 */
|
||||
|
||||
@@ -50,6 +50,7 @@ const {
|
||||
HOUR_WEIGHTS,
|
||||
BONE_INTERPRETATIONS
|
||||
} = require('./data.js');
|
||||
const { Solar } = require('../lunar.js');
|
||||
|
||||
/** 判断是否为闰年 */
|
||||
function isLeapYear(year) {
|
||||
@@ -648,13 +649,18 @@ function getAlmanacInfo(year, month, day) {
|
||||
const minorRen = getMinorRen(dayInfo.lunarMonth, dayInfo.lunarDay, 12);
|
||||
const phase = dayInfo.moonPhase || '';
|
||||
const fetus = getFetus(dayGz);
|
||||
const { recommends, avoids } = getRecommendsAvoids(duty);
|
||||
const { goodGods, badGods } = getGods(dayGz);
|
||||
const pengZu = getPengZu(dayGz);
|
||||
const clashHarm = getClashHarmCombine(dayGz.branch);
|
||||
const nayin = getNayin(dayGz.ganzhi);
|
||||
const hourDetails = getHourlyAlmanac(dayGz);
|
||||
|
||||
// 用 lunar-javascript 获取真实的宜忌/吉神/凶煞(老黄历数据,最多 20+ 项)
|
||||
const lunar = Solar.fromYmd(year, month, day).getLunar();
|
||||
const recommends = lunar.getDayYi();
|
||||
const avoids = lunar.getDayJi();
|
||||
const goodGods = lunar.getDayJiShen();
|
||||
const badGods = lunar.getDayXiongSha();
|
||||
|
||||
const luckyDuties = ['除', '执', '危', '成', '开'];
|
||||
const unluckyDuties = ['建', '满', '平', '破', '收', '闭'];
|
||||
let dutyLuck = 'neutral';
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user