<template>
  <custom-popup
    v-model="showPopup"
    mode="center"
    border-radius="24"
    width="540rpx"
    :bg-color="'transparent'"
  >
    <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>

      <!-- 助力按钮 -->
      <button class="help-button" @click="handleHelp">点击助力</button>

      <!-- 关闭按钮 -->
      <view class="close-button" @click="close">
        <image src="/static/img/activity/close2.png" mode="widthFix"></image>
      </view>
    </view>
  </custom-popup>
</template>

<script>
import customPopup from "../../../components/custom-popup.vue";

export default {
  components: {
    customPopup,
  },
  data() {
    return {
      showPopup: false,
      avatarUrl: "", // 用户头像URL
      username: "孙***", // 用户名，带星号
      // 自定义按钮样式
      rulesButtonStyle: {
        backgroundColor: "#39c248",
        color: "#FFFFFF",
        fontSize: "28rpx",
        width: "280rpx",
        height: "80rpx",
        borderRadius: "40rpx",
      },
    };
  },
  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 {
  position: relative;
  padding: 40rpx;
  border-radius: 24rpx;
  text-align: center;
  background: url("https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/bg.png")
    no-repeat center center;
  background-size: 100% 100%;
}

.title-text view {
  font-size: 50rpx;
  font-weight: bold;
  color: #000;
}

.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: #39c248;
    }

    &::before {
      left: -90rpx;
    }

    &::after {
      right: -90rpx;
    }
  }
}

.user-info {
  .avatar-container {
    margin: 0 auto 20rpx;
    width: 140rpx;
    height: 140rpx;
    border-radius: 50%;
    overflow: hidden;
  }

  .username {
    font-size: 28rpx;
    color: #333;
    background: #39c248;
    padding: 6rpx 20rpx;
    border-radius: 30rpx;
    color: #fff;
    display: inline-block;
    position: relative;
    top: -50rpx;
  }
}

.help-button {
  height: 90rpx;
  background: linear-gradient(to bottom, #47d46c, #24ad3c);
  font-size: 32rpx;
  color: #ffffff;
  border-radius: 10rpx;
  line-height: 90rpx;
  width: 100%;
  margin-top: 20rpx;
  border: none;
}

.close-button {
  position: absolute;
  bottom: -120rpx;
  left: 50%;
  transform: translateX(-50%);

  image {
    width: 70rpx;
    height: 70rpx;
  }
}
</style>
