index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="content">
  3. <Nav title="消息" :isBack="false" />
  4. <view class="section">
  5. <u-list finished-text="没有更多了" @scrolltolower="scrolltolower" height="85vh" :key="key">
  6. <view v-for="item in msgList" :key="item.id" @click="handelDetail(item)">
  7. <u-list-item>
  8. <u-cell-group class="cell">
  9. <u-cell :label="item.createTime" isLink>
  10. <view slot="title" class="title">
  11. <u-badge v-if="item.readState===0" isDot type="error" class="strick"></u-badge>
  12. <view class="title-content" :style="item.readState===0?'padding-left:20rpx':''">
  13. {{item.noticeTitle}}
  14. </view>
  15. </view>
  16. </u-cell>
  17. </u-cell-group>
  18. </u-list-item>
  19. </view>
  20. </u-list>
  21. <view class="empty" v-if="!this.msgList.length">
  22. <u-empty text="暂无数据" class="empty-icon" mode="data" icon="../../static/data.png">
  23. </u-empty>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. // 查询参数
  33. queryParams: {
  34. page: 1,
  35. limit: 20
  36. },
  37. // 列表数据
  38. msgList: [],
  39. key: 0
  40. };
  41. },
  42. onShow() {
  43. this.queryParams.limit = 20
  44. this.getMsgList()
  45. this.key++
  46. },
  47. onPullDownRefresh() {
  48. this.queryParams.limit += 10
  49. this.getMsgList()
  50. },
  51. methods: {
  52. // 获取消息数据
  53. getMsgList() {
  54. uni.$http.get('/messageNotice/getAllMessageNotice', this.queryParams).then(res => {
  55. const data = res.data
  56. if (data.code === 200) {
  57. this.msgList = data.data.messageNoticeList
  58. uni.stopPullDownRefresh()
  59. }
  60. })
  61. },
  62. // 跳转详情页
  63. handelDetail({
  64. id,
  65. readState
  66. }) {
  67. uni.navigateTo({
  68. url: "/pages/message/msg-detail/index?id=" + id + "&state=" + readState
  69. })
  70. },
  71. // 列表滚动到底部触发
  72. scrolltolower() {
  73. this.queryParams.limit += 10
  74. this.getMsgList()
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .content {
  81. padding: 0 25rpx 0rpx 25rpx;
  82. }
  83. .section {
  84. position: relative;
  85. }
  86. .empty {
  87. width: 400rpx;
  88. height: 400rpx;
  89. position: absolute;
  90. top: 50%;
  91. left: 50%;
  92. margin-top: -200rpx;
  93. margin-left: -200rpx;
  94. }
  95. .cell {
  96. .title {
  97. position: relative;
  98. .title-content {
  99. width: 550rpx;
  100. overflow: hidden;
  101. white-space: nowrap;
  102. text-overflow: ellipsis;
  103. }
  104. .strick {
  105. height: 15rpx;
  106. width: 15rpx;
  107. position: absolute;
  108. top: 0;
  109. left: 0;
  110. margin-top: 12rpx
  111. }
  112. }
  113. }
  114. </style>