const store = require('../../utils/store.js'); const api = require('../../utils/api.js'); Page({ data: { articles: [], sheetShow: false, sheetType: '', }, onLoad() { store .ready() .then(() => api.listArticles()) .then((list) => { this.setData({ articles: (list || []).map((a) => ({ id: a.id, icon: a.icon, title: a.title, desc: a.description, })), }); }) .catch((e) => wx.showToast({ title: e.message || '加载失败', icon: 'none' })); }, // 打开文章正文详情页 openArticle(e) { const id = e.currentTarget.dataset.id; if (id) wx.navigateTo({ url: `/pages/article/article?id=${id}` }); }, openSheet(e) { this.setData({ sheetType: e.currentTarget.dataset.type, sheetShow: true }); }, closeSheet() { this.setData({ sheetShow: false }); }, onFab() { this.setData({ sheetType: 'ai', sheetShow: true }); }, onShareAppMessage() { return { title: '新手养宠知识合集', path: '/pages/learn/learn' }; }, onShareTimeline() { return { title: '新手养宠知识合集' }; }, });