<template>
  <div class="shop_list">
    <div class="item_wrap" v-for="(item, index) in props.list" :key="item.id" @click="deleteItem(index)">
      <div class="item" :data-index="index + 1">
        <el-image :src="item.coverImg" style="width: 100%;height: 100%;"></el-image>
      </div>
      <div class="name">{{ item.name }}</div>
    </div>
  </div>
</template>
<script setup lang="ts">
const props = defineProps({
  list: {
    type: Array,
    default: () => [],
  },

});
const emit = defineEmits(['deleteItememit'])
function deleteItem(index: number) {
  props.list.splice(index, 1);
  emit('deleteItememit', props.list)
}
</script>
<style scoped lang="scss">
.shop_list {
  display: flex;
  flex-wrap: wrap;

  .item_wrap {
    $size: 80px;

    .item {
      $radius: 4px;
      width: $size;
      height: $size;
      border-radius: $radius;
      overflow: hidden;
      position: relative;
      margin-right: 10px;
      margin-top: 10px;

      &:hover {
        cursor: pointer;
      }

      &::after {
        content: attr(data-index);
        font-size: 12px;
        height: 20px;
        display: flex;
        padding: 0 10px;
        border-radius: 0 0 $radius 0;
        align-items: center;
        background-color: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(10px);
        color: #fff;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 10;
      }

      &::before {
        content: '删除';
        font-size: 12px;
        width: 100%;
        height: 20px;
        display: flex;
        padding: 0 10px;
        align-items: center;
        justify-content: center;
        background-color: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(10px);
        color: #fff;
        position: absolute;
        bottom: 0;
        left: 0;
        z-index: 10;
        transition: all .1s ease-in-out;
      }
    }

    .name {
      width: $size;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}
</style>