<template>
  <div class="my-group-item" @click="onClick">
    <div class="my-group-item-bd">
      <div class="my-group-item-main">
        <div class="my-group-item-title line-clamp">{{ data.org_name }}</div>
        <div class="my-group-item-content">
          <p>
            <b>类型:</b>
            <span>{{ data.org_type_str }}</span>
          </p>
          <p v-if="data.org_city">
            <b>地点:</b>
            <span>{{ data.org_city }}</span>
          </p>
          <p v-if="data.industry">
            <b>行业:</b>
            <span>{{ data.industry }}</span>
          </p>
          <p v-if="data.purpose">
            <b>宗旨:</b>
            <span>{{ data.purpose }}</span>
          </p>
          <p>
            <b>审核状态:</b>
            <span :class="statusClass">{{ data.approve_status_str }}</span>
          </p>
        </div>
      </div>
      <div class="my-group-item-pic" v-if="data.logo">
        <img :src="data.logo" />
      </div>
    </div>
    <div class="my-group-item-ft">
      <ul>
        <li v-if="data.is_mine && data.approve_status === '-1'">
          <div
            class="button default-button"
            @click.stop="
              $router.push({ name: 'groupUpdate', 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: 'groupMember',
                params: { id: data.id },
                query: { is_mine: `${data.is_mine}` }
              })
            "
          >
            成员列表
          </div>
        </li>
        <li>
          <div
            class="button primary-button"
            @click.stop="
              $router.push({ name: 'groupActivity', params: { id: data.id } })
            "
          >
            活动
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Card',
  props: {
    data: Object,
    index: Number,
    showIndex: { type: Boolean, default: false }
  },
  computed: {
    currentIndex() {
      return this.index + 1
    },
    topClass() {
      return this.currentIndex <= 3 ? `top${this.currentIndex}` : ''
    },
    statusClass() {
      const status = this.data.approve_status
      return {
        'status-default': status === '-1',
        'status-success': status === '1',
        'status-warning': status === '0'
      }
    }
  },
  methods: {
    onClick() {
      this.$router.push({ name: 'groupItem', params: { id: this.data.id } })
    }
  }
}
</script>
<style lang="scss" scoped>
.my-group-item {
  margin-bottom: 10px;
  padding: 20px;
  box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.05);
  border-radius: 6px;
}
.my-group-item-bd {
  display: flex;
  // align-items: flex-start;
  overflow: hidden;
}
.my-group-item-main {
  flex: 1;
}
.my-group-item-title {
  font-size: 15px;
  color: #222;
}
.my-group-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-group-item-pic {
  width: 100px;
  height: 100px;
  margin-left: 10px;
  border-radius: 6px;
  overflow: hidden;
  img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
}
.my-group-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>
