RTCMessageRender.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="bg_container rtc_wrap" :class="{ rtc_wrap_self: isSender }" @click="reCall">
  3. <image :src="rtcIcon" />
  4. <view>
  5. {{ messageCoontent }}
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import chating_message_video_other from '../../../../../static/images/chating_message_video_other.png';
  11. import chating_message_video from '../../../../../static/images/chating_message_video.png';
  12. import chating_message_voice from '../../../../../static/images/chating_message_voice.png';
  13. import { CustomMessageStatus, CustomType, PageEvents } from '../../../../../constant';
  14. export default {
  15. name: 'RTCMessageRender',
  16. components: {},
  17. props: {
  18. data: Object,
  19. isSender: Boolean
  20. },
  21. data() {
  22. return {};
  23. },
  24. mounted() {
  25. },
  26. computed: {
  27. rtcIcon() {
  28. if (this.data.type === CustomType.VideoCall) {
  29. return this.isSender ? chating_message_video : chating_message_video_other;
  30. }
  31. return chating_message_voice;
  32. },
  33. messageCoontent() {
  34. switch (this.data.status) {
  35. case CustomMessageStatus.Refuse:
  36. case CustomMessageStatus.Refused:
  37. return '已拒绝';
  38. case CustomMessageStatus.Cancel:
  39. case CustomMessageStatus.Canceled:
  40. return '已取消';
  41. case CustomMessageStatus.Timeout:
  42. return '超时未接听';
  43. case CustomMessageStatus.Success:
  44. return `通话时长 ${this.data.duration}`;
  45. case CustomMessageStatus.Timeout:
  46. return '通话中断';
  47. case CustomMessageStatus.AccessByOther:
  48. case CustomMessageStatus.RejectedByOther:
  49. return '已在其他设备处理';
  50. default:
  51. return '';
  52. }
  53. },
  54. isBlack() {
  55. return this.$store.getters.storeBlackList.some((black) => black.userID === this.$store.getters.storeCurrentConversation.userID);
  56. }
  57. },
  58. methods: {
  59. reCall() {
  60. if (this.isBlack) {
  61. return;
  62. }
  63. uni.$emit(PageEvents.RtcCall, this.data.type === CustomType.VideoCall ? 'video' : 'audio');
  64. }
  65. }
  66. };
  67. </script>
  68. <style lang="scss" scoped>
  69. .rtc_wrap {
  70. display: flex;
  71. align-items: center;
  72. image {
  73. width: 20px;
  74. height: 20px;
  75. margin-right: 12rpx;
  76. }
  77. &_self {
  78. flex-direction: row-reverse;
  79. image {
  80. margin-right: 0 !important;
  81. margin-left: 12rpx;
  82. }
  83. }
  84. }
  85. </style>