message-box.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <div class="box" :class="{teacher: item.isTeacher}">
  3. <span class="name">{{item.userName}}</span>
  4. <div class="container">
  5. <span class="time">{{item.createTime}}</span>
  6. <div v-if="item.msgType === 'TXT'" class="content">{{item.content}}</div>
  7. <div v-if="item.msgType === 'IMG'" class="content">
  8. <el-image
  9. style="width: 100px; height: 100px"
  10. :src="item.content"
  11. fit="cover"
  12. :preview-src-list="[item.content]">
  13. </el-image>
  14. </div>
  15. <div v-if="item.msgType === 'VC'" class="content">
  16. <audio controls
  17. style="width: 240px"
  18. :src="item.content"
  19. ref="dialogVideo">您的浏览器不支持音频播放</audio>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. export default {
  26. name: 'message-box',
  27. props: ['item'],
  28. mounted() {
  29. }
  30. }
  31. </script>
  32. <style lang="less" scoped>
  33. .box{
  34. display: flex;
  35. &.teacher{
  36. flex-direction: row-reverse;
  37. >.name{
  38. margin-left: 10px;
  39. margin-right: 0px;
  40. }
  41. .container{
  42. max-width: 80%;
  43. .content{
  44. margin-top: 10px;
  45. color: #fff;
  46. background-color: #13817a;
  47. text-align: left;
  48. line-height: 24px;
  49. &::before{
  50. border: 10px solid #13817a;
  51. border-top-color: transparent;
  52. border-bottom-color: transparent;
  53. border-right-color: transparent;
  54. left: auto;
  55. right: -18px;
  56. top: 8px;
  57. }
  58. }
  59. }
  60. }
  61. >.name{
  62. margin: 27px 10px;
  63. margin-left: 0;
  64. }
  65. .container{
  66. &:hover{
  67. .time{
  68. visibility: visible!important;
  69. }
  70. }
  71. .time{
  72. display: block;
  73. margin-bottom: 3px;
  74. font-size: 12px;
  75. visibility: hidden;
  76. }
  77. .content{
  78. margin-bottom: 10px;
  79. position: relative;
  80. background-color: #fff;
  81. padding: 10px;
  82. border-radius: 5px;
  83. line-height: 24px;
  84. &::before{
  85. width: 0;
  86. height: 0;
  87. border: 10px solid #fff;
  88. border-top-color: transparent;
  89. border-bottom-color: transparent;
  90. border-left-color: transparent;
  91. content: '';
  92. left: -18px;
  93. top: 8px;
  94. position: absolute;
  95. }
  96. }
  97. }
  98. }
  99. </style>