<!-- pages/shangjiazhongxin/shangjiazhongxin.wxml -->
<!-- 最终优化版：指标卡片缩小，图标缩小，资产卡片缩小，背景模糊 -->

<!-- 页面背景纹理 -->
<image class="page-bg" src="{{imgUrls.pageBg}}" mode="aspectFill" />

<!-- 未注册状态 -->
<view class="page-container unregistered" wx:if="{{!isShangjia}}">
  <view class="unreg-card" style="background-image: url('{{imgUrls.assetCardBg}}'); background-size: cover; background-position: center;">
    <view class="unreg-content">
      <text class="status-title">商家入驻</text>
      <text class="status-desc">输入邀请码，解锁专属商家权益</text>
      <view class="input-group">
        <input class="invite-input" type="text" placeholder="请输入邀请码" maxlength="100" value="{{inviteCode}}" bindinput="onInviteCodeInput" placeholder-class="input-placeholder"/>
      </view>
      <button class="register-btn" bindtap="onRegister">立即注册</button>
      <view class="register-tip">已有邀请码？点击上方注册</view>
      <view class="sys-item sys-item-unreg" bindtap="clearCache">
        <image class="sys-icon" src="{{imgUrls.iconClear}}" mode="aspectFit" />
        <text class="sys-text">清除缓存</text>
        <text class="sys-sub">回点单端</text>
      </view>
    </view>
  </view>
</view>

<!-- 已注册商家主页面 -->
<view class="page-container registered" wx:else>
  <!-- 刷新按钮 -->
  <view class="refresh-btn" bindtap="refreshShangjiaInfo">
    <image class="refresh-icon" src="{{imgUrls.iconRefresh}}" mode="aspectFit" />
  </view>

  <!-- 头像卡片 -->
  <view class="avatar-card" style="background-image: url('{{imgUrls.avatarCardBg}}'); background-size: cover; background-position: center;">
    <view class="avatar-content">
      <view class="avatar-wrapper" bindtap="previewAvatar">
        <image class="avatar-img" src="{{avatarUrl}}" mode="aspectFill" />
        <image class="avatar-frame" src="{{imgUrls.avatarFrame}}" mode="aspectFit" />
      </view>
      <view class="user-info">
        <text class="nicheng">{{nicheng || '商家'}}</text>
        <view class="uid-area">
          <text class="uid-label">UID</text>
          <text class="uid-value">{{uid || '------'}}</text>
          <image class="copy-icon" src="{{imgUrls.iconCopy}}" mode="aspectFit" bindtap="copyUid" />
        </view>
      </view>
    </view>
  </view>

  <!-- 荣誉称号区域 -->
  <view class="badge-area" wx:if="{{chenghaoList.length > 0}}">
    <scroll-view class="badge-scroll" scroll-x="true" show-scrollbar="{{false}}">
      <view class="badge-row">
        <block wx:for="{{chenghaoList}}" wx:key="index">
          <chenghao-tag mingcheng="{{item.mingcheng}}" texiaoJson="{{item.texiao_json}}" />
        </block>
      </view>
    </scroll-view>
  </view>

  <!-- 资产卡片（稍微缩小） -->
  <view class="asset-card" style="background-image: url('{{imgUrls.assetCardBg}}'); background-size: cover; background-position: center;">
    <view class="card-content glass-effect">
      <view class="balance-area">
        <text class="balance-label">账户余额（元）</text>
        <view class="balance-value">
          <text class="value-num">{{sjyue}}</text>
          <text class="value-unit">¥</text>
        </view>
        <view class="action-buttons">
          <view class="action-btn recharge" bindtap="goToRecharge">
            <image class="btn-icon" src="{{imgUrls.iconRecharge}}" mode="aspectFit" />
            <text>充值</text>
          </view>
          <view class="action-btn withdraw" bindtap="goToWithdraw">
            <image class="btn-icon" src="{{imgUrls.iconWithdraw}}" mode="aspectFit" />
            <text>提现</text>
          </view>
        </view>
      </view>
      <view class="divider"></view>
      <view class="stats-row">
        <view class="stat-item">
          <text class="stat-label">发单总量</text>
          <text class="stat-number">{{fabu}}</text>
        </view>
        <view class="stat-item">
          <text class="stat-label">退款总量</text>
          <text class="stat-number">{{tuikuan}}</text>
        </view>
        <view class="stat-item">
          <text class="stat-label">今日流水</text>
          <text class="stat-number">{{jinriliushui}}</text>
        </view>
        <view class="stat-item">
          <text class="stat-label">今月流水</text>
          <text class="stat-number">{{jinyueliushui}}</text>
        </view>
      </view>
    </view>
  </view>

  <!-- 核心指标卡片组（缩小版） -->
  <view class="metrics-section">
    <view class="metric-card" style="background-image: url('{{imgUrls.statCardBg}}'); background-size: cover; background-position: center;">
      <view class="metric-content">
        <image class="metric-icon" src="{{imgUrls.iconRelease}}" mode="aspectFit" />
        <text class="metric-value">{{jinridingdan}}</text>
        <text class="metric-label">今日派单</text>
      </view>
    </view>
    <view class="metric-card" style="background-image: url('{{imgUrls.statCardBg}}'); background-size: cover; background-position: center;">
      <view class="metric-content">
        <image class="metric-icon" src="{{imgUrls.iconPunish}}" mode="aspectFit" />
        <text class="metric-value">{{jinrituikuan}}</text>
        <text class="metric-label">今日退款</text>
      </view>
    </view>
  </view>

  <!-- 功能宫格（图标缩小） -->
  <view class="function-grid">
    <view class="func-item primary" style="background-image: url('{{imgUrls.primaryFuncBg}}'); background-size: cover; background-position: center;">
      <view class="func-content" bindtap="goToPaiDan">
        <image class="func-icon" src="{{imgUrls.iconRelease}}" mode="aspectFit" />
        <text class="func-name">发布订单</text>
        <text class="func-desc">快速派单</text>
      </view>
    </view>
    <view class="func-item highlight" style="background-image: url('{{imgUrls.highlightFuncBg}}'); background-size: cover; background-position: center;">
      <view class="func-content" bindtap="goToJiSuPaiDan">
        <image class="func-icon" src="{{imgUrls.iconFast}}" mode="aspectFit" />
        <text class="func-name">极速派单</text>
        <text class="func-desc">闪电体验</text>
      </view>
    </view>
    <view class="func-item" style="background-image: url('{{imgUrls.funcItemBg}}'); background-size: cover; background-position: center;">
      <view class="func-content" bindtap="goToMyOrders">
        <image class="func-icon" src="{{imgUrls.iconOrders}}" mode="aspectFit" />
        <text class="func-name">我的订单</text>
        <text class="func-desc">管理派单</text>
      </view>
    </view>
    <view class="func-item" style="background-image: url('{{imgUrls.funcItemBg}}'); background-size: cover; background-position: center;">
      <view class="func-content" bindtap="goToMessages">
        <image class="func-icon" src="{{imgUrls.iconPunish}}" mode="aspectFit" />
        <text class="func-name">处罚记录</text>
        <text class="func-desc">违规查询</text>
      </view>
    </view>
    <view class="func-item" style="background-image: url('{{imgUrls.funcItemBg}}'); background-size: cover; background-position: center;">
      <view class="func-content" bindtap="goToRanking">
        <image class="func-icon" src="{{imgUrls.iconRank}}" mode="aspectFit" />
        <text class="func-name">商家排行</text>
        <text class="func-desc">业绩排名</text>
      </view>
    </view>
    <view class="func-item" style="background-image: url('{{imgUrls.funcItemBg}}'); background-size: cover; background-position: center;">
      <view class="func-content" bindtap="goToKefu">
        <image class="func-icon" src="{{imgUrls.iconService}}" mode="aspectFit" />
        <text class="func-name">在线客服</text>
        <text class="func-desc">帮助中心</text>
      </view>
    </view>
  </view>

  <view class="sys-list">
    <view class="sys-item" bindtap="clearCache">
      <image class="sys-icon" src="{{imgUrls.iconClear}}" mode="aspectFit" />
      <text class="sys-text">清除缓存</text>
      <text class="sys-sub">回点单端</text>
    </view>
  </view>

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

<!-- 加载遮罩 -->
<view class="loading-mask" wx:if="{{isLoading}}">
  <view class="loading-content">
    <view class="loading-spinner"></view>
    <text class="loading-text">加载中...</text>
  </view>
</view>

<!-- 全局组件 -->
<global-notification id="global-notification" />
<popup-notice id="popupNotice" />
<custom-tab-bar />