<template>
  <view>
    <view v-if="list.length">
      <view v-for="item in list" :key="item.id" class="record-item">
        <view
          class="record-item__badge"
          :class="'record-item__badge--' + (item.tone || 'info')"
        >
          {{ item.tag || "记" }}
        </view>
        <view class="record-item__content">
          <view class="record-item__head">
            <text class="record-item__title">{{ item.title }}</text>
            <text
              class="record-item__amount asset-number-font"
              :class="'record-item__amount--' + (item.tone || 'info')"
            >
              {{ item.amount }}
            </text>
          </view>
          <text v-if="item.subtitle" class="record-item__subtitle asset-number-font">{{
            item.subtitle
          }}</text>
          <view class="record-item__meta">
            <text class="record-item__time asset-number-font">{{ item.time }}</text>
            <text v-if="item.balance" class="record-item__balance asset-number-font">{{
              item.balance
            }}</text>
          </view>
        </view>
      </view>
    </view>
    <view v-else class="record-empty">
      <text class="record-empty__title">{{ emptyTitle }}</text>
      <text class="record-empty__desc">{{ emptyDesc }}</text>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default() {
        return [];
      },
    },
    emptyTitle: {
      type: String,
      default: "暂无记录",
    },
    emptyDesc: {
      type: String,
      default: "当前暂无流水数据。",
    },
  },
};
</script>

<style lang="scss" scoped>
@import "../styles/tokens.scss";

.record-item {
  display: flex;
  align-items: flex-start;
  padding: 24rpx 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.record-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.record-item__badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64rpx;
  height: 64rpx;
  margin-right: 20rpx;
  border-radius: 20rpx;
  font-size: 24rpx;
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
}

.record-item__badge--success {
  background: linear-gradient(135deg, #4fe0b5 0%, #36b98c 100%);
}

.record-item__badge--danger {
  background: linear-gradient(135deg, #ff8091 0%, #ff5d6e 100%);
}

.record-item__badge--info {
  background: linear-gradient(135deg, #5a71ff 0%, #4cc9ff 100%);
}

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

.record-item__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.record-item__title {
  flex: 1;
  min-width: 0;
  margin-right: 20rpx;
  font-size: 28rpx;
  line-height: 1.6;
  font-weight: 600;
  color: $asset-text-main;
}

.record-item__amount {
  font-size: 28rpx;
  font-weight: 700;
}

.record-item__amount--success {
  color: $asset-success;
}

.record-item__amount--danger {
  color: $asset-danger;
}

.record-item__amount--info {
  color: $asset-accent-strong;
}

.record-item__subtitle {
  display: block;
  margin-top: 10rpx;
  font-size: 22rpx;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.64);
}

.record-item__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14rpx;
  font-size: 22rpx;
  color: rgba(255, 255, 255, 0.58);
}

.record-item__time {
  margin-right: 20rpx;
}

.record-item__balance {
  text-align: right;
}

.record-empty {
  padding: 48rpx 20rpx;
  text-align: center;
}

.record-empty__title {
  display: block;
  font-size: 30rpx;
  font-weight: 700;
  color: $asset-text-main;
}

.record-empty__desc {
  display: block;
  margin-top: 16rpx;
  font-size: 24rpx;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.62);
}
</style>
