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
+21 -9
View File
@@ -10,24 +10,18 @@ Page({
onLoad(options) {
const eventChannel = this.getOpenerEventChannel();
let loadedFromEvent = false;
if (eventChannel && eventChannel.on) {
eventChannel.on('acceptDataFromOpenerPage', (res) => {
if (res.data) {
this.setPlantData(res.data);
loadedFromEvent = true;
}
});
}
if (options.id) {
// Give event channel a chance to fire
setTimeout(() => {
if (!loadedFromEvent && !this.data.plant) {
this.loadPlantDetail(options.id);
}
}, 100);
// Always fetch latest data (especially favorites status)
this.loadPlantDetail(options.id);
}
},
@@ -99,7 +93,8 @@ Page({
pestsDiseases: item.pestsDiseases || '',
commonPests,
classes: (item.classes || []).map(c => c.name),
imgList: item.imgList || []
imgList: item.imgList || [],
isFavorited: (item.hasStar === 1 || item.hasStar === '1')
};
this.setData({
@@ -108,6 +103,23 @@ Page({
});
},
toggleFavorite() {
if (!this.data.plant) return;
const { id, isFavorited } = this.data.plant;
const type = isFavorited ? 2 : 1;
request.get('/wiki/star', { id, type }).then(() => {
this.setData({
'plant.isFavorited': !isFavorited
});
wx.showToast({ title: type === 1 ? '已收藏' : '已取消', icon: 'success' });
}).catch(err => {
console.error('Toggle favorite failed', err);
wx.showToast({ title: '操作失败', icon: 'none' });
});
},
onSwiperChange(e) {
this.setData({
activeImageIndex: e.detail.current
+16 -2
View File
@@ -13,14 +13,24 @@
<view class="wd-counter" wx:if="{{swiperList.length > 0}}">
<text>{{activeImageIndex + 1}} / {{swiperList.length}}</text>
</view>
<!-- Share Button -->
<button class="header-share-btn" open-type="share">
<t-icon name="share" size="40rpx" color="#FFF" />
</button>
</view>
<!-- Plant Name Card -->
<view class="wd-name-card">
<view class="wd-name-row">
<text class="wd-name">{{plant.name}}</text>
<text class="wd-name" style="padding-right: 60rpx;">{{plant.name}}</text>
<text class="wd-scientific" wx:if="{{plant.latinName}}">{{plant.latinName}}</text>
</view>
<!-- Collect Button -->
<view class="card-collect-btn" bindtap="toggleFavorite">
<t-icon name="{{plant.isFavorited ? 'heart-filled' : 'heart'}}" size="52rpx" color="{{plant.isFavorited ? '#EF4444' : '#D1D5DB'}}" />
</view>
<view class="wd-badges" wx:if="{{plant.genus || plant.classes.length > 0}}">
<text class="wd-badge" wx:if="{{plant.genus}}">{{plant.genus}}</text>
<text class="wd-badge" wx:for="{{plant.classes}}" wx:key="*this">{{item}}</text>
@@ -37,6 +47,8 @@
<text class="wd-text">{{plant.growthHabit}}</text>
</view>
</view>
<!-- Basic Info -->
<view class="wd-section">
@@ -183,8 +195,10 @@
</view>
</view>
<view style="height: 120rpx;"></view>
<view style="height: 40rpx;"></view>
</scroll-view>
</view>
<!-- Loading -->
+43
View File
@@ -243,3 +243,46 @@ page {
justify-content: center;
background: #F4F6F0;
}
/* Header Share Button */
.header-share-btn {
position: absolute;
top: 24rpx;
right: 24rpx;
width: 72rpx;
height: 72rpx;
background: rgba(0,0,0,0.35);
backdrop-filter: blur(4px);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
z-index: 20;
border: none;
padding: 0;
line-height: normal;
margin: 0;
}
.header-share-btn::after { border: none; }
.header-share-btn:active {
transform: scale(0.9);
background: rgba(0,0,0,0.5);
transition: transform 0.1s;
}
/* Card Collect Button */
.card-collect-btn {
position: absolute;
top: 32rpx;
right: 32rpx;
width: 80rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
z-index: 20;
}
.card-collect-btn:active {
transform: scale(0.9);
transition: transform 0.1s;
}