MessageReadState.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 IMSDK from "openim-uniapp-polyfill";
  9. import { SessionType } from "openim-uniapp-polyfill";
  10. export default {
  11. name: "",
  12. components: {},
  13. props: {
  14. message: Object,
  15. },
  16. data() {
  17. return {
  18. };
  19. },
  20. computed: {
  21. unReadCount() {
  22. if (this.message.sessionType === SessionType.Single) {
  23. return 0
  24. }
  25. return this.message.attachedInfoElem?.groupHasReadInfo.unreadCount ?? 0
  26. },
  27. getReadStateStr() {
  28. if (this.message.sessionType === SessionType.Single) {
  29. return this.message.isRead ? "已读" : "未读";
  30. }
  31. if (this.message.sessionType !== SessionType.Notification) {
  32. return this.unReadCount < 1 ? '全部已读' : `${this.unReadCount}人未读`
  33. }
  34. return "";
  35. },
  36. },
  37. methods: {
  38. toMemberRead() {
  39. if (this.message.sessionType === SessionType.Single) {
  40. return;
  41. }
  42. uni.$u.route("/pages/conversation/groupMessageReadState/index", {
  43. messageState: JSON.stringify({
  44. conversationID: this.$store.getters.storeCurrentConversation.conversationID,
  45. clientMsgID: this.message.clientMsgID,
  46. readedCount: this.message.attachedInfoElem?.groupHasReadInfo.hasReadCount ?? 0,
  47. unReadCount: this.unReadCount
  48. })
  49. });
  50. },
  51. },
  52. };
  53. </script>
  54. <style lang="scss" scoped>
  55. .read_state {
  56. // font-size: 26rpx;
  57. font-size: 0.75rem;
  58. }
  59. </style>