teachingList.vue 3.2 KB

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