noticeList.vue 2.9 KB

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