feat: 整体页面优化,删除无用svg

This commit is contained in:
Blizzard
2026-02-14 08:32:47 +08:00
parent daea00ca60
commit cbbe82ef63
59 changed files with 1265 additions and 342 deletions
+101 -13
View File
@@ -7,11 +7,20 @@ Page({
groupedTasks: [],
progress: 0,
completingTask: null,
remark: ''
remark: '',
remarkPlaceholder: '',
scrollTop: 0,
// Reward Modals
showLevelUpModal: false,
levelUpData: null,
showBadgeModal: false,
badgeData: null
},
onLoad() {
this.fetchTodayTasks();
this._popupQueue = [];
},
onShow() {
@@ -23,6 +32,42 @@ Page({
this.fetchTodayTasks();
},
// ... (fetchTodayTasks, processTaskData Omitted) ...
// Reward Queue Processing
processPopupQueue() {
if (this._popupQueue.length === 0) return;
const next = this._popupQueue[0];
if (next.type === 'level') {
this.setData({
levelUpData: next.data,
showLevelUpModal: true
});
} else if (next.type === 'badge') {
this.setData({
badgeData: next.data,
showBadgeModal: true
});
}
},
closeLevelUpModal() {
this.setData({ showLevelUpModal: false });
this._popupQueue.shift();
setTimeout(() => {
this.processPopupQueue();
}, 300);
},
closeBadgeModal() {
this.setData({ showBadgeModal: false });
this._popupQueue.shift();
setTimeout(() => {
this.processPopupQueue();
}, 300);
},
fetchTodayTasks() {
request.get('/plant/todayTask').then(res => {
// Check if res is array (list of PlantTaskVO)
@@ -45,12 +90,7 @@ Page({
// Parse Image
let imageUrl = '';
if (plant.imgList && plant.imgList.length > 0) {
let url = plant.imgList[0].url;
if (url && !url.startsWith('http') && !url.startsWith('/') && !url.startsWith('wxfile')) {
imageUrl = '/assets/' + url;
} else {
imageUrl = url;
}
imageUrl = plant.imgList[0].url || '';
}
const plantGroup = {
@@ -149,9 +189,36 @@ Page({
handleTaskClick(e) {
const task = e.currentTarget.dataset.task;
if (task.isCompleted) return;
// Compute placeholder based on task type or name
let placeholder = '添加备注 (可选)...';
// Get name from taskIcon first, then name.
// name from backend is usually the name (e.g. "浇水").
const typeRaw = (task.taskIcon ? task.taskIcon.name : task.name) || '';
const typeStr = typeRaw.toLowerCase();
if (typeStr.includes('浇水')) {
placeholder = '例如:浇了 200ml 水...';
} else if (typeStr.includes('施肥')) {
placeholder = '例如:施了通用液肥...';
} else if (typeStr.includes('修剪')) {
placeholder = '例如:修剪了枯叶和黄叶...';
} else if (typeStr.includes('换盆')) {
placeholder = '例如:更换了陶盆,加了底肥...';
} else if (typeStr.includes('换土')) {
placeholder = '例如:更换了新配方土...';
} else if (typeStr.includes('喷雾')) {
placeholder = '例如:给叶面喷了水...';
} else if (typeStr.includes('用药') || typeStr.includes('虫')) {
placeholder = '例如:喷洒了杀虫剂...';
} else if (typeStr.includes('晒太阳') || typeStr.includes('日照')) {
placeholder = '例如:晒了 2 小时太阳...';
}
this.setData({
completingTask: task,
remark: ''
remark: '',
remarkPlaceholder: placeholder
});
},
@@ -172,16 +239,29 @@ Page({
const taskId = this.data.completingTask.id;
const remark = this.data.remark || '';
// Optimistic Update immediately for better feel?
// Or wait for server? Wait is safer.
wx.showLoading({ title: '提交中...', mask: true });
request.post('/plant/completeTask', {
taskId: taskId,
remark: remark
}).then(() => {
}).then(res => {
wx.hideLoading();
// Handle Rewards
const queue = [];
// Check if res has level up or badge data
// Note: res is already data.data from request.js
if (res && res.isLevelUp && res.currentLevel) {
queue.push({ type: 'level', data: res.currentLevel });
}
// Check for Badge using IsGetBadge flag (allowing for casing variance)
if (res && (res.IsGetBadge === true || res.isGetBadge === true) && res.newBadge) {
queue.push({ type: 'badge', data: res.newBadge });
}
this._popupQueue = queue;
// Optimistic UI Update Logic
const groups = this.data.groupedTasks;
let updated = false;
@@ -208,10 +288,14 @@ Page({
showSunshine: true
});
// Hide Animation after duration
// Hide Animation after duration and Start showing modals
setTimeout(() => {
this.setData({ showSunshine: false });
}, 3000);
// Show rewards after sunshine animation
if (this._popupQueue.length > 0) {
this.processPopupQueue();
}
}, 1000); // 1.0s delay usually covers animation
// Sync with backend silently
this.fetchTodayTasks();
@@ -227,5 +311,9 @@ Page({
wx.switchTab({
url: '/pages/garden/index'
});
},
onTabItemTap() {
this.setData({ scrollTop: Math.random() * 0.01 });
}
})