<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: 'vertical-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;
    margin-right: 0.05rem;
    width: 0.26rem;
    height: 0.26rem;
    border-radius: 100%;
    overflow: hidden;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .right {
    padding: 0.05rem 0.1rem;
    .name {
      line-height: 0.2rem;
      font-size: 0.12rem;
      color: #ffde8d;
    }
    .content {
      max-width: 80%;
      border-radius: 0.05rem;
      img {
        max-width: 100%;
        max-height: 1.5rem;
      }
    }
  }
}
</style>
