<template>
  <u-popup v-model="showPopup" mode="center" border-radius="24" width="540rpx">
    <view class="share-container">
      <!-- 标题 -->
      <view class="title-text">
        <view>好友邀您助力</view>
        <view>提升卖书收入</view>
      </view>
      
      <!-- 活动规则按钮 -->
      <view class="rules-button-container">
        <u-button class="rules-button" :custom-style="rulesButtonStyle" @click="viewRules">查看活动规则</u-button>
      </view>
      
      <!-- 用户信息区域 -->
      <view class="user-info">
        <view class="avatar-container">
          <u-avatar :src="avatarUrl" size="140"></u-avatar>
        </view>
        <view class="username">{{username}}</view>
      </view>
      
      <!-- 助力按钮 -->
      <u-button class="help-button" type="primary" :custom-style="helpButtonStyle" @click="handleHelp">点击助力</u-button>
    </view>
  </u-popup>
</template>

<script>
export default {
  data() {
    return {
      showPopup: false,
      avatarUrl: '', // 用户头像URL
      username: '孙***', // 用户名，带星号
      // 自定义按钮样式
      rulesButtonStyle: {
        backgroundColor: '#4CD964',
        color: '#FFFFFF',
        fontSize: '28rpx',
        width: '280rpx',
        height: '80rpx',
        borderRadius: '40rpx'
      },
      helpButtonStyle: {
        backgroundColor: '#4CD964',
        color: '#FFFFFF',
        fontSize: '32rpx',
        width: '100%',
        height: '100rpx',
        borderRadius: '50rpx',
        border: 'none'
      }
    };
  },
  methods: {
    open(avatarUrl = '', username = '孙***') {
      this.avatarUrl = avatarUrl;
      this.username = username;
      this.showPopup = true;
    },
    close() {
      this.showPopup = false;
    },
    viewRules() {
      // 打开活动规则弹窗
      this.$emit('view-rules');
      this.close();
    },
    handleHelp() {
      // 处理助力逻辑
      this.$emit('help');
      this.close();
    }
  }
};
</script>

<style lang="scss" scoped>
.share-container {
  background: linear-gradient(180deg, #e9ffe9 0%, #f7fff7 100%);
  padding: 40rpx 30rpx;
  border-radius: 24rpx;
  text-align: center;
}

.title-text {
  font-size: 40rpx;
  font-weight: bold;
  color: #000;
  line-height: 60rpx;
  margin-bottom: 20rpx;
}

.rules-button-container {
  display: flex;
  justify-content: center;
  margin: 20rpx 0 40rpx;
  
  .rules-button {
    position: relative;
    
    &::before, &::after {
      content: '';
      position: absolute;
      top: 50%;
      width: 80rpx;
      height: 2rpx;
      background-color: #4CD964;
    }
    
    &::before {
      left: -90rpx;
    }
    
    &::after {
      right: -90rpx;
    }
  }
}

.user-info {
  margin-bottom: 40rpx;
  
  .avatar-container {
    margin: 0 auto 20rpx;
    width: 140rpx;
    height: 140rpx;
    border-radius: 50%;
    overflow: hidden;
  }
  
  .username {
    font-size: 32rpx;
    color: #333;
    margin-top: 10rpx;
  }
}

.help-button {
  margin-top: 20rpx;
}
</style>
