<template>
  <div class="my-activity-item" @click="onClick">
    <div class="my-activity-item-bd">
      <div class="my-activity-item-main">
        <div class="my-activity-item-title">
          {{ data.activity_demand_type_str }}
        </div>
        <div class="my-activity-item-content">
          <p>
            <b>地点:</b><span>{{ data.activity_city }}</span>
          </p>
          <p>
            <b>时间:</b><span>{{ data.activity_time }}</span>
          </p>
          <p>
            <b>主题:</b><span>{{ data.activity_name }}</span>
          </p>
          <p>
            <b>审核状态:</b
            ><span :class="statusClass">{{ data.approve_status_str }}</span>
          </p>
        </div>
      </div>
      <div class="my-activity-item-pic" v-if="data.activity_image">
        <img :src="data.activity_image" />
      </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>
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'
      }
    }
  },
  methods: {
    onClick() {
      this.$router.push({ name: 'activityItem', params: { id: this.data.id } })
    }
  }
}
</script>
<style lang="scss" scoped>
.my-activity-item {
  margin-bottom: 10px;
  padding: 20px;
  box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.05);
  border-radius: 6px;
}
.my-activity-item-bd {
  display: flex;
  overflow: hidden;
}
.my-activity-item-main {
  flex: 1;
}
.my-activity-item-title {
  font-size: 15px;
  color: #222;
}
.my-activity-item-content {
  color: #999;
  p {
    margin-top: 10px;
    display: flex;
    b {
      color: #999;
      white-space: nowrap;
    }
    span {
      margin-left: 5px;
      flex: 1;
      color: #222;
      overflow: 1;
    }
  }
}
.my-activity-item-pic {
  width: 100px;
  height: 100px;
  margin-left: 10px;
  border-radius: 6px;
  overflow: hidden;
  img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
}
.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%
    );
  }
}
</style>
