// checkInShare.js Page({ data: { checkInList: [], userInfo: {} }, onLoad() { const userInfo = wx.getStorageSync('userInfo'); if (userInfo) { this.setData({ userInfo }); } const logs = wx.getStorageSync('logs') || []; const checkInList = logs.map(log => { return { userInfo: this.data.userInfo, date: log.date, cate: this.getCateText(log.cate), time: log.time }; }); this.setData({ checkInList }); }, getCateText(cateIndex) { const cateArr = [ { icon: 'work', text: '工作' }, { icon: 'study', text: "学习" }, { icon: 'think', text: '思考' }, { icon: 'write', text: '写作' }, { icon: 'sport', text: '运动' }, { icon: 'read', text: "阅读" } ]; return cateArr[cateIndex].text; }, publishCheckIn() { const logs = wx.getStorageSync('logs') || []; const lastLog = logs[0]; const newCheckIn = { userInfo: this.data.userInfo, date: lastLog.date, cate: this.getCateText(lastLog.cate), time: lastLog.time }; const checkInList = [newCheckIn, ...this.data.checkInList]; this.setData({ checkInList }); wx.showToast({ title: '打卡发布成功', icon: 'success' }); } });