feat: 祈福小助手万年历小程序第一期

This commit is contained in:
gouki
2026-08-06 08:47:09 +00:00
commit a3e6aa9c01
136 changed files with 16597 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
const { getDayInfo, getAlmanacInfo } = require('../../utils/core/index.js');
Page({
data: {
date: '',
dayInfo: {},
almanac: {}
},
onLoad(options) {
const date = options.date || new Date().toISOString().split('T')[0];
this.setData({ date });
this.loadData(date);
},
loadData(dateStr) {
const [year, month, day] = dateStr.split('-').map(Number);
const dayInfo = getDayInfo(year, month, day);
const almanac = getAlmanacInfo(year, month, day);
this.setData({ dayInfo, almanac });
},
addBookmark() {
const bookmarks = wx.getStorageSync('lunar-bookmarks') || [];
const { dayInfo } = this.data;
const exists = bookmarks.some(b => b.date === dayInfo.solarDate);
if (!exists) {
bookmarks.push({
date: dayInfo.solarDate,
lunarDate: `${dayInfo.lunarMonthName}${dayInfo.lunarDayName}`,
note: ''
});
wx.setStorageSync('lunar-bookmarks', bookmarks);
wx.showToast({ title: '已收藏', icon: 'success' });
} else {
wx.showToast({ title: '已收藏过', icon: 'none' });
}
},
goBazi() {
wx.navigateTo({ url: '/pages/bazi/bazi' });
}
});