chat-item.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view class="chat-item" @click="showChatBox()">
  3. <view class="left">
  4. <image class="head-image" :src="chat.headImage" mode="aspectFill" lazy-load="true"></image>
  5. <view v-show="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. .head-image {
  63. width: 100%;
  64. height: 100%;
  65. border-radius: 10%;
  66. border: #eeeeee solid 1px;
  67. }
  68. .unread-text {
  69. position: absolute;
  70. background-color: red;
  71. right: -12rpx;
  72. top: -12rpx;
  73. color: white;
  74. border-radius: 16rpx;
  75. padding: 4rpx 12rpx;
  76. font-size: 20rpx;
  77. text-align: center;
  78. white-space: nowrap;
  79. }
  80. }
  81. .chat-right {
  82. flex: 1;
  83. display: flex;
  84. flex-direction: column;
  85. padding-left: 20rpx;
  86. text-align: left;
  87. overflow: hidden;
  88. .chat-name {
  89. font-size: 30rpx;
  90. font-weight: 600;
  91. line-height: 60rpx;
  92. white-space: nowrap;
  93. overflow: hidden;
  94. }
  95. .chat-content {
  96. display: flex;
  97. .chat-content-text {
  98. flex: 1;
  99. font-size: 28rpx;
  100. white-space: nowrap;
  101. overflow: hidden;
  102. line-height: 50rpx;
  103. text-overflow: ellipsis;
  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. }
  114. }
  115. </style>