100 lines
3.0 KiB
Plaintext
100 lines
3.0 KiB
Plaintext
<!--pages/forum/forum.wxml-->
|
|
<view class="container">
|
|
<!-- 分类标签 -->
|
|
<scroll-view class="category-scroll" scroll-x>
|
|
<view class="category-list">
|
|
<view
|
|
class="category-item {{selectedCategory === item ? 'active' : ''}}"
|
|
wx:for="{{categories}}"
|
|
wx:key="index"
|
|
data-category="{{item}}"
|
|
bindtap="onCategoryChange"
|
|
>
|
|
{{item}}
|
|
</view>
|
|
</view>
|
|
</scroll-view>
|
|
|
|
<!-- 帖子列表 -->
|
|
<view class="post-list">
|
|
<view
|
|
class="post-card"
|
|
wx:for="{{posts}}"
|
|
wx:key="id"
|
|
bindtap="onPostDetail"
|
|
data-id="{{item.id}}"
|
|
>
|
|
<!-- 帖子头部 -->
|
|
<view class="post-header">
|
|
<image class="avatar" src="{{item.avatar || '/images/avatar-default.png'}}" mode="aspectFill"></image>
|
|
<view class="author-info">
|
|
<view class="author-name">{{item.author}}</view>
|
|
<view class="post-time">{{item.time}}</view>
|
|
</view>
|
|
<view class="category-tag">{{item.category}}</view>
|
|
</view>
|
|
|
|
<!-- 帖子内容 -->
|
|
<view class="post-content">
|
|
<view class="post-title">{{item.title}}</view>
|
|
<view class="post-text">{{item.content}}</view>
|
|
|
|
<!-- 图片 -->
|
|
<view class="post-images" wx:if="{{item.images && item.images.length > 0}}">
|
|
<image
|
|
class="post-image"
|
|
wx:for="{{item.images}}"
|
|
wx:key="index"
|
|
wx:for-item="img"
|
|
src="{{img}}"
|
|
mode="aspectFill"
|
|
catchtap="onPreviewImage"
|
|
data-url="{{img}}"
|
|
data-urls="{{item.images}}"
|
|
></image>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 帖子底部 -->
|
|
<view class="post-footer">
|
|
<view class="footer-left">
|
|
<view class="stat-item">
|
|
<text class="stat-icon">👀</text>
|
|
<text class="stat-text">{{item.views}}</text>
|
|
</view>
|
|
<view
|
|
class="stat-item like-item {{item.isLiked ? 'liked' : ''}}"
|
|
catchtap="onLike"
|
|
data-id="{{item.id}}"
|
|
>
|
|
<text class="stat-icon">{{item.isLiked ? '❤️' : '🤍'}}</text>
|
|
<text class="stat-text">{{item.likes}}</text>
|
|
</view>
|
|
<view class="stat-item">
|
|
<text class="stat-icon">💬</text>
|
|
<text class="stat-text">{{item.comments}}</text>
|
|
</view>
|
|
</view>
|
|
<view
|
|
class="favorite-btn {{item.isFavorite ? 'favorited' : ''}}"
|
|
catchtap="onFavorite"
|
|
data-id="{{item.id}}"
|
|
>
|
|
<text class="favorite-icon">{{item.isFavorite ? '⭐' : '☆'}}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 空状态 -->
|
|
<view class="empty-state" wx:if="{{posts.length === 0}}">
|
|
<text class="empty-icon">📝</text>
|
|
<text class="empty-text">暂无帖子,快来发布第一条吧</text>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 发布按钮 -->
|
|
<view class="fab" bindtap="onNewPost">
|
|
<text class="fab-icon">✏️</text>
|
|
</view>
|
|
</view>
|