feat: login rest
This commit is contained in:
+28
-16
@@ -172,36 +172,48 @@ Page({
|
||||
const taskId = this.data.completingTask.id;
|
||||
const remark = this.data.remark || '';
|
||||
|
||||
wx.showLoading({ title: '提交中...' });
|
||||
// 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(() => {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: '已完成', icon: 'success' });
|
||||
|
||||
// Optimistic UI Update
|
||||
// Optimistic UI Update Logic
|
||||
const groups = this.data.groupedTasks;
|
||||
let updated = false;
|
||||
// Need to deep clone possibly, but here we modify and set back
|
||||
for (let g of groups) {
|
||||
const t = g.tasks.find(x => x.id === taskId);
|
||||
if (t) {
|
||||
t.isCompleted = true;
|
||||
t.isOverdue = false;
|
||||
// Do NOT sort. Just update status.
|
||||
updated = true;
|
||||
break;
|
||||
// g is an object. groupedTasks is array of objects.
|
||||
if (g.tasks) {
|
||||
const t = g.tasks.find(x => x && x.id === taskId);
|
||||
if (t) {
|
||||
t.isCompleted = true;
|
||||
t.isOverdue = false;
|
||||
updated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
this.setData({ groupedTasks: groups, tasks: groups, completingTask: null, remark: '' });
|
||||
} else {
|
||||
this.setData({ completingTask: null, remark: '' });
|
||||
}
|
||||
// Trigger Animation and Close Modal
|
||||
this.setData({
|
||||
completingTask: null,
|
||||
remark: '',
|
||||
groupedTasks: groups, // Update UI
|
||||
tasks: groups,
|
||||
showSunshine: true
|
||||
});
|
||||
|
||||
// Sync with backend
|
||||
// Hide Animation after duration
|
||||
setTimeout(() => {
|
||||
this.setData({ showSunshine: false });
|
||||
}, 3000);
|
||||
|
||||
// Sync with backend silently
|
||||
this.fetchTodayTasks();
|
||||
|
||||
}).catch(err => {
|
||||
|
||||
@@ -114,6 +114,10 @@
|
||||
value="{{remark}}"
|
||||
bindinput="onRemarkInput"
|
||||
fixed="{{true}}"
|
||||
adjust-position="{{false}}"
|
||||
cursor-spacing="120"
|
||||
show-confirm-bar="{{false}}"
|
||||
disable-default-padding="{{true}}"
|
||||
/>
|
||||
</view>
|
||||
|
||||
@@ -126,4 +130,13 @@
|
||||
</view>
|
||||
</view>
|
||||
</t-popup>
|
||||
|
||||
<!-- Sunshine Animation Layer -->
|
||||
<view class="sunshine-layer" wx:if="{{showSunshine}}">
|
||||
<view class="sunshine-pkg">
|
||||
<view class="sun-halo"></view>
|
||||
<text class="sun-core-emoji">☀️</text>
|
||||
<text class="sun-add-text">+50 能量</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
+124
-28
@@ -253,67 +253,79 @@
|
||||
|
||||
.tasks-container {
|
||||
flex: 1;
|
||||
background: white;
|
||||
border-top-left-radius: 60rpx;
|
||||
border-top-right-radius: 60rpx;
|
||||
padding: 48rpx 40rpx 0;
|
||||
/* Removed background: white to avoid "too white" look */
|
||||
padding: 24rpx 32rpx 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 -8rpx 32rpx rgba(0,0,0,0.03);
|
||||
min-height: 0; /* Critical for flex scrolling */
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: 800;
|
||||
color: #263238;
|
||||
margin-bottom: 32rpx;
|
||||
padding-left: 8rpx;
|
||||
margin-bottom: 24rpx;
|
||||
padding-left: 12rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.task-list {
|
||||
flex: 1;
|
||||
height: 0; /* Force flex container to define height */
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.plant-task-card {
|
||||
background: linear-gradient(160deg, #FFFFFF 0%, #F5F9F6 100%);
|
||||
background: #FFFFFF;
|
||||
border-radius: 32rpx;
|
||||
padding: 32rpx;
|
||||
margin-bottom: 32rpx;
|
||||
box-shadow: 0 8rpx 24rpx rgba(0,0,0,0.04);
|
||||
border: 1rpx solid rgba(0,0,0,0.02);
|
||||
/* Enhanced shadow for depth */
|
||||
box-shadow: 0 12rpx 32rpx rgba(100, 110, 100, 0.08);
|
||||
border: none;
|
||||
transition: all 0.2s;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Decorator for card */
|
||||
/* Decorator for card - subtle green accent */
|
||||
.plant-task-card::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 8rpx;
|
||||
height: 100%;
|
||||
background: #66BB6A;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.plant-task-card::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
background: radial-gradient(circle at top right, #E8F5E9 0%, transparent 70%);
|
||||
opacity: 0.6;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.plant-task-card.has-overdue {
|
||||
border: 2rpx solid rgba(239, 83, 80, 0.2);
|
||||
background: linear-gradient(160deg, #FFEBEE 0%, #FFF 100%);
|
||||
background: #FFF;
|
||||
}
|
||||
.plant-task-card.has-overdue::after {
|
||||
background: #EF5350;
|
||||
}
|
||||
|
||||
.card-header-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 32rpx;
|
||||
padding-bottom: 24rpx;
|
||||
border-bottom: 2rpx dashed rgba(0, 0, 0, 0.05); /* Dashed line for ticket feel */
|
||||
margin-bottom: 28rpx;
|
||||
padding-bottom: 0;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.plant-info-brief {
|
||||
@@ -325,11 +337,10 @@
|
||||
.plant-thumb-small {
|
||||
width: 88rpx;
|
||||
height: 88rpx;
|
||||
border-radius: 24rpx;
|
||||
border-radius: 20rpx;
|
||||
overflow: hidden;
|
||||
background: #f0f0f0;
|
||||
box-shadow: 0 4rpx 10rpx rgba(0,0,0,0.05);
|
||||
border: 2rpx solid #FFF;
|
||||
}
|
||||
|
||||
.plant-thumb-small image {
|
||||
@@ -352,7 +363,7 @@
|
||||
.plant-name-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 800;
|
||||
color: #1B5E20; /* Dark Green theme */
|
||||
color: #1B5E20;
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
@@ -368,18 +379,20 @@
|
||||
.plant-tasks-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 28rpx;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
.mini-task-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background: rgba(255,255,255,0.6);
|
||||
padding: 16rpx;
|
||||
border-radius: 20rpx;
|
||||
/* Distinct background for task row */
|
||||
background: #F8F9FA;
|
||||
padding: 20rpx;
|
||||
border-radius: 24rpx;
|
||||
width: 100%;
|
||||
box-sizing: border-box; /* Important for padding */
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid #F1F3F4;
|
||||
}
|
||||
|
||||
.mini-task-left {
|
||||
@@ -768,3 +781,86 @@
|
||||
margin-top: 20rpx;
|
||||
box-shadow: 0 8rpx 16rpx rgba(85, 139, 47, 0.2);
|
||||
}
|
||||
|
||||
/* Sunshine Animation Layer */
|
||||
.sunshine-layer {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
z-index: 9999;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.sunshine-pkg {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
animation: flyAndCollect 3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
|
||||
}
|
||||
|
||||
.sun-halo {
|
||||
position: absolute;
|
||||
width: 300rpx;
|
||||
height: 300rpx;
|
||||
background: radial-gradient(circle, rgba(255, 235, 59, 0.6) 0%, rgba(255, 193, 7, 0) 70%);
|
||||
border-radius: 50%;
|
||||
z-index: 0;
|
||||
animation: sunPulse 1s ease-in-out infinite alternate;
|
||||
}
|
||||
|
||||
.sun-core-emoji {
|
||||
font-size: 140rpx;
|
||||
line-height: 1;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
text-shadow: 0 0 40rpx rgba(255, 160, 0, 0.5);
|
||||
}
|
||||
|
||||
.sun-add-text {
|
||||
position: absolute;
|
||||
top: 140rpx;
|
||||
font-size: 40rpx;
|
||||
font-weight: 900;
|
||||
color: #FF6F00;
|
||||
white-space: nowrap;
|
||||
text-shadow: 0 2rpx 4rpx rgba(255, 255, 255, 0.8), 0 0 10rpx rgba(255, 160, 0, 0.3);
|
||||
z-index: 3;
|
||||
animation: textFadeIn 0.5s ease-out forwards;
|
||||
}
|
||||
|
||||
@keyframes flyAndCollect {
|
||||
0% {
|
||||
transform: scale(0.2);
|
||||
opacity: 0;
|
||||
}
|
||||
15% {
|
||||
transform: scale(1.1);
|
||||
opacity: 1;
|
||||
}
|
||||
30% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
/* Fly to top left (approximate progress bar location) */
|
||||
transform: translate(-35vw, -45vh) scale(0.2);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes sunPulse {
|
||||
from { transform: scale(0.9); opacity: 0.5; }
|
||||
to { transform: scale(1.1); opacity: 0.8; }
|
||||
}
|
||||
|
||||
@keyframes textFadeIn {
|
||||
0% { transform: translateY(20rpx); opacity: 0; }
|
||||
100% { transform: translateY(0); opacity: 1; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user