Publish Mini Program Dev Version / publish (push) Successful in 3m16s
tabBar(5个,全部带图标): - 老黄历(首页) / 许愿 / 八字 / 百科(新) / 我的(原设置) - 移除日历tab,月历并入首页左上角切换 - 移除运势tab,改从'我的'页进入 首页重构: - custom 导航栏,标题'老黄历' - 老式万年历大日历卡片:大日期+农历+干支+宜忌 - 左右箭头切换日期,'回到今天' - 左上角'月历/日历'切换按钮,月历视图复用原日历网格 - 月历点选日期自动切回日视图 新增百科页: - 二十四节气/农历节日/公历节日/干支生肖/黄历术语 分类 - 搜索 + 展开详情 我的页(原设置): - 新增功能入口:每日运势/占卜/二十四节气/月历视图
79 lines
1.9 KiB
JavaScript
79 lines
1.9 KiB
JavaScript
Page({
|
|
data: {
|
|
userInfo: null,
|
|
weekStartDay: 0,
|
|
ziHourSect: 'lateZiNextDay',
|
|
solarTime: true,
|
|
bookmarks: []
|
|
},
|
|
|
|
onLoad() {
|
|
this.loadSettings();
|
|
this.loadBookmarks();
|
|
},
|
|
|
|
onShow() {
|
|
this.loadBookmarks();
|
|
},
|
|
|
|
loadSettings() {
|
|
const settings = wx.getStorageSync('lunar-settings') || {};
|
|
this.setData({
|
|
weekStartDay: settings.weekStartDay || 0,
|
|
ziHourSect: settings.ziHourSect || 'lateZiNextDay',
|
|
solarTime: settings.solarTime !== false
|
|
});
|
|
},
|
|
|
|
saveSettings() {
|
|
const { weekStartDay, ziHourSect, solarTime } = this.data;
|
|
wx.setStorageSync('lunar-settings', { weekStartDay, ziHourSect, solarTime });
|
|
},
|
|
|
|
loadBookmarks() {
|
|
const bookmarks = wx.getStorageSync('lunar-bookmarks') || [];
|
|
this.setData({ bookmarks });
|
|
},
|
|
|
|
setWeekStart(e) {
|
|
this.setData({ weekStartDay: Number(e.currentTarget.dataset.v) });
|
|
this.saveSettings();
|
|
},
|
|
|
|
setZiSect(e) {
|
|
this.setData({ ziHourSect: e.currentTarget.dataset.v });
|
|
this.saveSettings();
|
|
},
|
|
|
|
onSolarTimeChange(e) {
|
|
this.setData({ solarTime: e.detail.value });
|
|
this.saveSettings();
|
|
},
|
|
|
|
removeBookmark(e) {
|
|
const date = e.currentTarget.dataset.date;
|
|
let bookmarks = this.data.bookmarks.filter(b => b.date !== date);
|
|
wx.setStorageSync('lunar-bookmarks', bookmarks);
|
|
this.setData({ bookmarks });
|
|
wx.showToast({ title: '已删除', icon: 'success' });
|
|
},
|
|
|
|
navTo(e) {
|
|
wx.navigateTo({ url: e.currentTarget.dataset.url });
|
|
},
|
|
|
|
login() {
|
|
wx.getUserProfile({
|
|
desc: '用于完善用户资料',
|
|
success: (res) => {
|
|
this.setData({ userInfo: res.userInfo });
|
|
wx.setStorageSync('lunar-user-info', res.userInfo);
|
|
wx.showToast({ title: '登录成功', icon: 'success' });
|
|
},
|
|
fail: () => {
|
|
wx.showToast({ title: '登录失败', icon: 'none' });
|
|
}
|
|
});
|
|
}
|
|
});
|