<!-- pages/tixian/tixian.wxml -->
<!-- 最终版：资产卡片添加背景图，微调模糊 -->

<view class="app">
  <!-- 页面背景（全局模糊降低） -->
  <image class="global-bg" src="{{imgUrls.pageBg}}" mode="aspectFill" />
  
  <!-- 资产区域 -->
  <view class="assets-section">
    <view class="main-card" style="background-image: url('{{imgUrls.cardBg}}'); background-size: cover;">
      <!-- 总余额 -->
      <view class="balance-wrap">
        <text class="balance-label">可提总余额</text>
        <text class="balance-value">¥{{totalAmount}}</text>
      </view>

      <!-- 内部分隔线 -->
      <view class="inner-divider"></view>

      <!-- 左右滑动提示 -->
      <text class="assets-hint">← 左右滑动查看更多资产 →</text>

      <!-- 资产横向滚动区 -->
      <scroll-view class="assets-scroll" scroll-x="true" show-scrollbar="{{false}}" enhanced>
        <view class="assets-track">
          <block wx:for="{{assetList}}" wx:key="index">
            <!-- 每个资产卡片加上自己的背景图 -->
            <view class="asset-tile" bindtap="onSelectAsset" data-index="{{index}}" style="background-image: url('{{imgUrls.assetTileBg}}'); background-size: cover; background-position: center;">
              <text class="asset-name">{{item.label}}</text>
              <text class="asset-balance">¥{{item.amount}}</text>
              <text class="asset-fee">费率 {{item.rate}}%</text>
            </view>
          </block>
          <view wx:if="{{assetList.length === 0 && !isLoading}}" class="assets-empty">暂无可用资金</view>
        </view>
      </scroll-view>
    </view>

    <!-- 层次分隔线 -->
    <view class="divider-line"></view>
  </view>

  <!-- 提现记录区 -->
  <view class="history-section">
    <view class="history-header">
      <text class="history-title">提现记录</text>
      <text class="history-settings" bindtap="onSetSkfs">收款方式</text>
    </view>
    <scroll-view class="history-scroll" scroll-y enable-back-to-top bindscrolltolower="onLoadMoreFromScroll">
      <view wx:for="{{recordList}}" wx:key="index" class="history-item">
        <view class="history-info">
          <text class="history-amount">¥{{item.jine}}</text>
          <text class="history-time">{{item.create}}</text>
        </view>
        <view class="history-detail">
          <text class="history-method">{{item.fangshi == 1 ? '微信' : '支付宝'}}</text>
          <text class="history-type">{{item.leixing == 1 ? '佣金' : (item.leixing == 2 ? '分红' : (item.leixing == 3 ? '组长' : (item.leixing == 4 ? '考核官' : '保证金')))}}</text>
        </view>
        <view class="history-status">
          <view wx:if="{{item.zhuangtai == 1}}" class="status-badge status-wait" bindtap="onModifyRecord" data-record="{{item}}">{{item.statusText}} ✏修改</view>
          <view wx:elif="{{item.zhuangtai == 3}}" class="status-badge status-fail">
            {{item.statusText}}
            <text class="fail-link" bindtap="onViewFailReason" data-record="{{item}}">详情</text>
          </view>
          <view wx:else class="status-badge status-done">{{item.statusText}}</view>
        </view>
      </view>
      <view wx:if="{{loading}}" class="load-tip">加载中...</view>
      <view wx:if="{{nomore && recordList.length > 0}}" class="more-tip">—— 没有更多了 ——</view>
      <view wx:if="{{!nomore && recordList.length > 0}}" class="load-more-btn" bindtap="loadMoreRecords">加载更多记录</view>
    </scroll-view>
  </view>

  <view class="safe-bottom"></view>
</view>

<!-- ========== 弹窗（完整保留，无省略） ========== -->
<!-- 提现弹窗 -->
<view wx:if="{{showTixianModal}}" class="modal-mask" bindtap="onCloseTixianModal">
  <view class="modal-dialog" catchtap="stopPropagation">
    <view class="modal-header">提现</view>
    <view class="modal-body">
      <view class="info-row"><text>项目</text><text>{{selectedAsset.label}}</text></view>
      <view class="info-row"><text>可提</text><text>¥{{selectedAsset.amount}}</text></view>
      <view class="info-row"><text>费率</text><text>{{currentRate}}%</text></view>
      <view class="amount-row"><text>金额</text><input type="digit" placeholder="0.00" value="{{tixianAmount}}" bindinput="onAmountInput" /></view>
      <view class="quick-row"><view wx:for="{{[100,200,500,1000]}}" wx:key="item" class="quick-chip" data-value="{{item}}" bindtap="onQuickAmount">¥{{item}}</view></view>
      <view class="fee-row"><text>手续费 ¥{{shouxufei}}</text><text>到账 ¥{{shijidaozhang}}</text></view>
      <view class="method-row"><text>收款方式 {{txfangshi == 1 ? '微信' : (txfangshi == 2 ? '支付宝' : '未设置')}}</text><text class="link-text" bindtap="onSetSkfs">更换</text></view>
    </view>
    <view class="modal-footer"><view class="modal-btn cancel" bindtap="onCloseTixianModal">取消</view><view class="modal-btn confirm" bindtap="onConfirmWithdraw">确认</view></view>
  </view>
</view>

<!-- 设置收款方式弹窗 -->
<view wx:if="{{showSkfsModal}}" class="modal-mask" bindtap="onCloseSkfsModal">
  <view class="modal-dialog" catchtap="stopPropagation">
    <view class="modal-header">收款方式</view>
    <view class="modal-body">
      <view class="toggle-row"><view class="toggle-item {{tempTxfangshi == 1 ? 'active' : ''}}" bindtap="onSelectFangshi" data-fangshi="1">微信</view><view class="toggle-item {{tempTxfangshi == 2 ? 'active' : ''}}" bindtap="onSelectFangshi" data-fangshi="2">支付宝</view></view>
      <input class="field-input" placeholder="手机号" value="{{tempTxPhone}}" bindinput="onPhoneInput" />
      <view wx:if="{{tempTxfangshi == 2}}"><input class="field-input" placeholder="支付宝账号" value="{{tempTxAccount}}" bindinput="onAccountInput" /></view>
      <view class="upload-wrap"><view wx:if="{{!tempTxImage}}" class="upload-trigger" bindtap="onChooseImage">+ 上传收款码</view><view wx:else class="image-preview"><image src="{{tempTxImage}}" mode="aspectFill" /><view class="image-actions"><text bindtap="onPreviewImage">预览</text><text bindtap="onDeleteImage">删除</text></view></view></view>
    </view>
    <view class="modal-footer"><view class="modal-btn cancel" bindtap="onCloseSkfsModal">取消</view><view class="modal-btn confirm" bindtap="onConfirmSkfs">保存</view></view>
  </view>
</view>

<!-- 修改审核中记录弹窗 -->
<view wx:if="{{showModifyModal}}" class="modal-mask" bindtap="onCloseModifyModal">
  <view class="modal-dialog" catchtap="stopPropagation">
    <view class="modal-header">修改信息</view>
    <view class="modal-body">
      <view class="toggle-row"><view class="toggle-item {{modifyTxfangshi == 1 ? 'active' : ''}}" bindtap="onSelectModifyFangshi" data-fangshi="1">微信</view><view class="toggle-item {{modifyTxfangshi == 2 ? 'active' : ''}}" bindtap="onSelectModifyFangshi" data-fangshi="2">支付宝</view></view>
      <input class="field-input" placeholder="电话" value="{{modifyTxPhone}}" bindinput="onModifyPhoneInput" />
      <view wx:if="{{modifyTxfangshi == 2}}"><input class="field-input" placeholder="支付宝账号" value="{{modifyTxAccount}}" bindinput="onModifyAccountInput" /></view>
      <view class="upload-wrap"><view wx:if="{{modifyImageUrl}}" class="current-img"><image src="{{modifyImageUrl}}" mode="aspectFill" bindtap="onPreviewModifyImage" /></view><view class="upload-trigger" bindtap="onChooseModifyImage">+ 上传新图片</view><view wx:if="{{modifyTxImage}}" class="image-preview"><image src="{{modifyTxImage}}" mode="aspectFill" /><view class="image-actions"><text bindtap="onPreviewModifyImage">预览</text><text bindtap="onDeleteModifyImage">删除</text></view></view></view>
    </view>
    <view class="modal-footer"><view class="modal-btn cancel" bindtap="onCloseModifyModal">取消</view><view class="modal-btn confirm" bindtap="onConfirmModify">确认</view></view>
  </view>
</view>

<!-- 失败原因弹窗 -->
<view wx:if="{{showFailModal}}" class="modal-mask" bindtap="onCloseFailModal">
  <view class="modal-dialog" catchtap="stopPropagation">
    <view class="modal-header">失败原因</view>
    <view class="modal-body">{{currentFailReason}}</view>
    <view class="modal-footer"><view class="modal-btn confirm" bindtap="onCloseFailModal">知道了</view></view>
  </view>
</view>

<global-notification id="global-notification" />
<popup-notice id="popupNotice" />