Message.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <div class="mobile-center">
  3. <div class="com-mobile-header mobile-center-header">
  4. <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
  5. <p>消息</p>
  6. <p class="en-name"><img :src="`/images/mobile/center/${user.data.enterprise.uu ? 'en' : 'self'}.png`" alt="">{{currentEnName}}</p>
  7. </div>
  8. <div class="mobile-content">
  9. <div v-if="msgList && msgList.length" class="message-list" v-bind:key="item.id" v-for="item in msgList">
  10. <div class="content">
  11. <div class="new-dot">
  12. <b v-if="item.isRead === 0"></b>
  13. <img src="/images/mobile/center/user/message.png" alt="">
  14. </div>
  15. <div class="message">
  16. <p>{{item.createTime | time}}</p>
  17. <a :href="item.type === 'MALL跳转卖家待报价页面' ? '/mobile/center/user/seek?seekType=done' : item.type === 'MALL公共询价' ? '/mobile/center/vendor/seek?seekType=wait' : item.type === '商城公共询价采纳结果' ? '/mobile/center/vendor/seek?seekType=done' : ''"
  18. v-if="item.type"
  19. :title="item.content" class="info">{{item.content}}</a>
  20. <a v-else :title="item.content" class="noLink info">{{item.content}}</a>
  21. </div>
  22. </div>
  23. </div>
  24. <empty-status v-if="!msgList.length" :showLink="true" :text="'抱歉,暂无消息'"></empty-status>
  25. </div>
  26. <pull-up :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>
  27. </div>
  28. </template>
  29. <script>
  30. import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
  31. export default {
  32. data () {
  33. return {
  34. count: 10,
  35. page: 1,
  36. isChange: false,
  37. msgList: []
  38. }
  39. },
  40. computed: {
  41. user () {
  42. return this.$store.state.option.user
  43. },
  44. messageList () {
  45. return this.$store.state.messageShow.messageList.list.data
  46. },
  47. fetching () {
  48. return this.$store.state.messageShow.messageList.list.fetching
  49. },
  50. allPage () {
  51. return Math.floor(this.messageList.totalElements / this.messageList.size) + Math.floor(this.messageList.totalElements % this.messageList.size > 0 ? 1 : 0)
  52. }
  53. },
  54. components: {
  55. RemindBox,
  56. PullUp,
  57. EmptyStatus
  58. },
  59. watch: {
  60. 'messageList': {
  61. handler: function (val) {
  62. if (this.isChange) {
  63. this.msgList = val.content
  64. this.isChange = false
  65. } else {
  66. this.msgList = [...this.msgList, ...val.content]
  67. this.getRead()
  68. }
  69. },
  70. immediate: true
  71. }
  72. },
  73. methods: {
  74. reloadList: function () {
  75. this.$store.dispatch('messageShow/getAllMessage', { receiverUu: this.user.data.userUU, receiverEnuu: this.user.data.enterprise.uu, consumerApp: 'MALL', page: this.page, count: this.count, sorting: {'createTime': 'DESC'} })
  76. },
  77. onPullUpAction: function () {
  78. this.page++
  79. this.reloadList()
  80. },
  81. getRead () {
  82. let ids = []
  83. this.msgList.forEach((value) => {
  84. if (value.isRead !== 1) {
  85. ids.push(value.id)
  86. }
  87. })
  88. if (ids.length !== 0) {
  89. this.$http.post('/messages/read', {receiverUu: this.user.data.userUU, receiverEnuu: this.user.data.enterprise.uu, messageId: ids.join(','), consumerApp: 'MALL'})
  90. .then((res) => {
  91. console.log(res.data)
  92. })
  93. }
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .mobile-content {
  100. margin-top: .6rem !important;
  101. padding: .2rem;
  102. background: #f1f3f6;
  103. .com-none-state {
  104. padding-bottom: 100%;
  105. }
  106. .message-list {
  107. background: #fff;
  108. padding: 0 .15rem 0 .2rem;
  109. .content {
  110. padding: .14rem 0;
  111. overflow: hidden;
  112. border-bottom: 1px solid #d3d3d3;
  113. .new-dot {
  114. position: relative;
  115. b{
  116. position: absolute;
  117. left: .1rem;
  118. top: .25rem;
  119. width: .16rem;
  120. height: .16rem;
  121. border-radius: 50%;
  122. background: #fc0405;
  123. }
  124. }
  125. img{
  126. margin: .3rem 0 0 .12rem;
  127. float: left;
  128. width: .8rem;
  129. height: .8rem;
  130. }
  131. .message{
  132. margin-left: .24rem;
  133. float: left;
  134. width: 5.4rem;
  135. p{
  136. display: inherit;
  137. margin-bottom: .1rem;
  138. text-align: right;
  139. font-size: .24rem;
  140. color: #666;
  141. }
  142. a.info{
  143. font-size: .28rem;
  144. color: #333;
  145. word-break: break-all;
  146. }
  147. }
  148. }
  149. }
  150. }
  151. .message-list:last-child .content{
  152. border-bottom: none;
  153. }
  154. </style>