<template>
  <div class="message-item" :class="classes" @click="onClick">
    <!-- <div class="message-item-pic" :class="`message-item-pic-${type}`"></div> -->
    <div class="message-item-content margin-none">
      <div class="message-item-content-hd">
        <div class="message-item-content__title">{{ data.title }}</div>
        <div class="message-item-content__time">{{ data.created_time }}</div>
      </div>
      <div class="message-item-content-bd text-ellipsis" v-html="data.contents"></div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'MessageItem',
  props: { type: String, data: Object },
  computed: {
    isRead() {
      return this.data.status === '1'
    },
    classes() {
      return {
        'un-read': !this.isRead
      }
    }
  },
  methods: {
    onClick() {
      this.$router.push({ name: 'messageItem', params: { id: this.data.id } })
    }
  }
}
</script>

<style lang="scss">
#app{
  background: #F7F8F9;
}
.message-item {
  display: flex;
  align-items: center;
  // padding-bottom: 20px;
  padding-top: 20px;
  // border-bottom: 1px solid #f1f1f1;
  background: #fff;
  padding: 20px 12px;
}
.message-item-pic {
  width: 40px;
  height: 40px;
  background-size: contain;
}
.message-item-pic-1 {
  background-image: url('~@/assets/img/message_group_icon.png');
}
.message-item-pic-2 {
  background-image: url('~@/assets/img/message_activity_icon.png');
}
.message-item-pic-3 {
  background-image: url('~@/assets/img/message_settings_icon.png');
}
.message-item-content {
  flex: 1;
  margin-left: 10px;
}
.message-item-content-hd {
  display: flex;
  justify-content: space-between;
}
.message-item-content__title {
  font-size: 14px;
  color: #222;
  flex: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.message-item-content__time {
  font-size: 14px;
  color: #999;
}
.message-item-content-bd {
  margin-top: 8px;
  font-size: 14px;
  color: #999;
}
.un-read .message-item-content__title {
  font-weight: bold;
}
.margin-none{
  margin: 0;
}
.text-ellipsis{
  text-overflow: -o-ellipsis-lastline;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
</style>
