chat-item.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="chat-item" :class="active?'active':''" @click="showChatBox()">
  3. <view class="left">
  4. <head-image :url="chat.headImage" :name="chat.showName" :size="90"></head-image>
  5. <view v-if="chat.unreadCount>0" class="unread-text">{{chat.unreadCount}}</view>
  6. </view>
  7. <view class="chat-right">
  8. <view class="chat-name">
  9. <view class="chat-name-text">{{chat.showName}}</view>
  10. <view class="chat-time">{{$date.toTimeText(chat.lastSendTime,true)}}</view>
  11. </view>
  12. <view class="chat-content">
  13. <view class="chat-at-text">{{atText}}</view>
  14. <view class="chat-send-name" v-show="chat.sendNickName">{{chat.sendNickName+':&nbsp;'}}</view>
  15. <rich-text class="chat-content-text" :nodes="$emo.transform(chat.lastContent)"></rich-text>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: "chatItem",
  23. data() {
  24. return {}
  25. },
  26. props: {
  27. chat: {
  28. type: Object
  29. },
  30. index: {
  31. type: Number
  32. },
  33. active: {
  34. type: Boolean,
  35. default: false
  36. }
  37. },
  38. methods: {
  39. showChatBox() {
  40. uni.navigateTo({
  41. url: "/pages/chat/chat-box?chatIdx=" + this.index
  42. })
  43. }
  44. },
  45. computed: {
  46. atText() {
  47. if (this.chat.atMe) {
  48. return "[有人@我]"
  49. } else if (this.chat.atAll) {
  50. return "[@全体成员]"
  51. }
  52. return "";
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped lang="scss">
  58. .chat-item {
  59. height: 100rpx;
  60. display: flex;
  61. margin-bottom: 2rpx;
  62. position: relative;
  63. padding: 10rpx;
  64. padding-left: 20rpx;
  65. align-items: center;
  66. background-color: white;
  67. white-space: nowrap;
  68. &:hover {
  69. background-color: #eeeeee;
  70. }
  71. &.active {
  72. background-color: #eeeeee;
  73. }
  74. .left {
  75. position: relative;
  76. display: flex;
  77. justify-content: center;
  78. align-items: center;
  79. width: 100rpx;
  80. height: 100rpx;
  81. .unread-text {
  82. position: absolute;
  83. background-color: red;
  84. right: -12rpx;
  85. top: -12rpx;
  86. color: white;
  87. border-radius: 16rpx;
  88. padding: 4rpx 12rpx;
  89. font-size: 20rpx;
  90. text-align: center;
  91. white-space: nowrap;
  92. }
  93. }
  94. .chat-right {
  95. flex: 1;
  96. display: flex;
  97. flex-direction: column;
  98. padding-left: 20rpx;
  99. text-align: left;
  100. overflow: hidden;
  101. .chat-name {
  102. display: flex;
  103. line-height: 44rpx;
  104. height: 44rpx;
  105. .chat-name-text {
  106. flex: 1;
  107. font-size: 30rpx;
  108. font-weight: 600;
  109. white-space: nowrap;
  110. overflow: hidden;
  111. }
  112. .chat-time {
  113. font-size: 26rpx;
  114. text-align: right;
  115. color: #888888;
  116. white-space: nowrap;
  117. overflow: hidden;
  118. }
  119. }
  120. .chat-content {
  121. display: flex;
  122. line-height: 60rpx;
  123. height: 60rpx;
  124. .chat-at-text {
  125. color: #c70b0b;
  126. font-size: 24rpx;
  127. }
  128. .chat-send-name {
  129. font-size: 26rpx;
  130. }
  131. .chat-content-text {
  132. flex: 1;
  133. font-size: 28rpx;
  134. white-space: nowrap;
  135. overflow: hidden;
  136. text-overflow: ellipsis;
  137. }
  138. }
  139. }
  140. }
  141. </style>