<view class="page">
  <!-- 顶部导航栏 -->
  <view class="unified-header">
    <view class="unified-header-left" bindtap="onBack">
      <image src="/images/icon-back.png" class="unified-back-icon" mode="aspectFit"></image>
      <text class="unified-back-text">返回</text>
    </view>
    <text class="unified-header-title">公告</text>
    <view class="unified-header-right"></view>
  </view>

  <scroll-view scroll-y class="content" style="padding-top: 194rpx" enhanced show-scrollbar="{{false}}">
    <!-- 加载中 -->
    <view class="loading-tip" wx:if="{{loading}}">
      <text>加载中...</text>
    </view>

    <!-- 错误提示 -->
    <view class="error-tip" wx:if="{{error}}">
      <text>{{error}}</text>
      <text class="retry-btn" bindtap="loadNotices">点击重试</text>
    </view>

    <!-- 公告列表 -->
    <view class="notices-list" wx:if="{{!loading && notices.length > 0 && !error}}">
      <view class="notice-item" wx:for="{{notices}}" wx:key="id" bindtap="onNoticeTap" data-notice="{{item}}">
        <view class="notice-content">
          <rich-text nodes="{{item.content}}"></rich-text>
        </view>
        <view class="notice-footer" wx:if="{{item.linkType !== 'none'}}">
          <text class="link-hint">点击查看详情 ></text>
        </view>
        <view class="notice-date">{{item.createdAt}}</view>
      </view>
    </view>

    <!-- 空状态 -->
    <view class="empty-tip" wx:if="{{!loading && notices.length === 0 && !error}}">
      <image src="/images/icon-empty.png" mode="aspectFit"></image>
      <text>暂无公告</text>
    </view>
  </scroll-view>
</view>
