ChatItem.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div class="chat-item" :class="active ? 'active' : ''">
  3. <div class="left">
  4. <head-image :url="chat.headImage" :size="40" :id="chat.type=='PRIVATE'?chat.targetId:0"></head-image>
  5. <div v-show="chat.unreadCount>0" class="unread-text">{{chat.unreadCount}}</div>
  6. </div>
  7. <div class="mid">
  8. <div>{{ chat.showName}}</div>
  9. <div class="msg-text" v-html="$emo.transform(chat.lastContent)"></div>
  10. </div>
  11. <div class="right ">
  12. <div @click.stop="onClickClose()"><i class="el-icon-close close" style="border: none; font-size: 20px;color: black;" title="关闭"></i></div>
  13. <div class="msg-time">
  14. <chat-time :time="chat.lastSendTime"></chat-time>
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import ChatTime from "./ChatTime.vue";
  21. import HeadImage from '../common/HeadImage.vue';
  22. export default {
  23. name: "chatItem",
  24. components: {
  25. ChatTime,
  26. HeadImage
  27. },
  28. data() {
  29. return {}
  30. },
  31. props: {
  32. chat: {
  33. type: Object
  34. },
  35. active: {
  36. type: Boolean
  37. },
  38. index: {
  39. type: Number
  40. }
  41. },
  42. methods: {
  43. onClickClose(){
  44. this.$emit("del");
  45. }
  46. }
  47. }
  48. </script>
  49. <style scode lang="scss">
  50. .chat-item {
  51. height: 65px;
  52. display: flex;
  53. margin-bottom: 1px;
  54. position: relative;
  55. padding-left: 15px;
  56. align-items: center;
  57. padding-right: 5px;
  58. background-color: #fafafa;
  59. white-space: nowrap;
  60. &:hover {
  61. background-color: #eeeeee;
  62. }
  63. &.active {
  64. background-color: #dddddd;
  65. }
  66. &:hover {
  67. .close {
  68. display: block !important;
  69. }
  70. }
  71. .left {
  72. position: relative;
  73. display: flex;
  74. width: 45px;
  75. height: 45px;
  76. .unread-text {
  77. position: absolute;
  78. background-color: #f56c6c;
  79. right: -8px;
  80. top: -8px;
  81. color: white;
  82. border-radius: 30px;
  83. padding: 0 5px;
  84. font-size: 10px;
  85. text-align: center;
  86. white-space: nowrap;
  87. border: 1px solid #f1e5e5;
  88. }
  89. }
  90. .mid {
  91. margin-left: 15px;
  92. flex: 2;
  93. display: flex;
  94. flex-direction: column;
  95. height: 100%;
  96. flex-shrink: 0;
  97. overflow: hidden;
  98. &>div {
  99. display: flex;
  100. justify-content: flex-start;
  101. align-items: center;
  102. flex: 1;
  103. }
  104. .msg-text {
  105. font-size: 14px;
  106. color: #888888;
  107. white-space: nowrap;
  108. }
  109. }
  110. .right {
  111. flex: 1;
  112. display: flex;
  113. flex-direction: column;
  114. align-items: flex-end;
  115. height: 100%;
  116. flex-shrink: 0;
  117. overflow: hidden;
  118. &>div {
  119. display: flex;
  120. justify-content: flex-start;
  121. align-items: center;
  122. flex: 1;
  123. }
  124. .close {
  125. width: 1.5rem;
  126. height: 1.5rem;
  127. right: 0;
  128. top: 1rem;
  129. cursor: pointer;
  130. display: none;
  131. }
  132. .msg-time {
  133. font-size: 14px;
  134. color: #888888;
  135. white-space: nowrap;
  136. }
  137. }
  138. }
  139. </style>