notice.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="notice">
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption">
  4. <view v-for="(item, index) in lists" :key="index" class="notice-item bg-white">
  5. <view class="flex row-between item-header">
  6. <view class="header-title md bold">{{item.title}}</view>
  7. <view class="header-time muted xs">{{item.create_time}}</view>
  8. </view>
  9. <view class="item-main m-t-24">
  10. <view class="content sm lighter">{{item.content}}</view>
  11. </view>
  12. </view>
  13. </mescroll-body>
  14. </view>
  15. </template>
  16. <script>
  17. import {
  18. getNoticeLists
  19. } from '@/api/store';
  20. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins";
  21. export default {
  22. mixins: [MescrollMixin],
  23. data() {
  24. return {
  25. lists: [],
  26. upOption: {
  27. empty: {
  28. icon: '/static/images/news_null.png',
  29. tip: "暂无消息通知~",
  30. }
  31. },
  32. };
  33. },
  34. onLoad() {
  35. this.type = this.$Route.query.type;
  36. switch (this.type) {
  37. case "system":
  38. uni.setNavigationBarTitle({
  39. title: '系统通知'
  40. });
  41. break;
  42. case "earning":
  43. uni.setNavigationBarTitle({
  44. title: '收益通知'
  45. });
  46. break;
  47. }
  48. },
  49. methods: {
  50. upCallback(page) {
  51. getNoticeLists({
  52. page_size: page.size,
  53. page_no: page.num,
  54. type: this.type
  55. }).then(({
  56. data
  57. }) => {
  58. if (page.num == 1) this.lists = [];
  59. const curPageData = data.list;
  60. const curPageLen = curPageData.length;
  61. const hasNext = !!data.more;
  62. this.lists = this.lists.concat(curPageData);
  63. this.mescroll.endSuccess(curPageLen, hasNext);
  64. }).catch(() => {
  65. this.mescroll.endErr()
  66. })
  67. },
  68. }
  69. };
  70. </script>
  71. <style lang="scss">
  72. .notice {
  73. overflow: hidden;
  74. .notice-item {
  75. padding: 0 20rpx 30rpx;
  76. border-radius: 10rpx;
  77. margin: 20rpx 20rpx 0;
  78. .item-header {
  79. padding: 19rpx 0;
  80. border-bottom: $-solid-border;
  81. }
  82. }
  83. }
  84. </style>