MessageTips.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <WorkspaceCard class="message-card" v-if="messageList.length">
  3. <div slot="header-title">
  4. <span>我的消息</span>
  5. <span class="sub-text">(<span class="highlight-text">{{ unReadCount }} </span> 条未读)</span>
  6. </div>
  7. <div slot="header-right" class="header-right-set" @click="toMessageCenter">更多<i class="icon el-icon-arrow-right"></i></div>
  8. <div class="message-content message-list" v-loading="loading">
  9. <div class="message-item" v-for="item in messageList" :key="item.id">
  10. <div class="l-msg">
  11. <i class="red-dot" :class="{ invisible: item.isRead !== 0 }"></i>
  12. <!-- <h3 class="msg-type">{{item.msg_type}}</h3> -->
  13. <span class="text ellipsis" @click="titleGoto(item)">{{item.title}}</span>
  14. </div>
  15. <p class="time">{{item.createTime}}</p>
  16. </div>
  17. </div>
  18. </WorkspaceCard>
  19. </template>
  20. <script>
  21. import { mapState, mapActions } from 'vuex'
  22. import { Icon } from 'element-ui'
  23. import WorkspaceCard from '../ui/WorkspaceCard'
  24. export default {
  25. name: 'MessageTips',
  26. components: {
  27. [Icon.name]: Icon,
  28. WorkspaceCard
  29. },
  30. computed: {
  31. emptyShow () {
  32. return this.messageList.length === 0 && this.loaded
  33. },
  34. ...mapState({
  35. loading: state => state.workspace.message.loading,
  36. loaded: state => state.workspace.message.loaded,
  37. unReadCount: state => state.workspace.message.unReadCount,
  38. messageList: state => state.workspace.message.messageList
  39. })
  40. },
  41. created () {
  42. this.getList()
  43. },
  44. methods: {
  45. ...mapActions('workspace/message', [
  46. 'getList',
  47. 'remarkRead'
  48. ]),
  49. async titleGoto (item) {
  50. try {
  51. await this.remarkRead(item)
  52. this.toMessageCenter()
  53. } catch (error) {
  54. this.toMessageCenter()
  55. }
  56. },
  57. toMessageCenter () {
  58. location.href = '/swordfish/frontPage/messageCenter/sess/index'
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. ::v-deep{
  65. .fn-dialog{
  66. .el-dialog__header,
  67. .el-dialog__body {
  68. padding: 0;
  69. }
  70. }
  71. }
  72. .sub-text {
  73. font-size: 14px;
  74. color: #999;
  75. }
  76. .header-right-set {
  77. display: flex;
  78. align-items: center;
  79. color: #2cb7ca;
  80. font-size: 14px;
  81. text-decoration: none;
  82. cursor: pointer;
  83. .icon {
  84. margin-left: 4px;
  85. }
  86. }
  87. .message-content {
  88. min-height: 100px;
  89. }
  90. .message-item {
  91. display: flex;
  92. flex-direction: initial;
  93. align-items: center;
  94. justify-content: space-between;
  95. &:not(:last-of-type) {
  96. margin-bottom: 8px;
  97. }
  98. .l-msg {
  99. display: flex;
  100. align-items: center;
  101. max-width: 65%;
  102. .msg-type {
  103. margin-left: 8px;
  104. font-size: 16px;
  105. font-weight: bold;
  106. color: #2CB7CA;
  107. line-height: 24px;
  108. white-space: nowrap;
  109. }
  110. .text {
  111. margin-left: 8px;
  112. font-size: 14px;
  113. color: #1D1D1D;
  114. line-height: 22px;
  115. flex: 1;
  116. &:hover {
  117. color: #2CB7CA;
  118. cursor: pointer;
  119. }
  120. }
  121. }
  122. .time {
  123. font-size: 12px;
  124. color: #999999;
  125. line-height: 18px;
  126. white-space: nowrap;
  127. }
  128. }
  129. </style>