ChatItem.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="chat-item" v-on="$listeners">
  3. <div
  4. class="chat-item-l"
  5. :class="{ 'chat-item-l-img': img, 'chat-item-l-dot': dot }"
  6. >
  7. <img v-if="img" :src="img" alt="" />
  8. <span v-else>{{ name }}</span>
  9. <span v-if="dot" class="l-dot"></span>
  10. </div>
  11. <div class="chat-item-r">
  12. <div class="chat-item-r-top">
  13. <span class="r-title ellipsis visited-hd">{{ title }}</span>
  14. <span class="r-time" v-if="time">{{ time }}</span>
  15. </div>
  16. <div class="chat-item-r-bottom ellipsis" :title="content">
  17. {{ content }}
  18. </div>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. name: 'ChatItem',
  25. props: {
  26. img: {
  27. type: String,
  28. default: ''
  29. },
  30. name: {
  31. type: String,
  32. default: ''
  33. },
  34. title: {
  35. type: String,
  36. default: ''
  37. },
  38. time: {
  39. type: [String, Number],
  40. default: 0
  41. },
  42. content: {
  43. type: String,
  44. default: ''
  45. },
  46. visited: {
  47. type: Boolean,
  48. default: false
  49. },
  50. dot: {
  51. type: Boolean,
  52. default: false
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. .chat-item {
  59. padding: 8px;
  60. display: flex;
  61. justify-content: space-between;
  62. align-items: center;
  63. cursor: pointer;
  64. &-l {
  65. position: relative;
  66. display: flex;
  67. width: 36px;
  68. height: 36px;
  69. justify-content: center;
  70. align-items: center;
  71. margin-right: 6px;
  72. font-size: 13px;
  73. border-radius: 50%;
  74. color: #fff;
  75. flex-shrink: 0;
  76. background: #2cb7ca;
  77. overflow: hidden;
  78. .l-dot {
  79. position: absolute;
  80. right: 0;
  81. top: 2px;
  82. width: 6px;
  83. height: 6px;
  84. background: #fb483d;
  85. border: 1px solid #ffffff;
  86. border-radius: 50%;
  87. }
  88. }
  89. &-l-img {
  90. background: transparent;
  91. border: 1px solid #ececec;
  92. }
  93. &-l-dot {
  94. overflow: unset;
  95. }
  96. &-r {
  97. flex: 1;
  98. width: 0;
  99. &-top {
  100. display: flex;
  101. justify-content: space-between;
  102. align-items: center;
  103. }
  104. .r-title {
  105. width: 70%;
  106. font-size: 14px;
  107. line-height: 22px;
  108. color: #1d1d1d;
  109. }
  110. .r-time {
  111. margin-left: 6px;
  112. font-size: 12px;
  113. line-height: 20px;
  114. color: #999;
  115. text-align: right;
  116. white-space: nowrap;
  117. }
  118. &-bottom {
  119. height: 18px;
  120. margin-top: 2px;
  121. color: #686868;
  122. font-size: 12px;
  123. line-height: 18px;
  124. }
  125. }
  126. &:hover {
  127. background: #eaf8fa;
  128. border-radius: 8px;
  129. .r-title {
  130. color: #2cb7ca;
  131. }
  132. }
  133. &:not(:last-child) {
  134. border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  135. }
  136. }
  137. </style>