RTCMessageRender.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. .bg_container {
  70. padding: 18rpx 24rpx;
  71. border-radius: 0rpx 12rpx 12rpx 12rpx;
  72. background-color: #ffffff;
  73. }
  74. .rtc_wrap {
  75. display: flex;
  76. flex-direction: row;
  77. align-items: center;
  78. }
  79. .rtc_wrap_self {
  80. flex-direction: row-reverse;
  81. }
  82. .rtc_icon {
  83. width: 20px;
  84. height: 20px;
  85. margin-right: 12rpx;
  86. }
  87. .rtc_icon_self {
  88. margin-right: 0 !important;
  89. margin-left: 12rpx;
  90. }
  91. </style>