<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: '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 {
    flex: 0 0 auto;
    width: 0.36rem;
    height: 0.36rem;
    border-radius: 0.04rem;
    overflow: hidden;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .right {
    flex: 1;
    padding: 0 0.1rem;
    .name {
      line-height: 0.2rem;
      color: #9b9b9b;
      font-size: 0.12rem;
    }
    .content {
      padding: 0.05rem;
      display: inline-block;
      max-width: 80%;
      background: var(--chat-bg);
      border-radius: 0.05rem;
      border: 0.01rem solid var(--chat-border-color);
      img {
        max-width: 100%;
        max-height: 1.5rem;
      }
    }
  }
}
</style>
