<template>
  <div class="container">
    <!-- 导航栏 -->
    <div class="nav-bar">
      <div class="back-btn" @click="$router.back()">
        <i class="arrow-left"></i>
      </div>
      <div class="title">礼品福利</div>
    </div>

    <!-- 记录列表 -->
    <div class="llllll">
      <div class="list">
        <div class="listItem" v-for="(item, index) in records" :key="index">
          <div class="flex listItemC">
            <div>奖品名称</div>
            <div class="tr4">领取状态</div>
            <div class="right">中奖日期</div>
          </div>
          <div class="flex listItemB">
            <div>{{ item.prize_name }}</div>
            <div class="tr4">{{ getStatusText(item.status) }}</div>
            <div class="right gggg">{{ item.addtime }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getUserInfo } from '@/api/home';
import { getPrizeRecords } from '@/api/profile';

export default {
  name: 'LeverList',
  data() {
    return {
      userInfo: {},
      records: []
    }
  },
  created() {
    this.getUserInfo();
    this.getRecords();
  },
  methods: {
    async getUserInfo() {
      try {
        const res = await getUserInfo();
        this.userInfo = res.data;
      } catch (error) {
        console.error('获取用户信息失败:', error);
      }
    },
    async getRecords() {
      try {
        const res = await getPrizeRecords();
        this.records = res.data || [];
      } catch (error) {
        console.error('获取礼品记录失败:', error);
      }
    },
    getStatusText(status) {
      return status === 0 ? '申请邮寄' : '已领取';
    }
  }
}
</script>

<style scoped>
.container {
  min-height: 100vh;
  background: #f5f5f5;
}

.nav-bar {
  height: 44px;
  background-color: #fff;
  color: #000;
  display: flex;
  align-items: center;
  position: relative;
  padding: 0 15px;
  font-weight: bold;
}

.back-btn {
  width: 24px;
  height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.arrow-left {
  width: 12px;
  height: 12px;
  border-left: 2px solid #000;
  border-bottom: 2px solid #000;
  transform: rotate(45deg);
}

.title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
}

.llllll {
  padding: 15px;
}

.list {
  background: #f5f5f5;
}

.listItem {
  background: #fff;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 10px;
}

.flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.listItemC {
  color: #999;
  font-size: 14px;
  margin-bottom: 10px;
}

.listItemB {
  color: #333;
  font-size: 14px;
}

.tr4 {
  flex: 0 0 100px;
  text-align: center;
}

.right {
  flex: 0 0 150px;
  text-align: right;
}

.gggg {
  color: #999;
}
</style> 