<template>
  <div class="chat-wrapper">
    <div class="chat-content">
      <div v-for="(record,index) in recordContent" :key="`${record.chatTime}${index}`">
        <div v-if="!record.mineMsg" class="word">
          <!-- <img :src="record.headUrl"> -->
          <img src="@/assets/CRC.png">
          <div class="info">
            <p class="time">
              <span style="font-weight:700;">{{ record.userName }} </span>
              <span>({{ record.chatTime }}) </span>
            </p>
            <div class="info-content">{{ record.contactText }}</div>
          </div>
        </div>

        <div v-else class="word-my">
          <div class="info">
            <p class="time">
              <span style="font-weight:700;">{{ record.userName }} </span>
              <span>({{ record.chatTime }}) </span>
            </p>
            <div class="info-content">{{ record.contactText }}</div>
          </div>
          <!-- <img :src="record.headUrl"> -->
          <img src="@/assets/QC.png">
        </div>
      </div>
    </div>
    <div class="chat-message">
      <el-input
        v-model="newMessage"
        type="textarea"
        :autosize="{ minRows: 1, maxRows: 4}"
        placeholder="请输入内容"
        style="width:90%;"
      />
      <el-button type="primary">发送</el-button>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      recordContent: [
        {
          mineMsg: false,
          userName: 'CRC',
          chatTime: '2021.10.28 10:20:38',
          contactText: '影像已上传完毕',
          headUrl: ''
        },
        {
          mineMsg: false,
          userName: 'CRC',
          chatTime: '2021.10.30 16:05:12',
          contactText: '请核查',
          headUrl: ''
        },
        {
          mineMsg: true,
          userName: 'QC',
          chatTime: '2021.10.31 09:00:36',
          contactText: '确认无误',
          headUrl: ''
        },
        {
          mineMsg: false,
          userName: 'CRC',
          chatTime: '2021.10.30 16:05:12',
          contactText: '请核查',
          headUrl: ''
        },
        {
          mineMsg: true,
          userName: 'QC',
          chatTime: '2021.10.31 09:00:36',
          contactText: '确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误',
          headUrl: ''
        },
        {
          mineMsg: true,
          userName: 'QC',
          chatTime: '2021.10.31 09:00:36',
          contactText: '确认无误',
          headUrl: ''
        },
        {
          mineMsg: true,
          userName: 'QC',
          chatTime: '2021.10.31 09:00:36',
          contactText: '确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误确认无误',
          headUrl: ''
        },
        {
          mineMsg: true,
          userName: 'QC',
          chatTime: '2021.10.31 09:00:36',
          contactText: '确认无误',
          headUrl: ''
        }
      ],
      newMessage: ''
    }
  }
}
</script>
<style lang="scss">
.chat-wrapper{
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
  }
  ::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: #d0d0d0;
  }
  .chat-content{
    width:100%;
    padding: 20px;
    height: 500px;
    overflow-y: auto;
    .word{
      display: flex;
      margin-bottom: 20px;
      img{
        width:40px;
        height: 40px;
        border-radius: 50%;
      }
      .info{
        margin-left: 10px;
        .time{
          font-size: 12px;
          color:rgba(51,51,51,0.8);
          margin:0;
          height: 20px;
          line-height: 20px;
          margin-top: -5px;
        }
        .info-content{
          padding: 10px;
          font-size: 14px;
          background-color: #ebeef5;
          position: relative;
          margin-top: 8px;
        }
        .info-content::before{
          position: absolute;
          left: -8px;
          top: 8px;
          content: '';
          border-right: 10px solid #ebeef5;
          border-top: 8px solid transparent;
          border-bottom: 8px solid transparent;
        }
      }
    }
    .word-my{
      display: flex;
      justify-content: flex-end;
      margin-bottom: 20px;
      img{
        width: 40px;
        height: 40px;
        border-radius: 50%;
      }
      .info{
        width: 90%;
        margin-left: 10px;
        text-align: right;
        .time{
          font-size: 12px;
          color: rgba(51,51,51,0.8);
          margin: 0;
          height: 20px;
          line-height: 20px;
          margin-top: -5px;
          margin-right: 10px;
        }
        .info-content{
          position: relative;
          max-width: 70%;
          padding: 10px;
          font-size: 14px;
          float: right;
          margin-right: 10px;
          margin-top: 8px;
          background-color: #7574d9;
          color: #fff;
          text-align: left;
        }
        .info-content::after{
          position: absolute;
          right: -8px;
          top: 8px;
          content: '';
          border-left: 10px solid #7574d9;
          border-top: 8px solid transparent;
          border-bottom: 8px solid transparent;
        }
      }
    }
  }
}
</style>
