<template>
  <div class="my-activity-item" @click="onClick">
    <div class="my-activity-item-bd">
      <div class="my-activity-item-pic">
        <img :src="data.activity_image" v-if="data.activity_image" />
      </div>
      <div class="my-activity-item-main">
        <div class="my-activity-item-title">{{ data.activity_name }}</div>
        <div class="my-activity-item-content">
          <p>{{ data.activity_city }} · {{data.org_name}} · {{ data.stu_nums }}人参与</p>
          <p>{{ data.activity_time }}</p>
        </div>
        <div class="status" v-html="statusText"></div>
      </div>
    </div>
    <!-- <div class="my-activity-item-ft">
      <ul>
        <li v-if="data.is_mine && data.approve_status !== '1'">
          <div
            class="button default-button"
            @click.stop="
              $router.push({ name: 'activityUpdate', params: { id: data.id } })
            "
          >管理</div>
        </li>
        <li v-else>
          <div class="button default-button">详情</div>
        </li>
        <li>
          <div
            class="button default-button"
            @click.stop="
              $router.push({ name: 'activityMember', params: { id: data.id } })
            "
          >成员列表</div>
        </li>
      </ul>
    </div> -->
  </div>
</template>

<script>
import dayjs from 'dayjs'

export default {
  name: 'MyActivityItem',
  props: { data: Object, isCheck: Boolean },
  computed: {
    statusClass() {
      const status = this.data.approve_status
      return {
        'status-default': status === '-1',
        'status-success': status === '1' || status === '2',
        'status-warning': status === '0'
      }
    },
    statusText() {
      return dayjs().isAfter(dayjs(this.data.activity_time), 'day')
        ? '<span class="is-finish">已结束</span>'
        : '<span class="is-processing">进行中</span>'
    }
  },
  methods: {
    onClick() {
      this.$router.push({ name: 'activityItem', params: { id: this.data.id } })
    }
  }
}
</script>
<style lang="scss" scoped>
.my-activity-item {
  position: relative;
  display: flex;
  margin-bottom: 15px;
}
.my-activity-item-bd {
  display: flex;
  overflow: hidden;
}

.my-activity-item-pic {
  width: 120px;
  height: 75px;
  margin-right: 15px;
  background-color: #f3f4f5;
  border-radius: 4px;
  overflow: hidden;
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}
.my-activity-item-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 10px 0;
}
.my-activity-item-title {
  font-size: 15px;
  color: #1b1b1b;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.my-activity-item-content {
  p {
    margin-top: 8px;
    font-size: 12px;
    color: #a0a0a0;
    line-height: 1;
  }
}
.my-activity-item-ft {
  margin-top: 20px;
  ul {
    display: flex;
    justify-content: space-between;
  }
  .button {
    width: 64px;
    height: 30px;
    text-align: center;
    border-radius: 5px;
  }
  .default-button {
    font-size: 12px;
    color: #999;
    line-height: 30px;
    border: 1px solid #999;
  }
  .primary-button {
    font-size: 12px;
    color: #fff;
    line-height: 30px;
    background: linear-gradient(180deg, rgba(255, 201, 44, 1) 0%, rgba(255, 116, 42, 1) 100%);
  }
}
.status {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  ::v-deep span {
    height: 15px;
    padding: 0 4px;
    font-size: 12px;
    line-height: 15px;
    border-radius: 2px;
    display: inline-block;
  }
  ::v-deep .is-finish {
    color: #ce0022;
    background: #ffedf0;
  }
  ::v-deep .is-processing {
    color: #1f78d4;
    background: #e2f0ff;
  }
}
</style>
