chat-item.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="chat-item" @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. },
  34. methods: {
  35. showChatBox() {
  36. uni.navigateTo({
  37. url: "/pages/chat/chat-box?chatIdx=" + this.index
  38. })
  39. }
  40. },
  41. computed: {
  42. atText() {
  43. if (this.chat.atMe) {
  44. return "[有人@我]"
  45. } else if (this.chat.atAll) {
  46. return "[@全体成员]"
  47. }
  48. return "";
  49. }
  50. }
  51. }
  52. </script>
  53. <style scoped lang="scss">
  54. .chat-item {
  55. height: 100rpx;
  56. display: flex;
  57. margin-bottom: 2rpx;
  58. position: relative;
  59. padding: 10rpx;
  60. padding-left: 20rpx;
  61. align-items: center;
  62. background-color: white;
  63. white-space: nowrap;
  64. &:hover {
  65. background-color: #eeeeee;
  66. }
  67. .left {
  68. position: relative;
  69. display: flex;
  70. justify-content: center;
  71. align-items: center;
  72. width: 100rpx;
  73. height: 100rpx;
  74. .unread-text {
  75. position: absolute;
  76. background-color: red;
  77. right: -12rpx;
  78. top: -12rpx;
  79. color: white;
  80. border-radius: 16rpx;
  81. padding: 4rpx 12rpx;
  82. font-size: 20rpx;
  83. text-align: center;
  84. white-space: nowrap;
  85. }
  86. }
  87. .chat-right {
  88. flex: 1;
  89. display: flex;
  90. flex-direction: column;
  91. padding-left: 20rpx;
  92. text-align: left;
  93. overflow: hidden;
  94. .chat-name {
  95. display: flex;
  96. line-height: 50rpx;
  97. height: 50rpx;
  98. .chat-name-text {
  99. flex: 1;
  100. font-size: 30rpx;
  101. font-weight: 600;
  102. white-space: nowrap;
  103. overflow: hidden;
  104. }
  105. .chat-time {
  106. font-size: 26rpx;
  107. text-align: right;
  108. color: #888888;
  109. white-space: nowrap;
  110. overflow: hidden;
  111. }
  112. }
  113. .chat-content {
  114. display: flex;
  115. line-height: 44rpx;
  116. .chat-at-text {
  117. color: #c70b0b;
  118. font-size: 24rpx;
  119. }
  120. .chat-send-name {
  121. font-size: 26rpx;
  122. }
  123. .chat-content-text {
  124. flex: 1;
  125. font-size: 28rpx;
  126. white-space: nowrap;
  127. overflow: hidden;
  128. line-height: 50rpx;
  129. text-overflow: ellipsis;
  130. }
  131. }
  132. }
  133. }
  134. </style>