index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="content">
  3. <uni-list>
  4. <uni-list-item v-for="item in msgList" :key="item.id" :title="item.noticeTitle" :note="item.createTime" link
  5. ellipsis="1" :to="`/pages/message/msg-detail/index?id=${item.id}&state=${item.readState}`">
  6. <template v-slot:header v-if="item.readState===0">
  7. <view class="slot-box">
  8. <view class="strick"></view>
  9. </view>
  10. </template>
  11. </uni-list-item>
  12. </uni-list>
  13. <u-empty v-if="!msgList.length" class="empty" icon="../../static/data.png" text="暂无数据">
  14. </u-empty>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. // 查询参数
  22. queryParams: {
  23. page: 1,
  24. limit: 20
  25. },
  26. // 列表数据
  27. msgList: []
  28. };
  29. },
  30. onShow() {
  31. this.queryParams.limit = 20
  32. this.getMsgList()
  33. uni.pageScrollTo({
  34. scrollTop: 0,
  35. duration: 0
  36. })
  37. },
  38. onPullDownRefresh() {
  39. this.queryParams.limit = 20
  40. this.getMsgList()
  41. },
  42. onReachBottom() {
  43. this.queryParams.limit += 10
  44. this.getMsgList()
  45. },
  46. methods: {
  47. // 获取消息数据
  48. getMsgList() {
  49. uni.$http.get('/messageNotice/getAllMessageNotice', this.queryParams).then(res => {
  50. const data = res.data
  51. if (data.code === 200) {
  52. this.msgList = data.data.messageNoticeList
  53. uni.stopPullDownRefresh()
  54. }
  55. })
  56. },
  57. }
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. .content {
  62. padding: 0 25rpx 0rpx 25rpx;
  63. }
  64. .empty {
  65. width: 400rpx;
  66. height: 400rpx;
  67. position: absolute;
  68. top: 50%;
  69. left: 50%;
  70. margin-top: -280rpx !important;
  71. margin-left: -200rpx;
  72. }
  73. .slot-box {
  74. display: flex;
  75. align-items: center;
  76. .strick {
  77. height: 15rpx;
  78. width: 15rpx;
  79. border-radius: 50%;
  80. background-color: red;
  81. margin-right: 10rpx;
  82. }
  83. }
  84. </style>