<view class="container">
  <scroll-view scroll-y class="scroll" bindscrolltolower="onReachBottom">
    <view wx:if="{{ jiazhaozhong && chufaList.length === 0 }}" class="tip">加载中...</view>
    <block wx:for="{{ chufaList }}" wx:key="id">
      <view class="card" bindtap="chakanXiangqing" data-item="{{ item }}">
        <view class="card-head">
          <text class="time">{{ item.display_time }}</text>
          <text class="tag {{ item.status_class }}">{{ item.display_status }}</text>
        </view>
        <text class="info">申请人：{{ item.qingqiuid || '--' }}</text>
        <text class="info">理由：{{ item.cfliyou || '无' }}</text>
        <text class="info" wx:if="{{ item.dingdan_id }}">订单：{{ item.dingdan_id }}</text>
      </view>
    </block>

    <!-- ========== 底部：按钮 / 加载中 / 没有更多 ========== -->
    <view wx:if="{{ haiyougengduo && !jiazhaigengduo }}" class="load-more-btn" bindtap="onReachBottom">
      <text>点击获取更多</text>
    </view>
    <view wx:if="{{ jiazhaigengduo }}" class="tip">加载中...</view>
    <view wx:if="{{ !haiyougengduo && chufaList.length > 0 }}" class="tip">—— 没有更多了 ——</view>
    <view wx:if="{{ !jiazhaozhong && chufaList.length === 0 }}" class="empty">暂无积分处罚记录</view>
  </scroll-view>

  <!-- 详情弹窗（不动） -->
  <view wx:if="{{ showXiangqing }}" class="modal-mask">
    <view class="modal-panel">
      <view class="modal-head">
        <text class="modal-title">处罚详情</text>
        <view class="modal-close" bindtap="guanbiXiangqing">✕</view>
      </view>
      <scroll-view scroll-y class="modal-body">
        <view class="row"><text class="lbl">订单编号</text><text class="val">{{ xuanzhongChufa.dingdan_id || '--' }}</text></view>
        <view class="row"><text class="lbl">申请人ID</text><text class="val">{{ xuanzhongChufa.qingqiuid || '--' }}</text></view>
        <view class="row"><text class="lbl">时间</text><text class="val">{{ xuanzhongChufa.display_time }}</text></view>
        <view class="row"><text class="lbl">状态</text><text class="val"><text class="tag {{ xuanzhongChufa.status_class }}">{{ xuanzhongChufa.display_status }}</text></text></view>
        <view class="row"><text class="lbl">处罚理由</text><text class="val">{{ xuanzhongChufa.cfliyou || '无' }}</text></view>

        <view wx:if="{{ xuanzhongChufa.full_zhengju_tupian.length }}" class="section">
          <text class="sec-title">证据图片</text>
          <view class="img-grid">
            <block wx:for="{{ xuanzhongChufa.full_zhengju_tupian }}" wx:key="index">
              <view class="img-box" bindtap="yulanTupian" data-url="{{ item }}" data-urls="{{ xuanzhongChufa.full_zhengju_tupian }}">
                <image class="img" src="{{ item }}" mode="aspectFill" />
              </view>
            </block>
          </view>
        </view>

        <view wx:if="{{ xuanzhongChufa.ssliyou || xuanzhongChufa.full_shensu_tupian.length }}" class="section">
          <text class="sec-title">我的申诉</text>
          <view wx:if="{{ xuanzhongChufa.ssliyou }}" class="row"><text class="lbl">理由</text><text class="val">{{ xuanzhongChufa.ssliyou }}</text></view>
          <view wx:if="{{ xuanzhongChufa.full_shensu_tupian.length }}" class="img-grid">
            <block wx:for="{{ xuanzhongChufa.full_shensu_tupian }}" wx:key="index">
              <view class="img-box" bindtap="yulanTupian" data-url="{{ item }}" data-urls="{{ xuanzhongChufa.full_shensu_tupian }}">
                <image class="img" src="{{ item }}" mode="aspectFill" />
              </view>
            </block>
          </view>
        </view>
      </scroll-view>
      <view class="modal-foot">
        <view wx:if="{{ xuanzhongChufa.sqzhuangtai === 0 }}" class="btn primary" bindtap="openShensuModal">申诉</view>
        <view class="btn default" bindtap="guanbiXiangqing">关闭</view>
      </view>
    </view>
  </view>

  <!-- 申诉弹窗（不动） -->
  <view wx:if="{{ showShensuModal }}" class="modal-mask">
    <view class="modal-panel">
      <view class="modal-head">
        <text class="modal-title">提交申诉</text>
        <view class="modal-close" bindtap="closeShensuModal">✕</view>
      </view>
      <scroll-view scroll-y class="modal-body">
        <view class="form-group">
          <text class="sec-title">申诉理由</text>
          <textarea class="textarea" placeholder="请输入申诉理由（最多500字）" value="{{ shensuLiyou }}" bindinput="onShensuLiyouInput" maxlength="500" />
          <text class="word-count">{{ shensuLiyou.length }}/500</text>
        </view>
        <view class="form-group">
          <text class="sec-title">上传凭证（最多9张）</text>
          <view class="img-grid">
            <block wx:for="{{ shensuTupian }}" wx:key="index">
              <view class="img-box">
                <image class="img" src="{{ item }}" mode="aspectFill" bindtap="yulanShensuTupian" data-index="{{ index }}" />
                <view class="img-del" catchtap="deleteShensuTupian" data-index="{{ index }}">✕</view>
              </view>
            </block>
            <view wx:if="{{ shensuTupian.length < 9 }}" class="img-add" bindtap="chooseShensuTupian">+</view>
          </view>
          <view wx:if="{{ shangchuanZongshu > 0 }}" class="progress-box">
            <view class="progress-bar"><view class="progress-inner" style="width: {{ jinduWidth }}"></view></view>
            <text class="progress-text">{{ shangchuanJindu }}/{{ shangchuanZongshu }}</text>
          </view>
        </view>
      </scroll-view>
      <view class="modal-foot">
        <view class="btn default" bindtap="closeShensuModal">取消</view>
        <view class="btn primary" bindtap="submitShensu">提交申诉</view>
      </view>
    </view>
  </view>
</view>