index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="reply_msg_container" @click="extractMessageBodyValue">
  3. <view class="reply_msg_content_box">
  4. <view class="reply_msg_content_box_left">
  5. <view class="reply_msg_target">
  6. <!-- <u-icon
  7. name="/static/images/new_ui/message/replyMessage/replying_icon.png"
  8. size="16"
  9. ></u-icon> -->
  10. 正在回复:
  11. <text class="reply_msg_target_name u-line-1">{{
  12. previewMsgFromNickname
  13. }}</text>
  14. </view>
  15. <view class="reply_msg_content u-line-1"
  16. >{{ previewText }}
  17. <!-- 音频length含展示length -->
  18. <text
  19. class="reply_msg_audio_length"
  20. v-if="this.checkedPopupMsgBody.length"
  21. >
  22. {{ this.checkedPopupMsgBody.length }}″</text
  23. >
  24. </view>
  25. </view>
  26. <view
  27. v-if="this.checkedPopupMsgBody.type !== MESSAGE_TYPE.TEXT"
  28. class="reply_msg_content_box_rigth"
  29. >
  30. <u-icon :name="previewFileIcon" size="36"></u-icon>
  31. </view>
  32. </view>
  33. <u-icon
  34. @click="closeReplyMsgContainer"
  35. name="/static/images/new_ui/message/replyMessage/close_icon.png"
  36. size="20"
  37. ></u-icon>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. MESSAGE_TYPE,
  43. CUSTOM_EVENT_NAME,
  44. SESSION_MESSAGE_TYPE,
  45. } from '@/EaseIM/constant';
  46. import { CHAT_TYPE } from '../../../../EaseIM/constant';
  47. export default {
  48. props: {
  49. checkedPopupMsgBody: {
  50. type: Object,
  51. default: () => ({}),
  52. },
  53. },
  54. data() {
  55. return {
  56. MESSAGE_TYPE,
  57. CUSTOM_EVENT_NAME,
  58. SESSION_MESSAGE_TYPE,
  59. rootImageUrl: '/static/images/new_ui/message/replyMessage/',
  60. };
  61. },
  62. computed: {
  63. isSelf() {
  64. const checkedPopupMsgBody = this.checkedPopupMsgBody;
  65. return (
  66. checkedPopupMsgBody.from ===
  67. this.$store.state.LoginStore.loginUserBaseInfos.loginUserId
  68. );
  69. },
  70. friendUserInfoCollection() {
  71. return this.$store.getters.friendUserInfoCollection;
  72. },
  73. groupMembersProfileData() {
  74. return this.$store.getters.groupMembersProfile;
  75. },
  76. previewText() {
  77. if (this.checkedPopupMsgBody?.type === MESSAGE_TYPE.TEXT) {
  78. return this.checkedPopupMsgBody?.msg || '';
  79. } else if (this.checkedPopupMsgBody?.type === MESSAGE_TYPE.FILE) {
  80. return '[文件] ' + this.checkedPopupMsgBody?.filename || '[文件]';
  81. } else if (
  82. this.checkedPopupMsgBody?.type === MESSAGE_TYPE.CUSTOM &&
  83. this.checkedPopupMsgBody.customEvent === CUSTOM_EVENT_NAME.USER_CARD
  84. ) {
  85. return '[个人名片]';
  86. } else if (
  87. this.checkedPopupMsgBody?.type === MESSAGE_TYPE.CUSTOM &&
  88. this.checkedPopupMsgBody.customEvent === CUSTOM_EVENT_NAME.PRODUCTLINK
  89. ) {
  90. return '[商品链接]';
  91. }else {
  92. return SESSION_MESSAGE_TYPE[this.checkedPopupMsgBody?.type] || '';
  93. }
  94. },
  95. previewFileIcon() {
  96. if (this.checkedPopupMsgBody?.type === MESSAGE_TYPE.IMAGE) {
  97. //图片如果包含缩略图字段则优先展示缩略图作为icon预览
  98. if (this.checkedPopupMsgBody?.thumb) {
  99. return this.checkedPopupMsgBody.thumb;
  100. }
  101. return this.rootImageUrl + 'reply_msg_img.png';
  102. }
  103. if (this.checkedPopupMsgBody?.type === MESSAGE_TYPE.AUDIO) {
  104. return this.rootImageUrl + 'reply_msg_audio.png';
  105. }
  106. if (this.checkedPopupMsgBody?.type === MESSAGE_TYPE.VIDEO) {
  107. return this.rootImageUrl + 'reply_msg_video.png';
  108. }
  109. },
  110. previewMsgFromNickname() {
  111. if (this.isSelf) {
  112. return '我';
  113. }
  114. if (this.checkedPopupMsgBody?.chatType === CHAT_TYPE.SINGLE_CHAT) {
  115. const userId = this.checkedPopupMsgBody.from;
  116. if (
  117. this.friendUserInfoCollection[userId] &&
  118. this.friendUserInfoCollection[userId]?.nickname
  119. ) {
  120. return this.friendUserInfoCollection[userId].nickname;
  121. } else {
  122. return userId;
  123. }
  124. }
  125. if (this.checkedPopupMsgBody?.chatType === CHAT_TYPE.GROUP_CHAT) {
  126. const groupId = this.checkedPopupMsgBody.to;
  127. const userId = this.checkedPopupMsgBody.from;
  128. const groupMemberData = this.groupMembersProfileData[groupId];
  129. if (groupMemberData) {
  130. return (
  131. groupMemberData[userId]?.nickName ||
  132. groupMemberData[userId]?.nickname ||
  133. userId
  134. );
  135. } else {
  136. return userId;
  137. }
  138. }
  139. },
  140. },
  141. methods: {
  142. //关闭消息引用框
  143. closeReplyMsgContainer() {
  144. this.$emit('onShowReplyMessageContainer');
  145. },
  146. //提取原始消息内容至待发送的引用参数内
  147. extractMessageBodyValue() {
  148. const { type, msg: msgContent, id: mid, from } = this.checkedPopupMsgBody;
  149. //引用消息必传参数
  150. let msgQuote = {
  151. msgID: '', //引用消息id
  152. msgPreview: '', //引用消息预览
  153. msgSender: '', //引用消息发送人
  154. msgType: '', //引用消息类型
  155. };
  156. msgQuote.msgID = mid;
  157. msgQuote.msgType = type;
  158. msgQuote.msgSender = this.previewMsgFromNickname;
  159. if (type === MESSAGE_TYPE.TEXT) {
  160. msgQuote.msgPreview = msgContent;
  161. } else if (
  162. type === MESSAGE_TYPE.CUSTOM &&
  163. this.checkedPopupMsgBody.customEvent === CUSTOM_EVENT_NAME.USER_CARD
  164. ) {
  165. msgQuote.msgPreview = '[个人名片]';
  166. } else if(
  167. type === MESSAGE_TYPE.CUSTOM &&
  168. this.checkedPopupMsgBody.customEvent === CUSTOM_EVENT_NAME.PRODUCTLINK
  169. ){
  170. msgQuote.msgPreview = '[商品链接]';
  171. }else{
  172. msgQuote.msgPreview = SESSION_MESSAGE_TYPE[type];
  173. }
  174. console.log('msgQuote', msgQuote);
  175. return msgQuote;
  176. },
  177. },
  178. };
  179. </script>
  180. <style scoped>
  181. .reply_msg_container {
  182. width: 100%;
  183. min-height: 52px;
  184. box-sizing: border-box;
  185. background: #f1f2f3;
  186. display: flex;
  187. justify-content: space-between;
  188. align-items: center;
  189. padding: 0 5px;
  190. }
  191. .reply_msg_content_box {
  192. width: 100%;
  193. display: flex;
  194. flex-direction: row;
  195. }
  196. .reply_msg_content_box_left {
  197. flex: 1;
  198. }
  199. .reply_msg_target {
  200. display: flex;
  201. flex-direction: row;
  202. align-items: center;
  203. /* Nickname */
  204. height: 16px;
  205. /* 简体中文/标签/小 */
  206. font-family: 'PingFang SC';
  207. font-style: normal;
  208. font-weight: 400;
  209. font-size: 12px;
  210. line-height: 16px;
  211. /* identical to box height, or 133% */
  212. /* Neutral Special/5 */
  213. color: #5270ad;
  214. /* Inside auto layout */
  215. flex: none;
  216. order: 3;
  217. flex-grow: 0;
  218. }
  219. .reply_msg_target_name {
  220. font-weight: bold;
  221. }
  222. .reply_msg_content {
  223. /* 感恩陪伴 */
  224. height: 16px;
  225. /* 简体中文/文本/小 */
  226. font-family: 'PingFang SC';
  227. font-style: normal;
  228. font-weight: 400;
  229. font-size: 12px;
  230. line-height: 16px;
  231. /* identical to box height, or 133% */
  232. /* Neutral/5 */
  233. color: #75828a;
  234. /* Inside auto layout */
  235. flex: none;
  236. order: 0;
  237. flex-grow: 0;
  238. }
  239. .reply_msg_audio_length {
  240. margin-left: 4px;
  241. }
  242. </style>