teachingList.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="teachingList">
  3. <statusBar :item="navbarData"></statusBar>
  4. <view class="list">
  5. <scroll-view style="height: 100%;" scroll-y="true" refresher-enabled='true' :refresher-triggered="trigger"
  6. @refresherrefresh='pulling' @scrolltolower="lower">
  7. <view>
  8. <listBlock1 ref="listBlock1" :classList='classList'></listBlock1>
  9. </view>
  10. <view class="loading">
  11. <view v-if="Loading==1">数据加载中...</view>
  12. <view v-if="Loading==2">没有更多了~~</view>
  13. </view>
  14. </scroll-view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. navbarData: {
  23. title: '推荐列表',
  24. btn: 1
  25. },
  26. // 控制刷新
  27. trigger: false,
  28. // 渲染数据
  29. classList: [],
  30. // 触底加载动画提示
  31. Loading: 0, //0默认值 1加载中 2没有更多了
  32. currentPage: 1,
  33. };
  34. },
  35. methods: {
  36. // 资源库下拉刷新
  37. pulling() {
  38. this.trigger = true
  39. // this.isrepulling = true
  40. setTimeout(() => {
  41. this.trigger = false;
  42. }, 1000);
  43. // 资源库
  44. this.classList = []
  45. this.Loading = 0 //0默认值 1加载中 2没有更多了
  46. this.currentPage = 1 //页数
  47. this.getData()
  48. },
  49. // 触底
  50. lower() {
  51. console.log('没触底?');
  52. if (this.Loading == 2) return
  53. this.Loading = 1
  54. this.currentPage++
  55. setTimeout(this.getData, 1000)
  56. },
  57. // 获取页面数据
  58. getData() {
  59. let data = {
  60. openid: uni.getStorageSync('oId'),
  61. ty: 3,
  62. page: this.currentPage, //下拉获取更多的备用字段
  63. lim: 15 //一次获取多少数据
  64. }
  65. this.$request('/selectActivity', "POST", data).then(res => {
  66. console.log('获取数据', res[0]);
  67. if (!res[0].length) {
  68. this.Loading = 2
  69. } else {
  70. this.Loading = 0
  71. }
  72. // return
  73. this.classList = [...this.classList, ...res[0]]
  74. // this.trigger = false;
  75. // this.activeList = res[0]
  76. })
  77. },
  78. },
  79. // 触底加载更多
  80. // onReachBottom() {
  81. // if (this.newsLoading == 2) {
  82. // return
  83. // }
  84. // this.newsLoading = 1
  85. // this.currentPage++
  86. // setTimeout(this.getData, 2000)
  87. // },
  88. onLoad() {
  89. // this.getData()
  90. },
  91. onShow() {
  92. this.classList= []
  93. // 一进页面就加载数据
  94. this.getData()
  95. this.$refs.listBlock1.getdata()
  96. // this.$refs.listBlock1.getSub()
  97. }
  98. }
  99. </script>
  100. <style lang="scss">
  101. .teachingList {
  102. height: 100%;
  103. display: flex;
  104. flex-direction: column;
  105. .list{
  106. flex: 1;
  107. }
  108. .list1btn {
  109. z-index: 5;
  110. border: none;
  111. padding: 0;
  112. text-align: center;
  113. // padding: 8px, 24px, 8px, 24px;
  114. background-color: rgba(48, 129, 232, 1);
  115. color: #fff;
  116. border-radius: 100rpx;
  117. float: right;
  118. width: 144rpx;
  119. height: 48rpx;
  120. line-height: 48rpx;
  121. letter-spacing: 1px;
  122. }
  123. }
  124. </style>