feat: 整体页面优化,删除无用svg
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// pages/plant-detail/edit/index.js
|
||||
import request from '../../../utils/request';
|
||||
import { CARE_TASK_ICONS } from '../../../utils/mockData';
|
||||
import { CARE_TASK_ICONS } from '../../../utils/constant';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
@@ -296,7 +296,8 @@ Page({
|
||||
id: String(task.id),
|
||||
name: task.name,
|
||||
period: parseInt(task.period) || 1,
|
||||
icon: JSON.stringify(task.taskIcon || {})
|
||||
icon: JSON.stringify(task.taskIcon || {}),
|
||||
targetAction: (task.taskIcon && task.taskIcon.targetAction) ? task.taskIcon.targetAction : ''
|
||||
}));
|
||||
|
||||
// Build payload for /plant/update (UpdateMyPlant struct)
|
||||
@@ -317,7 +318,8 @@ Page({
|
||||
plantId: plantId,
|
||||
name: task.name,
|
||||
period: parseInt(task.period) || 1,
|
||||
icon: JSON.stringify(task.taskIcon || {})
|
||||
icon: JSON.stringify(task.taskIcon || {}),
|
||||
targetAction: (task.taskIcon && task.taskIcon.targetAction) ? task.taskIcon.targetAction : ''
|
||||
}))
|
||||
} : null;
|
||||
|
||||
@@ -358,17 +360,5 @@ Page({
|
||||
});
|
||||
},
|
||||
|
||||
handleDeletePlant() {
|
||||
wx.showModal({
|
||||
title: '确认删除',
|
||||
content: '确定要删除这个植物吗?删除后无法恢复。',
|
||||
confirmColor: '#EF5350',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
wx.showToast({ title: '已删除', icon: 'success' });
|
||||
setTimeout(() => { wx.switchTab({ url: '/pages/garden/index' }); }, 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
@@ -157,12 +157,7 @@
|
||||
</view>
|
||||
|
||||
<!-- Delete Button for Edit Page -->
|
||||
<view class="delete-section" style="margin-top: 16rpx; padding-bottom: 40rpx;">
|
||||
<view class="delete-page-btn" bindtap="handleDeletePlant">
|
||||
<t-icon name="delete" size="32rpx" />
|
||||
<text>删除植物档案</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view style="height: 180rpx;"></view>
|
||||
</scroll-view>
|
||||
|
||||
@@ -244,4 +244,31 @@ Page({
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
handleDeletePlant() {
|
||||
if (!this.data.currentPlant || !this.data.currentPlant.id) return;
|
||||
|
||||
wx.showModal({
|
||||
title: '确认删除',
|
||||
content: '确定要删除这个植物吗?删除后无法恢复。',
|
||||
confirmColor: '#EF5350',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
wx.showLoading({ title: '删除中...' });
|
||||
// Attempting to use consistent API pattern: POST /plant/deletePlant with ids array
|
||||
request.post('/plant/deletePlant', { ids: [this.data.currentPlant.id] }).then(() => {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: '已删除', icon: 'success' });
|
||||
setTimeout(() => {
|
||||
wx.switchTab({ url: '/pages/garden/index' });
|
||||
}, 1000);
|
||||
}).catch(err => {
|
||||
wx.hideLoading();
|
||||
console.error('Delete plant failed', err);
|
||||
wx.showToast({ title: '删除失败', icon: 'none' });
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
})
|
||||
|
||||
@@ -92,6 +92,11 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="delete-plant-box" bindtap="handleDeletePlant">
|
||||
<t-icon name="delete" size="32rpx" color="#EF5350" />
|
||||
<text class="delete-text">删除植物</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
|
||||
@@ -811,3 +811,21 @@ page {
|
||||
font-weight: 500;
|
||||
color: #90A4AE;
|
||||
}
|
||||
|
||||
.delete-plant-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12rpx;
|
||||
padding: 24rpx;
|
||||
margin-top: 40rpx;
|
||||
background: #FFF;
|
||||
border-radius: 24rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(239, 83, 80, 0.1);
|
||||
}
|
||||
|
||||
.delete-text {
|
||||
font-size: 28rpx;
|
||||
color: #EF5350;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user