RTCMessageRender.vue 2.6 KB

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