<template>
  <view class="red_packet_list">
    <view v-for="(packet, index) in redpackets" :key="packet.id" class="red_packet_item" :class="{ disabled: index == 0 }" @click="handleClick(packet)">
      <img src="../../static/icon/packet_list_backerground.png" alt="" class="redpacket_background" />
      <view class="packet_header">
        <view class="packet_image">福</view>
        <view class="packet_info">
          <h3 class="packet_title">{{ packet.title }}</h3>
          <p class="packet_date">{{ packet.date }}</p>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from "vue";

const redpackets = ref([
  { id: 1, title: "新年红包", date: "2023-01-01", amount: 88.88, image: "path/to/image1.jpg" },
  { id: 2, title: "生日红包", date: "2023-02-14", amount: 66.66, image: "path/to/image2.jpg" },
  { id: 3, title: "节日红包", date: "2023-03-08", amount: 99.99, image: "path/to/image3.jpg" },
]);

const handleClick = (packet) => {
  uni.navigateTo({
    url: "/pages/redpacket/index",
  });
};
</script>

<style lang="less" scoped>
.red_packet_list {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
  padding: 40rpx;
}

.red_packet_item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #c30a0a;
  border-radius: 20rpx;
  padding: 20rpx;
  box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
  cursor: pointer;
  position: relative;
  height: 140rpx;
  overflow: hidden;
  &.disabled {
    cursor: not-allowed;
    opacity: 0.3;
  }
  .redpacket_background {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 120px;
    z-index: 1;
  }

  .packet_header {
    display: flex;
    align-items: center;
    z-index: 10;
    .packet_image {
      width: 100rpx;
      height: 100rpx;
      border-radius: 50%;
      margin-right: 20rpx;
      background-color: #fede9f;
      color: #af3636;
      font-size: 48rpx;
      font-weight: bold;
      text-align: center;
      line-height: 100rpx;
    }

    .packet_info {
      display: flex;
      flex-direction: column;

      .packet_title {
        font-size: 32rpx;
        font-weight: bold;
        margin: 0;
        color: #fff;
      }

      .packet_date {
        font-size: 24rpx;
        color: #fff;
        margin: 0;
        margin-top: 10rpx;
      }
    }
  }

  .packet_amount {
    font-size: 36rpx;
    font-weight: bold;
    color: #e74c3c;
  }
}
</style>
