Message.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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=seekPurchase' : item.type === 'MALL公共询价' ? '/mobile/center/vendor/seek?seekType=personage&messageType=my' : item.type === '商城公共询价采纳结果' ? '/mobile/center/vendor/seek?seekType=enterprise' : ''"
  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. import config from '../../../nuxt.config'
  32. export default {
  33. data () {
  34. return {
  35. count: 10,
  36. page: 1,
  37. isChange: false,
  38. msgList: []
  39. }
  40. },
  41. computed: {
  42. user () {
  43. return this.$store.state.option.user
  44. },
  45. messageList () {
  46. return this.$store.state.messageShow.messageList.list.data
  47. },
  48. fetching () {
  49. return this.$store.state.messageShow.messageList.list.fetching
  50. },
  51. allPage () {
  52. return Math.floor(this.messageList.totalElements / this.messageList.size) + Math.floor(this.messageList.totalElements % this.messageList.size > 0 ? 1 : 0)
  53. }
  54. },
  55. components: {
  56. RemindBox,
  57. PullUp,
  58. EmptyStatus
  59. },
  60. watch: {
  61. 'messageList': {
  62. handler: function (val) {
  63. if (val) {
  64. if (this.isChange) {
  65. this.msgList = val.content || []
  66. this.isChange = false
  67. } else {
  68. this.msgList = [...this.msgList, ...(val.content || [])]
  69. this.getRead()
  70. }
  71. }
  72. },
  73. immediate: true
  74. }
  75. },
  76. methods: {
  77. reloadList: function () {
  78. 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'} })
  79. },
  80. onPullUpAction: function () {
  81. this.page++
  82. this.reloadList()
  83. },
  84. getRead () {
  85. let ids = []
  86. this.msgList.forEach((value) => {
  87. if (value.isRead !== 1) {
  88. ids.push(value.id)
  89. }
  90. })
  91. if (ids.length !== 0) {
  92. this.$http.post(`${config.env.messageUrl}/messages/read`, {receiverUu: this.user.data.userUU, receiverEnuu: this.user.data.enterprise.uu, messageId: ids.join(','), consumerApp: 'MALL'})
  93. .then((res) => {
  94. console.log(res.data)
  95. })
  96. }
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .mobile-content {
  103. margin-top: .6rem !important;
  104. padding: .2rem;
  105. background: #f1f3f6;
  106. .com-none-state {
  107. padding-bottom: 100%;
  108. }
  109. .message-list {
  110. background: #fff;
  111. padding: 0 .15rem 0 .2rem;
  112. &:active{
  113. background: #e1e1e1;
  114. }
  115. .content {
  116. padding: .14rem 0;
  117. overflow: hidden;
  118. border-bottom: 1px solid #d3d3d3;
  119. .new-dot {
  120. position: relative;
  121. b{
  122. position: absolute;
  123. left: .1rem;
  124. top: .25rem;
  125. width: .16rem;
  126. height: .16rem;
  127. border-radius: 50%;
  128. background: #fc0405;
  129. }
  130. }
  131. img{
  132. margin: .3rem 0 0 .12rem;
  133. float: left;
  134. width: .8rem;
  135. height: .8rem;
  136. }
  137. .message{
  138. margin-left: .24rem;
  139. float: left;
  140. width: 5.4rem;
  141. p{
  142. display: inherit;
  143. margin-bottom: .1rem;
  144. text-align: right;
  145. font-size: .24rem;
  146. color: #666;
  147. }
  148. a{
  149. font-size: .28rem;
  150. color: #666;
  151. word-break: break-all;
  152. padding: 0;
  153. &.info {
  154. color: #333;
  155. }
  156. &:active {
  157. background: #e1e1e1;
  158. }
  159. }
  160. }
  161. }
  162. }
  163. }
  164. .message-list:last-child .content{
  165. border-bottom: none;
  166. }
  167. </style>