message-box.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. console.log({...this.item})
  30. }
  31. }
  32. </script>
  33. <style lang="less" scoped>
  34. .box{
  35. display: flex;
  36. margin-top: 10px;
  37. &.teacher{
  38. flex-direction: row-reverse;
  39. >.name{
  40. margin-left: 10px;
  41. margin-right: 0px;
  42. }
  43. .container{
  44. max-width: 80%;
  45. .content{
  46. color: #fff;
  47. background-color: #13817a;
  48. text-align: right;
  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. .time{
  67. display: block;
  68. margin-bottom: 3px;
  69. font-size: 12px;
  70. }
  71. .content{
  72. position: relative;
  73. background-color: #fff;
  74. padding: 10px;
  75. border-radius: 5px;
  76. &::before{
  77. width: 0;
  78. height: 0;
  79. border: 10px solid #fff;
  80. border-top-color: transparent;
  81. border-bottom-color: transparent;
  82. border-left-color: transparent;
  83. content: '';
  84. left: -18px;
  85. top: 8px;
  86. position: absolute;
  87. }
  88. }
  89. }
  90. }
  91. </style>