index.vue 2.3 KB

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