Message.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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&messageType=my' : item.type === '商城公共询价采纳结果' ? '/mobile/center/vendor/seek?seekType=done' : ''"
  18. v-if="item.type"
  19. :title="item.content" :class="{info: item.isRead === 0}">{{item.content}}</a>
  20. <a v-else :title="item.content" class="noLink" :class="{info: item.isRead === 0}">{{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 (val) {
  63. if (this.isChange) {
  64. this.msgList = val.content || []
  65. this.isChange = false
  66. } else {
  67. this.msgList = [...this.msgList, ...(val.content || [])]
  68. this.getRead()
  69. }
  70. }
  71. },
  72. immediate: true
  73. }
  74. },
  75. methods: {
  76. reloadList: function () {
  77. 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'} })
  78. },
  79. onPullUpAction: function () {
  80. this.page++
  81. this.reloadList()
  82. },
  83. getRead () {
  84. let ids = []
  85. this.msgList.forEach((value) => {
  86. if (value.isRead !== 1) {
  87. ids.push(value.id)
  88. }
  89. })
  90. if (ids.length !== 0) {
  91. this.$http.post('/messages/read', {receiverUu: this.user.data.userUU, receiverEnuu: this.user.data.enterprise.uu, messageId: ids.join(','), consumerApp: 'MALL'})
  92. .then((res) => {
  93. console.log(res.data)
  94. })
  95. }
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .mobile-content {
  102. margin-top: .6rem !important;
  103. padding: .2rem;
  104. background: #f1f3f6;
  105. .com-none-state {
  106. padding-bottom: 100%;
  107. }
  108. .message-list {
  109. background: #fff;
  110. padding: 0 .15rem 0 .2rem;
  111. &:active{
  112. background: #e1e1e1;
  113. }
  114. .content {
  115. padding: .14rem 0;
  116. overflow: hidden;
  117. border-bottom: 1px solid #d3d3d3;
  118. .new-dot {
  119. position: relative;
  120. b{
  121. position: absolute;
  122. left: .1rem;
  123. top: .25rem;
  124. width: .16rem;
  125. height: .16rem;
  126. border-radius: 50%;
  127. background: #fc0405;
  128. }
  129. }
  130. img{
  131. margin: .3rem 0 0 .12rem;
  132. float: left;
  133. width: .8rem;
  134. height: .8rem;
  135. }
  136. .message{
  137. margin-left: .24rem;
  138. float: left;
  139. width: 5.4rem;
  140. p{
  141. display: inherit;
  142. margin-bottom: .1rem;
  143. text-align: right;
  144. font-size: .24rem;
  145. color: #666;
  146. }
  147. a{
  148. font-size: .28rem;
  149. color: #666;
  150. word-break: break-all;
  151. padding: 0;
  152. &.info {
  153. color: #333;
  154. }
  155. &:active {
  156. background: #e1e1e1;
  157. }
  158. }
  159. }
  160. }
  161. }
  162. }
  163. .message-list:last-child .content{
  164. border-bottom: none;
  165. }
  166. </style>