与牧同行-小程序用户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

175 lines
5.8 KiB

<!-- pages/search/index.wxml -->
<view class="container_zsl">
<!-- 搜索区域 -->
<view class="search-area">
<view class="search-box">
<view class="search-input-wrapper">
<image src="/pagesB/images/sou.png" class="search-icon" />
<input
class="search-input"
placeholder="请输入关键词搜索,如:猪瘟、饲养、疫苗..."
placeholder-class="placeholder"
value="{{searchValue}}"
bindinput="onInputSearch"
bindconfirm="onSearch"
/>
<icon
class="clear-icon"
type="clear"
size="16"
wx:if="{{searchValue}}"
bindtap="onClearSearch"
/>
</view>
</view>
<!-- 分类筛选 -->
<view class="category-filter">
<view
class="category-item {{activeCategory === item.value ? 'active' : ''}}"
wx:for="{{categories}}"
wx:key="value"
data-category="{{item.value}}"
bindtap="onFilterCategory"
>
{{item.name}}
<view class="category-dot" wx:if="{{activeCategory === item.value}}"></view>
</view>
</view>
</view>
<!-- 加载状态 -->
<view wx:if="{{isLoading}}" class="loading">
<view class="spinner">
<view class="spinner-item"></view>
<view class="spinner-item"></view>
<view class="spinner-item"></view>
</view>
<text class="loading-text">正在搜索...</text>
</view>
<!-- 搜索结果 -->
<scroll-view
wx:else
class="result-list"
scroll-y
enable-back-to-top
bindscrolltolower="onScrollToLower"
>
<!-- 搜索结果列表 -->
<view wx:if="{{searchResults.length > 0}}">
<view class="result-count">
<text>找到 {{total}} 条相关结果</text>
<text wx:if="{{currentCategory !== '全部'}}">(在{{currentCategory}}中搜索)</text>
<text wx:if="{{currentSearchKey && currentCategory !== '全部'}}">关键词:"{{currentSearchKey}}"</text>
</view>
<view class="knowledge-list">
<view
class="knowledge-item"
wx:for="{{searchResults}}"
wx:key="id"
data-value="{{item}}"
bindtap="onViewDetail"
>
<view class="item-header">
<view class="title-wrapper">
<view class="item-title">{{item.title}}</view>
<view class="item-category">{{item.categoryType}}</view>
</view>
</view>
<view class="item-content">{{item.content}}</view>
<view class="item-footer">
<view class="tags">
<view class="tag">
{{item.keywords}}
</view>
</view>
<view class="actions">
<view class="date-info">
<text class="date">{{item.publishTime}}</text>
</view>
<view
class="copy-btn"
data-content="{{item.content}}"
bindtap="onCopyContent"
>
<text>复制</text>
</view>
</view>
</view>
</view>
</view>
<!-- 加载更多提示 -->
<view wx:if="{{hasMore}}" class="load-more">
<view wx:if="{{!loadingMore}}" class="load-more-text">上拉加载更多</view>
<view wx:else class="load-more-loading">
<view class="loading-dots">
<view class="dot"></view>
<view class="dot"></view>
<view class="dot"></view>
</view>
<text>加载中...</text>
</view>
</view>
<!-- 没有更多数据提示 -->
<view wx:if="{{!hasMore && searchResults.length > 0}}" class="no-more">
<text>没有更多数据了</text>
</view>
</view>
<!-- 无结果 -->
<view class="empty-state" wx:if="{{!isLoading && searchResults.length==0}}">
<text class="empty-text" wx:if="{{currentSearchKey}}">未找到"{{currentSearchKey}}"的相关信息</text>
<text class="empty-text" wx:if="{{!currentSearchKey && currentCategory !== '全部'}}">当前分类"{{currentCategory}}"暂无数据</text>
<text class="empty-text" wx:if="{{!currentSearchKey && currentCategory === '全部'}}">暂无数据</text>
<view class="suggestions" wx:if="{{currentSearchKey}}">
<view class="suggestion-item">
<view class="suggestion-dot"></view>
<text>检查关键词拼写</text>
</view>
<view class="suggestion-item">
<view class="suggestion-dot"></view>
<text>尝试其他相关词汇</text>
</view>
<view class="suggestion-item">
<view class="suggestion-dot"></view>
<text>咨询专业兽医</text>
</view>
</view>
<view class="suggestions" wx:if="{{!currentSearchKey && currentCategory !== '全部'}}">
<view class="suggestion-item">
<view class="suggestion-dot"></view>
<text>尝试切换到"全部"分类</text>
</view>
<view class="suggestion-item">
<view class="suggestion-dot"></view>
<text>在搜索框中输入关键词进行搜索</text>
</view>
</view>
</view>
</scroll-view>
</view>
<!-- 使用提示弹框 -->
<view wx:if="{{showTipsModal}}" class="modal-mask" bindtap="hideTips">
<view class="modal-content" catchtap="stopPropagation">
<view class="modal-header">
<image src="/pagesB/images/syts.png" class="modal-icon" />
<text class="modal-title">使用提示</text>
</view>
<view class="modal-body">
<view class="tip-item" wx:for="{{tip}}">
<text class="tip-text">{{item}}</text>
</view>
</view>
<view class="modal-footer">
<button class="modal-confirm" bindtap="hideTips">我知道了</button>
</view>
</view>
</view>