<template>
  <view>
    <view class="records-list" v-if="records && records.length">
      <view v-for="(item, idx) in records" :key="item.id || idx" class="record-item">
        <image class="record-img" :src="item.image" mode="aspectFill" />
        <view class="record-info">
          <view class="record-title">{{ item.title }}</view>
          <view class="record-meta">
            <text class="record-count">x{{ item.count }}</text>
            <text v-if="item.percent" class="record-percent">{{ item.percent }}%</text>
          </view>
        </view>
      </view>
    </view>
    <view class="empty-state" v-else>
      <text class="empty-icon">📝</text>
      <text class="empty-text">{{ emptyText }}</text>
    </view>
  </view>
</template>

<script setup>
defineProps({
  records: {
    type: Array,
    default: () => []
  },
  emptyText: {
    type: String,
    default: '暂无购买记录'
  }
})
</script>

<style lang="scss" scoped>
.records-list {
  padding: $spacing-xs 0;
}

.record-item {
  display: flex;
  align-items: center;
  padding: $spacing-sm 0;
  border-bottom: 1rpx solid rgba(0, 0, 0, 0.03);
  
  &:last-child {
    border-bottom: none;
  }
}

.record-img {
  width: 80rpx;
  height: 80rpx;
  border-radius: $radius-md;
  margin-right: $spacing-md;
  background: $bg-secondary;
  flex-shrink: 0;
}

.record-info {
  flex: 1;
  min-width: 0;
}

.record-title {
  font-size: $font-md;
  font-weight: 600;
  color: $text-main;
  margin-bottom: $spacing-xs;
  @include text-ellipsis(1);
}

.record-meta {
  display: flex;
  align-items: center;
  gap: $spacing-sm;
}

.record-count {
  font-size: $font-sm;
  color: $brand-primary;
  font-weight: 600;
}

.record-percent {
  font-size: $font-xs;
  color: $text-sub;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: $spacing-xl;
  color: $text-sub;
}

.empty-icon {
  font-size: 64rpx;
  margin-bottom: $spacing-sm;
}

.empty-text {
  font-size: $font-sm;
}
</style>
