1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- // 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'
- });
- }
- });
|