42 lines
911 B
JavaScript
42 lines
911 B
JavaScript
Page({
|
|
data: {
|
|
bookmarks: []
|
|
},
|
|
|
|
onShow() {
|
|
this.loadBookmarks();
|
|
},
|
|
|
|
loadBookmarks() {
|
|
const bookmarks = wx.getStorageSync('lunar-bookmarks') || [];
|
|
this.setData({ bookmarks });
|
|
},
|
|
|
|
removeBookmark(e) {
|
|
const date = e.currentTarget.dataset.date;
|
|
const bookmarks = this.data.bookmarks.filter(b => b.date !== date);
|
|
wx.setStorageSync('lunar-bookmarks', bookmarks);
|
|
this.setData({ bookmarks });
|
|
wx.showToast({ title: '已删除', icon: 'success' });
|
|
},
|
|
|
|
// 点击收藏项跳转到当日详情
|
|
openDetail(e) {
|
|
const date = e.currentTarget.dataset.date;
|
|
wx.navigateTo({ url: `/pages/day-detail/day-detail?date=${date}` });
|
|
},
|
|
|
|
onShareAppMessage() {
|
|
return {
|
|
title: '我的收藏 - 老黄历',
|
|
path: '/pages/bookmarks/bookmarks'
|
|
};
|
|
},
|
|
|
|
onShareTimeline() {
|
|
return {
|
|
title: '我的收藏 - 老黄历'
|
|
};
|
|
}
|
|
});
|