noticeList.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view>
  3. <cc-pullScroolView class="pullScrollView" ref="pullScroll" :pullDown="pullDown" :isDownLoading="true">
  4. <view class="notice" v-for="(item,index) in list" :key="index">
  5. <view class="justify-content">
  6. <view class="font-forty">
  7. {{item.noticeTitle}}
  8. </view>
  9. <view class="font-thirty-two black" style="margin: 30rpx 0;">
  10. <rich-text :nodes="item.noticeContent"></rich-text>
  11. </view>
  12. <view class="font-twenty-eight gray">
  13. {{item.createTime}}
  14. </view>
  15. </view>
  16. </view>
  17. </cc-pullScroolView>
  18. </view>
  19. </template>
  20. <script>
  21. import CCBProjectList from '../../uni_modules/cc-pullScroolView/components/cc-pullScroolView/cc-pullScroolView.vue';
  22. import {
  23. getNoticeList,
  24. } from '@/api/common'
  25. export default {
  26. components: {
  27. CCBProjectList,
  28. },
  29. data() {
  30. return {
  31. list: [],
  32. pageSize: 10, // 条数
  33. totalNum: '',
  34. pageNum: 1, // 页数
  35. }
  36. },
  37. onLoad() {
  38. this.getList()
  39. },
  40. // 上拉加载
  41. onReachBottom() {
  42. // 数据全部加载完
  43. if (this.pageNum * 10 >= this.totalNum) {
  44. } else {
  45. // 显示加载中
  46. this.$refs.pullScroll.showUpLoading();
  47. this.pageNum++;
  48. this.requestData();
  49. }
  50. },
  51. methods: {
  52. // goDetails(item) {
  53. // uni.navigateTo({
  54. // url: '/pages/notice/noticeDetail?params=' + encodeURIComponent(JSON.stringify(
  55. // item))
  56. // })
  57. // },
  58. // 下拉刷新
  59. pullDown(pullScroll) {
  60. this.pageNum = 1;
  61. setTimeout(() => {
  62. this.requestData(pullScroll);
  63. }, 1000);
  64. },
  65. getList() {
  66. let myThis = this;
  67. this.$nextTick(() => {
  68. myThis.$refs.pullScroll.refresh();
  69. });
  70. },
  71. requestData() {
  72. uni.showLoading()
  73. getNoticeList('1', this.pageNum, this.pageSize).then(res => {
  74. this.totalNum = res.total
  75. if (res.code == '200') {
  76. uni.hideLoading()
  77. if (res.rows.length !== 0) {
  78. //首次加载10条数据,后进行拼接
  79. if (this.pageNum == 1) {
  80. this.list = [];
  81. this.list = res.rows
  82. } else {
  83. this.list = this.list.concat(res.rows)
  84. }
  85. // 如果是最后一页
  86. if (this.pageNum * 10 >= this.totalNum) {
  87. this.$refs.pullScroll.finish();
  88. } else {
  89. // 不是最后一页
  90. this.$refs.pullScroll.success();
  91. }
  92. } else {
  93. this.$modal.msg("暂无数据")
  94. }
  95. } else {
  96. this.$modal.msg(res.msg + "")
  97. }
  98. })
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .container {
  105. display: flex;
  106. margin-left: 10px;
  107. margin-top: 10px;
  108. margin-right: 10px;
  109. align-items: flex-start;
  110. justify-content: space-between;
  111. }
  112. .notice {
  113. margin: 20rpx;
  114. padding: 20rpx;
  115. background: #FFFFFF;
  116. box-shadow: 0rpx 8rpx 17rpx 0rpx rgba(0, 0, 0, 0.04);
  117. border-radius: 10rpx;
  118. }
  119. .text {
  120. border-left: 15rpx solid #3857F3;
  121. padding-left: 20rpx;
  122. }
  123. </style>