<template>
  <div class="chat-img">
    <div class="user-head">
      <img :src="userHead" alt="" />
    </div>
    <div class="right">
      <div class="name">{{ info.userNick }}</div>
      <div class="content">
        <img v-photoswipe="{ group: 'chat' }" :src="info.filterContent" />
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';
export default {
  name: 'pc-chat-img',
  props: {
    info: {}
  },
  computed: {
    ...mapGetters({
      channelInfo: 'channelInfo'
    }),
    userHead() {
      const userHeadImg = this.info.userHeadImg;
      if (userHeadImg === 'phoneHead') {
        return this.channelInfo.defaultPhoneHeadAva;
      } else if (userHeadImg === 'default') {
        return this.channelInfo.defaultUserAva;
      } else if (!userHeadImg) {
        return this.channelInfo.defaultUserAva;
      } else {
        return userHeadImg;
      }
    }
  }
};
</script>

<style lang="less" scoped>
.chat-img {
  display: flex;
  .user-head {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    overflow: hidden;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .right {
    flex: 1;
    padding: 0px 10px;
    .name {
      line-height: 20px;
      color: #9b9b9b;
      font-size: 12px;
    }
    .content {
      padding: 5px;
      display: inline-block;
      max-width: 80%;
      background: var(--chat-bg);
      border-radius: 4px;
      border: 1px solid var(--chat-border-color);
      img {
        max-width: 100%;
        max-height: 150px;
      }
    }
  }
}
</style>
