feat: 修复wiki样式问题
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
// pages/wiki/detail/index.js
|
||||
import { MOCK_WIKI } from '../../../utils/mockData';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
plant: null,
|
||||
activeImageIndex: 0,
|
||||
swiperList: []
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
if (options.id) {
|
||||
this.loadPlantDetail(options.id);
|
||||
}
|
||||
},
|
||||
|
||||
loadPlantDetail(id) {
|
||||
// Find plant in MOCK_WIKI
|
||||
const plant = MOCK_WIKI.find(p => p.id === id);
|
||||
if (plant) {
|
||||
// Set Page Title
|
||||
wx.setNavigationBarTitle({
|
||||
title: plant.name
|
||||
});
|
||||
|
||||
// Prepare swiper list
|
||||
const swiperList = (plant.images || []).map(img => {
|
||||
return (img.indexOf('http') === 0 || img.indexOf('wxfile') === 0) ? img : `/assets/${img}`;
|
||||
});
|
||||
|
||||
// Ensure some default values if missing
|
||||
const enrichedPlant = {
|
||||
...plant,
|
||||
light: plant.light || { level: '中等', description: '适合明亮的散射光' },
|
||||
water: plant.water || { frequency: '每周1-2次', description: '保持土壤微润' },
|
||||
temperature: plant.temperature || '15-28℃',
|
||||
humidity: plant.humidity || '50%-70%',
|
||||
soil: plant.soil || '疏松透气的营养土',
|
||||
fertilizer: plant.fertilizer || '生长季每月施一次薄肥',
|
||||
toxicity: plant.toxicity || '无毒',
|
||||
commonPests: plant.commonPests || ['红蜘蛛'],
|
||||
careTips: plant.careTips || ['注意通风', '定期清洁叶面']
|
||||
};
|
||||
|
||||
this.setData({
|
||||
plant: enrichedPlant,
|
||||
swiperList: swiperList
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onSwiperChange(e) {
|
||||
this.setData({
|
||||
activeImageIndex: e.detail.current
|
||||
});
|
||||
},
|
||||
|
||||
onShareAppMessage() {
|
||||
if (!this.data.plant) return {};
|
||||
return {
|
||||
title: `植物百科 - ${this.data.plant.name}`,
|
||||
path: `/pages/wiki/detail/index?id=${this.data.plant.id}`
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"navigationBarTitleText": "百科详情",
|
||||
"navigationBarBackgroundColor": "#FFFFFF",
|
||||
"navigationBarTextStyle": "black",
|
||||
"usingComponents": {
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-image": "tdesign-miniprogram/image/image",
|
||||
"t-swiper": "tdesign-miniprogram/swiper/swiper",
|
||||
"t-button": "tdesign-miniprogram/button/button"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
<!--pages/wiki/detail/index.wxml-->
|
||||
<view class="wiki-detail">
|
||||
<!-- Header Area -->
|
||||
<view class="wd-header">
|
||||
<view class="wd-gallery-container">
|
||||
<t-swiper
|
||||
t-class="custom-swiper"
|
||||
current="{{activeImageIndex}}"
|
||||
bind:change="onSwiperChange"
|
||||
height="500rpx"
|
||||
list="{{swiperList}}"
|
||||
navigation="{{ { type: '' } }}"
|
||||
/>
|
||||
<!-- Gradient applied externally to match plant-detail if needed or just rely on image -->
|
||||
<view class="wd-gradient-overlay"></view>
|
||||
</view>
|
||||
|
||||
<!-- Custom Indicators -->
|
||||
<view class="wd-indicators" wx:if="{{swiperList.length > 1}}">
|
||||
<view
|
||||
wx:for="{{swiperList}}"
|
||||
wx:key="index"
|
||||
class="wd-dot {{index === activeImageIndex ? 'active' : ''}}"
|
||||
></view>
|
||||
</view>
|
||||
|
||||
<!-- Header Overlay Info -->
|
||||
<view class="wd-overlay">
|
||||
<view class="wd-title">
|
||||
<text class="wd-name">{{plant.name}}</text>
|
||||
<text class="wd-scientific">{{plant.scientificName}}</text>
|
||||
</view>
|
||||
<view class="wd-badges">
|
||||
<text class="wd-badge">{{plant.family}}</text>
|
||||
<text class="wd-badge">{{plant.category}}</text>
|
||||
<text class="wd-badge">难度: {{plant.difficulty || 'Easy'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Content Area -->
|
||||
<view class="wd-content-wrapper">
|
||||
<scroll-view class="wd-content" scroll-y enhanced show-scrollbar="{{false}}">
|
||||
<!-- Description Section -->
|
||||
<section class="wd-section">
|
||||
<view class="wd-card">
|
||||
<text class="wd-text">{{plant.description}}</text>
|
||||
</view>
|
||||
</section>
|
||||
|
||||
<!-- Basic Info Section -->
|
||||
<section class="wd-section">
|
||||
<view class="section-title">
|
||||
<t-icon name="info-circle" size="40rpx" color="#558B2F" />
|
||||
<text>基础档案</text>
|
||||
</view>
|
||||
<view class="wd-card">
|
||||
<view class="wd-grid">
|
||||
<view class="wd-stat-item">
|
||||
<text class="wd-label">原产地</text>
|
||||
<text class="wd-value">{{plant.origin}}</text>
|
||||
</view>
|
||||
<view class="wd-stat-item">
|
||||
<text class="wd-label">毒性</text>
|
||||
<text class="wd-value">{{plant.toxicity}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</section>
|
||||
|
||||
<!-- Care Guide Section -->
|
||||
<section class="wd-section">
|
||||
<view class="section-title">
|
||||
<t-icon name="sprout" size="40rpx" color="#558B2F" />
|
||||
<text>养护指南</text>
|
||||
</view>
|
||||
<view class="wd-card">
|
||||
<!-- Light -->
|
||||
<view class="requirement-item">
|
||||
<view class="req-icon">
|
||||
<t-icon name="sunny" size="40rpx" color="#558B2F" />
|
||||
</view>
|
||||
<view class="req-content">
|
||||
<text class="req-title">光照 ({{plant.light.level}})</text>
|
||||
<text class="req-desc">{{plant.light.description}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Water -->
|
||||
<view class="requirement-item">
|
||||
<view class="req-icon">
|
||||
<t-icon name="water" size="40rpx" color="#558B2F" />
|
||||
</view>
|
||||
<view class="req-content">
|
||||
<text class="req-title">水分 ({{plant.water.frequency}})</text>
|
||||
<text class="req-desc">{{plant.water.description}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Environment -->
|
||||
<view class="requirement-item">
|
||||
<view class="req-icon">
|
||||
<t-icon name="temperate" size="40rpx" color="#558B2F" />
|
||||
</view>
|
||||
<view class="req-content">
|
||||
<text class="req-title">环境</text>
|
||||
<text class="req-desc">温度: {{plant.temperature}}</text>
|
||||
<text class="req-desc" style="display: block; margin-top: 4rpx;">湿度: {{plant.humidity}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Soil & Fertilizer -->
|
||||
<view class="requirement-item">
|
||||
<view class="req-icon">
|
||||
<t-icon name="layers" size="40rpx" color="#558B2F" />
|
||||
</view>
|
||||
<view class="req-content">
|
||||
<text class="req-title">土壤与肥料</text>
|
||||
<text class="req-desc">土: {{plant.soil}}</text>
|
||||
<text class="req-desc" style="display: block; margin-top: 4rpx;">肥: {{plant.fertilizer}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</section>
|
||||
|
||||
<!-- FAQ Section -->
|
||||
<section class="wd-section">
|
||||
<view class="section-title">
|
||||
<t-icon name="error-circle" size="40rpx" color="#558B2F" />
|
||||
<text>常见问题</text>
|
||||
</view>
|
||||
<view class="wd-card">
|
||||
<view class="pest-section">
|
||||
<text class="wd-label" style="display: block; margin-bottom: 16rpx;">易发病虫害</text>
|
||||
<view class="pest-tags">
|
||||
<text wx:for="{{plant.commonPests}}" wx:key="*this" class="pest-tag">{{item}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="tips-section">
|
||||
<text class="wd-label" style="display: block; margin-bottom: 16rpx; margin-top: 32rpx;">专家提示</text>
|
||||
<view class="care-tips-list">
|
||||
<view wx:for="{{plant.careTips}}" wx:key="*this" class="tip-item">
|
||||
<view class="tip-dot"></view>
|
||||
<text class="tip-text">{{item}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</section>
|
||||
|
||||
<!-- Bottom Spacer -->
|
||||
<view style="height: 100rpx;"></view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,315 @@
|
||||
/* pages/wiki/detail/index.wxss */
|
||||
.wiki-detail {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #F9FAFB;
|
||||
}
|
||||
|
||||
/* Page Layout */
|
||||
page {
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Hide Scrollbar Globally */
|
||||
::-webkit-scrollbar {
|
||||
display: none !important;
|
||||
width: 0 !important;
|
||||
height: 0 !important;
|
||||
color: transparent !important;
|
||||
}
|
||||
|
||||
scroll-view ::-webkit-scrollbar {
|
||||
display: none !important;
|
||||
width: 0 !important;
|
||||
height: 0 !important;
|
||||
color: transparent !important;
|
||||
}
|
||||
|
||||
/* Header Area */
|
||||
.wd-header {
|
||||
height: 500rpx;
|
||||
position: relative;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
/* Content Wrapper handles the flex growth and positioning overlap */
|
||||
.wd-content-wrapper {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
margin-top: -32rpx;
|
||||
z-index: 20;
|
||||
overflow: hidden; /* Ensure scroll-view is contained */
|
||||
}
|
||||
|
||||
/* Content Scroll View fills the wrapper */
|
||||
.wd-content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* Force override TDesign swiper radius */
|
||||
.custom-swiper {
|
||||
border-radius: 0 !important;
|
||||
overflow: hidden;
|
||||
--td-swiper-radius: 0px !important;
|
||||
}
|
||||
|
||||
.custom-swiper .t-swiper {
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
|
||||
t-swiper {
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
|
||||
.wd-gallery-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.wd-gradient-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 240rpx;
|
||||
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
|
||||
pointer-events: none;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.wd-indicators {
|
||||
position: absolute;
|
||||
bottom: 24rpx;
|
||||
right: 24rpx;
|
||||
display: flex;
|
||||
gap: 12rpx;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.wd-dot {
|
||||
width: 12rpx;
|
||||
height: 12rpx;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.4);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.wd-dot.active {
|
||||
background: white;
|
||||
width: 24rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.wd-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 32rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
pointer-events: none;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.wd-name {
|
||||
font-size: 56rpx;
|
||||
color: #FFFFFF;
|
||||
font-weight: 800;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.wd-scientific {
|
||||
font-size: 32rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
font-style: italic;
|
||||
font-family: serif;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.wd-badges {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.wd-badge {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
backdrop-filter: blur(4px);
|
||||
padding: 8rpx 20rpx;
|
||||
border-radius: 24rpx;
|
||||
font-size: 24rpx;
|
||||
color: #FFFFFF;
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.wd-section {
|
||||
margin-bottom: 32rpx;
|
||||
animation: fadeIn 0.5s ease-out;
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
|
||||
/* First section specific override: Adjust padding and background to create the seamless rounded look */
|
||||
.wd-section:first-child {
|
||||
padding: 0;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
.wd-section:first-child .wd-card {
|
||||
border-top-left-radius: 40rpx;
|
||||
border-top-right-radius: 40rpx;
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
padding: 48rpx 32rpx;
|
||||
box-shadow: none; /* Seamless blend */
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(20rpx); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 24rpx;
|
||||
padding-left: 8rpx;
|
||||
}
|
||||
|
||||
.section-title text {
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.wd-text {
|
||||
font-size: 30rpx;
|
||||
line-height: 1.6;
|
||||
color: #4B5563;
|
||||
}
|
||||
|
||||
.wd-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 32rpx;
|
||||
}
|
||||
|
||||
.wd-stat-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.wd-label {
|
||||
font-size: 24rpx;
|
||||
color: #9CA3AF;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
.wd-value {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #1F2937;
|
||||
}
|
||||
|
||||
.wd-card {
|
||||
background: white;
|
||||
border-radius: 24rpx;
|
||||
padding: 24rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.02);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
/* Requirement Items (Compact) */
|
||||
.requirement-item {
|
||||
display: flex;
|
||||
gap: 24rpx;
|
||||
margin-bottom: 24rpx;
|
||||
padding-bottom: 24rpx;
|
||||
border-bottom: 2rpx solid #F3F4F6;
|
||||
}
|
||||
|
||||
.requirement-item:last-child {
|
||||
margin-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.req-icon {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
background: #F1F8E9;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.req-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.req-title {
|
||||
display: block;
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
color: #1F2937;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.req-desc {
|
||||
font-size: 26rpx;
|
||||
color: #6B7280;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* FAQ / Pests */
|
||||
.pest-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.pest-tag {
|
||||
background: #FEF2F2;
|
||||
color: #DC2626;
|
||||
padding: 12rpx 24rpx;
|
||||
border-radius: 16rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.care-tips-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.tip-item {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.tip-dot {
|
||||
width: 12rpx;
|
||||
height: 12rpx;
|
||||
border-radius: 50%;
|
||||
background: #558B2F;
|
||||
margin-top: 14rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tip-text {
|
||||
font-size: 28rpx;
|
||||
color: #4B5563;
|
||||
line-height: 1.5;
|
||||
}
|
||||
+82
-7
@@ -3,15 +3,28 @@ import { MOCK_WIKI } from '../../utils/mockData';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
wikiList: [],
|
||||
// Data Source (effectively the backend result)
|
||||
filteredSourceList: [],
|
||||
|
||||
// Display Data (rendered list)
|
||||
displayedList: [],
|
||||
|
||||
// Filter State
|
||||
searchQuery: '',
|
||||
activeCategory: '全部',
|
||||
|
||||
// Pagination State
|
||||
page: 1,
|
||||
pageSize: 5,
|
||||
isLoading: false,
|
||||
hasMore: true,
|
||||
|
||||
// Modal State
|
||||
showIdentifyModal: false
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.setData({ wikiList: MOCK_WIKI });
|
||||
// Initial Load
|
||||
this.filterList();
|
||||
},
|
||||
|
||||
@@ -22,23 +35,29 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
// Search Input Handler
|
||||
onSearchInput(e) {
|
||||
// TDesign search event: e.detail.value
|
||||
this.setData({ searchQuery: e.detail.value }, () => {
|
||||
this.filterList();
|
||||
});
|
||||
},
|
||||
|
||||
// Category Filter Handler
|
||||
setCategory(e) {
|
||||
this.setData({ activeCategory: e.currentTarget.dataset.cat }, () => {
|
||||
this.filterList();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Simulates "Backend" Search & Filtering
|
||||
* Resets pagination and prepares the filtered data source.
|
||||
*/
|
||||
filterList() {
|
||||
const { wikiList, searchQuery, activeCategory } = this.data;
|
||||
let result = wikiList;
|
||||
const { searchQuery, activeCategory } = this.data;
|
||||
let result = MOCK_WIKI;
|
||||
|
||||
// Filter by Search Query
|
||||
if (searchQuery) {
|
||||
const q = searchQuery.toLowerCase();
|
||||
result = result.filter(item =>
|
||||
@@ -47,17 +66,73 @@ Page({
|
||||
);
|
||||
}
|
||||
|
||||
// Filter by Category
|
||||
if (activeCategory !== '全部') {
|
||||
result = result.filter(item => item.category.includes(activeCategory));
|
||||
}
|
||||
|
||||
this.setData({ displayedList: result });
|
||||
this.setData({
|
||||
filteredSourceList: result,
|
||||
displayedList: [],
|
||||
page: 1,
|
||||
hasMore: true
|
||||
}, () => {
|
||||
this.loadMoreData();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Simulates "Backend" Pagination
|
||||
* Appends the next page of data from filteredSourceList to displayedList.
|
||||
* key-value data path update is used for performance optimization.
|
||||
*/
|
||||
loadMoreData() {
|
||||
const { isLoading, hasMore, page, pageSize, filteredSourceList, displayedList } = this.data;
|
||||
|
||||
if (isLoading || !hasMore) return;
|
||||
|
||||
this.setData({ isLoading: true });
|
||||
|
||||
// Simulate Network Delay
|
||||
setTimeout(() => {
|
||||
const startIndex = (page - 1) * pageSize;
|
||||
const endIndex = startIndex + pageSize;
|
||||
const newItems = filteredSourceList.slice(startIndex, endIndex);
|
||||
|
||||
const isLastPage = endIndex >= filteredSourceList.length;
|
||||
|
||||
if (newItems.length > 0) {
|
||||
// Performance Optimization: Use data path to append items
|
||||
// Instead of setData({ displayedList: [...old, ...new] })
|
||||
const updateData = {};
|
||||
const currentLen = displayedList.length;
|
||||
newItems.forEach((item, index) => {
|
||||
updateData[`displayedList[${currentLen + index}]`] = item;
|
||||
});
|
||||
|
||||
updateData['page'] = page + 1;
|
||||
updateData['hasMore'] = !isLastPage;
|
||||
updateData['isLoading'] = false;
|
||||
|
||||
this.setData(updateData);
|
||||
} else {
|
||||
this.setData({
|
||||
hasMore: false,
|
||||
isLoading: false
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
},
|
||||
|
||||
// Infinite Scroll Handler
|
||||
onReachBottom() {
|
||||
this.loadMoreData();
|
||||
},
|
||||
|
||||
goToDetail(e) {
|
||||
const item = e.currentTarget.dataset.item;
|
||||
wx.navigateTo({
|
||||
url: `/pages/plant-detail/index?id=${item.id}&mode=wiki`
|
||||
url: `/pages/wiki/detail/index?id=${item.id}`
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
"t-popup": "tdesign-miniprogram/popup/popup",
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon"
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-loading": "tdesign-miniprogram/loading/loading",
|
||||
"t-button": "tdesign-miniprogram/button/button"
|
||||
}
|
||||
}
|
||||
+33
-4
@@ -1,7 +1,13 @@
|
||||
<!--pages/wiki/index.wxml-->
|
||||
<view class="wiki-page">
|
||||
|
||||
<view class="wiki-scroll-area">
|
||||
<scroll-view
|
||||
class="wiki-scroll-area"
|
||||
scroll-y
|
||||
bindscrolltolower="onReachBottom"
|
||||
enhanced
|
||||
show-scrollbar="{{false}}"
|
||||
>
|
||||
<view class="search-section">
|
||||
<t-search placeholder="搜索植物名称,如:龟背竹" value="{{searchQuery}}" bind:change="onSearchInput" shape="round" />
|
||||
</view>
|
||||
@@ -25,22 +31,45 @@
|
||||
<view class="wiki-list">
|
||||
<view wx:for="{{displayedList}}" wx:key="id" class="wiki-card" bindtap="goToDetail" data-item="{{item}}">
|
||||
<view class="wiki-image">
|
||||
<t-image src="/assets/{{item.images[0]}}" mode="aspectFill" width="100%" height="100%" />
|
||||
<t-image src="/assets/{{item.images[0]}}" mode="aspectFill" width="100%" height="100%" lazy />
|
||||
</view>
|
||||
<view class="wiki-info">
|
||||
<view class="wiki-top">
|
||||
<text class="wiki-name">{{item.name}}</text>
|
||||
<text class="scientific-name">{{item.scientificName}}</text>
|
||||
</view>
|
||||
<t-tag size="small" variant="light" theme="success">{{item.category}}</t-tag>
|
||||
|
||||
<!-- Tags Row -->
|
||||
<view class="tags-row">
|
||||
<t-tag
|
||||
wx:for="{{item.tags}}"
|
||||
wx:key="*this"
|
||||
wx:for-item="tag"
|
||||
size="small"
|
||||
variant="light"
|
||||
theme="primary"
|
||||
style="margin-right: 8rpx; margin-bottom: 8rpx;"
|
||||
>
|
||||
{{tag}}
|
||||
</t-tag>
|
||||
</view>
|
||||
</view>
|
||||
<t-icon name="chevron-right" size="48rpx" color="#ccc" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Loading / No More Data Footer -->
|
||||
<view class="loading-footer">
|
||||
<t-loading wx:if="{{isLoading}}" theme="circular" size="40rpx" text="加载中..." inherit-color />
|
||||
<text wx:elif="{{!hasMore && displayedList.length > 0}}" class="no-more-text">没有更多了</text>
|
||||
<view wx:elif="{{!hasMore && displayedList.length === 0}}" class="empty-state">
|
||||
<text>没有找到相关植物</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Spacer -->
|
||||
<view style="height: 160rpx;"></view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<t-fab icon="scan" text="植物识别" bind:click="openIdentifyModal" aria-label="植物识别"></t-fab>
|
||||
|
||||
|
||||
+42
-7
@@ -10,26 +10,31 @@
|
||||
|
||||
.wiki-scroll-area {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 20rpx 40rpx;
|
||||
overflow-y: hidden; /* Scroll-view handles overflow */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Scroll-view inner content padding wrapper if needed,
|
||||
but we can apply padding to children or use a wrapper view inside.
|
||||
Usually easier to apply padding to the items or a wrapper inside scroll-view. */
|
||||
|
||||
.search-section {
|
||||
padding: 20rpx 40rpx 0;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.category-scroll {
|
||||
display: flex;
|
||||
flex-wrap: wrap; /* TDesign Tags might wrap nicely */
|
||||
flex-wrap: wrap;
|
||||
padding: 0 40rpx;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
/* Old chips removed, replaced by t-tag */
|
||||
|
||||
.wiki-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 32rpx;
|
||||
padding: 0 40rpx;
|
||||
}
|
||||
|
||||
.wiki-card {
|
||||
@@ -40,6 +45,11 @@
|
||||
align-items: center;
|
||||
gap: 36rpx;
|
||||
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.03);
|
||||
transition: transform 0.1s;
|
||||
}
|
||||
|
||||
.wiki-card:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.wiki-image {
|
||||
@@ -52,12 +62,37 @@
|
||||
}
|
||||
.wiki-image t-image { width: 100%; height: 100%; display: block; }
|
||||
|
||||
.wiki-info { flex: 1; }
|
||||
.wiki-info { flex: 1; min-width: 0; }
|
||||
|
||||
.wiki-top { margin-bottom: 8rpx; }
|
||||
.wiki-top { margin-bottom: 12rpx; }
|
||||
.wiki-name { font-size: 34rpx; font-weight: 700; color: var(--text-main); display: block; margin-bottom: 4rpx; }
|
||||
.scientific-name { font-size: 24rpx; color: #90A4AE; font-style: italic; font-family: serif; display: block; }
|
||||
|
||||
.tags-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
/* Loading Footer */
|
||||
.loading-footer {
|
||||
padding: 40rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.no-more-text {
|
||||
font-size: 24rpx;
|
||||
color: #CCC;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 80rpx 0;
|
||||
text-align: center;
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
/* Popup Styles */
|
||||
.popup-content {
|
||||
|
||||
Reference in New Issue
Block a user