<template>
  <view class="invite-container">
    <!-- 顶部背景 -->
    <view class="top-bg"></view>

    <!-- 自定义导航栏 -->
    <view class="nav-bar">
      <view class="back-icon" @click="goBack">
        <u-icon name="arrow-left" color="#fff" size="20"></u-icon>
      </view>
      <text class="nav-title">邀约赚钱</text>
      <view class="nav-right"></view>
    </view>

    <!-- 主体内容 -->
    <view class="content">
      <!-- 邀请卡片 -->
      <view class="invite-card-wrap">
        <!-- 整个图片作为背景 -->
        <image class="card-bg-img" src="@/static/image/points/bg_card_invite.png" mode="widthFix"></image>
        
        <!-- 覆盖在图片上的内容 -->
        <view class="card-content">
          <!-- 顶部标题文字 -->
          <view class="card-top-title">
            每邀请1位好友，赚<text class="highlight-num">12</text>元
          </view>
          
          <view class="stats-row">
            <view class="stat-item">
              <view class="stat-val"><text class="num">2</text>人</view>
              <view class="stat-label">已邀请</view>
            </view>
            <view class="stat-item">
              <view class="stat-val"><text class="num">24</text>元</view>
              <view class="stat-label">已赚金额</view>
            </view>
          </view>
          
          <view class="btn-wrap">
            <button class="invite-btn" @click="showSharePopup = true">立即邀请</button>
          </view>
        </view>
      </view>

      <!-- 详细规则区域 -->
      <view class="rules-section">
        <view class="rules-title-wrap">
          <image class="title-icon" src="@/static/image/points/title_left.png" mode="aspectFit"></image>
          <text class="rules-title">详细规则</text>
          <image class="title-icon" src="@/static/image/points/title_right.png" mode="aspectFit"></image>
        </view>

        <view class="rewards-row">
          <view class="reward-box">
            <view class="reward-val">+12<text class="unit">元</text></view>
            <view class="reward-desc">每邀请一个好友</view>
          </view>
          <view class="reward-box">
            <view class="reward-val">+3<text class="unit">元</text></view>
            <view class="reward-desc">好友完成新人任务</view>
          </view>
        </view>

        <view class="rules-list">
          <text class="rule-text">这里展示详细规则例如：</text>
          <text class="rule-text">1、成功邀请好友成为徒弟，即可获得对应奖励。</text>
          <text class="rule-text">2、徒弟完成任务，师傅可额外获得收益分成。</text>
          <text class="rule-text">3、邀请次数与奖励上限以页面显示为准。</text>
          <text class="rule-text">4、奖励自动发放至账户，可随时查看明细。</text>
          <text class="rule-text">5、邀请次数与奖励上限以页面显示为准。</text>
          <text class="rule-text">6、奖励自动发放至账户，可随时查看明细。</text>
        </view>
      </view>
    </view>

    <!-- 分享弹窗 -->
    <u-popup :show="showSharePopup" @close="showSharePopup = false" mode="bottom" :round="20" bgColor="transparent">
      <view class="share-popup-wrap">
        <!-- 海报卡片区域 -->
        <view class="poster-card">
          <!-- 自定义背景图 -->
          <image class="poster-bg-img" src="@/static/image/points/img_invite_popup.png" mode="widthFix"></image>
          
          <!-- 覆盖在背景图上的内容 -->
          <view class="poster-content">
            <view class="poster-close" @click="showSharePopup = false">
              <u-icon name="close" color="#fff" size="20"></u-icon>
            </view>
            
            <!-- 这里可以根据实际背景图情况决定是否还需要保留文字标题 -->
            <!-- 如果背景图自带了"邀请好友 一起赚钱"的文字，可以隐藏或删除这部分 -->
            <!-- <view class="poster-title-wrap">
              <view class="poster-title">邀请好友</view>
              <view class="poster-subtitle">一起赚钱</view>
            </view> -->
            
            <view class="qr-code-box">
              <!-- 占位二维码，实际开发中可以替换为真实的二维码图片 -->
              <image class="qr-img" src="https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=https://example.com" mode="aspectFit"></image>
              <view class="qr-tips">扫描二维码，加入我们</view>
            </view>
          </view>
        </view>

        <!-- 底部操作栏 -->
        <view class="share-actions">
          <view class="action-item">
            <view class="action-icon-wrap wechat-icon">
              <u-icon name="weixin-fill" color="#fff" size="30"></u-icon>
            </view>
            <text class="action-text">分享微信</text>
          </view>
          <view class="action-item">
            <view class="action-icon-wrap moments-icon">
              <u-icon name="moments" color="#fff" size="30"></u-icon>
            </view>
            <text class="action-text">分享朋友圈</text>
          </view>
          <view class="action-item">
            <view class="action-icon-wrap save-icon">
              <u-icon name="photo" color="#fff" size="30"></u-icon>
            </view>
            <text class="action-text">保存图片</text>
          </view>
        </view>
      </view>
    </u-popup>

  </view>
</template>

<script>
export default {
  data() {
    return {
      showSharePopup: false
    };
  },
  methods: {
    goBack() {
      uni.navigateBack();
    }
  }
};
</script>

<style lang="scss" scoped>
.invite-container {
  min-height: 100vh;
  background-color: #FFF2EB; /* 底部背景色 */
  position: relative;
  padding-bottom: 60rpx;
}

.top-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 600rpx;
  background: linear-gradient(180deg, #FF7663 0%, #FFF2EB 100%);
  z-index: 0;
}

.nav-bar {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 80rpx 30rpx 20rpx; /* 适配状态栏 */
}

.back-icon, .nav-right {
  width: 60rpx;
  display: flex;
  align-items: center;
}

.nav-title {
  font-size: 36rpx;
  color: #fff;
  font-weight: bold;
  flex: 1;
  text-align: center;
}

.content {
  position: relative;
  z-index: 1;
  padding: 20rpx 30rpx;
}

.invite-card-wrap {
  margin-top: 20rpx;
  position: relative;
  display: flex;
  justify-content: center;
}

.card-bg-img {
  width: 100%;
  display: block;
}

.card-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* 将内容推到底部 */
  padding-bottom: 50rpx; /* 调整底部间距以匹配图片位置 */
  z-index: 2;
}

.card-top-title {
  position: absolute;
  top: 40rpx; /* 根据图片实际红色区域高度调整 */
  left: 0;
  width: 100%;
  text-align: center;
  color: #fff;
  font-size: 36rpx;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: baseline;
  text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2);
}

.highlight-num {
  font-size: 64rpx;
  color: #f8ff67; /* 偏黄色的高亮 */
  margin: 0 6rpx;
  text-shadow: 0 4rpx 0 #FF9C70, 0 6rpx 8rpx rgba(0, 0, 0, 0.2); /* 模拟图片中带有立体感和描边的数字 */
  font-style: italic; /* 图片中数字略带倾斜感 */
}

.stats-row {
  display: flex;
  justify-content: space-around;
  margin-bottom: 40rpx;
  padding: 0 40rpx;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-val {
  color: #333;
  font-size: 28rpx;
  margin-bottom: 10rpx;
  display: flex;
  align-items: baseline;
}

.stat-val .num {
  font-size: 56rpx;
  font-weight: bold;
  color: #EB5F28; /* 修改为匹配图片的暗橘色 */
  margin-right: 4rpx;
}

.stat-label {
  font-size: 26rpx;
  color: #666;
}

.btn-wrap {
  padding: 0 80rpx;
  margin-bottom: 20rpx; /* 距离底部边框的距离 */
 
}

.invite-btn {
  background: transparent; /* 背景透明，因为按钮已经在图片上了 */
  color: #fff;
  font-size: 34rpx;
  font-weight: bold;
  height: 96rpx;
  line-height: 96rpx;
  border-radius: 48rpx;
   box-shadow: 0 10rpx 20rpx rgba(255, 90, 31, 0.3);
  background: linear-gradient( 90deg, #FF4E27 0%, #FF6363 40%, #FF9131 100%);
  border: 4rpx solid #FE9F8D;
}

.invite-btn::after {
  border: none;
}

.rules-section {
  margin-top: 60rpx;
  padding: 0 20rpx;
}

.rules-title-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 40rpx;
}

.title-icon {
  width: 40rpx;
  height: 20rpx;
}

.rules-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
  margin: 0 20rpx;
}

.rewards-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 40rpx;
}

.reward-box {
  width: 48%;
  background: linear-gradient( 0deg, #FFE4E4 0%, #FFFFFF 100%);
  border-radius: 26rpx 26rpx 26rpx 26rpx;
  border: 2rpx solid #FFD0D0;
  padding: 30rpx 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.reward-val {
  color: #FF5A1F;
  font-size: 40rpx;
  font-weight: bold;
  margin-bottom: 10rpx;
}

.reward-val .unit {
  font-size: 24rpx;
  font-weight: normal;
}

.reward-desc {
  font-size: 24rpx;
  color: #666;
}

.rules-list {
  padding: 0 10rpx;
  display: flex;
  flex-direction: column;
}

.rule-text {
  font-size: 26rpx;
  color: #666;
  line-height: 1.8;
  margin-bottom: 10rpx;
}

/* 分享弹窗样式 */
.share-popup-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.poster-card {
  width: 600rpx;
  position: relative;
  display: flex;
  justify-content: center;
  margin-bottom: 40rpx;
  /* box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.2); 移除阴影或保留，视背景图效果而定 */
}

.poster-bg-img {
  width: 100%;
  display: block;
}

.poster-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* 将二维码推到底部区域 */
  align-items: center;
  padding-bottom: 60rpx; /* 根据实际图片底部留白调整 */
  box-sizing: border-box;
}

.poster-close {
  position: absolute;
  top: 30rpx;
  right: 30rpx;
  width: 50rpx;
  height: 50rpx;
  border: 2rpx solid #fff;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

.qr-code-box {
  background-color: #fff;
  border-radius: 20rpx;
  padding: 40rpx 30rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 480rpx; /* 控制二维码卡片的宽度，使其适应背景图 */
  box-sizing: border-box;
  box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.05); /* 为白色二维码卡片添加一点阴影 */
}

.qr-img {
  width: 320rpx;
  height: 320rpx;
  margin-bottom: 20rpx;
}

.qr-tips {
  font-size: 28rpx;
  color: #666;
}

.share-actions {
  width: 100%;
  background-color: #E8F0FF;
  border-radius: 40rpx 40rpx 0 0;
  display: flex;
  justify-content: space-around;
  padding: 60rpx 0 80rpx;
}

.action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.action-icon-wrap {
  width: 100rpx;
  height: 100rpx;
  border-radius: 50rpx;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20rpx;
}

.wechat-icon {
  background: linear-gradient(180deg, #15D65D 0%, #32E175 100%);
}

.moments-icon {
  background: linear-gradient(180deg, #FF9638 0%, #FFBA5A 100%);
}

.save-icon {
   background: linear-gradient(180deg, #3E8DFA 0%, #69ADF9 100%);
}

.action-text {
  font-size: 26rpx;
  color: #666;
}
</style>
