<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)">
        <div class="remark-tag" v-if="card.activityRemark">{{ card.activityRemark }}</div>
        <el-image style="width: 40px; height: 40px;margin-right:12px;border-radius:8px;" :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(card) {
      const { jumpUrl } = card;
      if (!jumpUrl) return;
      if (card.activityCode == 'hb_m0206') {
        const href = `${window.location.origin}/${jumpUrl}&hbPage=staffActCode`;
        window.open(href);
      } else {
        window.location.href = `${window.location.origin}/${jumpUrl}`;
      }
    }
  }
};
</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: 4px;
      height: 16px;
      margin-right: 12px;
      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;
      position: relative;
      width: 278px;
      height: 76px;
      padding-left: 16px;
      background: #f5f6f7;
      border-radius: 4px;
      cursor: pointer;
      transition: all 0.3s;
      box-sizing: border-box;
      &: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;
      }
      .remark-tag {
        position: absolute;
        right: 0;
        top: 0;
        padding: 0 8px;
        color: #fff;
        font-size: 12px;
        font-weight: 500;
        line-height: 20px;
        text-align: center;
        background: #fa8c16;
        border-radius: 0px 4px 0px 4px;
      }
    }
  }
}
</style>
