MessageReadState.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <view>
  3. <text @click="toMemberRead" class="read_state" :style="{ color: unReadCount < 1 ? '#8E9AB0' : '#0089FF' }">
  4. {{ getReadStateStr}}</text>
  5. </view>
  6. </template>
  7. <script>
  8. import { SessionType } from "@/pages_im/constant/imConstants";
  9. export default {
  10. name: "",
  11. components: {},
  12. props: {
  13. message: Object,
  14. },
  15. data() {
  16. return {
  17. };
  18. },
  19. computed: {
  20. unReadCount() {
  21. if (this.message.sessionType === SessionType.Single) {
  22. return 0
  23. }
  24. return this.message.attachedInfoElem?.groupHasReadInfo.unreadCount ?? 0
  25. },
  26. getReadStateStr() {
  27. if (this.message.sessionType === SessionType.Single) {
  28. return this.message.isRead ? "已读" : "未读";
  29. }
  30. if (this.message.sessionType !== SessionType.Notification) {
  31. return this.unReadCount < 1 ? '全部已读' : `${this.unReadCount}人未读`
  32. }
  33. return "";
  34. },
  35. },
  36. methods: {
  37. toMemberRead() {
  38. if (this.message.sessionType === SessionType.Single) {
  39. return;
  40. }
  41. uni.$u.route("/pages/conversation/groupMessageReadState/index", {
  42. messageState: JSON.stringify({
  43. conversationID: this.$store.getters.storeCurrentConversation.conversationID,
  44. clientMsgID: this.message.clientMsgID,
  45. readedCount: this.message.attachedInfoElem?.groupHasReadInfo.hasReadCount ?? 0,
  46. unReadCount: this.unReadCount
  47. })
  48. });
  49. },
  50. },
  51. };
  52. </script>
  53. <style lang="scss" scoped>
  54. .read_state {
  55. font-size: 24rpx;
  56. }
  57. </style>