<view class="invite-container">
  <view class="invite-header">
    <text class="title">邀请好友</text>
    <text class="subtitle">好友注册并完善资料，你将获得50爱心值</text>
  </view>

  <!-- 爱心值显示卡片 -->
  <view class="love-card">
    <view class="love-info">
      <text class="love-label">当前爱心值</text>
      <text class="love-value">{{lovePoints}}</text>
    </view>
    <view class="divider"></view>
    <view class="love-info">
      <text class="love-label">今日已获得</text>
      <text class="love-value">{{shareCount * 20}}</text>
    </view>
  </view>

  <!-- 邀请码区域 -->
  <view class="invite-code-section">
    <view class="code-display">
      <text class="label">我的{{isDistributor ? '专属' : ''}}邀请码</text>
      <text class="code">{{isDistributor && referralCode ? referralCode : invitationCode}}</text>
    </view>
    <button class="copy-btn" bindtap="copyInviteCode">复制邀请码</button>
  </view>

  <!-- 统计数据 -->
  <view class="stats-section">
    <view class="stat-item">
      <text class="value">{{stats.total_invites}}</text>
      <text class="label">邀请人数</text>
    </view>
    <view class="stat-item">
      <text class="value">{{stats.completed_invites}}</text>
      <text class="label">完成注册</text>
    </view>
  </view>

  <!-- 活动说明 -->
  <view class="tips-card">
    <view class="tips-title">
      <text>活动说明</text>
    </view>
    <view class="tips-list">
      <view class="tip-item">
        <text class="tip-dot">•</text>
        <text class="tip-text">每次分享获得20爱心值</text>
      </view>
      <view class="tip-item">
        <text class="tip-dot">•</text>
        <text class="tip-text">每天最多分享3次，共60爱心值</text>
      </view>
      <view class="tip-item">
        <text class="tip-dot">•</text>
        <text class="tip-text">爱心值可用于兑换会员和礼品</text>
      </view>
      <view class="tip-item">
        <text class="tip-dot">•</text>
        <text class="tip-text">每日0点重置分享次数</text>
      </view>
      <view wx:if="{{isDistributor}}" class="tip-item highlight">
        <text class="tip-dot">💰</text>
        <text class="tip-text">分销商推荐好友消费可获得佣金奖励</text>
      </view>
    </view>
  </view>

  <!-- 推广工具区域 -->
  <view class="promotion-section">
    <view class="section-title">推广工具</view>
    
    <!-- 海报生成器 -->
    <view class="poster-generator">
      <swiper class="poster-swiper" previous-margin="40rpx" next-margin="40rpx" bindchange="onPosterChange">
        <swiper-item wx:for="{{posterTemplates}}" wx:key="id" class="poster-item">
          <view class="poster-wrap {{currentPosterIndex === index ? 'active' : ''}}">
            <image src="{{item.imageUrl}}" class="poster-img" mode="aspectFill"></image>
            <view class="poster-overlay" wx:if="{{currentPosterIndex === index}}">
              <view class="poster-check">
                <icon type="success" size="24" color="#07c160"/>
              </view>
            </view>
          </view>
        </swiper-item>
      </swiper>
      <button class="generate-btn" bindtap="generatePoster" loading="{{generatingPoster}}">生成并保存海报</button>
    </view>

    <!-- 一键推广 -->
    <view class="share-action">
      <button class="action-btn promote-btn" open-type="share">
        <image src="/images/icon-share.png" class="btn-icon"></image>
        <text>我要推广 (转发给好友)</text>
      </button>
    </view>
  </view>

  <!-- 隐藏的画布，用于绘制海报 -->
  <canvas type="2d" id="posterCanvas" class="poster-canvas" style="width: 300px; height: 533px; position: fixed; left: -9999px;"></canvas>

  <!-- 查看明细按钮 -->
  <view class="action-section">
    <button class="action-btn outline-btn" bindtap="viewTransactions">查看爱心值明细</button>
  </view>
</view>
