<template>
  <div class="activity-center-list-item">
    <header class="item-header">
      <i class="column-line"></i><span class="item-header-title">{{ title }}</span>
    </header>
    <div class="flex-wrap">
      <div class="card-item" v-for="card in list" :key="card" @click="jump(card.jumpUrl)">
        <el-image style="width: 40px; height: 40px;margin-right:12px;" :src="card.activityImage" fit="cover" />
        <div class="card-right">
          <p class="card-right-title">{{ card.activityName }}</p>
          <p class="card-right-explain">{{ card.activityExplain }}</p>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'ListItem',
  props: {
    item: {
      type: Object,
      default() {
        return {
          activityCategoryId: '',
          categoryName: '',
          childs: []
        };
      }
    }
  },
  watch: {
    item: {
      handler: function(n, o) {
        this.title = n.categoryName;
        this.list = [...n.childs];
      },
      deep: true,
      immediate: true
    }
  },
  data() {
    return {
      list: [],
      title: ''
    };
  },
  methods: {
    jump(url = '') {
      if (url) window.location.href = url;
    }
  }
};
</script>
<style lang="scss" scoped>
.activity-center-list-item {
  & + .activity-center-list-item {
    margin-top: 40px;
  }
  .item-header {
    display: flex;
    align-items: center;
    height: 22px;
    margin-bottom: 20px;
    cursor: default;
    .column-line {
      display: block;
      width: 3px;
      height: 16px;
      margin-right: 8px;
      background: #2f54eb;
    }
    &-title {
      font-size: 16px;
      font-weight: 500;
      color: #303133;
      line-height: 22px;
    }
  }
  .flex-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    .card-item {
      display: flex;
      align-items: center;
      width: 280px;
      height: 76px;
      padding-left: 16px;
      background: #f5f6f7;
      border-radius: 4px;
      cursor: pointer;
      transition: all 0.3s;
      &:hover {
        background: #ebecf0;
        transform: translateY(-5px);
      }
      .card-right-title {
        margin-bottom: 3px;
        font-size: 14px;
        font-weight: 500;
        color: #303133;
        line-height: 20px;
      }
      .card-right-explain {
        font-size: 12px;
        color: #606266;
        line-height: 17px;
      }
    }
  }
}
</style>
