init: initial commit

This commit is contained in:
Blizzard
2026-02-04 14:02:31 +08:00
commit 6ceda92e9d
2234 changed files with 38231 additions and 0 deletions
+72
View File
@@ -0,0 +1,72 @@
// pages/garden/index.js
import { MOCK_PLANTS } from '../../utils/mockData';
Page({
data: {
plants: [],
dateString: '',
greeting: ''
},
onLoad(options) {
this.initTime();
this.loadPlants();
},
onShow() {
if (typeof this.getTabBar === 'function' &&
this.getTabBar()) {
this.getTabBar().setData({
selected: 0
})
}
// Refresh list in case new plant was added
this.loadPlants();
},
loadPlants() {
this.setData({ plants: MOCK_PLANTS });
},
initTime() {
const updateTime = () => {
const now = new Date();
const hour = now.getHours();
let greet = '晚上好';
if (hour >= 5 && hour < 12) greet = '上午好';
else if (hour >= 12 && hour < 14) greet = '中午好';
else if (hour >= 14 && hour < 19) greet = '下午好';
const month = now.getMonth() + 1;
const day = now.getDate();
const weekDays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
const weekDay = weekDays[now.getDay()];
this.setData({
greeting: greet,
dateString: `${month}${day}${weekDay}`
});
};
updateTime();
},
navigateToDetail(e) {
const { id } = e.currentTarget.dataset;
wx.navigateTo({
url: `/pages/plant-detail/index?id=${id}`,
});
},
navigateToAdd() {
wx.navigateTo({
url: '/pages/garden/add/index'
});
},
onScrollLower() {
console.log('Scroll to lower - loading more plants...');
// In a real app, this would trigger pagination
}
})