chat-item.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="chat-item" @click="showChatBox()">
  3. <view class="left">
  4. <head-image :url="chat.headImage" :name="chat.showName" :size="100"></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. {{ chat.showName}}
  10. </view>
  11. <view class="chat-content">
  12. <view class="chat-content-text" v-html="$emo.transform(chat.lastContent)"></view>
  13. <view class="chat-time">{{$date.toTimeText(chat.lastSendTime)}}</view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. name: "chatItem",
  21. data() {
  22. return {}
  23. },
  24. props: {
  25. chat: {
  26. type: Object
  27. },
  28. index: {
  29. type: Number
  30. }
  31. },
  32. methods: {
  33. showChatBox() {
  34. uni.navigateTo({
  35. url: "/pages/chat/chat-box?chatIdx=" + this.index
  36. })
  37. }
  38. }
  39. }
  40. </script>
  41. <style scoped lang="scss">
  42. .chat-item {
  43. height: 120rpx;
  44. display: flex;
  45. margin-bottom: 2rpx;
  46. position: relative;
  47. padding-left: 30rpx;
  48. align-items: center;
  49. padding-right: 10rpx;
  50. background-color: white;
  51. white-space: nowrap;
  52. &:hover {
  53. background-color: #eeeeee;
  54. }
  55. .left {
  56. position: relative;
  57. display: flex;
  58. justify-content: center;
  59. align-items: center;
  60. width: 100rpx;
  61. height: 100rpx;
  62. .unread-text {
  63. position: absolute;
  64. background-color: red;
  65. right: -12rpx;
  66. top: -12rpx;
  67. color: white;
  68. border-radius: 16rpx;
  69. padding: 4rpx 12rpx;
  70. font-size: 20rpx;
  71. text-align: center;
  72. white-space: nowrap;
  73. }
  74. }
  75. .chat-right {
  76. flex: 1;
  77. display: flex;
  78. flex-direction: column;
  79. padding-left: 20rpx;
  80. text-align: left;
  81. overflow: hidden;
  82. .chat-name {
  83. font-size: 30rpx;
  84. font-weight: 600;
  85. line-height: 60rpx;
  86. white-space: nowrap;
  87. overflow: hidden;
  88. }
  89. .chat-content {
  90. display: flex;
  91. .chat-content-text {
  92. flex: 1;
  93. font-size: 28rpx;
  94. white-space: nowrap;
  95. overflow: hidden;
  96. line-height: 50rpx;
  97. text-overflow: ellipsis;
  98. }
  99. .chat-time {
  100. font-size: 26rpx;
  101. text-align: right;
  102. color: #888888;
  103. white-space: nowrap;
  104. overflow: hidden;
  105. }
  106. }
  107. }
  108. }
  109. </style>