QuoteMessageRender.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="message_quote_wrap">
  3. <view class="message_quote_text">
  4. <u-parse :content="getSenderNickname" />
  5. <view style="margin-left: 6rpx" class="message_quote_media">
  6. <image v-if="isReplyFile" src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_message_file.png" alt="file" />
  7. <image v-if="isReplyImage" :src="getQuoteMessage.pictureElem.sourcePicture.url" alt="img" @click="clickImageItem" />
  8. <my-avatar v-if="isReplyCard" :src="getQuoteMessage.cardElem.faceURL" :desc="getQuoteMessage.cardElem.nickname" size="26" @click="clickCardUser" />
  9. <image v-if="isReplyVideo" :src="getQuoteMessage.videoElem.snapshotUrl" alt="video" />
  10. <image v-if="isReplyVideo" class="play_icon" src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/chating_message_video_play.png" alt="" srcset="" @click.stop="clickMediaItem" />
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import { mapGetters } from 'vuex';
  17. import { checkFileIsExist } from '../../../../../util/common';
  18. import UParse from '../../../../../components/gaoyia-parse/parse.vue';
  19. import { parseMessageByType } from '../../../../../util/imCommon';
  20. import { MessageType } from 'openim-uniapp-polyfill';
  21. import MyAvatar from '../../../../../components/MyAvatar/index.vue';
  22. import { myPreview } from '../../../../../util/preview';
  23. const extraTypes = [MessageType.FileMessage, MessageType.LocationMessage, MessageType.PictureMessage, MessageType.VideoMessage, MessageType.CardMessage];
  24. export default {
  25. name: '',
  26. components: {
  27. UParse,
  28. MyAvatar
  29. },
  30. props: {
  31. message: Object
  32. },
  33. data() {
  34. return {};
  35. },
  36. computed: {
  37. ...mapGetters(['storeCacheMap']),
  38. hasExtra() {
  39. return extraTypes.includes(this.message.quoteElem.quoteMessage.contentType);
  40. },
  41. isAtMessage() {
  42. return this.message.contentType === MessageType.AtTextMessage;
  43. },
  44. getQuoteMessage() {
  45. return this.isAtMessage ? this.message.atTextElem.quoteMessage : this.message.quoteElem.quoteMessage;
  46. },
  47. isReplyImage() {
  48. return this.getQuoteMessage.contentType === MessageType.PictureMessage;
  49. },
  50. isReplyVideo() {
  51. return this.getQuoteMessage.contentType === MessageType.VideoMessage;
  52. },
  53. isReplyFile() {
  54. return this.getQuoteMessage.contentType === MessageType.FileMessage;
  55. },
  56. isReplyCard() {
  57. return this.getQuoteMessage.contentType === MessageType.CardMessage;
  58. },
  59. isLocationMessage() {
  60. return this.getQuoteMessage.contentType === MessageType.LocationMessage;
  61. },
  62. isRevokedMessage() {
  63. return this.getQuoteMessage.contentType === MessageType.RevokeMessage;
  64. },
  65. getMessageContent() {
  66. if (this.isReplyImage || this.isReplyVideo) {
  67. return '';
  68. }
  69. if (this.isRevokedMessage) {
  70. return '引用内容已被撤回';
  71. }
  72. return parseMessageByType(this.getQuoteMessage);
  73. },
  74. getSenderNickname() {
  75. return `${this.getQuoteMessage.senderNickname}: ${this.getMessageContent}`;
  76. }
  77. },
  78. methods: {
  79. clickImageItem() {
  80. myPreview(0, [this.getQuoteMessage.pictureElem.sourcePicture.url]);
  81. },
  82. async clickMediaItem() {
  83. if (this.isReplyVideo) {
  84. const message = this.getQuoteMessage;
  85. const path = this.storeCacheMap[message.clientMsgID]?.path;
  86. const localPath = await checkFileIsExist({
  87. key: message.clientMsgID,
  88. path
  89. });
  90. const previewVideoUrl = localPath || message.videoElem.videoUrl;
  91. uni.navigateTo({
  92. url: `/pages_im/pages/conversation/previewVideo/index?clientMsgID=${message.clientMsgID}&previewVideoUrl=${previewVideoUrl}&snapshotUrl=${message.videoElem.snapshotUrl}`
  93. });
  94. }
  95. },
  96. clickCardUser() {
  97. uni.navigateTo({
  98. url: `/pages_im/pages/common/userCard/index?sourceID=${this.getQuoteMessage.cardElem.userID}`
  99. });
  100. }
  101. }
  102. };
  103. </script>
  104. <style lang="scss" scoped>
  105. .message_quote_wrap {
  106. display: flex;
  107. justify-content: flex-end;
  108. margin-top: 8rpx;
  109. .message_quote_text {
  110. display: flex;
  111. flex-direction: row;
  112. align-items: center;
  113. justify-content: space-between;
  114. width: fit-content;
  115. padding: 16rpx 16rpx;
  116. border-radius: 6rpx;
  117. color: #666;
  118. font-size: 24rpx;
  119. background-color: #f0f0f0;
  120. ::v-deep uni-view {
  121. @include ellipsisWithLine(3);
  122. }
  123. }
  124. .message_quote_media {
  125. position: relative;
  126. image {
  127. width: 26px;
  128. height: 26px;
  129. }
  130. .play_icon {
  131. width: 13px !important;
  132. height: 13px !important;
  133. position: absolute;
  134. top: 50%;
  135. left: 50%;
  136. transform: translate(-50%, -50%);
  137. }
  138. }
  139. }
  140. </style>