chat-item.vue 2.4 KB

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