feat(home): 修复swiper动画、宜忌布局、月历显示、节日速查
Build and Publish Server / build (push) Successful in 2m8s
Publish Mini Program Dev Version / publish (push) Failing after 11m17s

1. 修复swiper箭头点击动画丢失问题
   - 改用固定7天窗口,滑动到边缘时整体滚动数据
   - 保持dayIndex连续,确保swiper平滑动画

2. 修复宜忌两行显示压在一起
   - 设置item固定高度32rpx和行距12rpx
   - 超出2行显示...省略号

3. 修复月历数字竖向排列问题
   - 修正wxml嵌套结构,让42个格子正确排成6行7列
   - 压缩格子高度,放大数字字体

4. 节日速查功能优化
   - 默认显示3条,右侧添加更多
This commit is contained in:
gouki
2026-08-10 23:07:47 +00:00
parent 52c0d3c774
commit 2a68eae999
23 changed files with 2140 additions and 87 deletions
+53 -1
View File
@@ -1,4 +1,5 @@
const { SOLAR_TERMS, LUNAR_FESTIVALS, SOLAR_FESTIVALS, HEAVEN_STEMS, EARTH_BRANCHES, ZODIACS } = require('../../utils/core/data.js');
const { request } = require('../../utils/request.js');
const CATEGORIES = [
{ key: 'all', name: '全部' },
@@ -6,9 +7,16 @@ const CATEGORIES = [
{ key: 'lunarFest', name: '农历节日' },
{ key: 'solarFest', name: '公历节日' },
{ key: 'ganzhi', name: '干支生肖' },
{ key: 'termExplain', name: '黄历术语' }
{ key: 'termExplain', name: '黄历术语' },
{ key: 'other', name: '其他' }
];
// 服务端分类 key 到展示名的映射
const CAT_NAMES = {
term: '节气', lunarFest: '农历节日', solarFest: '公历节日',
ganzhi: '干支生肖', termExplain: '术语', other: '其他'
};
const TERM_BRIEFS = {
'立春': '春季开始,万物复苏', '雨水': '降雨增多,气温回升', '惊蛰': '春雷惊醒蛰伏动物',
'春分': '昼夜平分,春季过半', '清明': '天气晴朗,草木繁茂', '谷雨': '雨生百谷,播种时节',
@@ -112,6 +120,37 @@ Page({
onLoad() {
const entries = buildEntries();
this.setData({ entries, filteredEntries: entries });
this.loadServerEntries();
},
/** 从服务端加载百科条目(管理后台可维护),与本地数据合并:同标题以服务端为准,新增条目追加 */
loadServerEntries() {
request({ url: '/api/wiki/entries' })
.then(res => {
if (!res || res.code !== 0 || !res.data || !res.data.list) return;
const merged = [...this.data.entries];
const titleIndex = {};
merged.forEach((e, i) => { titleIndex[e.title] = i; });
res.data.list.forEach(s => {
const entry = {
cat: s.category,
catName: CAT_NAMES[s.category] || s.category,
title: s.title,
brief: s.brief,
content: s.content,
open: false
};
if (titleIndex[s.title] !== undefined) {
merged[titleIndex[s.title]] = entry; // 服务端内容覆盖本地
} else {
merged.push(entry);
}
});
this.setData({ entries: merged }, () => this.filter());
})
.catch(() => { /* 网络失败时使用本地内置数据 */ });
},
switchCat(e) {
@@ -134,5 +173,18 @@ Page({
const index = e.currentTarget.dataset.index;
const key = `filteredEntries[${index}].open`;
this.setData({ [key]: !this.data.filteredEntries[index].open });
},
onShareAppMessage() {
return {
title: '黄历百科 - 传统文化知识',
path: '/pages/wiki/wiki'
};
},
onShareTimeline() {
return {
title: '黄历百科 - 传统文化知识'
};
}
});