GlobalResultItem.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view @click="clickItem" class="result_item">
  3. <view class="wrap">
  4. <my-avatar
  5. :src="item.faceURL || item.senderFaceUrl"
  6. :desc="item.remark || item.nickname || item.showName || item.senderNickname"
  7. :isGroup="item.groupID !== undefined && !item.senderNickname"
  8. size="42"
  9. v-if="!isFile"
  10. />
  11. <my-avatar
  12. v-else
  13. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_message_file.png"
  14. size="42"
  15. />
  16. <view class="result_item_details">
  17. <view class="title">
  18. <view class="name">
  19. {{
  20. item.remark ||
  21. item.nickname ||
  22. item.groupName ||
  23. item.showName ||
  24. item.senderNickname
  25. }}
  26. </view>
  27. <text class="desc">{{ item.position }}</text>
  28. </view>
  29. <view
  30. class="sub_title"
  31. v-if="item.company || item.latestMsg || messageContent"
  32. >
  33. {{ item.company || item.latestMsg || messageContent }}
  34. </view>
  35. </view>
  36. </view>
  37. <view v-if="item.sendTime !== undefined" class="time">
  38. {{ getLatestTime }}
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import MyAvatar from "../../../../components/MyAvatar/index.vue";
  44. import { formatConversionTime, parseMessageByType } from "../../../../util/imCommon";
  45. export default {
  46. name: "GlobalResultItem",
  47. components: {
  48. MyAvatar,
  49. },
  50. props: {
  51. item: Object,
  52. isPreview: Boolean,
  53. isFile: {
  54. type: Boolean,
  55. default: false,
  56. },
  57. },
  58. data() {
  59. return {};
  60. },
  61. computed: {
  62. getLatestTime() {
  63. return formatConversionTime(this.item.sendTime);
  64. },
  65. messageContent() {
  66. if (this.item.clientMsgID) {
  67. return parseMessageByType(this.item);
  68. }
  69. return "";
  70. },
  71. },
  72. methods: {
  73. clickItem() {
  74. if (this.isPreview) {
  75. this.$emit("click", this.item);
  76. return;
  77. }
  78. if (this.item.userID) {
  79. uni.$u.route("/pages/common/userCard/index", {
  80. sourceID: this.item.userID,
  81. });
  82. return;
  83. }
  84. if (this.item.groupName) {
  85. uni.$u.route("/pages/common/groupCard/index", {
  86. sourceID: this.item.groupID,
  87. });
  88. return;
  89. }
  90. if (this.item.conversationID) {
  91. uni.$u.route("/pages/common/globalChatLosPreview/index", {
  92. chatData: encodeURIComponent(JSON.stringify(this.item)),
  93. });
  94. return;
  95. }
  96. if (this.item.fileElem) {
  97. uni.$u.route("/pages/conversation/previewFile/index", {
  98. fileEl: JSON.stringify(this.item.fileElem),
  99. msgID: this.item.clientMsgID,
  100. });
  101. }
  102. },
  103. },
  104. };
  105. </script>
  106. <style lang="scss" scoped>
  107. .result_item {
  108. display: flex;
  109. padding: 24rpx 36rpx;
  110. color: $uni-text-color;
  111. position: relative;
  112. background-color: #fff;
  113. .wrap {
  114. @include vCenterBox();
  115. flex: 1;
  116. overflow: hidden;
  117. }
  118. &_details {
  119. flex: 1;
  120. margin-left: 20rpx;
  121. overflow: hidden;
  122. .title {
  123. display: flex;
  124. align-items: baseline;
  125. .name {
  126. @include nomalEllipsis();
  127. max-width: 280rpx;
  128. color: $uni-text-color;
  129. }
  130. .desc {
  131. @include nomalEllipsis();
  132. margin-left: 20rpx;
  133. font-size: 24rpx;
  134. color: #666;
  135. }
  136. }
  137. .sub_title {
  138. @include nomalEllipsis();
  139. font-size: 24rpx;
  140. color: #999;
  141. max-width: 360rpx;
  142. margin-top: 8rpx;
  143. }
  144. }
  145. .time {
  146. font-size: 24rpx;
  147. color: #adadad;
  148. }
  149. }
  150. </style>