Files
PetCommunity/miniprogram/pages/search/search.wxml
2026-06-05 17:46:51 +08:00

75 lines
2.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<view class="page">
<view class="safe-top" style="height: {{statusBarHeight}}px"></view>
<view class="search-bar">
<view class="back" bindtap="onBack"></view>
<view class="input-wrap">
<text class="search-icon">🔍</text>
<input
class="search-input"
value="{{keyword}}"
bindinput="onInput"
bindconfirm="onSearch"
placeholder="搜索宠物、话题、用户..."
focus="{{true}}"
confirm-type="search"
/>
<view wx:if="{{keyword}}" class="clear" bindtap="onClear">×</view>
</view>
<view class="search-btn" bindtap="onSearch">搜索</view>
</view>
<!-- 热门话题 -->
<view wx:if="{{!keyword && !loading}}" class="hot-section">
<text class="section-title">热门话题</text>
<view class="hot-tags">
<view
wx:for="{{hotTopics}}"
wx:key="index"
class="hot-tag"
bindtap="onTopicTap"
data-tag="{{item.tag}}"
>
<text class="tag-rank">{{index + 1}}</text>
<text class="tag-text">{{item.tag}}</text>
<text class="tag-count">{{item.count}}篇</text>
</view>
</view>
</view>
<!-- 搜索结果 -->
<scroll-view wx:if="{{keyword}}" scroll-y="true" class="results-scroll" enhanced="true" show-scrollbar="false">
<view class="results-tabs">
<view class="rtab {{resultTab === 'posts' ? 'rtab-on' : ''}}" bindtap="onResultTab" data-t="posts">帖子</view>
<view class="rtab {{resultTab === 'users' ? 'rtab-on' : ''}}" bindtap="onResultTab" data-t="users">用户</view>
</view>
<view wx:if="{{resultTab === 'posts'}}">
<post-card wx:for="{{postResults}}" wx:key="_id" post="{{item}}" />
<view wx:if="{{!loading && postResults.length === 0}}" class="empty">
<text>没有找到相关帖子</text>
</view>
</view>
<view wx:if="{{resultTab === 'users'}}">
<view
wx:for="{{userResults}}"
wx:key="_id"
class="user-result"
bindtap="onUserTap"
data-uid="{{item._id}}"
>
<view class="u-avatar" style="background: {{item.gradient}}">{{item.nickName[0]}}</view>
<view class="u-info">
<text class="u-name">{{item.nickName}}</text>
<text class="u-bio">{{item.bio || '宠物爱好者'}}</text>
</view>
</view>
<view wx:if="{{!loading && userResults.length === 0}}" class="empty">
<text>没有找到相关用户</text>
</view>
</view>
<view style="height: 60rpx;"></view>
</scroll-view>
</view>